fixtures: make code flow clearer
Make the two cases (direct/indirect fixture) clearer. The try-catch forces the reader to jump around.
This commit is contained in:
parent
5c69eced6c
commit
52fbf3dbaa
|
@ -597,8 +597,17 @@ class FixtureRequest:
|
||||||
funcitem = self._pyfuncitem
|
funcitem = self._pyfuncitem
|
||||||
scope = fixturedef._scope
|
scope = fixturedef._scope
|
||||||
try:
|
try:
|
||||||
param = funcitem.callspec.getparam(argname)
|
callspec = funcitem.callspec
|
||||||
except (AttributeError, ValueError):
|
except AttributeError:
|
||||||
|
callspec = None
|
||||||
|
if callspec is not None and argname in callspec.params:
|
||||||
|
param = callspec.params[argname]
|
||||||
|
param_index = callspec.indices[argname]
|
||||||
|
# If a parametrize invocation set a scope it will override
|
||||||
|
# the static scope defined with the fixture function.
|
||||||
|
with suppress(KeyError):
|
||||||
|
scope = callspec._arg2scope[argname]
|
||||||
|
else:
|
||||||
param = NOTSET
|
param = NOTSET
|
||||||
param_index = 0
|
param_index = 0
|
||||||
has_params = fixturedef.params is not None
|
has_params = fixturedef.params is not None
|
||||||
|
@ -638,12 +647,6 @@ class FixtureRequest:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
fail(msg, pytrace=False)
|
fail(msg, pytrace=False)
|
||||||
else:
|
|
||||||
param_index = funcitem.callspec.indices[argname]
|
|
||||||
# If a parametrize invocation set a scope it will override
|
|
||||||
# the static scope defined with the fixture function.
|
|
||||||
with suppress(KeyError):
|
|
||||||
scope = funcitem.callspec._arg2scope[argname]
|
|
||||||
|
|
||||||
subrequest = SubRequest(
|
subrequest = SubRequest(
|
||||||
self, scope, param, param_index, fixturedef, _ispytest=True
|
self, scope, param, param_index, fixturedef, _ispytest=True
|
||||||
|
|
Loading…
Reference in New Issue