Skip to content

Commit b510adf

Browse files
authored
Merge pull request #12023 from bluetech/fixtures-cleanups-2
fixtures: remove an unneeded suppress
2 parents 93cd7ba + ad651dd commit b510adf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/_pytest/fixtures.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import abc
33
from collections import defaultdict
44
from collections import deque
5-
from contextlib import suppress
65
import dataclasses
76
import functools
87
import inspect
@@ -578,21 +577,20 @@ def _compute_fixture_value(self, fixturedef: "FixtureDef[object]") -> None:
578577
# (latter managed by fixturedef)
579578
argname = fixturedef.argname
580579
funcitem = self._pyfuncitem
581-
scope = fixturedef._scope
582580
try:
583581
callspec = funcitem.callspec
584582
except AttributeError:
585583
callspec = None
586584
if callspec is not None and argname in callspec.params:
587585
param = callspec.params[argname]
588586
param_index = callspec.indices[argname]
589-
# If a parametrize invocation set a scope it will override
590-
# the static scope defined with the fixture function.
591-
with suppress(KeyError):
592-
scope = callspec._arg2scope[argname]
587+
# The parametrize invocation scope overrides the fixture's scope.
588+
scope = callspec._arg2scope[argname]
593589
else:
594590
param = NOTSET
595591
param_index = 0
592+
scope = fixturedef._scope
593+
596594
has_params = fixturedef.params is not None
597595
fixtures_not_supported = getattr(funcitem, "nofuncargs", False)
598596
if has_params and fixtures_not_supported:

0 commit comments

Comments
 (0)