XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/234842
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, 9 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/42/234842/1
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 03fe23d..82e7cb6 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -387,7 +387,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 +408,10 @@
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)
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__':
--
To view, visit https://gerrit.wikimedia.org/r/234842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I15cc1446ddc85312993c6a27310228c10415cb52
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits