Skip to content

Commit 3c7a496

Browse files
committed
use function scope async fixtures
1 parent fb4478f commit 3c7a496

File tree

4 files changed

+10
-104
lines changed

4 files changed

+10
-104
lines changed

src/py/reactpy/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pre-install-command = "hatch build --hooks-only"
8080
dependencies = [
8181
"coverage[toml]>=6.5",
8282
"pytest",
83-
"pytest-asyncio>=0.17",
83+
"pytest-asyncio>=0.23",
8484
"pytest-mock",
8585
"pytest-rerunfailures",
8686
"pytest-timeout",

src/py/reactpy/tests/conftest.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
capture_reactpy_logs,
1919
clear_reactpy_web_modules_dir,
2020
)
21-
from tests.tooling.loop import open_event_loop
21+
22+
REACTPY_FEATURE_CONCURRENT_RENDERING.current = True
2223

2324

2425
def pytest_addoption(parser: Parser) -> None:
@@ -30,22 +31,19 @@ def pytest_addoption(parser: Parser) -> None:
3031
)
3132

3233

33-
REACTPY_FEATURE_CONCURRENT_RENDERING.current = True
34-
35-
3634
@pytest.fixture
3735
async def display(server, page):
3836
async with DisplayFixture(server, page) as display:
3937
yield display
4038

4139

42-
@pytest.fixture(scope="session")
40+
@pytest.fixture
4341
async def server():
4442
async with BackendFixture() as server:
4543
yield server
4644

4745

48-
@pytest.fixture(scope="session")
46+
@pytest.fixture
4947
async def page(browser):
5048
pg = await browser.new_page()
5149
pg.set_default_timeout(REACTPY_TESTING_DEFAULT_TIMEOUT.current * 1000)
@@ -55,18 +53,18 @@ async def page(browser):
5553
await pg.close()
5654

5755

58-
@pytest.fixture(scope="session")
56+
@pytest.fixture
5957
async def browser(pytestconfig: Config):
6058
async with async_playwright() as pw:
6159
yield await pw.chromium.launch(headless=not bool(pytestconfig.option.headed))
6260

6361

6462
@pytest.fixture(scope="session")
65-
def event_loop():
63+
def event_loop_policy():
6664
if os.name == "nt": # nocov
67-
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
68-
with open_event_loop() as loop:
69-
yield loop
65+
return asyncio.WindowsProactorEventLoopPolicy()
66+
else:
67+
return asyncio.DefaultEventLoopPolicy()
7068

7169

7270
@pytest.fixture(autouse=True)

src/py/reactpy/tests/test_backend/test_all.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@pytest.fixture(
1515
params=[*list(all_implementations()), default_implementation],
1616
ids=lambda imp: imp.__name__,
17-
scope="module",
1817
)
1918
async def display(page, request):
2019
imp: BackendType = request.param

src/py/reactpy/tests/tooling/loop.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)