From 7ffff723685b66f9a4cafbe2a339932a428b6cef Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 16 Sep 2015 07:11:30 +0200 Subject: [PATCH] ipc: Make sure server is always shut down in tests. Hopefully fixes #947. --- tests/unit/misc/test_ipc.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 90eb7e14f..f6114d7f2 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -51,6 +51,18 @@ def short_tmpdir(): yield py.path.local(tdir) +@pytest.yield_fixture(autouse=True) +def shutdown_server(): + """If ipc.send_or_listen was called, make sure to shut server down.""" + yield + try: + server = objreg.get('ipc-server') + except KeyError: + pass + else: + server.shutdown() + + @pytest.yield_fixture def ipc_server(qapp, qtbot): server = ipc.IPCServer('qute-test') @@ -662,7 +674,6 @@ class TestSendOrListen: ret_client = ipc.send_or_listen(args) assert ret_client is None - ret_server.shutdown() @pytest.mark.posix # Unneeded on Windows def test_legacy_name(self, caplog, qtbot, args, legacy_server): @@ -711,7 +722,6 @@ class TestSendOrListen: ret_client = ipc.send_or_listen(args) assert ret_client is None - ret_server.shutdown() @pytest.mark.posix # Unneeded on Windows def test_correct_socket_name(self, args):