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.

farnalabs pushed a commit to farnalabs/modulo-bak that referenced this pull request Sep 2, 2026
The BDD (full suite) CI step failed at 'uv sync --frozen' because the
pytest-bdd dev dependency was pinned to a GitHub git ref/commit
(pytest-dev/pytest-bdd#827). GitHub rejects anonymous fetch-by-SHA, and even
the ref-based pin forces a SHA fetch when the uv git cache is cold, so the
install step died with 'could not read Username'.

No PyPI release carries the pytest-9.1 _register_fixture(nodeid=...) fix yet
(pytest-dev/pytest-bdd#823); 8.1.0 is the latest. Vendor the prebuilt wheel
(built from pytest-bdd commit 60f6625b) under backend/vendor/ and point
[tool.uv.sources] at it so the dependency installs fully offline. Replace
with a >=8.1.1 PyPI pin once the fix is released.

Fixes the red BDD (full suite) check on head commit of
fix/integration-testcontainers-deprecation-1788357736 (PR #2397).
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