diff --git a/test/test_printers/test_printer_cups.py b/test/test_printers/test_printer_cups.py index 96c3fda..cabc9cd 100644 --- a/test/test_printers/test_printer_cups.py +++ b/test/test_printers/test_printer_cups.py @@ -65,6 +65,7 @@ def test_open(cupsprinter, caplog, mocker): mocker.patch("escpos.printer.CupsPrinter.printers", new={"test_printer": "Test"}) cupsprinter.printer_name = "test_printer" + assert cupsprinter.printer_name in cupsprinter.printers with caplog.at_level(logging.INFO): cupsprinter.open() diff --git a/test/test_printers/test_printer_lp.py b/test/test_printers/test_printer_lp.py index a84eb8c..440eec8 100644 --- a/test/test_printers/test_printer_lp.py +++ b/test/test_printers/test_printer_lp.py @@ -65,6 +65,7 @@ def test_open(lpprinter, caplog, mocker): mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"}) lpprinter.printer_name = "test_printer" + assert lpprinter.printer_name in lpprinter.printers with caplog.at_level(logging.INFO): lpprinter.open() diff --git a/test/test_printers/test_printer_win32raw.py b/test/test_printers/test_printer_win32raw.py index 52d8c71..cd33e0c 100644 --- a/test/test_printers/test_printer_win32raw.py +++ b/test/test_printers/test_printer_win32raw.py @@ -67,6 +67,10 @@ def test_open(win32rawprinter, caplog, mocker): THEN check the success is logged and the device property is set """ mocker.patch("win32print.__init__") + mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"}) + + win32rawprinter.printer_name = "test_printer" + assert win32rawprinter.printer_name in win32rawprinter.printers with caplog.at_level(logging.INFO): win32rawprinter.open() @@ -83,6 +87,9 @@ def test_close_on_reopen(win32rawprinter, mocker): """ mocker.patch("win32print.__init__") spy = mocker.spy(win32rawprinter, "close") + mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"}) + + win32rawprinter.printer_name = "test_printer" win32rawprinter.open() assert win32rawprinter._device @@ -98,6 +105,9 @@ def test_close(win32rawprinter, mocker, caplog): THEN check the closing is logged and the device property is False """ mocker.patch("win32print.__init__") + mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"}) + + win32rawprinter.printer_name = "test_printer" win32rawprinter.open() with caplog.at_level(logging.INFO):