From e43889091bf7b21f6ffd27544d74cc1d57db22d2 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Tue, 20 Sep 2022 16:28:43 -0400 Subject: [PATCH] fix: disconnect connected buses at end of tests (#25) --- tests/client/test_properties.py | 1 + tests/service/test_export.py | 6 ++++++ tests/service/test_methods.py | 3 +++ tests/service/test_properties.py | 6 ++++++ tests/service/test_signals.py | 6 ++++++ tests/service/test_standard_interfaces.py | 12 ++++++++++++ tests/test_aio_low_level.py | 8 ++++++++ tests/test_big_message.py | 6 ++++++ tests/test_fd_passing.py | 2 ++ tests/test_glib_low_level.py | 8 ++++++++ 10 files changed, 58 insertions(+) diff --git a/tests/client/test_properties.py b/tests/client/test_properties.py index f342286..eb3ecb3 100644 --- a/tests/client/test_properties.py +++ b/tests/client/test_properties.py @@ -140,3 +140,4 @@ def test_glib_properties(): raise e service_bus.disconnect() + bus.disconnect() diff --git a/tests/service/test_export.py b/tests/service/test_export.py index a3a0259..31fbe3b 100644 --- a/tests/service/test_export.py +++ b/tests/service/test_export.py @@ -65,6 +65,8 @@ async def test_export_unexport(): assert not node.interfaces assert not node.nodes + bus.disconnect() + @pytest.mark.asyncio async def test_export_alias(): @@ -102,6 +104,8 @@ async def test_export_alias(): assert result.message_type is MessageType.METHOD_RETURN, result.body[0] assert interface._method_called + bus.disconnect() + @pytest.mark.asyncio async def test_export_introspection(): @@ -117,3 +121,5 @@ async def test_export_introspection(): root = bus._introspect_export_path("/") assert len(root.nodes) == 1 + + bus.disconnect() diff --git a/tests/service/test_methods.py b/tests/service/test_methods.py index 6d4a93d..7236fd0 100644 --- a/tests/service/test_methods.py +++ b/tests/service/test_methods.py @@ -179,3 +179,6 @@ async def test_methods(interface_class): reply = await call("throws_dbus_error", flags=MessageFlag.NO_REPLY_EXPECTED) assert reply is None + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/service/test_properties.py b/tests/service/test_properties.py index 54a4f80..2b57743 100644 --- a/tests/service/test_properties.py +++ b/tests/service/test_properties.py @@ -243,6 +243,9 @@ async def test_property_methods(interface_class): assert result.error_name == "test.error" assert result.body == ["told you so"] + bus1.disconnect() + bus2.disconnect() + @pytest.mark.parametrize("interface_class", [ExampleInterface, AsyncInterface]) @pytest.mark.asyncio @@ -295,3 +298,6 @@ async def test_property_changed_signal(interface_class): {"string_prop": Variant("s", "asdf")}, ["container_prop"], ] + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/service/test_signals.py b/tests/service/test_signals.py index 6e1ab12..5534ea3 100644 --- a/tests/service/test_signals.py +++ b/tests/service/test_signals.py @@ -159,6 +159,9 @@ async def test_signals(): with pytest.raises(SignalDisabledError): interface.signal_disabled() + bus1.disconnect() + bus2.disconnect() + @pytest.mark.asyncio async def test_interface_add_remove_signal(): @@ -249,3 +252,6 @@ async def test_interface_add_remove_signal(): signature="oas", body=[export_path, ["test.interface.first", "test.interface.second"]], ) + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/service/test_standard_interfaces.py b/tests/service/test_standard_interfaces.py index 1537a0d..dc8213c 100644 --- a/tests/service/test_standard_interfaces.py +++ b/tests/service/test_standard_interfaces.py @@ -79,6 +79,9 @@ async def test_introspectable_interface(): assert not node.interfaces assert not node.nodes + bus1.disconnect() + bus2.disconnect() + @pytest.mark.asyncio async def test_peer_interface(): @@ -110,6 +113,9 @@ async def test_peer_interface(): assert reply.message_type == MessageType.METHOD_RETURN, reply.body[0] assert reply.signature == "s" + bus1.disconnect() + bus2.disconnect() + @pytest.mark.asyncio async def test_object_manager(): @@ -180,6 +186,9 @@ async def test_object_manager(): expected_reply.update(reply_ext) assert reply_root.body == [expected_reply] + bus1.disconnect() + bus2.disconnect() + @pytest.mark.asyncio async def test_standard_interface_properties(): @@ -236,3 +245,6 @@ async def test_standard_interface_properties(): ) assert result.message_type is MessageType.METHOD_RETURN assert result.body == [{}] + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/test_aio_low_level.py b/tests/test_aio_low_level.py index 92e0c3a..587618d 100644 --- a/tests/test_aio_low_level.py +++ b/tests/test_aio_low_level.py @@ -41,6 +41,8 @@ async def test_standard_interfaces(): assert reply.signature == "s" assert type(reply.body[0]) is str + bus.disconnect() + @pytest.mark.asyncio async def test_sending_messages_between_buses(): @@ -103,6 +105,9 @@ async def test_sending_messages_between_buses(): reply = await bus2.call(msg) assert reply is None + bus1.disconnect() + bus2.disconnect() + @pytest.mark.asyncio async def test_sending_signals_between_buses(event_loop): @@ -145,3 +150,6 @@ async def test_sending_signals_between_buses(event_loop): assert signal.member == "SomeSignal" assert signal.signature == "s" assert signal.body == ["a signal"] + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/test_big_message.py b/tests/test_big_message.py index f11573c..0be3a51 100644 --- a/tests/test_big_message.py +++ b/tests/test_big_message.py @@ -39,6 +39,9 @@ async def test_aio_big_message(): assert result.message_type == MessageType.METHOD_RETURN, result.body[0] assert result.body[0] == big_body[0] + bus1.disconnect() + bus2.disconnect() + @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_glib_big_message(): @@ -62,3 +65,6 @@ def test_glib_big_message(): ) assert result.message_type == MessageType.METHOD_RETURN, result.body[0] assert result.body[0] == big_body[0] + + bus1.disconnect() + bus2.disconnect() diff --git a/tests/test_fd_passing.py b/tests/test_fd_passing.py index 21d3033..001ee25 100644 --- a/tests/test_fd_passing.py +++ b/tests/test_fd_passing.py @@ -278,6 +278,8 @@ async def test_sending_file_descriptor_with_proxy(event_loop): interface.cleanup() os.close(fd) + bus.disconnect() + @pytest.mark.asyncio @pytest.mark.parametrize( diff --git a/tests/test_glib_low_level.py b/tests/test_glib_low_level.py index 8c76620..ab8d7a4 100644 --- a/tests/test_glib_low_level.py +++ b/tests/test_glib_low_level.py @@ -47,6 +47,8 @@ def test_standard_interfaces(): assert reply.signature == "s" assert type(reply.body[0]) is str + bus.disconnect() + @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_sending_messages_between_buses(): @@ -109,6 +111,9 @@ def test_sending_messages_between_buses(): reply = bus2.call_sync(msg) assert reply is None + bus1.disconnect() + bus2.disconnect() + @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_sending_signals_between_buses(): @@ -156,3 +161,6 @@ def test_sending_signals_between_buses(): assert signal.member == "SomeSignal" assert signal.signature == "s" assert signal.body == ["a signal"] + + bus1.disconnect() + bus2.disconnect()