From d2ce4a18462b5e304bc75983be3fffa3c426affc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 1 Oct 2022 23:03:11 -1000 Subject: [PATCH] fix: add missing closes to tests (#49) --- tests/service/test_methods.py | 2 ++ tests/service/test_properties.py | 4 ++++ tests/service/test_signals.py | 4 ++++ tests/test_glib_low_level.py | 4 ++++ tests/test_introspection.py | 3 ++- tests/test_marshaller.py | 3 ++- 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/service/test_methods.py b/tests/service/test_methods.py index 7236fd0..6fdfe5d 100644 --- a/tests/service/test_methods.py +++ b/tests/service/test_methods.py @@ -182,3 +182,5 @@ async def test_methods(interface_class): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() diff --git a/tests/service/test_properties.py b/tests/service/test_properties.py index ebf85a9..f587cb3 100644 --- a/tests/service/test_properties.py +++ b/tests/service/test_properties.py @@ -245,6 +245,8 @@ async def test_property_methods(interface_class): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() @pytest.mark.parametrize("interface_class", [ExampleInterface, AsyncInterface]) @@ -301,3 +303,5 @@ async def test_property_changed_signal(interface_class): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() diff --git a/tests/service/test_signals.py b/tests/service/test_signals.py index 35d0af9..8485d24 100644 --- a/tests/service/test_signals.py +++ b/tests/service/test_signals.py @@ -161,6 +161,8 @@ async def test_signals(): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() @pytest.mark.asyncio @@ -255,3 +257,5 @@ async def test_interface_add_remove_signal(): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() diff --git a/tests/test_glib_low_level.py b/tests/test_glib_low_level.py index ab8d7a4..33f7276 100644 --- a/tests/test_glib_low_level.py +++ b/tests/test_glib_low_level.py @@ -113,6 +113,8 @@ def test_sending_messages_between_buses(): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) @@ -164,3 +166,5 @@ def test_sending_signals_between_buses(): bus1.disconnect() bus2.disconnect() + bus1._sock.close() + bus2._sock.close() diff --git a/tests/test_introspection.py b/tests/test_introspection.py index ba8794d..b110cc8 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -3,7 +3,8 @@ import os from dbus_fast import ArgDirection, PropertyAccess, SignatureType from dbus_fast import introspection as intr -example_data = open(f"{os.path.dirname(__file__)}/data/introspection.xml").read() +with open(f"{os.path.dirname(__file__)}/data/introspection.xml") as f: + example_data = f.read() def test_example_introspection_from_xml(): diff --git a/tests/test_marshaller.py b/tests/test_marshaller.py index ecfaa97..be6d1b6 100644 --- a/tests/test_marshaller.py +++ b/tests/test_marshaller.py @@ -21,7 +21,8 @@ def print_buf(buf): # these messages have been verified with another library -table = json.load(open(os.path.dirname(__file__) + "/data/messages.json")) +with open(os.path.dirname(__file__) + "/data/messages.json") as f: + table = json.load(f) def json_to_message(message: Dict[str, Any]) -> Message: