jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Redirect testcase.assertRegexpMatches ......................................................................
[IMPROV] Redirect testcase.assertRegexpMatches
With Python 3 the assertRegexpMatches was renamed to assertRegex, but the old name is still available (with a deprecation warning). To remove it, aspects.TestCase adds a assertRegex in Python 2 which calls the actual method. All usages have been replaced.
Change-Id: I988ce51bf72293d93069ee3f1bfaac786febeb94 --- M tests/aspects.py M tests/site_tests.py 2 files changed, 11 insertions(+), 3 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py index be4e36f..cbd870c 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -56,6 +56,14 @@ """ return self.assertRaisesRegexp(*args, **kwargs)
+ def assertRegex(self, *args, **kwargs): + """ + Wrapper of unittest.assertRegexpMatches for Python 2 unittest. + + assertRegexpMatches is deprecated in Python 3. + """ + return self.assertRegexpMatches(*args, **kwargs) +
class TestTimerMixin(TestCaseBase):
diff --git a/tests/site_tests.py b/tests/site_tests.py index c29d60d..c9b99bf 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -218,7 +218,7 @@ self.assertIsInstance(mysite.getcurrenttime(), pywikibot.Timestamp) ts = mysite.getcurrenttimestamp() self.assertIsInstance(ts, basestring) - self.assertRegexpMatches(ts, r'(19|20)\d\d[0-1]\d[0-3]\d[0-2]\d[0-5]\d[0-5]\d') + self.assertRegex(ts, r'(19|20)\d\d[0-1]\d[0-3]\d[0-2]\d[0-5]\d[0-5]\d')
self.assertIsInstance(mysite.siteinfo, pywikibot.site.Siteinfo) self.assertIsInstance(mysite.months_names, list) @@ -1104,7 +1104,7 @@ try: token = self.mysite.tokens[ttype] except pywikibot.Error as error_msg: - self.assertRegexpMatches( + self.assertRegex( unicode(error_msg), "Action '[a-z]+' is not allowed for user .* on .* wiki.") else: @@ -1193,7 +1193,7 @@ self.assertIsInstance(mysite.siteinfo['timeoffset'], (int, float)) self.assertTrue(-12 * 60 <= mysite.siteinfo['timeoffset'] <= +14 * 60) self.assertEqual(mysite.siteinfo['timeoffset'] % 15, 0) - self.assertRegexpMatches(mysite.siteinfo['timezone'], "([A-Z]{3,4}|[A-Z][a-z]+/[A-Z][a-z]+)") + self.assertRegex(mysite.siteinfo['timezone'], "([A-Z]{3,4}|[A-Z][a-z]+/[A-Z][a-z]+)") self.assertIsInstance(datetime.strptime(mysite.siteinfo['time'], "%Y-%m-%dT%H:%M:%SZ"), datetime) self.assertGreater(mysite.siteinfo['maxuploadsize'], 0) self.assertIn(mysite.case(), ["first-letter", "case-sensitive"])