Skip to content

PytestRemovedIn10Warning for base_url with pytest 9.2.0 and pytest-playwright 0.10.0 without pytest-base-url #341

Closed

Description

@kcharlan

With pytest 9.2.0 and pytest-playwright 0.10.0 without pytest-base-url, a test using page passes with 1 PytestRemovedIn10Warning naming the base_url fixture, and reports ERROR at setup of test_page_fixture[chromium] when that warning is an error. I saw the same warning with pytest-playwright-asyncio 0.10.0. I did not see it with pytest 9.1.1, with pytest-base-url 2.1.0 installed, or with pytest-playwright 0.9.0, which requires pytest-base-url.

Version

pytest-playwright 0.10.0, pytest 9.2.0, playwright 1.64.1. PyPI listed pytest-playwright 0.10.0 and pytest 9.2.0 as latest at 2026-10-30T19:43:53Z.

Steps to reproduce

test_repro.py:

def test_page_fixture(page):
    page.goto("about:blank")
python -m pip install pytest==9.2.0 pytest-playwright==0.10.0
python -m pytest -q -p no:cacheprovider
python -m pytest -q -p no:cacheprovider -W error::pytest.PytestRemovedIn10Warning

Chromium builds chromium-1248 and chromium_headless_shell-1248 were already installed. Each row below is a fresh venv:

pytest Plugin pytest-base-url Flags Result
9.2.0 pytest-playwright 0.10.0 not installed 1 passed, 1 warning
9.2.0 pytest-playwright 0.10.0 not installed -W error::pytest.PytestRemovedIn10Warning 1 error
9.2.0 pytest-playwright 0.10.0 2.1.0 1 passed
9.1.1 pytest-playwright 0.10.0 not installed 1 passed
9.2.0 pytest-playwright 0.9.0 2.1.0, installed as its dependency 1 passed
9.2.0 pytest-playwright-asyncio 0.10.0 not installed 1 passed, 1 warning

The asyncio row used a separate file, test_repro_async.py:

import pytest


@pytest.mark.asyncio(loop_scope="session")
async def test_page_fixture(page):
    await page.goto("about:blank")

Every row used Python 3.14.10 and playwright 1.64.1. pytest-asyncio 1.4.1 was also installed in the asyncio row.

Evidence: repro/run_all.zsh, repro/run_scenario.zsh and the six scenarios in ledger.md, in the attached bundle.zip. The commands above leave out the venv path, --quiet --disable-pip-version-check and 2>&1 | tail -2 on the install, and, on the pytest runs, PYTHONDONTWRITEBYTECODE=1, the cd into the case directory, and the 2>&1, sed and tail output handling. Result cells leave out the duration. Each scenario prints hashes of its installed _pytest/fixtures.py and plugin file.

Actual behavior

test_repro.py::test_page_fixture[chromium]
  <venv>/lib/python3.14/site-packages/_pytest/fixtures.py:1392: PytestRemovedIn10Warning: Session-scoped fixtures defined as instance methods are deprecated.
  Instance attributes set in the 'base_url' fixture will NOT be visible to test methods,
  as each test gets a new instance while the fixture runs only once per class.
  Use a @classmethod decorator below @pytest.fixture and set attributes on cls instead.
  See https://docs.pytest.org/en/stable/deprecations.html#class-scoped-fixture-as-instance-method
    fixturefunc = resolve_fixture_function(fixturedef, request)

With the warning as an error, adding --tb=short:

________________ ERROR at setup of test_page_fixture[chromium] _________________
[...]
ERROR test_repro.py::test_page_fixture[chromium] - pytest.PytestRemovedIn10Wa...
1 error in 1.09s

Evidence: excerpts of scenario A and of the --tb=short run of scenario B in ledger.md. <venv> replaces the temporary venv path. [...] replaces the traceback lines, the E lines and the short test summary info rule.

Additional context

Pointer Label
pytest_playwright.py L818 _BaseUrlFallback registration
pytest_playwright.py L828-L836 _BaseUrlFallback.base_url
pytest_playwright.py L420 browser_context_args parameter
asyncio pytest_playwright.py L821, L831-L839, L423 asyncio registration, fixture, browser_context_args parameter
pyproject L27 declared pytest range, v0.10.0
pyproject L28 pytest-base-url requirement, v0.9.0
63a07cd first commit on the v0.10.0 history touching _BaseUrlFallback in pytest_playwright.py
pytest fixtures.py L1355-L1368 CLASS_FIXTURE_INSTANCE_METHOD warnings.warn call and the conditions above it, pytest 9.2.0
pytest deprecations.rst L292-L294 deprecation text, pytest 9.2.0
pytest changelog.rst L67-L69 changelog entry, pytest 9.2.0
pytest #15200 comment pytest 9.2 release planning, comment of 2026-10-25T14:47:34Z
pytest #15203 draft PR, PytestRemovedIn11Warning

The plugin file pointers without a stated version are at v0.10.0 (80d7569). The _BaseUrlFallback registration and fixture lines, sync and asyncio, are identical at main (f71b92f).

Downstream PRs mentioning _BaseUrlFallback:

Not examined: Python versions other than 3.14.10; Linux and Windows; Firefox and WebKit; pytest-playwright built from main; unreleased pytest.

Evidence: commands and output are in ledger.md in the attached bundle.zip, with scenario output limited to the last 14 lines per run except the --tb=short run.

Environment

- Operating System: macOS 27.2
- CPU: arm64
- Browser: Chromium
- Python Version: 3.14.10
- Other info: uv 0.13.6 created the venvs

bundle.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions