Replace yield_fixture -> fixture in internal code
`yield_fixture` is a deprecated alias to `fixture`.
This commit is contained in:
parent
d69e9e60d6
commit
f00bec2a12
|
@ -924,9 +924,7 @@ def _teardown_yield_fixture(fixturefunc, it) -> None:
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
fail_fixturefunc(
|
fail_fixturefunc(fixturefunc, "fixture function has more than one 'yield'")
|
||||||
fixturefunc, "yield_fixture function has more than one 'yield'"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _eval_scope_callable(
|
def _eval_scope_callable(
|
||||||
|
|
|
@ -13,14 +13,14 @@ from typing import Union
|
||||||
|
|
||||||
from _pytest.compat import overload
|
from _pytest.compat import overload
|
||||||
from _pytest.compat import TYPE_CHECKING
|
from _pytest.compat import TYPE_CHECKING
|
||||||
from _pytest.fixtures import yield_fixture
|
from _pytest.fixtures import fixture
|
||||||
from _pytest.outcomes import fail
|
from _pytest.outcomes import fail
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
|
|
||||||
@yield_fixture
|
@fixture
|
||||||
def recwarn():
|
def recwarn():
|
||||||
"""Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
|
"""Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@ def checked_order():
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def fix1(request, arg1, checked_order):
|
def fix1(request, arg1, checked_order):
|
||||||
checked_order.append((request.node.name, "fix1", arg1))
|
checked_order.append((request.node.name, "fix1", arg1))
|
||||||
yield "fix1-" + arg1
|
yield "fix1-" + arg1
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def fix2(request, fix1, arg2, checked_order):
|
def fix2(request, fix1, arg2, checked_order):
|
||||||
checked_order.append((request.node.name, "fix2", arg2))
|
checked_order.append((request.node.name, "fix2", arg2))
|
||||||
yield "fix2-" + arg2 + fix1
|
yield "fix2-" + arg2 + fix1
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ class TestFixtureUsages:
|
||||||
|
|
||||||
DB_INITIALIZED = None
|
DB_INITIALIZED = None
|
||||||
|
|
||||||
@pytest.yield_fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
def db():
|
def db():
|
||||||
global DB_INITIALIZED
|
global DB_INITIALIZED
|
||||||
DB_INITIALIZED = True
|
DB_INITIALIZED = True
|
||||||
|
@ -2960,8 +2960,7 @@ class TestFixtureMarker:
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.yield_fixture(params=[object(), object()],
|
@pytest.fixture(params=[object(), object()], ids=['alpha', 'beta'])
|
||||||
ids=['alpha', 'beta'])
|
|
||||||
def fix(request):
|
def fix(request):
|
||||||
yield request.param
|
yield request.param
|
||||||
|
|
||||||
|
|
|
@ -1176,7 +1176,7 @@ class TestDoctestAutoUseFixtures:
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True, scope='session')
|
@pytest.fixture(autouse=True, scope='session')
|
||||||
def myfixture():
|
def myfixture():
|
||||||
assert not hasattr(sys, 'pytest_session_data')
|
assert not hasattr(sys, 'pytest_session_data')
|
||||||
sys.pytest_session_data = 1
|
sys.pytest_session_data = 1
|
||||||
|
|
|
@ -91,7 +91,7 @@ class TestImportPath:
|
||||||
Having our own pyimport-like function is inline with removing py.path dependency in the future.
|
Having our own pyimport-like function is inline with removing py.path dependency in the future.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.yield_fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def path1(self, tmpdir_factory):
|
def path1(self, tmpdir_factory):
|
||||||
path = tmpdir_factory.mktemp("path")
|
path = tmpdir_factory.mktemp("path")
|
||||||
self.setuptestfs(path)
|
self.setuptestfs(path)
|
||||||
|
|
Loading…
Reference in New Issue