Skip to content

Use pytest.fixture instead of the deprecated pytest.yield_fixture - #56

Merged
nicoddemus merged 4 commits into
pytest-dev:mainfrom
kushaldave002:fix/replace-yield-fixture
Nov 18, 2026
Merged

nicoddemus merged 4 commits into
pytest-dev:mainfrom
kushaldave002:fix/replace-yield-fixture

Conversation

@kushaldave002

@kushaldave002 kushaldave002 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #55

Problem

With pytest 9, importing pytest_services.folders emits PytestRemovedIn10Warning: @pytest.yield_fixture is deprecated for both session fixtures in that module. Any project that runs with -W error fails as soon as the plugin loads.

Fix

Both decorators now use @pytest.fixture. It has supported yield fixtures since pytest 3, and setup.py doesn't pin an older pytest. I also added a changelog entry under UNRELEASED.

Testing

New test test_folders_import_does_not_warn reloads pytest_services.folders with warnings turned into errors. It fails on main and passes with this change.

Commands run, on Python 3.12 with pytest 9.2.0:

  • pytest tests -k "not memcached and not mysql": 5 passed.
    • The memcached and mysql tests were deselected because I couldn't build pylibmc or mysqlclient without a C compiler.
  • The PytestRemovedIn10Warning entries are gone from the warnings summary.

This change is Reviewable

pytest 9 emits PytestRemovedIn10Warning for @pytest.yield_fixture when
pytest_services.folders is imported, which breaks runs with -W error.
pytest.fixture has supported yield since pytest 3.

Fixes pytest-dev#55
Comment thread tests/test_plugin.py Resolved

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicoddemus
nicoddemus merged commit b0d583b into pytest-dev:main Nov 18, 2026
1 of 7 checks passed
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 warning with pytest>=9

2 participants