fixtures: remove a level of indentation

A bit easier to follow.
This commit is contained in:
Ran Benita 2024-02-21 09:58:59 +02:00
parent 79def57cc6
commit 2007cf6296
1 changed files with 22 additions and 24 deletions

View File

@ -169,16 +169,14 @@ def get_parametrized_fixture_keys(
the specified scope.""" the specified scope."""
assert scope is not Scope.Function assert scope is not Scope.Function
try: try:
callspec = item.callspec # type: ignore[attr-defined] callspec: CallSpec2 = item.callspec # type: ignore[attr-defined]
except AttributeError: except AttributeError:
pass return
else:
cs: CallSpec2 = callspec
# cs.indices is random order of argnames. Need to # cs.indices is random order of argnames. Need to
# sort this so that different calls to # sort this so that different calls to
# get_parametrized_fixture_keys will be deterministic. # get_parametrized_fixture_keys will be deterministic.
for argname in sorted(cs.indices): for argname in sorted(callspec.indices):
if cs._arg2scope[argname] != scope: if callspec._arg2scope[argname] != scope:
continue continue
item_cls = None item_cls = None
@ -194,7 +192,7 @@ def get_parametrized_fixture_keys(
else: else:
assert_never(scope) assert_never(scope)
param_index = cs.indices[argname] param_index = callspec.indices[argname]
yield FixtureArgKey(argname, param_index, scoped_item_path, item_cls) yield FixtureArgKey(argname, param_index, scoped_item_path, item_cls)