summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-12-01 11:15:58 +0100
committerBastien Nocera <hadess@hadess.net>2021-12-01 17:35:26 +0100
commit87fa6544a601bbcf8a66470a1cc767739756b6ce (patch)
treecfe562c8cc05995237bb3f9eedd29782f15d62ea /tests
parentb0d163996474932629c716f4673ca6d3a69ccabf (diff)
downloadgnome-bluetooth-87fa6544a601bbcf8a66470a1cc767739756b6ce.tar.gz
tests: Add a timeout in wait_for_condition()
Diffstat (limited to 'tests')
-rwxr-xr-xtests/integration-test9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/integration-test b/tests/integration-test
index 1a196bb6..16b1360e 100755
--- a/tests/integration-test
+++ b/tests/integration-test
@@ -76,9 +76,14 @@ class OopTests(dbusmock.DBusTestCase):
GLib.timeout_add_seconds(1, ml.quit)
ml.run()
- def wait_for_condition(self, condition):
+ def wait_for_condition(self, condition, timeout=5):
ctx = GLib.main_context_default()
- while not condition():
+ timed_out = False
+ def timeout_cb():
+ nonlocal timed_out
+ timed_out = True
+ GLib.timeout_add_seconds(1, timeout_cb)
+ while not condition() and not timed_out:
ctx.iteration(True)
def test_no_adapters(self):