Skip to content

Commit f2f3ced

Browse files
committed
Fixed the fixture function signature.
1 parent 10bf6aa commit f2f3ced

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

src/_pytest/fixtures.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,16 @@ def __call__(self, function):
10121012

10131013

10141014
def _parse_fixture_args(callable_or_scope, *args, **kwargs):
1015-
arguments = dict(scope="function", params=None, autouse=False, ids=None, name=None)
1015+
arguments = {
1016+
"scope": "function",
1017+
"params": None,
1018+
"autouse": False,
1019+
"ids": None,
1020+
"name": None,
1021+
}
1022+
kwargs = {
1023+
key: value for key, value in kwargs.items() if arguments.get(key) != value
1024+
}
10161025

10171026
fixture_function = None
10181027
if isinstance(callable_or_scope, str):
@@ -1041,7 +1050,15 @@ def _parse_fixture_args(callable_or_scope, *args, **kwargs):
10411050
return fixture_function, arguments
10421051

10431052

1044-
def fixture(callable_or_scope=None, *args, **kwargs):
1053+
def fixture(
1054+
callable_or_scope=None,
1055+
*args,
1056+
scope="function",
1057+
params=None,
1058+
autouse=False,
1059+
ids=None,
1060+
name=None
1061+
):
10451062
"""Decorator to mark a fixture factory function.
10461063
10471064
This decorator can be used, with or without parameters, to define a
@@ -1088,7 +1105,13 @@ def fixture(callable_or_scope=None, *args, **kwargs):
10881105
``@pytest.fixture(name='<fixturename>')``.
10891106
"""
10901107
fixture_function, arguments = _parse_fixture_args(
1091-
callable_or_scope, *args, **kwargs
1108+
callable_or_scope,
1109+
*args,
1110+
scope=scope,
1111+
params=params,
1112+
autouse=autouse,
1113+
ids=ids,
1114+
name=name
10921115
)
10931116
scope = arguments.get("scope")
10941117
params = arguments.get("params")
@@ -1107,13 +1130,29 @@ def fixture(callable_or_scope=None, *args, **kwargs):
11071130
return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name)
11081131

11091132

1110-
def yield_fixture(callable_or_scope=None, *args, **kwargs):
1133+
def yield_fixture(
1134+
callable_or_scope=None,
1135+
*args,
1136+
scope="function",
1137+
params=None,
1138+
autouse=False,
1139+
ids=None,
1140+
name=None
1141+
):
11111142
""" (return a) decorator to mark a yield-fixture factory function.
11121143
11131144
.. deprecated:: 3.0
11141145
Use :py:func:`pytest.fixture` directly instead.
11151146
"""
1116-
return fixture(callable_or_scope=callable_or_scope, *args, **kwargs)
1147+
return fixture(
1148+
callable_or_scope,
1149+
*args,
1150+
scope=scope,
1151+
params=params,
1152+
autouse=autouse,
1153+
ids=ids,
1154+
name=name
1155+
)
11171156

11181157

11191158
defaultfuncargprefixmarker = fixture()

0 commit comments

Comments
 (0)