FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Mark ``yield_fixture`` as deprecated by MarcoGorelli · Pull Request #14340 · pytest-dev/pytest · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions changelog/14340.improvement.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Marked ``yield_fixture`` as deprecated with ``deprecated`` decorator.
4 changes: 4 additions & 0 deletions src/_pytest/fixtures.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from typing import TypeVar
import warnings

from .compat import deprecated
import _pytest
from _pytest import nodes
from _pytest._code import getfslineno
Expand Down Expand Up @@ -1416,6 +1417,9 @@ def fixture(
return fixture_marker


@deprecated(
"pytest.yield_fixture is deprecated, use pytest.fixture to access configuration values instead.",

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Let's use the same text as the existing runtime deprecation.

Suggested change
"pytest.yield_fixture is deprecated, use pytest.fixture to access configuration values instead.",
"@pytest.yield_fixture is deprecated. Use @pytest.fixture instead; they are the same.",

)
def yield_fixture(
fixture_function=None,
*args,
Expand Down
2 changes: 1 addition & 1 deletion src/pytest/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from _pytest.fixtures import FixtureDef
from _pytest.fixtures import FixtureLookupError
from _pytest.fixtures import FixtureRequest
from _pytest.fixtures import yield_fixture
from _pytest.fixtures import yield_fixture # type: ignore[deprecated]
from _pytest.freeze_support import freeze_includes
from _pytest.legacypath import TempdirFactory
from _pytest.legacypath import Testdir
Expand Down
2 changes: 1 addition & 1 deletion testing/deprecated_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def pytest_runtest_call(self):
def test_yield_fixture_is_deprecated() -> None:
with pytest.warns(DeprecationWarning, match=r"yield_fixture is deprecated"):

@pytest.yield_fixture
@pytest.yield_fixture # type: ignore[deprecated]
def fix():
assert False

Expand Down
Loading

Back | FazBrowse Home | New Git URL