jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[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(-)

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):

To view, visit change 510446. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief76609cfbdc976a34f5161373015ab25343860f
Gerrit-Change-Number: 510446
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Lokal Profil <andre.costa@wikimedia.se>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Hashar <hashar@free.fr>