How to use the escpos.magicencode.MagicEncode function in escpos

To help you get started, we’ve selected a few escpos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test(self, driver):
            encode = MagicEncode(driver)
            encode.force_encoding('CP437')
            assert driver.output == b'\x1bt\x00'

            encode.write('€ ist teuro.')
            assert driver.output == b'\x1bt\x00? ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_write(self, driver):
            encode = MagicEncode(driver)
            encode.write('€ ist teuro.')
            assert driver.output == b'\x1bt\x0f\xa4 ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_disabled_requires_encoding(self, driver):
            """
            Test that disabled without encoder raises an error.

            :param driver:
            """
            with pytest.raises(Error):
                MagicEncode(driver, disabled=True)
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_no_change(self, driver):
            encode = MagicEncode(driver, encoding='CP858')
            encode.write_with_encoding('CP858', '€ ist teuro.')
            assert driver.output == b'\xd5 ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_write_disabled(self, driver):
            encode = MagicEncode(driver, encoding='CP437', disabled=True)
            encode.write('€ ist teuro.')
            assert driver.output == b'? ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_write_no_codepage(self, driver):
            encode = MagicEncode(
                driver, defaultsymbol="_", encoder=Encoder({'CP437': 1}),
                encoding='CP437')
            encode.write(u'€ ist teuro.')
            assert driver.output == b'_ ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_change_from_another(self, driver):
            encode = MagicEncode(driver, encoding='CP437')
            encode.write_with_encoding('CP858', '€ ist teuro.')
            assert driver.output == b'\x1bt\x13\xd5 ist teuro.'
github python-escpos / python-escpos / test / test_magicencode.py View on Github external
def test_init_from_none(self, driver):
            encode = MagicEncode(driver, encoding=None)
            encode.write_with_encoding('CP858', '€ ist teuro.')
            assert driver.output == b'\x1bt\x13\xd5 ist teuro.'