@@ -32,7 +32,9 @@ def pytester(pytester: pytest.Pytester) -> pytest.Pytester:
3232
3333
3434@pytest .fixture (autouse = True )
35- def _add_async_marker (testdir : pytest .Testdir ) -> None :
35+ def _add_ini_asyncio (request : pytest .FixtureRequest , testdir : pytest .Testdir ) -> None :
36+ if "no_add_ini" in request .keywords :
37+ return
3638 testdir .makefile (
3739 ".ini" ,
3840 pytest = """
@@ -44,6 +46,42 @@ def _add_async_marker(testdir: pytest.Testdir) -> None:
4446 )
4547
4648
49+ @pytest .mark .no_add_ini
50+ def test_sync_async_incompatibility (testdir : pytest .Testdir ) -> None :
51+ # This test needs to load both playwright and playwright-asyncio plugins
52+ # to trigger the incompatibility check
53+ testdir .makefile (
54+ ".ini" ,
55+ pytest = """
56+ [pytest]
57+ addopts = --maxfail=1
58+ asyncio_default_test_loop_scope = session
59+ asyncio_default_fixture_loop_scope = session
60+ """ ,
61+ )
62+ testdir .makepyfile (
63+ """
64+ import pytest
65+ @pytest.mark.asyncio
66+ async def test_foo():
67+ pass
68+ """
69+ )
70+ # Explicitly load both plugins to trigger the incompatibility
71+ result = testdir .runpytest (
72+ "-p" ,
73+ "pytest_playwright.pytest_playwright" ,
74+ "-p" ,
75+ "pytest_playwright_asyncio.pytest_playwright" ,
76+ )
77+ assert result .ret != 0
78+ output = "\n " .join (result .outlines + result .errlines )
79+ assert (
80+ "pytest-playwright and pytest-playwright-asyncio are not compatible. Please use only one of them."
81+ in output
82+ )
83+
84+
4785def test_default (testdir : pytest .Testdir ) -> None :
4886 testdir .makepyfile (
4987 """
@@ -237,7 +275,7 @@ async def test_is_firefox(page, browser_name, is_chromium, is_firefox, is_webkit
237275 assert is_chromium is False
238276 assert is_firefox
239277 assert is_webkit is False
240- """
278+ """
241279 )
242280 result = testdir .runpytest ("--browser" , "firefox" )
243281 result .assert_outcomes (passed = 1 )
0 commit comments