jenkins-bot merged this change.

View Change

Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
[tests] Do not use test_family for tests

test_family is deprecated in favour of wikipedia:test

- use "wikipedia" instead of "test" for *_obsolete_readonly tests
- use subTest with test_family_load_valid
- suppress warning for deprecated test_family in test_family_load_valid

Bug: T228375
Change-Id: Idb572837fc364579c2ba1e4ca20344afeea7d06e
---
M tests/family_tests.py
1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/tests/family_tests.py b/tests/family_tests.py
index 8c321a1..28c5007 100644
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -37,30 +37,34 @@
def test_family_load_valid(self):
"""Test that a family can be loaded via Family.load."""
for name in pywikibot.config.family_files:
- f = Family.load(name)
- self.assertIsInstance(f.langs, dict)
- self.assertTrue(f.langs)
- self.assertTrue(f.codes)
- self.assertTrue(iter(f.codes))
- self.assertIsInstance(next(iter(f.codes)), basestring)
- self.assertTrue(f.domains)
- self.assertTrue(iter(f.domains))
- for domain in f.domains:
- self.assertIsInstance(domain, basestring)
- if domain.split(':', 1)[0] != 'localhost':
- self.assertIn('.', domain)
- self.assertEqual(f.name, name)
+ with self.subTest(family=name):
+ with suppress_warnings('test_family is deprecated'):
+ f = Family.load(name)
+ self.assertIsInstance(f.langs, dict)
+ self.assertTrue(f.langs)
+ self.assertTrue(f.codes)
+ self.assertTrue(iter(f.codes))
+ self.assertIsInstance(next(iter(f.codes)), basestring)
+ self.assertTrue(f.domains)
+ self.assertTrue(iter(f.domains))
+ for domain in f.domains:
+ self.assertIsInstance(domain, basestring)
+ if domain.split(':', 1)[0] != 'localhost':
+ self.assertIn('.', domain)
+ self.assertEqual(f.name, name)

- with suppress_warnings(
- 'wowwiki_family.Family.languages_by_size is deprecated'):
- self.assertIsInstance(f.languages_by_size, list)
- self.assertGreaterEqual(set(f.langs), set(f.languages_by_size))
+ with suppress_warnings(
+ 'wowwiki_family.Family.languages_by_size '
+ 'is deprecated'):
+ self.assertIsInstance(f.languages_by_size, list)
+ self.assertGreaterEqual(set(f.langs),
+ set(f.languages_by_size))

- if isinstance(f, SingleSiteFamily):
- self.assertIsNotNone(f.code)
- self.assertIsNotNone(f.domain)
- self.assertEqual(set(f.langs), {f.code})
- self.assertEqual(set(f.codes), {f.code})
+ if isinstance(f, SingleSiteFamily):
+ self.assertIsNotNone(f.code)
+ self.assertIsNotNone(f.domain)
+ self.assertEqual(set(f.langs), {f.code})
+ self.assertEqual(set(f.codes), {f.code})

def test_family_load_invalid(self):
"""Test that an invalid family raised UnknownFamily exception."""
@@ -118,11 +122,6 @@
self.assertIsNone(family.obsolete['mh'])
# offline site (see site tests test_removed_site)
self.assertIsNone(family.obsolete['ru-sib'])
-
- def test_get_obsolete_test(self):
- """Test WikimediaFamily default obsolete."""
- family = Family.load('test')
- self.assertIn('dk', family.obsolete)
self.assertIn('dk', family.interwiki_replacements)

def test_set_obsolete(self):
@@ -141,7 +140,7 @@

def test_obsolete_readonly(self):
"""Test obsolete result not updatable."""
- family = Family.load('test')
+ family = Family.load('wikipedia')
self.assertRaisesRegex(
TypeError,
self.FAMILY_TYPEERROR_RE,
@@ -156,7 +155,7 @@

def test_WikimediaFamily_obsolete_readonly(self):
"""Test WikimediaFamily obsolete is readonly."""
- family = Family.load('test')
+ family = Family.load('wikipedia')
self.assertRaisesRegex(
TypeError,
self.FROZENSET_TYPEERROR_RE,

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idb572837fc364579c2ba1e4ca20344afeea7d06e
Gerrit-Change-Number: 571699
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)