jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] MediaWikiVersion: Support other versions ......................................................................
[FIX] MediaWikiVersion: Support other versions
There are certain versions which use custom version suffixes and should be properly supported.
Bug: T96813 Change-Id: I15cc1446ddc85312993c6a27310228c10415cb52 --- M pywikibot/tools/__init__.py M tests/mediawikiversion_tests.py 2 files changed, 15 insertions(+), 3 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index 03fe23d..35570d7 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -42,6 +42,8 @@ # pywikibot updates it to use logging in bot.init_handlers() debug = print_debug
+_logger = 'tools' +
class _NotImplementedWarning(RuntimeWarning):
@@ -387,7 +389,8 @@ Any other suffixes are considered invalid. """
- MEDIAWIKI_VERSION = re.compile(r'^(\d+(?:.\d+)+)(wmf(\d+)|alpha|beta(\d+)|-?rc.?(\d+))?$') + MEDIAWIKI_VERSION = re.compile( + r'^(\d+(?:.\d+)+)(wmf(\d+)|alpha|beta(\d+)|-?rc.?(\d+)|.*)?$')
def parse(self, vstring): """Parse version string.""" @@ -407,6 +410,14 @@ elif version_match.group(2) == 'alpha': self._dev_version = (1, ) else: + assert 'wmf' not in version_match.group(2) + assert 'alpha' not in version_match.group(2) + assert 'beta' not in version_match.group(2) + assert 'rc' not in version_match.group(2) + if version_match.group(2): + debug('Additional unused version part ' + '"{0}"'.format(version_match.group(2)), + _logger) self._dev_version = (4, ) self.suffix = version_match.group(2) or '' self.version = tuple(components) diff --git a/tests/mediawikiversion_tests.py b/tests/mediawikiversion_tests.py index 125a257..3dee097 100644 --- a/tests/mediawikiversion_tests.py +++ b/tests/mediawikiversion_tests.py @@ -69,14 +69,15 @@ self._version_check('1.23rc1', (1, 23), (3, 1), 'rc1') self._version_check('1.23-rc1', (1, 23), (3, 1), '-rc1') self._version_check('1.23-rc.1', (1, 23), (3, 1), '-rc.1') + self._version_check('1.23text', (1, 23), (4, ), 'text')
def test_invalid_versions(self): """Verify that insufficient version fail creating.""" self.assertRaises(ValueError, V, 'invalid') self.assertRaises(ValueError, V, '1number') self.assertRaises(ValueError, V, '1.missing') - self.assertRaises(ValueError, V, '1.23wmf-1') - self.assertRaises(ValueError, V, '1.23text') + + self.assertRaises(AssertionError, V, '1.23wmf-1')
if __name__ == '__main__':
pywikibot-commits@lists.wikimedia.org