@@ -1012,7 +1012,16 @@ def __call__(self, function):
1012
1012
1013
1013
1014
1014
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
+ }
1016
1025
1017
1026
fixture_function = None
1018
1027
if isinstance (callable_or_scope , str ):
@@ -1041,7 +1050,15 @@ def _parse_fixture_args(callable_or_scope, *args, **kwargs):
1041
1050
return fixture_function , arguments
1042
1051
1043
1052
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
+ ):
1045
1062
"""Decorator to mark a fixture factory function.
1046
1063
1047
1064
This decorator can be used, with or without parameters, to define a
@@ -1088,7 +1105,13 @@ def fixture(callable_or_scope=None, *args, **kwargs):
1088
1105
``@pytest.fixture(name='<fixturename>')``.
1089
1106
"""
1090
1107
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
1092
1115
)
1093
1116
scope = arguments .get ("scope" )
1094
1117
params = arguments .get ("params" )
@@ -1107,13 +1130,29 @@ def fixture(callable_or_scope=None, *args, **kwargs):
1107
1130
return FixtureFunctionMarker (scope , params , autouse , ids = ids , name = name )
1108
1131
1109
1132
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
+ ):
1111
1142
""" (return a) decorator to mark a yield-fixture factory function.
1112
1143
1113
1144
.. deprecated:: 3.0
1114
1145
Use :py:func:`pytest.fixture` directly instead.
1115
1146
"""
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
+ )
1117
1156
1118
1157
1119
1158
defaultfuncargprefixmarker = fixture ()
0 commit comments