python-escpos/test/test_functions/test_function_softbarcode.py

27 lines
689 B
Python
Raw Permalink Normal View History

#!/usr/bin/python
2020-11-08 21:04:27 +00:00
import barcode.errors
import pytest
import escpos.printer as printer
@pytest.fixture
def instance():
return printer.Dummy()
2021-10-30 16:15:22 +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):
instance.barcode("1234", "ean8", force_software=True)
2021-10-30 16:15:22 +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"""
instance.barcode("1234567", "ean8", force_software=True)
def test_soft_barcode_ean8_nocenter(instance: printer.Dummy) -> None:
instance.barcode("1234567", "ean8", align_ct=False, force_software=True)