[gnome-bluetooth/wip/hadess/more-timeout-fixes: 1/2] tests: Fix wait_for_condition() again




commit 49799919f1078d1bb1d8bddede552e9f1806c321
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Feb 23 16:01:39 2022 +0100

    tests: Fix wait_for_condition() again
    
    UnboundLocalError: local variable 'timeout' referenced before assignment
    
    Fixes: 9fb72c027f9119e6992771e4ce1f0a33c80d3e7c

 tests/integration-test.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/tests/integration-test.py b/tests/integration-test.py
index 4ec7f82f..3fa5f703 100755
--- a/tests/integration-test.py
+++ b/tests/integration-test.py
@@ -79,13 +79,12 @@ class OopTests(dbusmock.DBusTestCase):
 
     def wait_for_condition(self, condition, timeout=5):
         ctx = GLib.main_context_default()
-        timeout = timeout * 1000
+        remaining = timeout * 1000
         interval = 100
         timed_out = False
         def timeout_cb():
-            nonlocal timed_out
-            nonlocal interval
-            timeout = timeout - interval
+            nonlocal timed_out, interval, timeout
+            remaining = remaining - interval
             if timeout <= 0:
                 timed_out = True
                 return False


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]