Merge pull request #7253 from bluetech/fixture-special-case
fixtures: remove special cases when deciding when pytest.fixture() is a direct decoration
This commit is contained in:
commit
e7c26a92d7
|
@ -0,0 +1,3 @@
|
|||
When using ``pytest.fixture`` on a function directly, as in ``pytest.fixture(func)``,
|
||||
if the ``autouse`` or ``params`` arguments are also passed, the function is no longer
|
||||
ignored, but is marked as a fixture.
|
|
@ -1152,13 +1152,15 @@ def fixture(
|
|||
if params is not None:
|
||||
params = list(params)
|
||||
|
||||
if fixture_function and params is None and autouse is False:
|
||||
# direct decoration
|
||||
return FixtureFunctionMarker(scope, params, autouse, name=name)(
|
||||
fixture_function
|
||||
)
|
||||
fixture_marker = FixtureFunctionMarker(
|
||||
scope=scope, params=params, autouse=autouse, ids=ids, name=name,
|
||||
)
|
||||
|
||||
return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)
|
||||
# Direct decoration.
|
||||
if fixture_function:
|
||||
return fixture_marker(fixture_function)
|
||||
|
||||
return fixture_marker
|
||||
|
||||
|
||||
def yield_fixture(
|
||||
|
|
Loading…
Reference in New Issue