Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/676867 )
Change subject: [tests] Use subTest in reflinks_tests.py to avoid code duplications ......................................................................
[tests] Use subTest in reflinks_tests.py to avoid code duplications
Change-Id: Ia8fac78f2f8e959a27da176dd5d710cff72cc2ca --- M tests/reflinks_tests.py 1 file changed, 16 insertions(+), 17 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/tests/reflinks_tests.py b/tests/reflinks_tests.py index 15af1cf..dc94f11 100644 --- a/tests/reflinks_tests.py +++ b/tests/reflinks_tests.py @@ -63,7 +63,7 @@ start_variants = ( None, # None 'Fake', # prefix - 'Fake_page', # title + 'Fake_page', # underscore )
filename = join_xml_data_path('dummy-reflinks.xml') @@ -139,23 +139,22 @@ self.assertPageTitlesCountEqual(gen, ['Fake page', 'Talk:Fake page'], site=self.get_site())
- def test_xml_start_prefix(self): - """Test the generator using a start partial page.""" - main('-xml:' + join_xml_data_path('dummy-reflinks.xml'), - '-namespace:1', '-xmlstart:Fake') - gen = self.constructor_kwargs['generator'] - pages = list(gen) - self.assertPageTitlesEqual(pages, ['Talk:Fake page'], - site=self.get_site()) + def test_xml_start_variants(self): + """Test the generator using variants of start page.""" + start_variants = ( + '-xmlstart:Fake page', # title + '-xmlstart:Fake_page', # underscore + '-xmlstart:Fake', # prefix + )
- def test_xml_start_underscore(self): - """Test the generator using a start page with an underscore.""" - main('-xml:' + join_xml_data_path('dummy-reflinks.xml'), - '-namespace:1', '-xmlstart:Fake_page') - gen = self.constructor_kwargs['generator'] - pages = list(gen) - self.assertPageTitlesEqual(pages, ['Talk:Fake page'], - site=self.get_site()) + filename = '-xml:' + join_xml_data_path('dummy-reflinks.xml') + for start in start_variants: + with self.subTest(xmlstart=start): + main(filename, '-namespace:1', start) + gen = self.constructor_kwargs['generator'] + pages = list(gen) + self.assertPageTitlesEqual(pages, ['Talk:Fake page'], + site=self.site)
def test_xml_namespace_name(self): """Test the generator using a namespace name."""
pywikibot-commits@lists.wikimedia.org