From 14210c248a9dd313671dcddf443096c17deb052a Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Sat, 4 Jul 2020 14:28:40 +1200 Subject: python tests: drop python 2.6 compatibility functions Signed-off-by: Douglas Bagnall Reviewed-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/tests/__init__.py | 106 ----------------------------------------- 1 file changed, 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.""" -- cgit v1.2.1