Skip to content

Commit

Permalink
Fix failing LP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
belono committed Oct 22, 2023
1 parent a48e0f2 commit 363d322
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/test_printers/test_printer_lp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,28 @@ def test_device_not_initialized(lpprinter):
assert lpprinter._device is False


def test_open_raise_exception(lpprinter, devicenotfounderror):
def test_open_raise_exception(lpprinter, devicenotfounderror, mocker):
"""
GIVEN a lp printer object
WHEN open() is set to raise a DeviceNotFoundError on error
THEN check the exception is raised
"""
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})

lpprinter.printer_name = "fakeprinter"

with pytest.raises(devicenotfounderror):
lpprinter.open(raise_not_found=True)


def test_open_not_raise_exception(lpprinter, caplog):
def test_open_not_raise_exception(lpprinter, caplog, mocker):
"""
GIVEN a lp printer object
WHEN open() is set to not raise on error but simply cancel
THEN check the error is logged and open() canceled
"""
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})

lpprinter.printer_name = "fakeprinter"

with caplog.at_level(logging.ERROR):
Expand Down

0 comments on commit 363d322

Please sign in to comment.