10
10
11
11
from typing_extensions import ParamSpec , Protocol
12
12
13
- from idom .config import IDOM_WEB_MODULES_DIR
13
+ from idom .config import IDOM_TESTING_DEFAULT_TIMEOUT , IDOM_WEB_MODULES_DIR
14
14
from idom .core .events import EventHandler , to_event_handler_function
15
15
from idom .core .hooks import LifeCycleHook , current_hook
16
16
@@ -24,13 +24,10 @@ def clear_idom_web_modules_dir() -> None:
24
24
_P = ParamSpec ("_P" )
25
25
_R = TypeVar ("_R" )
26
26
_RC = TypeVar ("_RC" , covariant = True )
27
- _DEFAULT_TIMEOUT = 3.0
28
27
29
28
30
29
class _UntilFunc (Protocol [_RC ]):
31
- def __call__ (
32
- self , condition : Callable [[_RC ], bool ], timeout : float = _DEFAULT_TIMEOUT
33
- ) -> Any :
30
+ def __call__ (self , condition : Callable [[_RC ], bool ], timeout : float = ...) -> Any :
34
31
...
35
32
36
33
@@ -50,7 +47,8 @@ def __init__(
50
47
coro_function = cast (Callable [_P , Awaitable [_R ]], function )
51
48
52
49
async def coro_until (
53
- condition : Callable [[_R ], bool ], timeout : float = _DEFAULT_TIMEOUT
50
+ condition : Callable [[_R ], bool ],
51
+ timeout : float = IDOM_TESTING_DEFAULT_TIMEOUT .current ,
54
52
) -> None :
55
53
started_at = time .time ()
56
54
while True :
@@ -68,7 +66,8 @@ async def coro_until(
68
66
sync_function = cast (Callable [_P , _R ], function )
69
67
70
68
def sync_until (
71
- condition : Callable [[_R ], bool ] | Any , timeout : float = _DEFAULT_TIMEOUT
69
+ condition : Callable [[_R ], bool ] | Any ,
70
+ timeout : float = IDOM_TESTING_DEFAULT_TIMEOUT .current ,
72
71
) -> None :
73
72
started_at = time .time ()
74
73
while True :
@@ -83,11 +82,19 @@ def sync_until(
83
82
84
83
self .until = sync_until
85
84
86
- def until_is (self , right : Any , timeout : float = _DEFAULT_TIMEOUT ) -> Any :
85
+ def until_is (
86
+ self ,
87
+ right : Any ,
88
+ timeout : float = IDOM_TESTING_DEFAULT_TIMEOUT .current ,
89
+ ) -> Any :
87
90
"""Wait until the result is identical to the given value"""
88
91
return self .until (lambda left : left is right , timeout )
89
92
90
- def until_equals (self , right : Any , timeout : float = _DEFAULT_TIMEOUT ) -> Any :
93
+ def until_equals (
94
+ self ,
95
+ right : Any ,
96
+ timeout : float = IDOM_TESTING_DEFAULT_TIMEOUT .current ,
97
+ ) -> Any :
91
98
"""Wait until the result is equal to the given value"""
92
99
# not really sure why I need a type ignore comment here
93
100
return self .until (lambda left : left == right , timeout ) # type: ignore
0 commit comments