1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

Add replacement addCleanup.

Change-Id: Ie85756effde344fc4cc9b693c4a28611ea091677
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Jelmer Vernooij 2015-01-27 03:44:10 +01:00 committed by Andrew Bartlett
parent e3a9feb698
commit 9a4a7b9d3e

View File

@ -53,6 +53,7 @@ class TestCase(unittest.TestCase):
def get_credentials(self):
return cmdline_credentials
# These functions didn't exist before Python2.7:
if not getattr(unittest.TestCase, "skipTest", None):
def skipTest(self, reason):
raise SkipTest(reason)
@ -65,6 +66,16 @@ class TestCase(unittest.TestCase):
def assertIsNot(self, a, b):
self.assertTrue(a is not b)
if not getattr(unittest.TestCase, "addCleanup", None):
def addCleanup(self, fn, *args, **kwargs):
self._cleanups = getattr(self, "_cleanups", []) + [
(fn, args, kwargs)]
def tearDown(self):
super(TestCase, self).tearDown()
for (fn, args, kwargs) in reversed(getattr(self, "_cleanups", [])):
fn(*args, **kwargs)
class LdbTestCase(unittest.TestCase):
"""Trivial test case for running tests against a LDB."""