diff --git a/test/test_abstract_base_class.py b/test/test_abstract_base_class.py index 3154469..0bfb269 100644 --- a/test/test_abstract_base_class.py +++ b/test/test_abstract_base_class.py @@ -14,14 +14,14 @@ import pytest import escpos.escpos as escpos -def test_abstract_base_class_raises(): +def test_abstract_base_class_raises() -> None: """test whether the abstract base class raises an exception for ESC/POS""" with pytest.raises(TypeError): # This call should raise TypeError because of abstractmethod _raw() - escpos.Escpos() + escpos.Escpos() # type: ignore [abstract] -def test_abstract_base_class(): +def test_abstract_base_class() -> None: """test whether Escpos has the metaclass ABCMeta""" assert issubclass(escpos.Escpos, object) assert type(escpos.Escpos) is ABCMeta diff --git a/test/test_load_module.py b/test/test_load_module.py index c7c4d54..4b6c28c 100644 --- a/test/test_load_module.py +++ b/test/test_load_module.py @@ -11,7 +11,7 @@ import escpos.printer as printer -def test_instantiation(): +def test_instantiation() -> None: """test the instantiation of a escpos-printer class and basic printing""" instance = printer.Dummy() instance.text("This is a test\n") diff --git a/test/test_load_module_missing_capability.py b/test/test_load_module_missing_capability.py index c3bff7d..b23bc4a 100644 --- a/test/test_load_module_missing_capability.py +++ b/test/test_load_module_missing_capability.py @@ -13,7 +13,7 @@ import tempfile import pytest -def test_instantiation(): +def test_instantiation() -> None: """test the instantiation of a escpos-printer class""" # inject an environment variable that points to an empty capabilities file os.environ["ESCPOS_CAPABILITIES_FILE"] = tempfile.NamedTemporaryFile().name diff --git a/test/test_magicencode.py b/test/test_magicencode.py index dc3729f..77d1575 100644 --- a/test/test_magicencode.py +++ b/test/test_magicencode.py @@ -13,6 +13,7 @@ import hypothesis.strategies as st import pytest from hypothesis import example, given +from escpos import printer from escpos.exceptions import Error from escpos.katakana import encode_katakana from escpos.magicencode import Encoder, MagicEncode @@ -54,7 +55,7 @@ class TestMagicEncode: Test initialization. """ - def test_disabled_requires_encoding(self, driver): + def test_disabled_requires_encoding(self, driver: printer.Dummy) -> None: """ Test that disabled without encoder raises an error. @@ -64,33 +65,33 @@ class TestMagicEncode: MagicEncode(driver, disabled=True) class TestWriteWithEncoding: - def test_init_from_none(self, driver): + def test_init_from_none(self, driver: printer.Dummy) -> None: encode = MagicEncode(driver, encoding=None) encode.write_with_encoding("CP858", "€ ist teuro.") assert driver.output == b"\x1bt\x13\xd5 ist teuro." - def test_change_from_another(self, driver): + def test_change_from_another(self, driver: printer.Dummy) -> None: 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): + def test_no_change(self, driver: printer.Dummy) -> None: encode = MagicEncode(driver, encoding="CP858") encode.write_with_encoding("CP858", "€ ist teuro.") assert driver.output == b"\xd5 ist teuro." class TestWrite: - def test_write(self, driver): + def test_write(self, driver: printer.Dummy) -> None: encode = MagicEncode(driver) encode.write("€ ist teuro.") assert driver.output == b"\x1bt\x0f\xa4 ist teuro." - def test_write_disabled(self, driver): + def test_write_disabled(self, driver: printer.Dummy) -> None: encode = MagicEncode(driver, encoding="CP437", disabled=True) encode.write("€ ist teuro.") assert driver.output == b"? ist teuro." - def test_write_no_codepage(self, driver): + def test_write_no_codepage(self, driver: printer.Dummy) -> None: encode = MagicEncode( driver, defaultsymbol="_", @@ -101,7 +102,7 @@ class TestMagicEncode: assert driver.output == b"_ ist teuro." class TestForceEncoding: - def test(self, driver): + def test(self, driver: printer.Dummy) -> None: encode = MagicEncode(driver) encode.force_encoding("CP437") assert driver.output == b"\x1bt\x00" diff --git a/test/test_raise_arbitrary_error.py b/test/test_raise_arbitrary_error.py index 07ad76e..0080053 100644 --- a/test/test_raise_arbitrary_error.py +++ b/test/test_raise_arbitrary_error.py @@ -14,13 +14,13 @@ import escpos import escpos.exceptions -def test_raise_error_wrongly(): +def test_raise_error_wrongly() -> None: """raise error the wrong way should reproduce https://github.com/python-escpos/python-escpos/issues/257 """ with pytest.raises(AttributeError): - raise escpos.Error("This should raise an AttributeError.") + raise escpos.Error("This should raise an AttributeError.") # type: ignore [attr-defined] def tests_raise_error() -> None: diff --git a/test/test_with_statement.py b/test/test_with_statement.py index a4f922c..330d795 100644 --- a/test/test_with_statement.py +++ b/test/test_with_statement.py @@ -12,7 +12,7 @@ import escpos.escpos as escpos import escpos.printer as printer -def test_with_statement(): +def test_with_statement() -> None: """Use with statement .. todo:: Extend these tests as they don't really do anything at the moment"""