diff options
author | Ran Benita <ran@unusedvar.com> | 2020-10-31 22:44:10 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-11-07 17:06:40 +0200 |
commit | 4c0513bc18f52b24b69d60c0b1b5e9666e084c06 (patch) | |
tree | 1adeaee44cb3f5d7a9d046aa5d1778d04856276c /src/_pytest | |
parent | 3bcd316f076b185bcc89c41a41345861f752aff7 (diff) | |
download | pytest-4c0513bc18f52b24b69d60c0b1b5e9666e084c06.tar.gz |
fixtures: deprecate pytest.yield_fixture()
Diffstat (limited to 'src/_pytest')
-rw-r--r-- | src/_pytest/deprecated.py | 4 | ||||
-rw-r--r-- | src/_pytest/fixtures.py | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index a9a162f41..2e9154e83 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -32,6 +32,10 @@ PYTEST_COLLECT_MODULE = UnformattedWarning( "Please update to the new name.", ) +YIELD_FIXTURE = PytestDeprecationWarning( + "@pytest.yield_fixture is deprecated.\n" + "Use @pytest.fixture instead; they are the same." +) MINUS_K_DASH = PytestDeprecationWarning( "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead." diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 18094f21c..cef998c03 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -50,6 +50,7 @@ from _pytest.config import _PluggyPlugin from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.deprecated import FILLFUNCARGS +from _pytest.deprecated import YIELD_FIXTURE from _pytest.mark import Mark from _pytest.mark import ParameterSet from _pytest.mark.structures import MarkDecorator @@ -1339,6 +1340,7 @@ def yield_fixture( .. deprecated:: 3.0 Use :py:func:`pytest.fixture` directly instead. """ + warnings.warn(YIELD_FIXTURE, stacklevel=2) return fixture( fixture_function, *args, |