python-escpos/test/test_printer_network.py

27 lines
598 B
Python
Raw Normal View History

2020-11-08 21:33:51 +00:00
#!/usr/bin/python
import socket
import mock
import pytest
import escpos.printer as printer
2020-11-08 21:33:51 +00:00
@pytest.fixture
def instance():
socket.socket.connect = mock.Mock()
return printer.Network("localhost")
2021-10-30 16:15:22 +00:00
2020-11-08 21:33:51 +00:00
def test_close_without_open(instance):
"""try to close without opening (should fail gracefully)
Currently we never open from our fixture, so calling close once
should be enough. In the future this might not be enough,
therefore we have to close twice in order to provoke an error
(if possible, this should not raise)
"""
instance.close()
2021-10-30 16:15:22 +00:00
instance.close()