Skip to content

Add PytestRemovedIn11Warning for unreleased deprecations - #15203

Draft
RonnyPfannschmidt wants to merge 1 commit into
mainfrom
claude/pytest11-deprecations-ws7d1o
Draft

RonnyPfannschmidt wants to merge 1 commit into
mainfrom
claude/pytest11-deprecations-ws7d1o

Conversation

@RonnyPfannschmidt

@RonnyPfannschmidt RonnyPfannschmidt commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Requested by Ronny · project thread

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Before: three deprecations that exist only on main use PytestRemovedIn10Warning. With the next release planned as 10.0 (#15200), which turns those warnings into errors, they would go from not existing straight to an error.

After: they use a new PytestRemovedIn11Warning, so 10.0 ships them as warnings and 11.0 removes them:

All deprecations released in 9.1 or earlier stay scheduled for pytest 10.

How: add and export the warning class, add a HIGHER_SCOPED_FIXTURE_INSTANCE_METHOD warning that reuses the class-scope message and is picked by fixture scope, and update docs, tests and the unreleased changelog fragments. Also fixes two wrong .. deprecated:: versions in deprecations.rst: config.inicfg was deprecated in 9.1 (not 9.0), and the CallSpec2 alias is unreleased (not 9.1).

Coverage of the warning sites

Checked by running the full test suite under coverage on this branch and looking up every line in src/_pytest that emits a constant from _pytest/deprecated.py.

Moved to pytest 11, all covered:

Warning Emit site Covered by
CLASS_FIXTURE_INSTANCE_METHOD / HIGHER_SCOPED_FIXTURE_INSTANCE_METHOD fixtures.py resolve_fixture_function (scope pick and __tracebackhide__) deprecated_test.py::test_higher_scope_instance_method_is_deprecated (class → In10, module/package/session → In11)
INI_STRING_TYPE_NON_STR_VALUE config/__init__.py _getini test_config.py::TestConfigAPI::test_addini_string_non_str_deprecated
CALLSPEC2_RENAMED python.py module __getattr__ deprecated_test.py::test_callspec2_renamed

Staying on pytest 10: every emit site is covered except MONKEYPATCH_LEGACY_NAMESPACE_PACKAGES (monkeypatch.py). Its only test, test_monkeypatch.py::test_syspath_prepend_with_namespace_packages, does importorskip("pkg_resources") and was skipped locally because the installed setuptools has no pkg_resources. I did not check whether any CI job installs it. Codecov patch is green for this PR.

Affected open PRs

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 18, 2026
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Oct 18, 2026
The next release is planned as pytest 10.0 (#15200), which turns
PytestRemovedIn10Warning into errors. Three deprecations on main were
never released, so they would go straight from nothing to an error.

Add PytestRemovedIn11Warning and use it for:

- module/package/session-scoped fixtures defined as instance methods
  (class-scoped ones, deprecated in 9.1, stay on pytest 10)
- non-string values for string-typed ini options
- the _pytest.python.CallSpec2 alias

Also correct two "deprecated since" versions in deprecations.rst:
config.inicfg was deprecated in 9.1 (not 9.0), and the CallSpec2 alias
is unreleased (not 9.1).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@RonnyPfannschmidt
RonnyPfannschmidt force-pushed the claude/pytest11-deprecations-ws7d1o branch from 7f8c6da to 9664b82 Compare October 18, 2026 15:44
@RonnyPfannschmidt RonnyPfannschmidt changed the title Reschedule pytest 9.1+ deprecations for removal in pytest 11 Add PytestRemovedIn11Warning for unreleased deprecations Oct 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant