summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2022-02-23 13:20:43 +0100
committerBastien Nocera <hadess@hadess.net>2022-02-23 13:20:43 +0100
commit9fb72c027f9119e6992771e4ce1f0a33c80d3e7c (patch)
tree8d7a0d7f42d3e7dbd7672673e2b103fb0015a9d4 /tests
parent24a43c250f829e9283c719700bcd3e394d3099e2 (diff)
downloadgnome-bluetooth-9fb72c027f9119e6992771e4ce1f0a33c80d3e7c.tar.gz
tests: Fix wait_for_condition()
Correctly loop for "timeout" seconds instead of returning after the first iteration of the mainloop.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/integration-test.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/integration-test.py b/tests/integration-test.py
index 306cc0c0..99d97def 100755
--- a/tests/integration-test.py
+++ b/tests/integration-test.py
@@ -79,11 +79,18 @@ class OopTests(dbusmock.DBusTestCase):
def wait_for_condition(self, condition, timeout=5):
ctx = GLib.main_context_default()
+ timeout = timeout * 1000
+ interval = 100
timed_out = False
def timeout_cb():
nonlocal timed_out
- timed_out = True
- GLib.timeout_add(100, timeout_cb)
+ nonlocal interval
+ timeout = timeout - interval
+ if timeout <= 0:
+ timed_out = True
+ return False
+ return True
+ GLib.timeout_add(interval, timeout_cb)
while not condition() and not timed_out:
ctx.iteration(True)