Skip to content

Commit

Permalink
testcase: switch to seconds from deciseconds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
whot authored and martinpitt committed Nov 30, 2023
1 parent a049f9a commit 6368b5f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dbusmock/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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}'
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6368b5f

Please sign in to comment.