Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(self, driver):
encode = MagicEncode(driver)
encode.write('€ ist teuro.')
assert driver.output == b'\x1bt\x0f\xa4 ist teuro.'
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_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_disabled(self, driver):
encode = MagicEncode(driver, encoding='CP437', disabled=True)
encode.write('€ ist teuro.')
assert driver.output == b'? 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 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_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.'