From 6368b5f5c206377e187b75e36fdf73f62293c551 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 30 Nov 2023 12:11:35 +1000 Subject: [PATCH] testcase: switch to seconds from deciseconds deciseconds is a rather unusual unit. Let's switch the real API we now have to use seconds: float like time.sleep() and wrap our old API around that. --- dbusmock/testcase.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dbusmock/testcase.py b/dbusmock/testcase.py index b9d7ebe0..21e298af 100644 --- a/dbusmock/testcase.py +++ b/dbusmock/testcase.py @@ -66,12 +66,11 @@ def reload_configuration(self): dbus_if = dbus.Interface(dbus_obj, 'org.freedesktop.DBus') dbus_if.ReloadConfig() - def wait_for_bus_object(self, dest: str, path: str, timeout: int = 600): + def wait_for_bus_object(self, dest: str, path: str, timeout: float = 60.0): '''Wait for an object to appear on D-Bus Raise an exception if object does not appear within one minute. You can - change the timeout with the "timeout" keyword argument which specifies - deciseconds. + change the timeout in seconds with the "timeout" keyword argument. ''' bus = self.get_connection() @@ -91,7 +90,7 @@ def wait_for_bus_object(self, dest: str, path: str, timeout: int = 600): if '.UnknownInterface' in str(e): break - timeout -= 1 + timeout -= 0.1 time.sleep(0.1) if timeout <= 0: assert timeout > 0, f'timed out waiting for D-Bus object {path}: {last_exc}' @@ -380,7 +379,7 @@ def wait_for_bus_object(dest: str, path: str, system_bus: bool = False, timeout: BusType.wait_for_bus_object() instead. ''' bustype = BusType.SYSTEM if system_bus else BusType.SESSION - bustype.wait_for_bus_object(dest, path, timeout) + bustype.wait_for_bus_object(dest, path, timeout / 10.0) @staticmethod def spawn_server(name: str, path: str, interface: str, system_bus: bool = False, stdout=None) -> subprocess.Popen: