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.'
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.'
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."
def open_printer(self): if self.device: return try: if device_type == 'usb': printers = self.connected_usb_devices() if printers: printer = printers[0] self.interface = printer.get('interface', 0) self.idVendor = printer.get('vendor') self.idProduct = printer.get('product') self.in_ep = printer.get('in_ep', 0x82) self.out_ep = printer.get('out_ep', 0x01) self.timeout = 0 self.profile = capabilities.get_profile(None) self.magic = MagicEncode(self, {}) self.open() self.vendor_product = '%s_%s' % (self.idVendor, self.idProduct) elif device_type == 'serial': self.devfile = config.get('escpos_driver', 'serial_device_name') self.baudrate = config.getint('escpos_driver', 'serial_baudrate') self.bytesize = config.getint('escpos_driver', 'serial_bytesize') self.timeout = config.getint('escpos_driver', 'serial_timeout') self.open() except Exception as e: self.set_status('error', str(e))
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)
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."
def test_write_disabled(self, driver): encode = MagicEncode(driver, encoding='CP437', disabled=True) encode.write('€ ist teuro.') assert driver.output == b'? ist teuro.'
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.'
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.'
def test_write(self, driver): encode = MagicEncode(driver) encode.write('€ ist teuro.') assert driver.output == b'\x1bt\x0f\xa4 ist teuro.'
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.'
def test_disabled_requires_encoding(self, driver): with pytest.raises(Error): MagicEncode(driver, disabled=True)
def test_write_disabled(self, driver): encode = MagicEncode(driver, encoding="CP437", disabled=True) encode.write("€ ist teuro.") assert driver.output == b"? ist teuro."
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."
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."
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.'