File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Marked ``yield_fixture `` as deprecated to type checkers using the ``deprecated `` decorator. Note it
2+ :ref: `has originally been deprecated <yield-fixture-deprecated >` in pytest 6.2 already.
Original file line number Diff line number Diff line change @@ -287,6 +287,8 @@ conflicts (such as :class:`pytest.File` now taking ``path`` instead of
287287deprecation warning is now raised.
288288
289289
290+ .. _yield-fixture-deprecated :
291+
290292The ``yield_fixture `` function/decorator
291293~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292294
Original file line number Diff line number Diff line change 3232from typing import TypeVar
3333import warnings
3434
35+ from .compat import deprecated
3536import _pytest
3637from _pytest import nodes
3738from _pytest ._code import getfslineno
@@ -1416,6 +1417,10 @@ def fixture(
14161417 return fixture_marker
14171418
14181419
1420+ @deprecated (
1421+ "@pytest.yield_fixture is deprecated. Use @pytest.fixture instead; they are the same." ,
1422+ category = None , # We have our own runtime warning logic
1423+ )
14191424def yield_fixture (
14201425 fixture_function = None ,
14211426 * args ,
Original file line number Diff line number Diff line change 2626from _pytest .fixtures import FixtureDef
2727from _pytest .fixtures import FixtureLookupError
2828from _pytest .fixtures import FixtureRequest
29- from _pytest .fixtures import yield_fixture
29+ from _pytest .fixtures import yield_fixture # type: ignore[deprecated]
3030from _pytest .freeze_support import freeze_includes
3131from _pytest .legacypath import TempdirFactory
3232from _pytest .legacypath import Testdir
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def pytest_runtest_call(self):
6868def test_yield_fixture_is_deprecated () -> None :
6969 with pytest .warns (DeprecationWarning , match = r"yield_fixture is deprecated" ):
7070
71- @pytest .yield_fixture
71+ @pytest .yield_fixture # type: ignore[deprecated]
7272 def fix ():
7373 assert False
7474
You can’t perform that action at this time.
0 commit comments