Skip to content

Commit 7bda5f2

Browse files
committed
refactor GITHUB_ACTIONS variable
1 parent d906dc8 commit 7bda5f2

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/reactpy/testing/backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from reactpy.config import REACTPY_TESTS_DEFAULT_TIMEOUT
1717
from reactpy.core.component import component
1818
from reactpy.core.hooks import use_callback, use_effect, use_state
19+
from reactpy.testing.common import GITHUB_ACTIONS
1920
from reactpy.testing.logs import (
2021
LogAssertionError,
2122
capture_reactpy_logs,
@@ -138,7 +139,9 @@ async def __aexit__(
138139
msg = "Unexpected logged exception"
139140
raise LogAssertionError(msg) from logged_errors[0]
140141

141-
await asyncio.wait_for(self.webserver.shutdown(), timeout=60)
142+
await asyncio.wait_for(
143+
self.webserver.shutdown(), timeout=60 if GITHUB_ACTIONS else 5
144+
)
142145

143146
async def restart(self) -> None:
144147
"""Restart the server"""

src/reactpy/testing/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import inspect
5+
import os
56
import shutil
67
import time
78
from collections.abc import Awaitable
@@ -28,6 +29,14 @@ def clear_reactpy_web_modules_dir() -> None:
2829

2930

3031
_DEFAULT_POLL_DELAY = 0.1
32+
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "False") in {
33+
"y",
34+
"yes",
35+
"t",
36+
"true",
37+
"on",
38+
"1",
39+
}
3140

3241

3342
class poll(Generic[_R]): # noqa: N801

tests/conftest.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,10 @@
1919
capture_reactpy_logs,
2020
clear_reactpy_web_modules_dir,
2121
)
22+
from reactpy.testing.common import GITHUB_ACTIONS
2223

2324
REACTPY_ASYNC_RENDERING.set_current(True)
2425
REACTPY_DEBUG.set_current(True)
25-
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "False") in {
26-
"y",
27-
"yes",
28-
"t",
29-
"true",
30-
"on",
31-
"1",
32-
}
3326

3427

3528
def pytest_addoption(parser: Parser) -> None:

tests/tooling/common.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import os
21
from typing import Any
32

3+
from reactpy.testing.common import GITHUB_ACTIONS
44
from reactpy.types import LayoutEventMessage, LayoutUpdateMessage
55

6-
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "False")
7-
DEFAULT_TYPE_DELAY = (
8-
250 if GITHUB_ACTIONS.lower() in {"y", "yes", "t", "true", "on", "1"} else 50
9-
)
6+
DEFAULT_TYPE_DELAY = 250 if GITHUB_ACTIONS else 50
107

118

129
def event_message(target: str, *data: Any) -> LayoutEventMessage:

0 commit comments

Comments
 (0)