summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r--Lib/unittest/case.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 8e01c3d..7b1e869 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -645,6 +645,18 @@ class TestCase(object):
else:
addUnexpectedSuccess(self)
+ def _callSetUp(self):
+ self.setUp()
+
+ def _callTestMethod(self, method):
+ method()
+
+ def _callTearDown(self):
+ self.tearDown()
+
+ def _callCleanup(self, function, /, *args, **kwargs):
+ function(*args, **kwargs)
+
def run(self, result=None):
orig_result = result
if result is None:
@@ -676,14 +688,14 @@ class TestCase(object):
self._outcome = outcome
with outcome.testPartExecutor(self):
- self.setUp()
+ self._callSetUp()
if outcome.success:
outcome.expecting_failure = expecting_failure
with outcome.testPartExecutor(self, isTest=True):
- testMethod()
+ self._callTestMethod(testMethod)
outcome.expecting_failure = False
with outcome.testPartExecutor(self):
- self.tearDown()
+ self._callTearDown()
self.doCleanups()
for test, reason in outcome.skipped:
@@ -721,7 +733,7 @@ class TestCase(object):
while self._cleanups:
function, args, kwargs = self._cleanups.pop()
with outcome.testPartExecutor(self):
- function(*args, **kwargs)
+ self._callCleanup(function, *args, **kwargs)
# return this for backwards compatibility
# even though we no longer use it internally