Skip to content

fix: avoid deprecated nodeid argument to _register_fixture - #827

Merged
youtux merged 8 commits into
pytest-dev:masterfrom
Sanjays2402:fix-register-fixture-node-deprecation
Sep 14, 2026
Merged

youtux merged 8 commits into
pytest-dev:masterfrom
Sanjays2402:fix-register-fixture-node-deprecation

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #823

inject_fixture calls FixtureManager._register_fixture(nodeid=...), which pytest 9.1 deprecated in favour of node=, so every scenario using a target_fixture emits PytestRemovedIn10Warning (and fails outright in suites that error on deprecation warnings). Now passes node=request.node on pytest >= 9.1 and keeps nodeid on older versions, matching the existing version-branching in compat.py.

Regression test added in tests/steps/test_given.py; it fails on master and passes with the fix. Full suite is unchanged on pytest 9.1, and tests/steps + tests/feature still pass on pytest 9.0.

Injecting a step's target_fixture called
FixtureManager._register_fixture(nodeid=...). pytest 9.1 deprecated the
nodeid argument in favour of node, so every scenario using a
target_fixture emitted PytestRemovedIn10Warning, and suites that turn
deprecation warnings into errors failed at collection.

Pass node=request.node on pytest >= 9.1 and keep nodeid on older
versions, matching the existing version-branching in compat.py.

Added a regression test asserting the injection scenario runs clean
under -W error::DeprecationWarning; it fails without this change.
youtux
youtux previously approved these changes Aug 5, 2026
@youtux
youtux enabled auto-merge August 5, 2026 21:16
@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.13%. Comparing base (c17dbb2) to head (e05e4d8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #827      +/-   ##
==========================================
+ Coverage   96.12%   96.13%   +0.01%     
==========================================
  Files          55       55              
  Lines        2423     2430       +7     
  Branches      136      137       +1     
==========================================
+ Hits         2329     2336       +7     
  Misses         57       57              
  Partials       37       37              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

auto-merge was automatically disabled September 10, 2026 04:36

Head branch was pushed to by a user without write access

@Sanjays2402

Copy link
Copy Markdown
Contributor Author

Closed the patch-coverage gap Codecov flagged on compat.py: added tests/test_compat.py with direct unit tests for both version branches of inject_fixture — node= on pytest 9.1+ and the legacy nodeid= path (via a mocked pytest_version, since no CI job runs pytest < 9.1). Both pass locally along with the existing given-injection regression test.

@youtux

youtux commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

can you add pytest 9.1 to the tox.ini matrix and delete the tests you added? it should fail without your fix right?

@youtux
youtux enabled auto-merge September 14, 2026 20:01
- refine Python versions, pytest, and gherkin configurations
- avoid cartesian product of pytest ✕ gherkin_official
@youtux
youtux force-pushed the fix-register-fixture-node-deprecation branch from 9784146 to e05e4d8 Compare September 14, 2026 20:25
@youtux
youtux disabled auto-merge September 14, 2026 20:34
@youtux
youtux merged commit 5caa29f into pytest-dev:master Sep 14, 2026
11 of 12 checks passed
wahidyankf added a commit to wahidyankf/proto-account-ledger-py that referenced this pull request Sep 24, 2026
… deprecation warnings

pytest-bdd 8.1.0 passes arguments that pytest 9.1 deprecates, so every test level
warned PytestRemovedIn10Warning. The fix (pytest-dev/pytest-bdd#827) is merged but
unreleased; lift the cap once a later pytest-bdd ships it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation warnings with pytest 9.1.1 and python 3.14.0

2 participants