Fix failing LP tests
This commit is contained in:
parent
a48e0f2f23
commit
363d322265
@ -28,24 +28,28 @@ def test_device_not_initialized(lpprinter):
|
|||||||
assert lpprinter._device is False
|
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
|
GIVEN a lp printer object
|
||||||
WHEN open() is set to raise a DeviceNotFoundError on error
|
WHEN open() is set to raise a DeviceNotFoundError on error
|
||||||
THEN check the exception is raised
|
THEN check the exception is raised
|
||||||
"""
|
"""
|
||||||
|
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
lpprinter.printer_name = "fakeprinter"
|
lpprinter.printer_name = "fakeprinter"
|
||||||
|
|
||||||
with pytest.raises(devicenotfounderror):
|
with pytest.raises(devicenotfounderror):
|
||||||
lpprinter.open(raise_not_found=True)
|
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
|
GIVEN a lp printer object
|
||||||
WHEN open() is set to not raise on error but simply cancel
|
WHEN open() is set to not raise on error but simply cancel
|
||||||
THEN check the error is logged and open() canceled
|
THEN check the error is logged and open() canceled
|
||||||
"""
|
"""
|
||||||
|
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
lpprinter.printer_name = "fakeprinter"
|
lpprinter.printer_name = "fakeprinter"
|
||||||
|
|
||||||
with caplog.at_level(logging.ERROR):
|
with caplog.at_level(logging.ERROR):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user