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