Skip to content

fix: avoid deprecated nodeid argument to _register_fixture - #827

Open
Sanjays2402 wants to merge 1 commit into
pytest-dev:masterfrom
Sanjays2402:fix-register-fixture-node-deprecation
Open

fix: avoid deprecated nodeid argument to _register_fixture#827
Sanjays2402 wants to merge 1 commit into
pytest-dev:masterfrom
Sanjays2402:fix-register-fixture-node-deprecation

Conversation

@Sanjays2402

Copy link
Copy Markdown

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 enabled auto-merge August 5, 2026 21:16
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.22%. Comparing base (582f045) to head (60f6625).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/pytest_bdd/compat.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #827      +/-   ##
==========================================
- Coverage   96.12%   95.22%   -0.90%     
==========================================
  Files          55       55              
  Lines        2423     2431       +8     
  Branches      136      137       +1     
==========================================
- Hits         2329     2315      -14     
- Misses         57       76      +19     
- Partials       37       40       +3     

☔ 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.

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