summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Hilhorst <git@hilhorst.be>2022-01-02 22:20:04 +0100
committerPatrick Hilhorst <git@hilhorst.be>2022-01-02 22:20:04 +0100
commit7830f000c57bb616b178a6a8eaef9659938ca7ea (patch)
tree6cf934382549cebe51a257e0532e2ed8e2362fe6
parentac6c06c549ed0d18e87776405d8daba16de4ae1e (diff)
downloadnixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar.gz
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar.bz2
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar.lz
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar.xz
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.tar.zst
nixpkgs-7830f000c57bb616b178a6a8eaef9659938ca7ea.zip
nixos/test-driver: simplify coopmulti
-rw-r--r--nixos/lib/test-driver/test_driver/polling_condition.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/nixos/lib/test-driver/test_driver/polling_condition.py b/nixos/lib/test-driver/test_driver/polling_condition.py
index f38dea71376..fe064b1f830 100644
--- a/nixos/lib/test-driver/test_driver/polling_condition.py
+++ b/nixos/lib/test-driver/test_driver/polling_condition.py
@@ -10,25 +10,15 @@ class PollingConditionFailed(Exception):
     pass
 
 
-def coopmulti(fun: Callable, *, machine: Any = None) -> Callable:
-    assert not (fun is None and machine is None)
+def coopmulti(fun: Callable) -> Callable:
+    @wraps(fun)
+    def wrapper(machine: Any, *args: List[Any], **kwargs: Dict[str, Any]) -> Any:
+        if machine.fail_early():  # type: ignore
+            raise PollingConditionFailed("Test interrupted early...")
 
-    def inner(fun_: Callable) -> Any:
-        @wraps(fun_)
-        def wrapper(*args: List[Any], **kwargs: Dict[str, Any]) -> Any:
-            this_machine = args[0] if machine is None else machine
+        return fun(machine, *args, **kwargs)
 
-            if this_machine.fail_early():  # type: ignore
-                raise PollingConditionFailed("Action interrupted early...")
-
-            return fun_(*args, **kwargs)
-
-        return wrapper
-
-    if fun is None:
-        return inner
-    else:
-        return inner(fun)
+    return wrapper
 
 
 class PollingCondition: