diff options
author | Federico Mena Quintero <federico@gnome.org> | 2022-07-12 14:21:39 -0500 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2022-07-12 21:48:16 -0500 |
commit | d281f8e0cf0d023789006b449dd83d63edb08301 (patch) | |
tree | d044accb57f04ccb7710681cda33f41b181fb262 /tests/registryd | |
parent | 178a4238c147363150266d3524d87bbed4887e22 (diff) | |
download | at-spi2-core-d281f8e0cf0d023789006b449dd83d63edb08301.tar.gz |
Control the registry fixture's lifetime via a mock gnome-session
As for the code coverage job, we need registryd's tests to be able to
control the lifetime of at-spi-bus-launcher and at-spi2-registryd.
So, the session_manager() fixture assumes that it is running alonside
a gnome-session dbus mock. The teardown code tells the session to
Logout - this will make the mock notify session clients that they have
to terminate.
Diffstat (limited to 'tests/registryd')
-rw-r--r-- | tests/registryd/__init__.py | 1 | ||||
-rw-r--r-- | tests/registryd/conftest.py | 23 |
2 files changed, 21 insertions, 3 deletions
diff --git a/tests/registryd/__init__.py b/tests/registryd/__init__.py index e69de29b..d18f92c6 100644 --- a/tests/registryd/__init__.py +++ b/tests/registryd/__init__.py @@ -0,0 +1 @@ +dummy = "hello" diff --git a/tests/registryd/conftest.py b/tests/registryd/conftest.py index 738a5836..0729b3c8 100644 --- a/tests/registryd/conftest.py +++ b/tests/registryd/conftest.py @@ -14,7 +14,10 @@ # # * main_loop - a GLib.MainLoop integrated with the DBusGMainLoop. # -# * session_manager - A mock gnome-session to control the lifetime of daemons. +# * session_manager - A mock gnome-session to control the lifetime of daemons. In +# reality, the fixture assumes that there is a gnome-session mock running (see +# ci/run-registryd-tests.sh) and just tells that mock to Logout at fixture teardown +# time, so that all daemons that monitor the session's lifetime will exit at teardown. # # * registry - A dbus.proxies.ProxyObject for the registry's root object. This automatically # depends on a session_manager fixture to control its lifetime. @@ -29,7 +32,6 @@ def main_loop(): DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() - print("main loop created") return loop def get_accesssibility_bus_address(): @@ -42,7 +44,22 @@ def get_registry_root(a11y_bus): @pytest.fixture def session_manager(): - return None # FIXME - return a gnome-session mock + # This assumes that pytest is running in this environment: + # + # * A session dbus daemon is running + # + # * There is a gnome-session mock running + # + # See the ci/run-registryd-tests.sh script to see how that environment is set up. + + bus = dbus.SessionBus() + mock_session = bus.get_object('org.gnome.SessionManager', '/org/gnome/SessionManager') + + # return a dummy object as a fixture + yield object() + + # Tell all session clients to terminate + mock_session.Logout(0, dbus_interface='org.gnome.SessionManager') @pytest.fixture def registry(main_loop, session_manager): |