2023-08-10 00:18:02 +02:00
|
|
|
import pytest
|
2023-08-15 01:03:36 +02:00
|
|
|
|
2016-08-25 15:56:32 +02:00
|
|
|
from escpos.printer import Dummy
|
|
|
|
|
|
|
|
|
|
|
|
def test_line_spacing_code_gen():
|
|
|
|
printer = Dummy()
|
|
|
|
printer.line_spacing(10)
|
2021-10-30 18:15:22 +02:00
|
|
|
assert printer.output == b"\x1b3\n"
|
2016-08-25 15:56:32 +02:00
|
|
|
|
|
|
|
|
2016-08-26 10:38:36 +02:00
|
|
|
def test_line_spacing_rest():
|
|
|
|
printer = Dummy()
|
|
|
|
printer.line_spacing()
|
2021-10-30 18:15:22 +02:00
|
|
|
assert printer.output == b"\x1b2"
|
2016-08-26 10:38:36 +02:00
|
|
|
|
|
|
|
|
2016-08-25 15:56:32 +02:00
|
|
|
def test_line_spacing_error_handling():
|
|
|
|
printer = Dummy()
|
2023-08-10 00:18:02 +02:00
|
|
|
with pytest.raises(ValueError):
|
2017-01-30 00:10:14 +01:00
|
|
|
printer.line_spacing(99, divisor=44)
|
2023-08-10 00:18:02 +02:00
|
|
|
with pytest.raises(ValueError):
|
2017-01-30 00:10:14 +01:00
|
|
|
printer.line_spacing(divisor=80, spacing=86)
|
2023-08-10 00:18:02 +02:00
|
|
|
with pytest.raises(ValueError):
|
2017-01-30 00:10:14 +01:00
|
|
|
printer.line_spacing(divisor=360, spacing=256)
|
2023-08-10 00:18:02 +02:00
|
|
|
with pytest.raises(ValueError):
|
2017-01-30 00:10:14 +01:00
|
|
|
printer.line_spacing(divisor=180, spacing=256)
|