jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/331913 )
Change subject: Replace assertRaises with assertRaisesRegex in mediawikiversion_tests.py ......................................................................
Replace assertRaises with assertRaisesRegex in mediawikiversion_tests.py
Bug: T154281 Change-Id: I2fdcfcd358bc8e174ae2625883399c0744fec6df --- M tests/mediawikiversion_tests.py 1 file changed, 9 insertions(+), 6 deletions(-)
Approvals: jenkins-bot: Verified Sn1per: Looks good to me, approved
diff --git a/tests/mediawikiversion_tests.py b/tests/mediawikiversion_tests.py index 7c19053..cabd78e 100644 --- a/tests/mediawikiversion_tests.py +++ b/tests/mediawikiversion_tests.py @@ -19,6 +19,8 @@
"""Test MediaWikiVersion class comparisons."""
+ GENERATOR_STRING_RE = 'Generator string' + INVALID_VERSION_RE = 'Invalid version number' net = False
def _make(self, version): @@ -74,18 +76,19 @@
def test_invalid_versions(self): """Verify that insufficient version fail creating.""" - self.assertRaises(ValueError, MediaWikiVersion, 'invalid') - self.assertRaises(ValueError, MediaWikiVersion, '1number') - self.assertRaises(ValueError, MediaWikiVersion, '1.missing') + self.assertRaisesRegex(ValueError, self.INVALID_VERSION_RE, MediaWikiVersion, 'invalid') + self.assertRaisesRegex(ValueError, self.INVALID_VERSION_RE, MediaWikiVersion, '1number') + self.assertRaisesRegex(ValueError, self.INVALID_VERSION_RE, MediaWikiVersion, '1.missing')
- self.assertRaises(AssertionError, MediaWikiVersion, '1.23wmf-1') + self.assertRaisesRegex(AssertionError, 'Found "wmf" in "wmf-1"', + MediaWikiVersion, '1.23wmf-1')
def test_generator(self): """Test from_generator classmethod.""" self.assertEqual(MediaWikiVersion.from_generator('MediaWiki 1.2.3'), self._make('1.2.3')) - self.assertRaises(ValueError, MediaWikiVersion.from_generator, - 'Invalid 1.2.3') + self.assertRaisesRegex(ValueError, self.GENERATOR_STRING_RE, + MediaWikiVersion.from_generator, 'Invalid 1.2.3')
if __name__ == '__main__': # pragma: no cover
pywikibot-commits@lists.wikimedia.org