jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] TestBaseCase: Only add backward compatible aliases if needed ......................................................................
[IMPROV] TestBaseCase: Only add backward compatible aliases if needed
Instead of assuming that Python 2 won't support currently Python 3 specific methods this just adds a wrapper for the old name if the new name isn't implemented.
Change-Id: I1022d27fcecdc516b3ebf42dc3380458163b2aa4 --- M tests/aspects.py 1 file changed, 2 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py index d6da7b8..40edb6d 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -49,7 +49,7 @@
"""Base class for all tests."""
- if sys.version_info[0] == 2: + if not hasattr(unittest.TestCase, 'assertRaisesRegex'): def assertRaisesRegex(self, *args, **kwargs): """ Wrapper of unittest.assertRaisesRegexp for Python 2 unittest. @@ -58,6 +58,7 @@ """ return self.assertRaisesRegexp(*args, **kwargs)
+ if not hasattr(unittest.TestCase, 'assertRegex'): def assertRegex(self, *args, **kwargs): """ Wrapper of unittest.assertRegexpMatches for Python 2 unittest.
pywikibot-commits@lists.wikimedia.org