jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/960108 )
Change subject: [tests] combine 3 textlib tests to prevent similar code blocks ......................................................................
[tests] combine 3 textlib tests to prevent similar code blocks
Use subTest instead.
Change-Id: I29e1f580cdeb171cb4719c483ac8b7e26b2f4da4 --- M tests/textlib_tests.py 1 file changed, 24 insertions(+), 21 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index b0a642b..142b474 100755 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -1464,28 +1464,20 @@ self.assertIsNone(re.search(builder.pattern('quick'), string))
def test_match(self): - """Test text with one match without parameters.""" - string = 'The {{quick}} brown fox' + """Test text with one match.""" + tests = ( + 'The {{quick}} brown fox', # without parameters + 'The {{quick|brown}} fox', # with parameters + 'The {{msg:quick}} brown fox', # with {{msg:..}} + ) builder = MultiTemplateMatchBuilder(self.site) - self.assertIsNotNone(re.search(builder.pattern('quick'), string)) - self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), - self._template_not_case_sensitive) - - def test_match_with_params(self): - """Test text with one match with parameters.""" - string = 'The {{quick|brown}} fox' - builder = MultiTemplateMatchBuilder(self.site) - self.assertIsNotNone(re.search(builder.pattern('quick'), string)) - self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), - self._template_not_case_sensitive) - - def test_match_msg(self): - """Test text with {{msg:..}}.""" - string = 'The {{msg:quick}} brown fox' - builder = MultiTemplateMatchBuilder(self.site) - self.assertIsNotNone(re.search(builder.pattern('quick'), string)) - self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), - self._template_not_case_sensitive) + for string in tests: + with self.subTest(string=string): + self.assertIsNotNone( + re.search(builder.pattern('quick'), string)) + self.assertEqual( + bool(re.search(builder.pattern('Quick'), string)), + self._template_not_case_sensitive)
def test_match_template_prefix(self): """Test pages with {{template:..}}."""
pywikibot-commits@lists.wikimedia.org