Skip to content

Commit 54e79af

Browse files
committed
unittest: Add setUp/tearDown methods to TestCase.
By ensuring that the `setUp`/`tearDown` methods exist in `TestCase`, we simplify the logic needed when subclassing tests. Previously people would need to know if their super class had a `setUp` method before attempting to call it from their overwritten version. Signed-off-by: Greg Darke <micropython@me.tsukasa.au>
1 parent 38675aa commit 54e79af

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

python-stdlib/unittest/unittest/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ class TestCase:
7171
def __init__(self):
7272
pass
7373

74+
def setUp(self):
75+
pass
76+
77+
@classmethod
78+
def setUpClass(cls):
79+
pass
80+
81+
def tearDown(self):
82+
pass
83+
84+
@classmethod
85+
def tearDownClass(cls):
86+
pass
87+
7488
def addCleanup(self, func, *args, **kwargs):
7589
if not hasattr(self, "_cleanups"):
7690
self._cleanups = []

0 commit comments

Comments
 (0)