From 6ce695db3b342bc7e2d9e9361f6ce5a8b97dae91 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 13 Dec 2023 14:39:42 +1000 Subject: [PATCH] test: yield the proxy, not the subprocess for the liboeffis fixtures There's virtually no use for the process, so let's yield the proxy object instead because we can make use of that. --- test/test_oeffis.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/test_oeffis.py b/test/test_oeffis.py index 6eeefc5..b4cd883 100644 --- a/test/test_oeffis.py +++ b/test/test_oeffis.py @@ -53,6 +53,7 @@ from dbus.mainloop.glib import DBusGMainLoop import attr import ctypes import dbus +import dbus.proxies import dbusmock import fcntl import os @@ -317,11 +318,12 @@ def session_bus(session_bus_unmonitored) -> Iterator[dbusmock.DBusTestCase]: @pytest.fixture() -def daemon( +def mock( session_bus, portal_name="RemoteDesktop", params=None, extra_templates=[] -) -> Iterator[subprocess.Popen]: +) -> Iterator[dbus.proxies.ProxyObject]: """ - Fixture that starts a DBusMock daemon in a separate process. + Fixture that starts a DBusMock daemon in a separate process and returns + the ProxyObject for the mock. If extra_templates is specified, it is a list of tuples with the portal name as first value and the param dict to be passed to that @@ -344,7 +346,7 @@ def daemon( dbus_interface=dbusmock.MOCK_IFACE, ) - yield p_mock + yield obj_portal if p_mock.stdout: out = (p_mock.stdout.read() or b"").decode("utf-8") @@ -379,7 +381,7 @@ class TestOeffis: Test class that sets up a mocked DBus session bus to be used by liboeffis.so. """ - def test_create_session(self, daemon, mainloop): + def test_create_session(self, mock, mainloop): oeffis = Oeffis() oeffis.create_session(oeffis.DEVICE_POINTER | oeffis.DEVICE_KEYBOARD) # type: ignore oeffis.dispatch() # type: ignore