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:
|
||||
pass
|
||||
else:
|
||||
fail_fixturefunc(
|
||||
fixturefunc, "yield_fixture function has more than one 'yield'"
|
||||
)
|
||||
fail_fixturefunc(fixturefunc, "fixture function has more than one 'yield'")
|
||||
|
||||
|
||||
def _eval_scope_callable(
|
||||
|
|
|
@ -13,14 +13,14 @@ from typing import Union
|
|||
|
||||
from _pytest.compat import overload
|
||||
from _pytest.compat import TYPE_CHECKING
|
||||
from _pytest.fixtures import yield_fixture
|
||||
from _pytest.fixtures import fixture
|
||||
from _pytest.outcomes import fail
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Type
|
||||
|
||||
|
||||
@yield_fixture
|
||||
@fixture
|
||||
def recwarn():
|
||||
"""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):
|
||||
checked_order.append((request.node.name, "fix1", arg1))
|
||||
yield "fix1-" + arg1
|
||||
|
||||
|
||||
@pytest.yield_fixture(scope="function")
|
||||
@pytest.fixture(scope="function")
|
||||
def fix2(request, fix1, arg2, checked_order):
|
||||
checked_order.append((request.node.name, "fix2", arg2))
|
||||
yield "fix2-" + arg2 + fix1
|
||||
|
|
|
@ -1315,7 +1315,7 @@ class TestFixtureUsages:
|
|||
|
||||
DB_INITIALIZED = None
|
||||
|
||||
@pytest.yield_fixture(scope="session", autouse=True)
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def db():
|
||||
global DB_INITIALIZED
|
||||
DB_INITIALIZED = True
|
||||
|
@ -2960,8 +2960,7 @@ class TestFixtureMarker:
|
|||
"""
|
||||
import pytest
|
||||
|
||||
@pytest.yield_fixture(params=[object(), object()],
|
||||
ids=['alpha', 'beta'])
|
||||
@pytest.fixture(params=[object(), object()], ids=['alpha', 'beta'])
|
||||
def fix(request):
|
||||
yield request.param
|
||||
|
||||
|
|
|
@ -1176,7 +1176,7 @@ class TestDoctestAutoUseFixtures:
|
|||
import pytest
|
||||
import sys
|
||||
|
||||
@pytest.yield_fixture(autouse=True, scope='session')
|
||||
@pytest.fixture(autouse=True, scope='session')
|
||||
def myfixture():
|
||||
assert not hasattr(sys, 'pytest_session_data')
|
||||
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.
|
||||
"""
|
||||
|
||||
@pytest.yield_fixture(scope="session")
|
||||
@pytest.fixture(scope="session")
|
||||
def path1(self, tmpdir_factory):
|
||||
path = tmpdir_factory.mktemp("path")
|
||||
self.setuptestfs(path)
|
||||
|
|
Loading…
Reference in New Issue