Bring back explicit tear down

Otherwise 'normal' failures won't call teardown explicitly
This commit is contained in:
Bruno Oliveira 2019-11-12 14:03:40 -03:00
parent f7b1de70c0
commit 59369651db
1 changed files with 4 additions and 0 deletions

View File

@ -110,12 +110,15 @@ class TestCaseFunction(Function):
_testcase = None
def setup(self):
self._needs_explicit_tearDown = False
self._testcase = self.parent.obj(self.name)
self._obj = getattr(self._testcase, self.name)
if hasattr(self, "_request"):
self._request._fillfixtures()
def teardown(self):
if self._needs_explicit_tearDown:
self._testcase.tearDown()
self._testcase = None
self._obj = None
@ -217,6 +220,7 @@ class TestCaseFunction(Function):
expecting_failure = self._expecting_failure(testMethod)
if expecting_failure:
raise
self._needs_explicit_tearDown = True
raise _GetOutOf_testPartExecutor(exc)
setattr(self._testcase, self._testcase._testMethodName, wrapped_testMethod)