From f320686fe06bb6a9a9c2009613206114edc55d40 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 11 Nov 2017 03:07:34 -0200 Subject: [PATCH] Make SubRequest.addfinalizer an explicit method This implicit definition really tripped me while debugging #2127, unfortunately hidden as it was in the middle of all the variable declarations. I think the explicit definition is much easier for the eyes and IDEs to find. --- _pytest/fixtures.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index f71f35768..966913fa6 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -575,7 +575,6 @@ class SubRequest(FixtureRequest): self.param_index = param_index self.scope = scope self._fixturedef = fixturedef - self.addfinalizer = fixturedef.addfinalizer self._pyfuncitem = request._pyfuncitem self._fixture_values = request._fixture_values self._fixture_defs = request._fixture_defs @@ -586,6 +585,9 @@ class SubRequest(FixtureRequest): def __repr__(self): return "" % (self.fixturename, self._pyfuncitem) + def addfinalizer(self, finalizer): + self._fixturedef.addfinalizer(finalizer) + class ScopeMismatchError(Exception): """ A fixture function tries to use a different fixture function which