diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-12-01 11:15:58 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-12-10 14:30:26 +0100 |
commit | 39ef9cb0719674e8a5bbab66d8796fa617348a00 (patch) | |
tree | b75e24ed8b6c70b3347416c6a6ab4a6f133f6084 | |
parent | a619ef1c130873e76feb80ae18ab26ddc79dd7e2 (diff) | |
download | gnome-bluetooth-39ef9cb0719674e8a5bbab66d8796fa617348a00.tar.gz |
tests: Add a timeout in wait_for_condition()
-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 a71fcecd..dee4cb77 100755 --- a/tests/integration-test +++ b/tests/integration-test @@ -73,9 +73,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): |