From 5e627fd3f42359d4df4d95acc4479a691fd7c0a1 Mon Sep 17 00:00:00 2001 From: md-info Date: Sun, 1 Nov 2026 14:52:15 -0500 Subject: [PATCH] Fix base_url fallback fixture deprecation with pytest 9.2 --- .../pytest_playwright_asyncio/pytest_playwright.py | 3 ++- pytest-playwright/pytest_playwright/pytest_playwright.py | 3 ++- tests/test_asyncio.py | 7 ++++++- tests/test_sync.py | 7 ++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py b/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py index f1ebce0..74bc23e 100644 --- a/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py +++ b/pytest-playwright-asyncio/pytest_playwright_asyncio/pytest_playwright.py @@ -831,7 +831,8 @@ def _is_pytest_base_url_loaded(pluginmanager: pytest.PytestPluginManager) -> boo class _BaseUrlFallback: # Provides the base_url fixture when pytest-base-url is not in use. @pytest.fixture(scope="session") - def base_url(self, pytestconfig: Any) -> Optional[str]: + @staticmethod + def base_url(pytestconfig: Any) -> Optional[str]: return ( pytestconfig.getoption("--base-url") or pytestconfig.getini("base_url") diff --git a/pytest-playwright/pytest_playwright/pytest_playwright.py b/pytest-playwright/pytest_playwright/pytest_playwright.py index fce034a..5f5663c 100644 --- a/pytest-playwright/pytest_playwright/pytest_playwright.py +++ b/pytest-playwright/pytest_playwright/pytest_playwright.py @@ -828,7 +828,8 @@ def _is_pytest_base_url_loaded(pluginmanager: pytest.PytestPluginManager) -> boo class _BaseUrlFallback: # Provides the base_url fixture when pytest-base-url is not in use. @pytest.fixture(scope="session") - def base_url(self, pytestconfig: Any) -> Optional[str]: + @staticmethod + def base_url(pytestconfig: Any) -> Optional[str]: return ( pytestconfig.getoption("--base-url") or pytestconfig.getini("base_url") diff --git a/tests/test_asyncio.py b/tests/test_asyncio.py index d34e3ea..7554775 100644 --- a/tests/test_asyncio.py +++ b/tests/test_asyncio.py @@ -457,7 +457,12 @@ def test_base_url_without_pytest_base_url( source: str, ) -> None: # https://github.com/microsoft/playwright-pytest/issues/311 - args = ["-p", "no:base_url"] + args = [ + "-p", + "no:base_url", + "-W", + "error:session-scoped fixtures defined as instance methods:pytest.PytestDeprecationWarning", + ] if source == "option": args += ["--base-url", test_server.PREFIX] elif source == "ini": diff --git a/tests/test_sync.py b/tests/test_sync.py index 9528fc5..7b7f416 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -473,7 +473,12 @@ def test_base_url_without_pytest_base_url( source: str, ) -> None: # https://github.com/microsoft/playwright-pytest/issues/311 - args = ["-p", "no:base_url"] + args = [ + "-p", + "no:base_url", + "-W", + "error:session-scoped fixtures defined as instance methods:pytest.PytestDeprecationWarning", + ] if source == "option": args += ["--base-url", test_server.PREFIX] elif source == "ini":