jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/510446 )
Change subject: [bugfix] Enable all families are tested in TestFamilyUrlRegex.test_each_family ......................................................................
[bugfix] Enable all families are tested in TestFamilyUrlRegex.test_each_family
With skipTest the whole test is skipped if the condition was reached. In this case all tests after 'lyricwiki' was found in config.family_files where droppend and btw the order of the config.family_files.keys seems not deterministic.
With this patch a subTest is used. subTest was introduced with Python 3.4. After we annouced to drop Python 2 it is not necessary to backport this context manager or find another solution. Just skip this test for older Pythons.
Bug: T223367 Change-Id: Ief76609cfbdc976a34f5161373015ab25343860f --- M tests/family_tests.py 1 file changed, 19 insertions(+), 17 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/family_tests.py b/tests/family_tests.py index e529066..43db8ed 100644 --- a/tests/family_tests.py +++ b/tests/family_tests.py @@ -237,23 +237,25 @@ def test_each_family(self): """Test each family builds a working regex.""" for family in pywikibot.config.family_files: - if family in ('wowwiki', 'lyricwiki'): - self.skipTest( - 'Family.from_url() does not work for {} (T215077)' - .format(family)) - self.current_family = family - family = Family.load(family) - for code in family.codes: - self.current_code = code - url = ('{}://{}{}/$1'.format(family.protocol(code), - family.hostname(code), - family.path(code))) - # Families can switch off if they want to be detected using URL - # this applies for test:test (there is test:wikipedia) - if family._ignore_from_url or code in family._ignore_from_url: - self.assertIsNone(family.from_url(url)) - else: - self.assertEqual(family.from_url(url), code) + with self.subTest(family=family): + if family in ('wowwiki', 'lyricwiki'): + self.skipTest( + 'Family.from_url() does not work for {} (T215077)' + .format(family)) + self.current_family = family + family = Family.load(family) + for code in family.codes: + self.current_code = code + url = ('{}://{}{}/$1'.format(family.protocol(code), + family.hostname(code), + family.path(code))) + # Families can switch off if they want to be detected using + # URL. This applies for test:test (there is test:wikipedia) + if (family._ignore_from_url + or code in family._ignore_from_url): + self.assertIsNone(family.from_url(url)) + else: + self.assertEqual(family.from_url(url), code)
class TestOldFamilyMethod(DeprecationTestCase):