diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2020-07-04 14:28:40 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2020-08-03 02:51:35 +0000 |
commit | 14210c248a9dd313671dcddf443096c17deb052a (patch) | |
tree | bd00b139c60f856a42b60c14d4c2c229f836242f | |
parent | 9148f38c203c3481a43ef6d39ea9313dfa1c1bea (diff) | |
download | samba-14210c248a9dd313671dcddf443096c17deb052a.tar.gz |
python tests: drop python 2.6 compatibility functions
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | python/samba/tests/__init__.py | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index e7979a7e3ab..768231384d8 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -141,112 +141,6 @@ class TestCase(unittest.TestCase): c.set_kerberos_state(kerberos_state) return c - # These functions didn't exist before Python2.7: - if sys.version_info < (2, 7): - import warnings - - def skipTest(self, reason): - raise SkipTest(reason) - - def assertIn(self, member, container, msg=None): - self.assertTrue(member in container, msg) - - def assertIs(self, a, b, msg=None): - self.assertTrue(a is b, msg) - - def assertIsNot(self, a, b, msg=None): - self.assertTrue(a is not b, msg) - - def assertIsNotNone(self, a, msg=None): - self.assertTrue(a is not None) - - def assertIsInstance(self, a, b, msg=None): - self.assertTrue(isinstance(a, b), msg) - - def assertIsNone(self, a, msg=None): - self.assertTrue(a is None, msg) - - def assertGreater(self, a, b, msg=None): - self.assertTrue(a > b, msg) - - def assertGreaterEqual(self, a, b, msg=None): - self.assertTrue(a >= b, msg) - - def assertLess(self, a, b, msg=None): - self.assertTrue(a < b, msg) - - def assertLessEqual(self, a, b, msg=None): - self.assertTrue(a <= b, msg) - - def addCleanup(self, fn, *args, **kwargs): - self._cleanups = getattr(self, "_cleanups", []) + [ - (fn, args, kwargs)] - - def assertRegexpMatches(self, text, regex, msg=None): - # PY3 note: Python 3 will never see this, but we use - # text_type for the benefit of linters. - if isinstance(regex, (str, text_type)): - regex = re.compile(regex) - if not regex.search(text): - self.fail(msg) - - def _addSkip(self, result, reason): - addSkip = getattr(result, 'addSkip', None) - if addSkip is not None: - addSkip(self, reason) - else: - warnings.warn("TestResult has no addSkip method, skips not reported", - RuntimeWarning, 2) - result.addSuccess(self) - - def run(self, result=None): - if result is None: - result = self.defaultTestResult() - result.startTest(self) - testMethod = getattr(self, self._testMethodName) - try: - try: - self.setUp() - except SkipTest as e: - self._addSkip(result, str(e)) - return - except KeyboardInterrupt: - raise - except: - result.addError(self, self._exc_info()) - return - - ok = False - try: - testMethod() - ok = True - except SkipTest as e: - self._addSkip(result, str(e)) - return - except self.failureException: - result.addFailure(self, self._exc_info()) - except KeyboardInterrupt: - raise - except: - result.addError(self, self._exc_info()) - - try: - self.tearDown() - except SkipTest as e: - self._addSkip(result, str(e)) - except KeyboardInterrupt: - raise - except: - result.addError(self, self._exc_info()) - ok = False - - for (fn, args, kwargs) in reversed(getattr(self, "_cleanups", [])): - fn(*args, **kwargs) - if ok: - result.addSuccess(self) - finally: - result.stopTest(self) - def assertStringsEqual(self, a, b, msg=None, strip=False): """Assert equality between two strings and highlight any differences. If strip is true, leading and trailing whitespace is ignored.""" |