Skip to content

Commit

Permalink
avoid exponential recursion by checking if already added
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmonMode committed Jan 23, 2020
1 parent bab4dd0 commit 83349d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/_pytest/fixtures.py
Expand Up @@ -889,7 +889,15 @@ def execute(self, request):
for argname in self._dependee_fixture_argnames(request):
fixturedef = request._get_active_fixturedef(argname)
if argname != "request":
fixturedef.addfinalizer(functools.partial(self.finish, request=request))
for fin in fixturedef._finalizers:
if "request" in getattr(fin, "keywords", {}):
if self == fin.keywords["request"]._fixturedef:
break
else:
fixturedef.addfinalizer(
functools.partial(self.finish, request=request)
)


my_cache_key = self.cache_key(request)
cached_result = getattr(self, "cached_result", None)
Expand Down

0 comments on commit 83349d7

Please sign in to comment.