diff --git a/test/test_cli.py b/test/test_cli.py index 648dd6e..c40f8cc 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -89,9 +89,6 @@ class TestCLI: # test that additional information on e.g. Serial is printed assert "Serial" in result.stdout - @pytest.mark.skip( - reason="disable this test as it is not that easy anymore to predict the outcome of this call" - ) def test_cli_text(self): """Make sure text returns what we sent it""" test_text = "this is some text" @@ -107,7 +104,9 @@ class TestCLI: ) assert not result.stderr assert DEVFILE_NAME in result.files_updated.keys() - assert result.files_updated[DEVFILE_NAME].bytes == test_text + "\n" + assert ( + result.files_updated[DEVFILE_NAME].bytes == "\x1bt\x00" + test_text + "\n" + ) def test_cli_text_invalid_args(self): """Test a failure to send valid arguments""" diff --git a/test/test_function_qr_native.py b/test/test_function_qr_native.py index 876b38d..e8cac69 100644 --- a/test/test_function_qr_native.py +++ b/test/test_function_qr_native.py @@ -3,7 +3,7 @@ :author: `Michael Billington `_ :organization: `python-escpos `_ -:copyright: Copyright (c) 2016 `Michael Billington `_ +:copyright: Copyright (c) 2023 `Michael Billington `_ :license: MIT """ @@ -86,22 +86,6 @@ def test_invalid_model(): instance.qr("1234", native=True, model="Hello") -@pytest.mark.skip("this test has to be debugged") -def test_image(): - """Test QR as image""" - instance = printer.Dummy() - instance.qr("1", native=False, size=1) - print(instance.output) - expected = ( - b"\x1bt\x00\n" - b"\x1dv0\x00\x03\x00\x17\x00\x00\x00\x00\x7f]\xfcA\x19\x04]it]et" - b"]ItA=\x04\x7fU\xfc\x00\x0c\x00y~t4\x7f =\xa84j\xd9\xf0\x05\xd4\x90\x00" - b"i(\x7f<\xa8A \xd8]'\xc4]y\xf8]E\x80Ar\x94\x7fR@\x00\x00\x00" - b"\n\n" - ) - assert instance.output == expected - - def test_image_invalid_model(): """Test unsupported QR model as image""" instance = printer.Dummy() diff --git a/test/test_function_qr_non-native.py b/test/test_function_qr_non-native.py index 6b4ce92..04b768f 100644 --- a/test/test_function_qr_non-native.py +++ b/test/test_function_qr_non-native.py @@ -4,7 +4,7 @@ :author: `Patrick Kanzler `_ :organization: `python-escpos `_ -:copyright: Copyright (c) 2016 `python-escpos `_ +:copyright: Copyright (c) 2023 `python-escpos `_ :license: MIT """ @@ -18,6 +18,28 @@ from PIL import Image from escpos.printer import Dummy +def test_image(): + """Test QR as image""" + instance = Dummy() + image_arguments = { + "high_density_vertical": True, + "high_density_horizontal": True, + "impl": "bitImageRaster", + "fragment_height": 960, + "center": False, + } + instance.qr("1", native=False, image_arguments=image_arguments, size=1) + print(instance.output) + expected = ( + b"\x1bt\x00\n" + b"\x1dv0\x00\x03\x00\x17\x00\x00\x00\x00\x7f\x1d\xfcAu\x04]\x1dt]et" + b"]%tAI\x04\x7fU\xfc\x00 \x00}\xca\xa8h\xdf u\x95\x80x/ \x0b\xf4\x98\x00" + b"T\x90\x7fzxA\x00\xd0]zp]o ]u\x80Ao(\x7fd\x90\x00\x00\x00" + b"\n\n" + ) + assert instance.output == expected + + @mock.patch("escpos.printer.Dummy.image", spec=Dummy) def test_type_of_object_passed_to_image_function(img_function): """