Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/test_abstract_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
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
2 changes: 1 addition & 1 deletion test/test_load_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion test/test_load_module_missing_capability.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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
Expand Down
17 changes: 9 additions & 8 deletions test/test_magicencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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
Expand Down Expand Up @@ -54,7 +55,7 @@ class TestInit:
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.

Expand All @@ -64,33 +65,33 @@ def test_disabled_requires_encoding(self, driver):
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="_",
Expand All @@ -101,7 +102,7 @@ def test_write_no_codepage(self, driver):
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"
Expand Down
4 changes: 2 additions & 2 deletions test/test_raise_arbitrary_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
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:
Expand Down
2 changes: 1 addition & 1 deletion test/test_with_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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"""
Expand Down