Skip to content

Commit 02484e8

Browse files
committed
Do not pass on None as scope
Make sure that the default scope always is "function" so as to avoid issues with pytest <= 6, which 'translates' the scope string kwarg into an index from a list. The list does not contain None.
1 parent c5432af commit 02484e8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pytest_cases/fixture_parametrize_plus.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def create(cls,
316316
i, # type: int
317317
argvalue, # type: Any
318318
id, # type: Union[str, Callable]
319-
scope='function', # type: str
319+
scope=None, # type: str
320320
hook=None, # type: Callable
321321
debug=False # type: bool
322322
):
@@ -427,7 +427,7 @@ def create(cls,
427427
to_i, # type: int
428428
argvalues, # type: Any
429429
ids, # type: Union[Sequence[str], Callable]
430-
scope='function', # type: str
430+
scope="function", # type: str
431431
hook=None, # type: Callable
432432
debug=False # type: bool
433433
):
@@ -876,15 +876,17 @@ def _create_params_alt(fh, test_func, union_name, from_i, to_i, hook): # noqa
876876
return SingleParamAlternative.create(new_fixture_host=fh, test_func=test_func,
877877
param_union_name=union_name, argnames=argnames, i=i,
878878
argvalue=marked_argvalues[i], id=_id,
879-
scope=scope, hook=hook, debug=debug)
879+
scope=scope or "function",
880+
hook=hook, debug=debug)
880881
else:
881882
# If an explicit list of ids was provided, slice it. Otherwise the provided callable will be used later
882883
_ids = ids[from_i:to_i] if explicit_ids_to_use else ids
883884

884885
return MultiParamAlternative.create(new_fixture_host=fh, test_func=test_func,
885886
param_union_name=union_name, argnames=argnames, from_i=from_i,
886887
to_i=to_i, argvalues=marked_argvalues[from_i:to_i], ids=_ids,
887-
scope=scope, hook=hook, debug=debug)
888+
scope=scope or "function",
889+
hook=hook, debug=debug)
888890

889891

890892
def _create_fixture_ref_alt(union_name, test_func, i): # noqa

0 commit comments

Comments
 (0)