Skip to content

Commit c8e06fb

Browse files
committed
Fix tests on windows
1 parent 6e64956 commit c8e06fb

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

requirements/test-env.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
twine
22
pytest
3-
pytest-asyncio
3+
anyio
44
pytest-cov
55
reactpy[testing,starlette]
66
nodejs-bin==18.4.0a4

tests/conftest.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import asyncio
21
import os
3-
import sys
42

53
import pytest
64
from playwright.async_api import async_playwright
@@ -18,27 +16,25 @@ def pytest_addoption(parser) -> None:
1816
)
1917

2018

21-
@pytest.fixture
19+
@pytest.fixture(scope="session")
2220
async def display(backend, browser):
2321
async with DisplayFixture(backend, browser) as display_fixture:
2422
display_fixture.page.set_default_timeout(10000)
2523
yield display_fixture
2624

2725

28-
@pytest.fixture
26+
@pytest.fixture(scope="session")
2927
async def backend():
3028
async with BackendFixture() as backend_fixture:
3129
yield backend_fixture
3230

3331

34-
@pytest.fixture
32+
@pytest.fixture(scope="session")
3533
async def browser(pytestconfig):
3634
async with async_playwright() as pw:
3735
yield await pw.chromium.launch(headless=True if GITHUB_ACTIONS else pytestconfig.getoption("headless"))
3836

3937

40-
@pytest.fixture
41-
def event_loop_policy(request):
42-
if sys.platform == "win32":
43-
return asyncio.WindowsProactorEventLoopPolicy()
44-
return asyncio.get_event_loop_policy()
38+
@pytest.fixture(scope="session")
39+
def anyio_backend():
40+
return "asyncio"

tests/test_router.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from typing import Any
33

4+
import pytest
45
from playwright.async_api._generated import Browser, Page
56
from reactpy import Ref, component, html, use_location, use_state
67
from reactpy.testing import DisplayFixture
@@ -9,6 +10,7 @@
910

1011
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "").lower() == "true"
1112
CLICK_DELAY = 500 if GITHUB_ACTIONS else 25 # Delay in miliseconds.
13+
pytestmark = pytest.mark.anyio
1214

1315

1416
async def test_simple_router(display: DisplayFixture):

0 commit comments

Comments
 (0)