jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] Don't use all() and any() within tests

Use unittests methods instead to get a better failing message.
Also subTest may be implemented.

Change-Id: If64445826b50000d332e26a4e4e32d1b7cf45b4b
---
M tests/aspects.py
M tests/flow_tests.py
M tests/logentries_tests.py
M tests/namespace_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/site_tests.py
M tests/user_tests.py
M tests/wikibase_tests.py
M tests/wikistats_tests.py
M tests/xmlreader_tests.py
11 files changed, 148 insertions(+), 136 deletions(-)

diff --git a/tests/aspects.py b/tests/aspects.py
index f9d67a4..941136e 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1541,12 +1541,12 @@
if msg:
self.assertNotIn(msg, self.deprecation_messages)
else:
- self.assertEqual([], self.deprecation_messages)
+ self.assertIsEmpty(self.deprecation_messages)

def assertDeprecationClass(self, cls):
"""Assert that all deprecation warning are of one class."""
- self.assertTrue(all(isinstance(item.message, cls)
- for item in self.warning_log))
+ for item in self.warning_log:
+ self.assertIsInstance(item.message, cls)

def assertDeprecationFile(self, filename):
"""Assert that all deprecation warning are of one filename."""
diff --git a/tests/flow_tests.py b/tests/flow_tests.py
index 8083358..21575da 100644
--- a/tests/flow_tests.py
+++ b/tests/flow_tests.py
@@ -235,8 +235,8 @@
self.assertEqual(topic.root.uuid, 'u5y4l1rzitlplyc5')
replies = topic.replies()
self.assertLength(replies, 4)
- self.assertTrue(all(isinstance(reply, Post)
- for reply in replies))
+ for reply in replies:
+ self.assertIsInstance(reply, Post)
self.assertEqual(replies[1].uuid, 'u5y5lysqcvyne4k1')

def test_topic_moderation(self):
diff --git a/tests/logentries_tests.py b/tests/logentries_tests.py
index bcacfdb..30717be 100644
--- a/tests/logentries_tests.py
+++ b/tests/logentries_tests.py
@@ -197,7 +197,9 @@
if logentry.action() == 'block':
self.assertIsInstance(logentry.flags(), list)
# Check that there are no empty strings
- self.assertTrue(all(logentry.flags()))
+ for flag in logentry.flags():
+ self.assertIsInstance(flag, str)
+ self.assertNotEqual(flag, '')
if logentry.expiry() is not None:
self.assertIsInstance(logentry.expiry(),
pywikibot.Timestamp)
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index 8a511c0..5549c9e 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -68,21 +68,18 @@
ns = Namespace.builtin_namespaces()

self.assertIsInstance(ns, dict)
- self.assertTrue(all(x in ns for x in range(16)))
+ for ns_number in range(16):
+ self.assertIn(ns_number, ns)
+ # Use a namespace object as a dict key
+ self.assertEqual(ns[ns[ns_number]], ns[ns_number])

- self.assertTrue(all(isinstance(key, int)
- for key in ns))
- self.assertTrue(all(isinstance(val, Iterable)
- for val in ns.values()))
- self.assertTrue(all(isinstance(name, str)
- for val in ns.values()
- for name in val))
-
- # test boolean
- self.assertTrue(all(x for x in ns.values()))
-
- # Use a namespace object as a dict key
- self.assertEqual(ns[ns[6]], ns[6])
+ for key, value in ns.items():
+ self.assertIsInstance(key, int)
+ self.assertIsInstance(value, Iterable)
+ self.assertTrue(value)
+ for name in value:
+ self.assertIsInstance(name, str)
+ self.assertEqual(ns[ns[key]], ns[key])

def testNamespaceConstructor(self):
"""Test Namespace constructor."""
@@ -238,22 +235,19 @@
"""Test converting sequence of Namespace to a set."""
namespaces = Namespace.builtin_namespaces()

- self.assertTrue(all(isinstance(x, int) for x in namespaces))
- self.assertTrue(all(isinstance(x, int) for x in namespaces.keys()))
- self.assertTrue(all(isinstance(x, Namespace)
- for x in namespaces.values()))
+ for key, value in namespaces.items():
+ self.assertIsInstance(key, int)
+ self.assertIsInstance(value, Namespace)

namespaces_set = set(namespaces)
-
self.assertLength(namespaces, namespaces_set)
- self.assertTrue(all(isinstance(x, int) for x in namespaces_set))
+ for key in namespaces_set:
+ self.assertIsInstance(key, int)

def test_set_minus(self):
"""Test performing set minus operation on set of Namespace objects."""
namespaces = Namespace.builtin_namespaces()
-
excluded_namespaces = {-1, -2}
-
positive_namespaces = set(namespaces) - excluded_namespaces

self.assertLength(namespaces,
diff --git a/tests/page_tests.py b/tests/page_tests.py
index fa81453..f42f319 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -648,8 +648,9 @@
gen = page.globalusage(total=3)
pages = list(gen)
self.assertLength(pages, 3)
- self.assertTrue(any(isinstance(p), pywikibot.Page) for p in pages)
- self.assertTrue(any(p.site != self.site for p in pages))
+ for p in pages:
+ self.assertIsInstance(p, pywikibot.Page)
+ self.assertNotEqual(p.site, self.site)


class TestPageRepr(TestPageBaseUnicode):
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 2455530..cf76c78 100644
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -279,12 +279,12 @@
self.assertPageTitlesEqual(gen, titles=expect, site=self.site)

gen = PagesFromTitlesGenerator(self.titles, self.site)
- gen = pagegenerators.EdittimeFilterPageGenerator(
+ opposite_pages = pagegenerators.EdittimeFilterPageGenerator(
gen, first_edit_start=datetime.datetime(2006, 1, 1))
- opposite_pages = list(gen)
- self.assertTrue(all(isinstance(p, pywikibot.Page)
- for p in opposite_pages))
- self.assertTrue(all(p.title not in expect for p in opposite_pages))
+
+ for p in opposite_pages:
+ self.assertIsInstance(p, pywikibot.Page)
+ self.assertNotIn(p.title(), expect)

def test_last_edit(self):
"""Test last edit."""
@@ -411,8 +411,13 @@
timestamps = [pywikibot.Timestamp.fromISOformat(item['timestamp'])
for item in items]
self.assertEqual(sorted(timestamps), timestamps)
- self.assertTrue(all(item['ns'] == 0 for item in items))
- self.assertLength({item['revid'] for item in items}, self.length)
+
+ itemsset = set()
+ for item in items:
+ self.assertEqual(item['ns'], 0)
+ revid = item['revid']
+ self.assertNotIn(revid, itemsset)
+ itemsset.add(revid)


class TestTextIOPageGenerator(DefaultSiteTestCase):
@@ -622,12 +627,12 @@
if not page.isTalkPage():
pages.extend([page.toggleTalkPage()])

- self.assertTrue(all(isinstance(page,
- pywikibot.Page) for page in pages_out))
self.assertIn(mainpage, pages_out)
self.assertIn(mainpage.toggleTalkPage(), pages_out)
self.assertLength(pages_out, 2)
self.assertTrue(pages_out[1].isTalkPage())
+ for page in pages_out:
+ self.assertIsInstance(page, pywikibot.Page)


class TestPreloadingEntityGenerator(WikidataTestCase):
@@ -640,8 +645,8 @@
page = pywikibot.Page(site, 'Property:P31')
ref_gen = page.getReferences(follow_redirects=False, total=5)
gen = pagegenerators.PreloadingEntityGenerator(ref_gen)
- is_all_type = all(isinstance(i, pywikibot.ItemPage) for i in gen)
- self.assertTrue(is_all_type)
+ for ipage in gen:
+ self.assertIsInstance(ipage, pywikibot.ItemPage)


class WikibaseItemFilterPageGeneratorTestCase(TestCase):
@@ -1559,8 +1564,8 @@
self.assertIsNotNone(gen)
pages = set(gen)
self.assertIsNotEmpty(pages)
- self.assertTrue(all(isinstance(item, pywikibot.User)
- for item in pages))
+ for item in pages:
+ self.assertIsInstance(item, pywikibot.User)

def test_logevents_with_start_and_end_timestamp(self):
"""Test -logevents which uses timestamps for start and end."""
@@ -1580,8 +1585,8 @@
self.assertIsNotNone(gen)
pages = set(gen)
self.assertLength(pages, 1)
- self.assertTrue(all(isinstance(item, pywikibot.User)
- for item in pages))
+ for item in pages:
+ self.assertIsInstance(item, pywikibot.User)


class PageGeneratorIntersectTestCase(GeneratorIntersectTestCase,
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 443b563..6cac649 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -246,9 +246,8 @@
with self.subTest(test='months_names'):
self.assertIsInstance(mysite.months_names, list)
self.assertLength(mysite.months_names, 12)
- self.assertTrue(all(isinstance(month, tuple)
- for month in mysite.months_names))
for month in mysite.months_names:
+ self.assertIsInstance(month, tuple)
self.assertLength(month, 2)

with self.subTest(test='list_to_text'):
@@ -601,10 +600,13 @@
"""Test the site.alllinks() method."""
mysite = self.get_site()
fwd = list(mysite.alllinks(total=10))
- self.assertLessEqual(len(fwd), 10)
- self.assertTrue(all(isinstance(link, pywikibot.Page) for link in fwd))
uniq = list(mysite.alllinks(total=10, unique=True))
- self.assertTrue(all(link in uniq for link in fwd))
+
+ self.assertLessEqual(len(fwd), 10)
+
+ for link in fwd:
+ self.assertIsInstance(link, pywikibot.Page)
+ self.assertIn(link, uniq)
for page in mysite.alllinks(start='Link', total=5):
self.assertIsInstance(page, pywikibot.Page)
self.assertEqual(page.namespace(), 0)
@@ -630,8 +632,9 @@
mysite = self.get_site()
ac = list(mysite.allcategories(total=10))
self.assertLessEqual(len(ac), 10)
- self.assertTrue(all(isinstance(cat, pywikibot.Category)
- for cat in ac))
+ for cat in ac:
+ self.assertIsInstance(cat, pywikibot.Category)
+
for cat in mysite.allcategories(total=5, start='Abc'):
self.assertIsInstance(cat, pywikibot.Category)
self.assertGreaterEqual(cat.title(with_ns=False), 'Abc')
@@ -648,8 +651,9 @@
mysite = self.get_site()
ai = list(mysite.allimages(total=10))
self.assertLessEqual(len(ai), 10)
- self.assertTrue(all(isinstance(image, pywikibot.FilePage)
- for image in ai))
+ for image in ai:
+ self.assertIsInstance(image, pywikibot.FilePage)
+
for impage in mysite.allimages(start='Ba', total=5):
self.assertIsInstance(impage, pywikibot.FilePage)
self.assertTrue(impage.exists())
@@ -675,51 +679,50 @@
def test_querypage(self):
"""Test the site.querypage() method."""
mysite = self.get_site()
- pages = list(mysite.querypage('Longpages', total=10))
-
- self.assertTrue(all(isinstance(p, pywikibot.Page) for p in pages))
+ pages = mysite.querypage('Longpages', total=10)
+ for p in pages:
+ self.assertIsInstance(p, pywikibot.Page)
with self.assertRaises(AssertionError):
mysite.querypage('LongpageX')

def test_longpages(self):
"""Test the site.longpages() method."""
mysite = self.get_site()
- longpages = list(mysite.longpages(total=10))
+ longpages = mysite.longpages(total=10)

# Make sure each object returned by site.longpages() is
# a tuple of a Page object and an int
- self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2
- for tup in longpages))
- self.assertTrue(all(isinstance(tup[0], pywikibot.Page)
- for tup in longpages))
- self.assertTrue(all(isinstance(tup[1], int) for tup in longpages))
+ for tup in longpages:
+ self.assertIsInstance(tup, tuple)
+ self.assertLength(tup, 2)
+ self.assertIsInstance(tup[0], pywikibot.Page)
+ self.assertIsInstance(tup[1], int)

def test_shortpages(self):
"""Test the site.shortpages() method."""
mysite = self.get_site()
- shortpages = list(mysite.shortpages(total=10))
+ shortpages = mysite.shortpages(total=10)

# Make sure each object returned by site.shortpages() is
# a tuple of a Page object and an int
- self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2
- for tup in shortpages))
- self.assertTrue(all(isinstance(tup[0], pywikibot.Page)
- for tup in shortpages))
- self.assertTrue(all(isinstance(tup[1], int) for tup in shortpages))
+ for tup in shortpages:
+ self.assertIsInstance(tup, tuple)
+ self.assertLength(tup, 2)
+ self.assertIsInstance(tup[0], pywikibot.Page)
+ self.assertIsInstance(tup[1], int)

def test_ancientpages(self):
"""Test the site.ancientpages() method."""
mysite = self.get_site()
- ancientpages = list(mysite.ancientpages(total=10))
+ ancientpages = mysite.ancientpages(total=10)

# Make sure each object returned by site.ancientpages() is
# a tuple of a Page object and a Timestamp object
- self.assertTrue(all(isinstance(tup, tuple) and len(tup) == 2
- for tup in ancientpages))
- self.assertTrue(all(isinstance(tup[0], pywikibot.Page)
- for tup in ancientpages))
- self.assertTrue(all(isinstance(tup[1], pywikibot.Timestamp)
- for tup in ancientpages))
+ for tup in ancientpages:
+ self.assertIsInstance(tup, tuple)
+ self.assertLength(tup, 2)
+ self.assertIsInstance(tup[0], pywikibot.Page)
+ self.assertIsInstance(tup[1], pywikibot.Timestamp)

def test_unwatchedpages(self):
"""Test the site.unwatchedpages() method."""
@@ -736,8 +739,8 @@

# Make sure each object returned by site.unwatchedpages() is a
# Page object
- self.assertTrue(all(isinstance(p, pywikibot.Page)
- for p in unwatchedpages))
+ for p in unwatchedpages:
+ self.assertIsInstance(p, pywikibot.Page)

def test_blocks(self):
"""Test the site.blocks() method."""
@@ -826,8 +829,9 @@
url = 'www.google.com'
eu = list(mysite.exturlusage(url, total=10))
self.assertLessEqual(len(eu), 10)
- self.assertTrue(all(isinstance(link, pywikibot.Page)
- for link in eu))
+ for link in eu:
+ self.assertIsInstance(link, pywikibot.Page)
+
for link in mysite.exturlusage(url, namespaces=[2, 3], total=5):
self.assertIsInstance(link, pywikibot.Page)
self.assertIn(link.namespace(), (2, 3))
@@ -1088,8 +1092,8 @@
imagepage = self.imagepage
iu = list(mysite.imageusage(imagepage, total=10))
self.assertLessEqual(len(iu), 10)
- self.assertTrue(all(isinstance(link, pywikibot.Page)
- for link in iu))
+ for link in iu:
+ self.assertIsInstance(link, pywikibot.Page)

def test_image_usage_in_namespaces(self):
"""Test the site.imageusage() method with namespaces."""
@@ -1157,8 +1161,8 @@
mysite = self.get_site()
le = list(mysite.logevents(total=10))
self.assertLessEqual(len(le), 10)
- self.assertTrue(all(isinstance(entry, pywikibot.logentries.LogEntry)
- for entry in le))
+ for entry in le:
+ self.assertIsInstance(entry, pywikibot.logentries.LogEntry)

for logtype in mysite.logtypes:
with self.subTest(logtype=logtype):
@@ -1251,8 +1255,8 @@
mysite = self.site
rc = list(mysite.recentchanges(total=10))
self.assertLessEqual(len(rc), 10)
- self.assertTrue(all(isinstance(change, dict)
- for change in rc))
+ for change in rc:
+ self.assertIsInstance(change, dict)

def test_time_range(self):
"""Test the site.recentchanges() method with start/end."""
@@ -1440,9 +1444,9 @@
try:
se = list(mysite.search('wiki', total=100, namespaces=0))
self.assertLessEqual(len(se), 100)
- self.assertTrue(all(isinstance(hit, pywikibot.Page)
- for hit in se))
- self.assertTrue(all(hit.namespace() == 0 for hit in se))
+ for hit in se:
+ self.assertIsInstance(hit, pywikibot.Page)
+ self.assertEqual(hit.namespace(), 0)
for hit in mysite.search('common', namespaces=4, total=5):
self.assertIsInstance(hit, pywikibot.Page)
self.assertEqual(hit.namespace(), 4)
@@ -1462,6 +1466,7 @@
if e.code == 'gsrsearch-text-disabled':
self.skipTest('gsrsearch is diabled on site {}:\n{!r}'
.format(mysite, e))
+ raise

def test_search_where_title(self):
"""Test site.search() method with 'where' parameter set to title."""
@@ -1492,11 +1497,10 @@
mysite = self.get_site()
uc = list(mysite.usercontribs(user=mysite.user(), total=10))
self.assertLessEqual(len(uc), 10)
- self.assertTrue(all(isinstance(contrib, dict)
- for contrib in uc))
- self.assertTrue(
- all('user' in contrib and contrib['user'] == mysite.user()
- for contrib in uc))
+ for contrib in uc:
+ self.assertIsInstance(contrib, dict)
+ self.assertIn('user', contrib)
+ self.assertEqual(contrib['user'], mysite.user())

def test_namespaces(self):
"""Test the site.usercontribs() method using namespaces."""
@@ -1814,8 +1818,8 @@
mysite = self.get_site()
wl = list(mysite.watchlist_revs(total=10))
self.assertLessEqual(len(wl), 10)
- self.assertTrue(all(isinstance(rev, dict)
- for rev in wl))
+ for rev in wl:
+ self.assertIsInstance(rev, dict)
for rev in mysite.watchlist_revs(start='2008-10-11T01:02:03Z',
total=5):
self.assertIsInstance(rev, dict)
@@ -1913,7 +1917,8 @@
self.skipTest(
'{} contains no deleted revisions.'.format(mainpage))
self.assertLessEqual(len(dr['revisions']), 10)
- self.assertTrue(all(isinstance(rev, dict) for rev in dr['revisions']))
+ for rev in dr['revisions']:
+ self.assertIsInstance(rev, dict)

with self.subTest(start='2008-10-11T01:02:03Z', reverse=False):
for item in mysite.deletedrevs(start='2008-10-11T01:02:03Z',
@@ -2372,9 +2377,9 @@
mysite = self.get_site()
rn = list(mysite.randompages(total=10))
self.assertLessEqual(len(rn), 10)
- self.assertTrue(all(isinstance(a_page, pywikibot.Page)
- for a_page in rn))
- self.assertFalse(all(a_page.isRedirectPage() for a_page in rn))
+ for a_page in rn:
+ self.assertIsInstance(a_page, pywikibot.Page)
+ self.assertFalse(a_page.isRedirectPage())

def test_redirects(self):
"""Test site.randompages() with redirects."""
@@ -2515,12 +2520,12 @@
"""Test the site.loadrevisions() method, listing based on revid."""
# revids as list of int
self.mysite.loadrevisions(self.mainpage, revids=[139992, 139993])
- self.assertTrue(all(rev in self.mainpage._revisions
- for rev in [139992, 139993]))
+ for rev in [139992, 139993]:
+ self.assertIn(rev, self.mainpage._revisions)
# revids as list of str
self.mysite.loadrevisions(self.mainpage, revids=['139994', '139995'])
- self.assertTrue(all(rev in self.mainpage._revisions
- for rev in [139994, 139995]))
+ for rev in [139994, 139995]:
+ self.assertIn(rev, self.mainpage._revisions)
# revids as int
self.mysite.loadrevisions(self.mainpage, revids=140000)
self.assertIn(140000, self.mainpage._revisions)
@@ -2548,7 +2553,8 @@
self.assertLength(self.mainpage._revisions, 15)
revs = self.mainpage._revisions
timestamps = [str(revs[rev].timestamp) for rev in revs]
- self.assertTrue(all(ts < '2002-01-31T00:00:00Z' for ts in timestamps))
+ for ts in timestamps:
+ self.assertLess(ts, '2002-01-31T00:00:00Z')

# Retrieve oldest revisions; listing based on timestamp.
# Raises "loadrevisions: starttime > endtime with rvdir=True"
@@ -2569,7 +2575,8 @@
self.mysite.loadrevisions(self.mainpage, rvdir=True, total=15)
self.assertLength(self.mainpage._revisions, 15)
revs = self.mainpage._revisions
- self.assertTrue(all(139900 <= rev <= 140100 for rev in revs))
+ for rev in revs:
+ self.assertTrue(139900 <= rev <= 140100)

# Retrieve oldest revisions; listing based on revid.
# Raises "loadrevisions: startid > endid with rvdir=True"
@@ -2589,18 +2596,17 @@
self.mainpage._revisions = {}
self.mysite.loadrevisions(self.mainpage, rvdir=True,
user='Magnus Manske')
- revs = self.mainpage._revisions
- self.assertTrue(all(revs[rev].user == 'Magnus Manske' for rev in revs))
+ for rev in self.mainpage._revisions.values():
+ self.assertEqual(rev.user, 'Magnus Manske')

def test_loadrevisions_excludeuser(self):
"""Test the site.loadrevisions() method, excluding user."""
- # Do not list revisions made by this user.
+ excludeuser = 'Magnus Manske' # exclude revisions made by this user
self.mainpage._revisions = {}
self.mysite.loadrevisions(self.mainpage, rvdir=True,
- excludeuser='Magnus Manske')
- revs = self.mainpage._revisions
- self.assertFalse(any(revs[rev].user == 'Magnus Manske'
- for rev in revs))
+ excludeuser=excludeuser)
+ for rev in self.mainpage._revisions.values():
+ self.assertNotEqual(rev.user, excludeuser)

# TODO test other optional arguments

diff --git a/tests/user_tests.py b/tests/user_tests.py
index 23afe79..aed7a6e 100644
--- a/tests/user_tests.py
+++ b/tests/user_tests.py
@@ -75,11 +75,12 @@
self.assertTrue(user.is_thankable)
contribs = user.contributions(total=10)
self.assertLength(list(contribs), 10)
- self.assertTrue(all(isinstance(contrib, tuple)
- for contrib in contribs))
- self.assertTrue(all('user' in contrib
- and contrib['user'] == user.username
- for contrib in contribs))
+
+ for contrib in contribs:
+ self.assertIsInstance(contrib, tuple)
+ self.assertIn('user', contrib)
+ self.assertIsEqual(contrib['user'], user.username)
+
self.assertIn('user', user.groups())
self.assertIn('edit', user.rights())
self.assertFalse(user.is_locked())
@@ -199,8 +200,9 @@
.format(mysite.user(), mysite))
self.assertLessEqual(len(le), 10)
last = le[0]
- self.assertTrue(all(event.user() == user.username for event in le))
self.assertEqual(last, user.last_event)
+ for event in le:
+ self.assertEqual(event.user(), user.username)


if __name__ == '__main__': # pragma: no cover
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 29cd12b..4ced0de 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1818,7 +1818,8 @@
page = pywikibot.Page(site, 'Property:P31')
ref_gen = page.getReferences(follow_redirects=False, total=5)
gen = pagegenerators.PreloadingEntityGenerator(ref_gen)
- self.assertTrue(all(isinstance(item, ItemPage) for item in gen))
+ for item in gen:
+ self.assertIsInstance(item, ItemPage)

def test_foreign_page_item_gen(self):
"""Test PreloadingEntityGenerator with connected pages."""
@@ -1826,7 +1827,8 @@
page_gen = [pywikibot.Page(site, 'Main Page'),
pywikibot.Page(site, 'New York City')]
gen = pagegenerators.PreloadingEntityGenerator(page_gen)
- self.assertTrue(all(isinstance(item, ItemPage) for item in gen))
+ for item in gen:
+ self.assertIsInstance(item, ItemPage)


class TestNamespaces(WikidataTestCase):
diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py
index 778a80e..3b70de9 100644
--- a/tests/wikistats_tests.py
+++ b/tests/wikistats_tests.py
@@ -33,9 +33,9 @@
self.assertIn(key, top)
self.assertIn(key, bottom)

- self.assertTrue(all(isinstance(key, str)
- for key in top.keys()
- if key is not None))
+ for key in top:
+ self.assertIsInstance(key, (str, type(None)))
+
self.assertIsInstance(top['good'], str)
self.assertIsInstance(top['total'], str)
self.assertIsInstance(bottom['good'], str)
diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py
index bcb4a32..cf60983 100644
--- a/tests/xmlreader_tests.py
+++ b/tests/xmlreader_tests.py
@@ -89,25 +89,25 @@
"""Test reading the main page/user talk page pair file."""
entries = get_entries('pair-0.10.xml', allrevisions=True)
self.assertLength(entries, 4)
- self.assertTrue(all(entry.username == 'Carlossuarez46'
- for entry in entries))
- self.assertTrue(all(entry.isredirect is False for entry in entries))
+ for entry in entries:
+ self.assertEqual(entry.username, 'Carlossuarez46')
+ self.assertFalse(entry.isredirect)

articles = entries[0:2]
talks = entries[2:4]

self.assertLength(articles, 2)
- self.assertTrue(all(entry.id == '19252820' for entry in articles))
- self.assertTrue(all(entry.title == 'Çullu, Agdam'
- for entry in articles))
- self.assertTrue(all('Çullu, Quzanlı' in entry.text
- for entry in articles))
- self.assertEqual(articles[0].text, '#REDIRECT [[Çullu, Quzanlı]]')
+ for entry in articles:
+ self.assertEqual(entry.id, '19252820')
+ self.assertEqual(entry.title, 'Çullu, Agdam')
+ self.assertIn('Çullu, Quzanlı', entry.text)

self.assertLength(talks, 2)
- self.assertTrue(all(entry.id == '19252824' for entry in talks))
- self.assertTrue(all(entry.title == 'Talk:Çullu, Agdam'
- for entry in talks))
+ for entry in talks:
+ self.assertEqual(entry.id, '19252824')
+ self.assertEqual(entry.title, 'Talk:Çullu, Agdam')
+
+ self.assertEqual(articles[0].text, '#REDIRECT [[Çullu, Quzanlı]]')
self.assertEqual(talks[1].text, '{{DisambigProject}}')
self.assertEqual(talks[1].comment, 'proj')


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If64445826b50000d332e26a4e4e32d1b7cf45b4b
Gerrit-Change-Number: 763944
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged