diff --git a/tests/pyportaltest/__init__.py b/tests/pyportaltest/__init__.py index af053c2a..80f04a91 100644 --- a/tests/pyportaltest/__init__.py +++ b/tests/pyportaltest/__init__.py @@ -83,6 +83,14 @@ def setUpClass(cls): except AttributeError: pytest.skip("Updated version of dbusmock required") + cls.__have_session_bus = False + + @classmethod + def ensure_session_bus(cls): + if not cls.__have_session_bus: + cls.__have_session_bus = True + cls.start_session_bus() + def setUp(self): self.p_mock = None self._mainloop = None @@ -96,7 +104,7 @@ def setup_daemon(self, params=None, extra_templates: List[Tuple[str, Dict]] = [] portal name as first value and the param dict to be passed to that template as second value, e.g. ("ScreenCast", {...}). """ - self.start_session_bus() + self.ensure_session_bus() self.p_mock, self.obj_portal = self.spawn_server_template( template=f"pyportaltest/templates/{self.PORTAL_NAME.lower()}.py", parameters=params,