]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python tests: drop python 2.6 compatibility functions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 4 Jul 2020 02:28:40 +0000 (14:28 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Aug 2020 02:51:35 +0000 (02:51 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/__init__.py

index e7979a7e3abd97a9d9f9a59984e81ef31cfa7901..768231384d8ac41db17575ecb3b881e5e5a0a574 100644 (file)
@@ -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."""