Skip to content

Commit

Permalink
fix: disconnect connected buses at end of tests (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Sep 20, 2022
1 parent cfad28b commit e438890
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/client/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ def test_glib_properties():
raise e

service_bus.disconnect()
bus.disconnect()
6 changes: 6 additions & 0 deletions tests/service/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand All @@ -117,3 +121,5 @@ async def test_export_introspection():

root = bus._introspect_export_path("/")
assert len(root.nodes) == 1

bus.disconnect()
3 changes: 3 additions & 0 deletions tests/service/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,6 @@ async def call(member, signature="", body=[], flags=MessageFlag.NONE):

reply = await call("throws_dbus_error", flags=MessageFlag.NO_REPLY_EXPECTED)
assert reply is None

bus1.disconnect()
bus2.disconnect()
6 changes: 6 additions & 0 deletions tests/service/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ async def call_properties(member, signature, body):
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
Expand Down Expand Up @@ -295,3 +298,6 @@ def message_handler(signal):
{"string_prop": Variant("s", "asdf")},
["container_prop"],
]

bus1.disconnect()
bus2.disconnect()
6 changes: 6 additions & 0 deletions tests/service/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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()
12 changes: 12 additions & 0 deletions tests/service/test_standard_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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()
8 changes: 8 additions & 0 deletions tests/test_aio_low_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -103,6 +105,9 @@ def message_handler_error(sent):
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):
Expand Down Expand Up @@ -145,3 +150,6 @@ def message_handler(signal):
assert signal.member == "SomeSignal"
assert signal.signature == "s"
assert signal.body == ["a signal"]

bus1.disconnect()
bus2.disconnect()
6 changes: 6 additions & 0 deletions tests/test_big_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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()
2 changes: 2 additions & 0 deletions tests/test_fd_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def on_signal_fd(fd):
interface.cleanup()
os.close(fd)

bus.disconnect()


@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
8 changes: 8 additions & 0 deletions tests/test_glib_low_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -109,6 +111,9 @@ def message_handler_error(sent):
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():
Expand Down Expand Up @@ -156,3 +161,6 @@ def message_handler(signal):
assert signal.member == "SomeSignal"
assert signal.signature == "s"
assert signal.body == ["a signal"]

bus1.disconnect()
bus2.disconnect()

0 comments on commit e438890

Please sign in to comment.