Skip to content

Commit 709d6bc

Browse files
committed
increase default testing timeout
1 parent 5772176 commit 709d6bc

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

noxfile.py

+3
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,8 @@ def get_idom_script_env() -> dict[str, str]:
390390
return {
391391
"PYTHONPATH": os.getcwd(),
392392
"IDOM_DEBUG_MODE": os.environ.get("IDOM_DEBUG_MODE", "1"),
393+
"IDOM_TESTING_DEFAULT_TIMEOUT": os.environ.get(
394+
"IDOM_TESTING_DEFAULT_TIMEOUT", "6.0"
395+
),
393396
"IDOM_CHECK_VDOM_SPEC": os.environ.get("IDOM_CHECK_VDOM_SPEC", "0"),
394397
}

src/idom/config.py

+7
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@
7777
For more information on changes to this feature flag see:
7878
https://github.com/idom-team/idom/issues/351
7979
"""
80+
81+
IDOM_TESTING_DEFAULT_TIMEOUT = _Option(
82+
"IDOM_TESTING_DEFAULT_TIMEOUT",
83+
3.0,
84+
mutable=False,
85+
validator=float,
86+
)

src/idom/testing/common.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from typing_extensions import ParamSpec, Protocol
1212

13-
from idom.config import IDOM_WEB_MODULES_DIR
13+
from idom.config import IDOM_TESTING_DEFAULT_TIMEOUT, IDOM_WEB_MODULES_DIR
1414
from idom.core.events import EventHandler, to_event_handler_function
1515
from idom.core.hooks import LifeCycleHook, current_hook
1616

@@ -24,13 +24,10 @@ def clear_idom_web_modules_dir() -> None:
2424
_P = ParamSpec("_P")
2525
_R = TypeVar("_R")
2626
_RC = TypeVar("_RC", covariant=True)
27-
_DEFAULT_TIMEOUT = 3.0
2827

2928

3029
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:
3431
...
3532

3633

@@ -50,7 +47,8 @@ def __init__(
5047
coro_function = cast(Callable[_P, Awaitable[_R]], function)
5148

5249
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,
5452
) -> None:
5553
started_at = time.time()
5654
while True:
@@ -68,7 +66,8 @@ async def coro_until(
6866
sync_function = cast(Callable[_P, _R], function)
6967

7068
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,
7271
) -> None:
7372
started_at = time.time()
7473
while True:
@@ -83,11 +82,19 @@ def sync_until(
8382

8483
self.until = sync_until
8584

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:
8790
"""Wait until the result is identical to the given value"""
8891
return self.until(lambda left: left is right, timeout)
8992

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:
9198
"""Wait until the result is equal to the given value"""
9299
# not really sure why I need a type ignore comment here
93100
return self.until(lambda left: left == right, timeout) # type: ignore

tests/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from _pytest.config.argparsing import Parser
88
from playwright.async_api import async_playwright
99

10+
from idom.config import IDOM_TESTING_DEFAULT_TIMEOUT
1011
from idom.testing import (
1112
DisplayFixture,
1213
ServerFixture,
@@ -40,7 +41,7 @@ async def server():
4041
@pytest.fixture(scope="session")
4142
async def page(browser):
4243
pg = await browser.new_page()
43-
pg.set_default_timeout(5000)
44+
pg.set_default_timeout(IDOM_TESTING_DEFAULT_TIMEOUT.current * 1000)
4445
try:
4546
yield pg
4647
finally:

0 commit comments

Comments
 (0)