2018-05-14 23:03:07 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2020-11-08 21:04:27 +00:00
|
|
|
import barcode.errors
|
2018-05-14 23:03:07 +00:00
|
|
|
import pytest
|
|
|
|
|
2023-08-14 23:03:36 +00:00
|
|
|
import escpos.printer as printer
|
|
|
|
|
2018-05-14 23:03:07 +00:00
|
|
|
|
2020-05-10 12:05:33 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def instance():
|
|
|
|
return printer.Dummy()
|
|
|
|
|
2021-10-30 16:15:22 +00:00
|
|
|
|
2023-12-16 22:09:20 +00:00
|
|
|
def test_soft_barcode_ean8_invalid(instance: printer.Dummy) -> None:
|
2020-11-08 21:04:27 +00:00
|
|
|
"""test with an invalid barcode"""
|
|
|
|
with pytest.raises(barcode.errors.BarcodeError):
|
2023-07-12 18:45:41 +00:00
|
|
|
instance.barcode("1234", "ean8", force_software=True)
|
2020-05-10 12:05:33 +00:00
|
|
|
|
2021-10-30 16:15:22 +00:00
|
|
|
|
2023-12-16 22:09:20 +00:00
|
|
|
def test_soft_barcode_ean8(instance: printer.Dummy) -> None:
|
2020-11-08 21:04:27 +00:00
|
|
|
"""test with a valid ean8 barcode"""
|
2023-07-12 18:45:41 +00:00
|
|
|
instance.barcode("1234567", "ean8", force_software=True)
|
2018-05-14 23:03:07 +00:00
|
|
|
|
2020-05-10 12:06:00 +00:00
|
|
|
|
2023-12-16 22:09:20 +00:00
|
|
|
def test_soft_barcode_ean8_nocenter(instance: printer.Dummy) -> None:
|
2023-07-12 18:45:41 +00:00
|
|
|
instance.barcode("1234567", "ean8", align_ct=False, force_software=True)
|