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:..}}."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/960108
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I29e1f580cdeb171cb4719c483ac8b7e26b2f4da4
Gerrit-Change-Number: 960108
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to