summaryrefslogtreecommitdiff
path: root/src/_pytest/unittest.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2019-11-12 14:03:40 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2019-11-12 14:03:40 -0300
commit59369651dbe6a3bac420e16dcded9ad095b1680b (patch)
treee2315146c5331a428cbb89791b349c7bcb840940 /src/_pytest/unittest.py
parentf7b1de70c037d0ca43adc25966677d5a78034abc (diff)
downloadpytest-59369651dbe6a3bac420e16dcded9ad095b1680b.tar.gz
Bring back explicit tear down
Otherwise 'normal' failures won't call teardown explicitly
Diffstat (limited to 'src/_pytest/unittest.py')
-rw-r--r--src/_pytest/unittest.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py
index de6be7dc5..71ff580a6 100644
--- a/src/_pytest/unittest.py
+++ b/src/_pytest/unittest.py
@@ -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)