diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-12-01 11:15:58 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-12-01 17:35:26 +0100 |
commit | 87fa6544a601bbcf8a66470a1cc767739756b6ce (patch) | |
tree | cfe562c8cc05995237bb3f9eedd29782f15d62ea /tests | |
parent | b0d163996474932629c716f4673ca6d3a69ccabf (diff) | |
download | gnome-bluetooth-87fa6544a601bbcf8a66470a1cc767739756b6ce.tar.gz |
tests: Add a timeout in wait_for_condition()
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/integration-test | 9 |
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): |