jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Use proper asserts ......................................................................
[IMPROV] Use proper asserts
- assert(Not)Equal instead of assert(Not)Equals - assertIn(X, Y) instead of assertTrue(X in Y) - assertNotIn(X, Y) instead of assertTrue(X not in Y) and instead of assertFalse(X in Y) - assertEqual(X, Y) instead of assertEqual(X == Y)
Change-Id: I1bbef226a75d6ddc2e536ca94459595b198d81cc --- M tests/http_tests.py M tests/namespace_tests.py M tests/page_tests.py M tests/pagegenerators_tests.py M tests/site_tests.py M tests/wikibase_tests.py M tests/wikidataquery_tests.py M tests/xmlreader_tests.py 8 files changed, 263 insertions(+), 263 deletions(-)
Approvals: Nullzero: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/http_tests.py b/tests/http_tests.py index 4a200e5..e139fbb 100644 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -19,31 +19,31 @@ def test_get(self): r = http.request(site=None, uri='http://www.wikipedia.org/') self.assertIsInstance(r, str) - self.assertTrue('<html lang="mul"' in r) + self.assertIn('<html lang="mul"', r)
def test_request(self): o = threadedhttp.Http() r = o.request('http://www.wikipedia.org/') self.assertIsInstance(r, tuple) self.assertIsInstance(r[0], dict) - self.assertTrue('status' in r[0]) + self.assertIn('status', r[0]) self.assertIsInstance(r[0]['status'], str) - self.assertEquals(r[0]['status'], '200') + self.assertEqual(r[0]['status'], '200')
self.assertIsInstance(r[1], str) - self.assertTrue('<html lang="mul"' in r[1]) - self.assertEquals(int(r[0]['content-length']), len(r[1])) + self.assertIn('<html lang="mul"', r[1]) + self.assertEqual(int(r[0]['content-length']), len(r[1]))
def test_gzip(self): o = threadedhttp.Http() r = o.request('http://www.wikipedia.org/') - self.assertTrue('-content-encoding' in r[0]) - self.assertEquals(r[0]['-content-encoding'], 'gzip') + self.assertIn('-content-encoding', r[0]) + self.assertEqual(r[0]['-content-encoding'], 'gzip')
url = 'https://test.wikidata.org/w/api.php?action=query&meta=siteinfo' r = o.request(url) - self.assertTrue('-content-encoding' in r[0]) - self.assertEquals(r[0]['-content-encoding'], 'gzip') + self.assertIn('-content-encoding', r[0]) + self.assertEqual(r[0]['-content-encoding'], 'gzip')
if __name__ == '__main__': diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py index de7b216..b8458e4 100644 --- a/tests/namespace_tests.py +++ b/tests/namespace_tests.py @@ -84,19 +84,19 @@ y = Namespace(id=6, custom_name=u'dummy', canonical_name=u'File', aliases=[u'Image', u'Immagine'], **kwargs)
- self.assertEquals(y.id, 6) - self.assertEquals(y.custom_name, u'dummy') - self.assertEquals(y.canonical_name, u'File') + self.assertEqual(y.id, 6) + self.assertEqual(y.custom_name, u'dummy') + self.assertEqual(y.canonical_name, u'File')
- self.assertNotEquals(y.custom_name, u'Dummy') - self.assertNotEquals(y.canonical_name, u'file') + self.assertNotEqual(y.custom_name, u'Dummy') + self.assertNotEqual(y.canonical_name, u'file')
self.assertIn(u'Image', y.aliases) self.assertIn(u'Immagine', y.aliases)
- self.assertEquals(len(y), 4) - self.assertEquals(list(y), ['dummy', u'File', u'Image', u'Immagine']) - self.assertEquals(y.case, u'first-letter') + self.assertEqual(len(y), 4) + self.assertEqual(list(y), ['dummy', u'File', u'Image', u'Immagine']) + self.assertEqual(y.case, u'first-letter')
def testNamespaceNameCase(self): """Namespace names are always case-insensitive.""" @@ -115,30 +115,30 @@ def testNamespaceToString(self): ns = Namespace.builtin_namespaces(use_image_name=False)
- self.assertEquals(str(ns[0]), ':') - self.assertEquals(str(ns[1]), 'Talk:') - self.assertEquals(str(ns[6]), ':File:') + self.assertEqual(str(ns[0]), ':') + self.assertEqual(str(ns[1]), 'Talk:') + self.assertEqual(str(ns[6]), ':File:')
- self.assertEquals(unicode(ns[0]), u':') - self.assertEquals(unicode(ns[1]), u'Talk:') - self.assertEquals(unicode(ns[6]), u':File:') + self.assertEqual(unicode(ns[0]), u':') + self.assertEqual(unicode(ns[1]), u'Talk:') + self.assertEqual(unicode(ns[6]), u':File:')
kwargs = {u'case': u'first-letter'} y = Namespace(id=6, custom_name=u'ملف', canonical_name=u'File', aliases=[u'Image', u'Immagine'], **kwargs)
if sys.version_info[0] == 2: - self.assertEquals(str(y), ':File:') - self.assertEquals(unicode(y), u':ملف:') + self.assertEqual(str(y), ':File:') + self.assertEqual(unicode(y), u':ملف:') else: - self.assertEquals(str(y), u':ملف:') + self.assertEqual(str(y), u':ملف:')
def testNamespaceCompare(self): a = Namespace(id=0, canonical_name=u'')
- self.assertEquals(a, 0) - self.assertEquals(a, '') - self.assertEquals(a, None) + self.assertEqual(a, 0) + self.assertEqual(a, '') + self.assertEqual(a, None)
x = Namespace(id=6, custom_name=u'dummy', canonical_name=u'File', aliases=[u'Image', u'Immagine']) @@ -147,23 +147,23 @@ z = Namespace(id=7, custom_name=u'dummy', canonical_name=u'File', aliases=[u'Image', u'Immagine'])
- self.assertEquals(x, x) - self.assertEquals(x, y) - self.assertNotEquals(x, a) - self.assertNotEquals(x, z) + self.assertEqual(x, x) + self.assertEqual(x, y) + self.assertNotEqual(x, a) + self.assertNotEqual(x, z)
- self.assertEquals(x, 6) - self.assertEquals(x, u'dummy') - self.assertEquals(x, u'Dummy') - self.assertEquals(x, u'file') - self.assertEquals(x, u'File') - self.assertEquals(x, u':File') - self.assertEquals(x, u':File:') - self.assertEquals(x, u'File:') - self.assertEquals(x, u'image') - self.assertEquals(x, u'Image') + self.assertEqual(x, 6) + self.assertEqual(x, u'dummy') + self.assertEqual(x, u'Dummy') + self.assertEqual(x, u'file') + self.assertEqual(x, u'File') + self.assertEqual(x, u':File') + self.assertEqual(x, u':File:') + self.assertEqual(x, u'File:') + self.assertEqual(x, u'image') + self.assertEqual(x, u'Image')
- self.assertEquals(y, u'ملف') + self.assertEqual(y, u'ملف')
# FIXME: Namespace is missing operators required for py3 if sys.version_info[0] > 2: @@ -174,48 +174,48 @@ self.assertTrue(z > x)
def testNamespaceNormalizeName(self): - self.assertEquals(Namespace.normalize_name(u'File'), u'File') - self.assertEquals(Namespace.normalize_name(u':File'), u'File') - self.assertEquals(Namespace.normalize_name(u'File:'), u'File') - self.assertEquals(Namespace.normalize_name(u':File:'), u'File') + self.assertEqual(Namespace.normalize_name(u'File'), u'File') + self.assertEqual(Namespace.normalize_name(u':File'), u'File') + self.assertEqual(Namespace.normalize_name(u'File:'), u'File') + self.assertEqual(Namespace.normalize_name(u':File:'), u'File')
- self.assertEquals(Namespace.normalize_name(u''), u'') + self.assertEqual(Namespace.normalize_name(u''), u'')
- self.assertEquals(Namespace.normalize_name(u':'), False) - self.assertEquals(Namespace.normalize_name(u'::'), False) - self.assertEquals(Namespace.normalize_name(u':::'), False) - self.assertEquals(Namespace.normalize_name(u':File::'), False) - self.assertEquals(Namespace.normalize_name(u'::File:'), False) - self.assertEquals(Namespace.normalize_name(u'::File::'), False) + self.assertEqual(Namespace.normalize_name(u':'), False) + self.assertEqual(Namespace.normalize_name(u'::'), False) + self.assertEqual(Namespace.normalize_name(u':::'), False) + self.assertEqual(Namespace.normalize_name(u':File::'), False) + self.assertEqual(Namespace.normalize_name(u'::File:'), False) + self.assertEqual(Namespace.normalize_name(u'::File::'), False)
def test_repr(self): a = Namespace(id=0, canonical_name=u'Foo') s = repr(a) r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[])" \ % (unicode('Foo'), unicode('Foo')) - self.assertEquals(s, r) + self.assertEqual(s, r)
a.info['defaultcontentmodel'] = 'bar' r = {'defaultcontentmodel': 'bar'} - self.assertEquals(a.info, r) + self.assertEqual(a.info, r)
s = repr(a) r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], defaultcontentmodel='bar')" \ % (unicode('Foo'), unicode('Foo')) - self.assertEquals(s, r) + self.assertEqual(s, r)
a.info['case'] = 'upper' r = {'defaultcontentmodel': 'bar', 'case': 'upper'} - self.assertEquals(a.info, r) + self.assertEqual(a.info, r)
s = repr(a) r = "Namespace(id=0, custom_name=%r, canonical_name=%r, aliases=[], case='upper', defaultcontentmodel='bar')" \ % (unicode('Foo'), unicode('Foo')) - self.assertEquals(s, r) + self.assertEqual(s, r)
b = eval(repr(a)) - self.assertEquals(a, b) - self.assertEquals(a.info, b.info) + self.assertEqual(a, b) + self.assertEqual(a.info, b.info)
if __name__ == '__main__': diff --git a/tests/page_tests.py b/tests/page_tests.py index ebc37d6..ec8f6f4 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -347,7 +347,7 @@ self.assertIsInstance(p, pywikibot.Link) for p2 in mainpage.interwiki(expand=False): self.assertIsInstance(p2, pywikibot.Link) - self.assertTrue(p2 in iw) + self.assertIn(p2, iw) for p in mainpage.langlinks(): self.assertIsInstance(p, pywikibot.Link) for p in mainpage.imagelinks(): diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index c564e6a..706ea11 100644 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -43,74 +43,74 @@ self.assertTrue(hasattr(getattr(pagegenerators, obj), '__call__'))
def test_module_import(self): - self.assertTrue("pywikibot.pagegenerators" in sys.modules) + self.assertIn("pywikibot.pagegenerators", sys.modules)
def test_PagesFromTitlesGenerator(self): self.assertFunction("PagesFromTitlesGenerator") gen = pagegenerators.PagesFromTitlesGenerator(self.titles) - self.assertTrue(len(self.titles) == len(tuple(gen))) + self.assertEqual(len(self.titles), len(tuple(gen)))
def test_NamespaceFilterPageGenerator(self): self.assertFunction("NamespaceFilterPageGenerator") gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.NamespaceFilterPageGenerator(gen, 0) - self.assertTrue(len(tuple(gen)) == 3) + self.assertEqual(len(tuple(gen)), 3) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.NamespaceFilterPageGenerator(gen, 1) - self.assertTrue(len(tuple(gen)) == 4) + self.assertEqual(len(tuple(gen)), 4) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.NamespaceFilterPageGenerator(gen, 10) - self.assertTrue(len(tuple(gen)) == 6) + self.assertEqual(len(tuple(gen)), 6) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.NamespaceFilterPageGenerator(gen, (1, 10)) - self.assertTrue(len(tuple(gen)) == 10) + self.assertEqual(len(tuple(gen)), 10)
def test_RegexFilterPageGenerator(self): self.assertFunction("RegexFilterPageGenerator") gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, '/doc') - self.assertTrue(len(tuple(gen)) == 2) + self.assertEqual(len(tuple(gen)), 2) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, '/doc', quantifier='none') - self.assertTrue(len(tuple(gen)) == 11) + self.assertEqual(len(tuple(gen)), 11) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta']) - self.assertTrue(len(tuple(gen)) == 4) + self.assertEqual(len(tuple(gen)), 4) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'], quantifier='none') - self.assertTrue(len(tuple(gen)) == 9) + self.assertEqual(len(tuple(gen)), 9) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, ['/doc', '/meta'], quantifier='all') - self.assertTrue(len(tuple(gen)) == 0) + self.assertEqual(len(tuple(gen)), 0) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, ['Template', '/meta'], quantifier='all') - self.assertTrue(len(tuple(gen)) == 1) + self.assertEqual(len(tuple(gen)), 1) gen = pagegenerators.PagesFromTitlesGenerator(self.titles) gen = pagegenerators.RegexFilterPageGenerator(gen, ['template', '/meta'], quantifier='any') - self.assertTrue(len(tuple(gen)) == 4) + self.assertEqual(len(tuple(gen)), 4) gen = pagegenerators.PagesFromTitlesGenerator(self.titles, site=self.site) gen = pagegenerators.RegexFilterPageGenerator(gen, ['template', '/meta'], quantifier='any', ignore_namespace=False) - self.assertTrue(len(tuple(gen)) == 6) + self.assertEqual(len(tuple(gen)), 6) gen = pagegenerators.PagesFromTitlesGenerator(self.titles, site=self.site) gen = pagegenerators.RegexFilterPageGenerator(gen, ['template', '/meta'], quantifier='all', ignore_namespace=False) - self.assertTrue(len(tuple(gen)) == 2) + self.assertEqual(len(tuple(gen)), 2) gen = pagegenerators.PagesFromTitlesGenerator(self.titles, site=self.site) gen = pagegenerators.RegexFilterPageGenerator(gen, ['template', '/meta'], quantifier='none', ignore_namespace=False) - self.assertTrue(len(tuple(gen)) == 7) + self.assertEqual(len(tuple(gen)), 7)
def test_RegexBodyFilterPageGenerator(self): self.assertFunction("RegexBodyFilterPageGenerator") @@ -121,12 +121,12 @@ p.text = u"This is the content of %s as a sample" % p.title() pages.append(p) gen = pagegenerators.RegexBodyFilterPageGenerator(iter(pages), '/doc') - self.assertTrue(len(tuple(gen)) == 2) + self.assertEqual(len(tuple(gen)), 2) gen = pagegenerators.RegexBodyFilterPageGenerator(iter(pages), 'This') - self.assertTrue(len(tuple(gen)) == 13) + self.assertEqual(len(tuple(gen)), 13) gen = pagegenerators.RegexBodyFilterPageGenerator(iter(pages), 'talk', quantifier='none') - self.assertTrue(len(tuple(gen)) == 9) + self.assertEqual(len(tuple(gen)), 9)
if __name__ == "__main__": try: diff --git a/tests/site_tests.py b/tests/site_tests.py index 3477872..bac24c9 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -80,14 +80,14 @@ """Test cases for languages() and related methods""" langs = mysite.languages() self.assertIsInstance(langs, list) - self.assertTrue(mysite.code in langs) + self.assertIn(mysite.code, langs) mysite.family.obsolete ipf = mysite.interwiki_putfirst() if ipf: # Not all languages use this self.assertIsInstance(ipf, list)
for item in mysite.validLanguageLinks(): - self.assertTrue(item in langs, item) + self.assertIn(item, langs)
def testNamespaceMethods(self): """Test cases for methods manipulating namespace names.""" @@ -134,25 +134,25 @@ def testNamespaceCase(self): site = pywikibot.Site('en', 'wiktionary') main_namespace = site.namespaces()[0] - self.assertEquals(main_namespace.case, 'case-sensitive') + self.assertEqual(main_namespace.case, 'case-sensitive') user_namespace = site.namespaces()[2] - self.assertEquals(user_namespace.case, 'first-letter') + self.assertEqual(user_namespace.case, 'first-letter')
def testNamespaceAliases(self): site = pywikibot.Site('nn', 'wikipedia')
namespaces = site.namespaces() image_namespace = namespaces[6] - self.assertEquals(image_namespace.custom_name, 'Fil') - self.assertEquals(image_namespace.canonical_name, 'File') - self.assertEquals(str(image_namespace), ':File:') - self.assertEquals(unicode(image_namespace), ':Fil:') - self.assertEquals(image_namespace.aliases, ['Image']) - self.assertEquals(len(image_namespace), 3) + self.assertEqual(image_namespace.custom_name, 'Fil') + self.assertEqual(image_namespace.canonical_name, 'File') + self.assertEqual(str(image_namespace), ':File:') + self.assertEqual(unicode(image_namespace), ':Fil:') + self.assertEqual(image_namespace.aliases, ['Image']) + self.assertEqual(len(image_namespace), 3)
- self.assertEquals(len(namespaces[1].aliases), 0) - self.assertEquals(len(namespaces[4].aliases), 1) - self.assertEquals(namespaces[4].aliases[0], 'WP') + self.assertEqual(len(namespaces[1].aliases), 0) + self.assertEqual(len(namespaces[4].aliases), 1) + self.assertEqual(namespaces[4].aliases[0], 'WP') self.assertIn('WP', namespaces[4])
def testApiMethods(self): @@ -194,7 +194,7 @@ # Load all messages and check that '*' is not a valid key. self.assertIsInstance(mysite.mediawiki_messages('*'), dict) self.assertTrue(len(mysite.mediawiki_messages(['*'])) > 10) - self.assertFalse('*' in mysite.mediawiki_messages(['*'])) + self.assertNotIn('*', mysite.mediawiki_messages(['*']))
self.assertIsInstance(mysite.getcurrenttime(), pywikibot.Timestamp) ts = mysite.getcurrenttimestamp() @@ -278,10 +278,10 @@ self.assertTrue(embedded.issubset(refs)) for bl in backlinks: self.assertIsInstance(bl, pywikibot.Page) - self.assertTrue(bl in refs) + self.assertIn(bl, refs) for ei in embedded: self.assertIsInstance(ei, pywikibot.Page) - self.assertTrue(ei in refs) + self.assertIn(ei, refs) for ref in refs: self.assertTrue(ref in backlinks or ref in embedded) # test embeddedin arguments @@ -382,13 +382,13 @@ for page in mysite.allpages(protect_type="edit", total=5): self.assertIsInstance(page, pywikibot.Page) self.assertTrue(mysite.page_exists(page)) - self.assertTrue("edit" in page._protection) + self.assertIn("edit", page._protection) for page in mysite.allpages(protect_type="edit", protect_level="sysop", total=5): self.assertIsInstance(page, pywikibot.Page) self.assertTrue(mysite.page_exists(page)) - self.assertTrue("edit" in page._protection) - self.assertTrue("sysop" in page._protection["edit"]) + self.assertIn("edit", page._protection) + self.assertIn("sysop", page._protection["edit"])
def testAllLinks(self): """Test the site.alllinks() method""" @@ -439,27 +439,27 @@ self.assertTrue(len(au) <= 10) for user in au: self.assertIsInstance(user, dict) - self.assertTrue("name" in user) - self.assertTrue("editcount" in user) - self.assertTrue("registration" in user) + self.assertIn("name", user) + self.assertIn("editcount", user) + self.assertIn("registration", user) for user in mysite.allusers(start="B", total=5): self.assertIsInstance(user, dict) - self.assertTrue("name" in user) + self.assertIn("name", user) self.assertTrue(user["name"] >= "B") - self.assertTrue("editcount" in user) - self.assertTrue("registration" in user) + self.assertIn("editcount", user) + self.assertIn("registration", user) for user in mysite.allusers(prefix="C", total=5): self.assertIsInstance(user, dict) - self.assertTrue("name" in user) + self.assertIn("name", user) self.assertTrue(user["name"].startswith("C")) - self.assertTrue("editcount" in user) - self.assertTrue("registration" in user) + self.assertIn("editcount", user) + self.assertIn("registration", user) for user in mysite.allusers(prefix="D", group="sysop", total=5): self.assertIsInstance(user, dict) - self.assertTrue("name" in user) + self.assertIn("name", user) self.assertTrue(user["name"].startswith("D")) - self.assertTrue("editcount" in user) - self.assertTrue("registration" in user) + self.assertIn("editcount", user) + self.assertIn("registration", user) self.assertTrue("groups" in user and "sysop" in user["groups"])
def testAllImages(self): @@ -498,7 +498,7 @@ for block in bl: self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) # timestamps should be in descending order timestamps = [block['timestamp'] for block in bl] for t in range(1, len(timestamps)): @@ -509,7 +509,7 @@ for block in b2: self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) # timestamps should be in ascending order timestamps = [block['timestamp'] for block in b2] for t in range(1, len(timestamps)): @@ -518,23 +518,23 @@ for block in mysite.blocks(starttime="2008-07-01T00:00:01Z", total=5): self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) for block in mysite.blocks(endtime="2008-07-31T23:59:59Z", total=5): self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) for block in mysite.blocks(starttime="2008-08-02T00:00:01Z", endtime="2008-08-02T23:59:59Z", reverse=True, total=5): self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) for block in mysite.blocks(starttime="2008-08-03T23:59:59Z", endtime="2008-08-03T00:00:01Z", total=5): self.assertIsInstance(block, dict) for prop in props: - self.assertTrue(prop in block) + self.assertIn(prop, block) # starttime earlier than endtime self.assertRaises(pywikibot.Error, mysite.blocks, starttime="2008-08-03T00:00:01Z", @@ -556,7 +556,7 @@ for link in eu)) for link in mysite.exturlusage(url, namespaces=[2, 3], total=5): self.assertIsInstance(link, pywikibot.Page) - self.assertTrue(link.namespace() in (2, 3)) + self.assertIn(link.namespace(), (2, 3))
def testImageusage(self): """Test the site.imageusage() method""" @@ -566,7 +566,7 @@ for link in iu)) for using in mysite.imageusage(imagepage, namespaces=[3, 4], total=5): self.assertIsInstance(using, pywikibot.Page) - self.assertTrue(imagepage in list(using.imagelinks())) + self.assertIn(imagepage, list(using.imagelinks())) for using in mysite.imageusage(imagepage, filterredir=True, total=5): self.assertIsInstance(using, pywikibot.Page) self.assertTrue(using.isRedirectPage()) @@ -585,9 +585,9 @@ for entry in mysite.logevents(logtype=typ, total=3): self.assertEqual(entry.type(), typ) for entry in mysite.logevents(page=mainpage, total=3): - self.assertTrue(entry.title().title() == mainpage.title()) + self.assertEqual(entry.title().title(), mainpage.title()) for entry in mysite.logevents(user=mysite.user(), total=3): - self.assertTrue(entry.user() == mysite.user()) + self.assertEqual(entry.user(), mysite.user()) for entry in mysite.logevents(start="2008-09-01T00:00:01Z", total=5): self.assertIsInstance(entry, pywikibot.logentries.LogEntry) self.assertTrue(str(entry.timestamp()) <= "2008-09-01T00:00:01Z") @@ -661,52 +661,52 @@ self.assertIsInstance(change, dict) self.assertTrue("title" in change and "ns" in change) title = change['title'] - self.assertTrue(":" in title) + self.assertIn(":", title) prefix = title[:title.index(":")] - self.assertTrue(mysite.ns_index(prefix) in [6, 7]) - self.assertTrue(change["ns"] in [6, 7]) + self.assertIn(mysite.ns_index(prefix), [6, 7]) + self.assertIn(change["ns"], [6, 7]) if LV(mysite.version()) <= LV("1.14"): for change in mysite.recentchanges(pagelist=[mainpage, imagepage], total=5): self.assertIsInstance(change, dict) - self.assertTrue("title" in change) - self.assertTrue(change["title"] in (mainpage.title(), - imagepage.title())) + self.assertIn("title", change) + self.assertIn(change["title"], (mainpage.title(), + imagepage.title())) for typ in ("edit", "new", "log"): for change in mysite.recentchanges(changetype=typ, total=5): self.assertIsInstance(change, dict) - self.assertTrue("type" in change) + self.assertIn("type", change) self.assertEqual(change["type"], typ) for change in mysite.recentchanges(showMinor=True, total=5): self.assertIsInstance(change, dict) - self.assertTrue("minor" in change) + self.assertIn("minor", change) for change in mysite.recentchanges(showMinor=False, total=5): self.assertIsInstance(change, dict) - self.assertTrue("minor" not in change) + self.assertNotIn("minor", change) for change in mysite.recentchanges(showBot=True, total=5): self.assertIsInstance(change, dict) - self.assertTrue("bot" in change) + self.assertIn("bot", change) for change in mysite.recentchanges(showBot=False, total=5): self.assertIsInstance(change, dict) - self.assertTrue("bot" not in change) + self.assertNotIn("bot", change) for change in mysite.recentchanges(showAnon=True, total=5): self.assertIsInstance(change, dict) for change in mysite.recentchanges(showAnon=False, total=5): self.assertIsInstance(change, dict) for change in mysite.recentchanges(showRedirects=True, total=5): self.assertIsInstance(change, dict) - self.assertTrue("redirect" in change) + self.assertIn("redirect", change) for change in mysite.recentchanges(showRedirects=False, total=5): self.assertIsInstance(change, dict) - self.assertTrue("redirect" not in change) + self.assertNotIn("redirect", change) for change in mysite.recentchanges(showPatrolled=True, total=5): self.assertIsInstance(change, dict) if mysite.has_right('patrol'): - self.assertTrue("patrolled" in change) + self.assertIn("patrolled", change) for change in mysite.recentchanges(showPatrolled=False, total=5): self.assertIsInstance(change, dict) if mysite.has_right('patrol'): - self.assertTrue("patrolled" not in change) + self.assertNotIn("patrolled", change)
def testSearch(self): """Test the site.search() method""" @@ -721,10 +721,10 @@ self.assertEqual(hit.namespace(), 4) for hit in mysite.search("word", namespaces=[5, 6, 7], total=5): self.assertIsInstance(hit, pywikibot.Page) - self.assertTrue(hit.namespace() in [5, 6, 7]) + self.assertIn(hit.namespace(), [5, 6, 7]) for hit in mysite.search("another", namespaces="8|9|10", total=5): self.assertIsInstance(hit, pywikibot.Page) - self.assertTrue(hit.namespace() in [8, 9, 10]) + self.assertIn(hit.namespace(), [8, 9, 10]) for hit in mysite.search("wiki", namespaces=0, total=10, getredirects=True): self.assertIsInstance(hit, pywikibot.Page) @@ -746,7 +746,7 @@ for contrib in mysite.usercontribs(userprefix="John", total=5): self.assertIsInstance(contrib, dict) for key in ("user", "title", "ns", "pageid", "revid"): - self.assertTrue(key in contrib) + self.assertIn(key, contrib) self.assertTrue(contrib["user"].startswith("John")) for contrib in mysite.usercontribs(userprefix="Jane", start="2008-10-06T01:02:03Z", @@ -790,21 +790,21 @@ for contrib in mysite.usercontribs(user=mysite.user(), namespaces=14, total=5): self.assertIsInstance(contrib, dict) - self.assertTrue("title" in contrib) + self.assertIn("title", contrib) self.assertTrue(contrib["title"].startswith(mysite.namespace(14))) for contrib in mysite.usercontribs(user=mysite.user(), namespaces=[10, 11], total=5): self.assertIsInstance(contrib, dict) - self.assertTrue("title" in contrib) - self.assertTrue(contrib["ns"] in (10, 11)) + self.assertIn("title", contrib) + self.assertIn(contrib["ns"], (10, 11)) for contrib in mysite.usercontribs(user=mysite.user(), showMinor=True, total=5): self.assertIsInstance(contrib, dict) - self.assertTrue("minor" in contrib) + self.assertIn("minor", contrib) for contrib in mysite.usercontribs(user=mysite.user(), showMinor=False, total=5): self.assertIsInstance(contrib, dict) - self.assertTrue("minor" not in contrib) + self.assertNotIn("minor", contrib)
def testWatchlistrevs(self): """Test the site.watchlist_revs() method""" @@ -852,22 +852,22 @@ self.assertIsInstance(rev, dict) self.assertTrue("title" in rev and "ns" in rev) title = rev['title'] - self.assertTrue(":" in title) + self.assertIn(":", title) prefix = title[:title.index(":")] - self.assertTrue(mysite.ns_index(prefix) in [6, 7]) - self.assertTrue(rev["ns"] in [6, 7]) + self.assertIn(mysite.ns_index(prefix), [6, 7]) + self.assertIn(rev["ns"], [6, 7]) for rev in mysite.watchlist_revs(showMinor=True, total=5): self.assertIsInstance(rev, dict) - self.assertTrue("minor" in rev) + self.assertIn("minor", rev) for rev in mysite.watchlist_revs(showMinor=False, total=5): self.assertIsInstance(rev, dict) - self.assertTrue("minor" not in rev) + self.assertNotIn("minor", rev) for rev in mysite.watchlist_revs(showBot=True, total=5): self.assertIsInstance(rev, dict) - self.assertTrue("bot" in rev) + self.assertIn("bot", rev) for rev in mysite.watchlist_revs(showBot=False, total=5): self.assertIsInstance(rev, dict) - self.assertTrue("bot" not in rev) + self.assertNotIn("bot", rev) for rev in mysite.watchlist_revs(showAnon=True, total=5): self.assertIsInstance(rev, dict) for rev in mysite.watchlist_revs(showAnon=False, total=5): @@ -954,7 +954,7 @@ self.assertTrue(rndpage.isRedirectPage()) for rndpage in mysite.randompages(total=5, namespaces=[6, 7]): self.assertIsInstance(rndpage, pywikibot.Page) - self.assertTrue(rndpage.namespace() in [6, 7]) + self.assertIn(rndpage.namespace(), [6, 7])
# TODO: test newimages, longpages, shortpages, ancientpages, unwatchedpages # and the other following methods in site.py @@ -1018,16 +1018,16 @@ return False
self.assertIsInstance(mysite.siteinfo.get('restrictions'), dict) - self.assertTrue('restrictions' in mysite.siteinfo) + self.assertIn('restrictions', mysite.siteinfo) # the following line only works in 1.23+ self.assertTrue(mysite.siteinfo.is_recognised('restrictions')) del mysite.siteinfo._cache['restrictions'] self.assertIsInstance(mysite.siteinfo.get('restrictions', cache=False), dict) - self.assertFalse('restrictions' in mysite.siteinfo) + self.assertNotIn('restrictions', mysite.siteinfo)
not_exists = 'this-property-does-not-exist' self.assertRaises(KeyError, mysite.siteinfo.__getitem__, not_exists) - self.assertFalse(not_exists in mysite.siteinfo) + self.assertNotIn(not_exists, mysite.siteinfo) self.assertEqual(len(mysite.siteinfo.get(not_exists)), 0) self.assertFalse(entered_loop(mysite.siteinfo.get(not_exists))) self.assertFalse(entered_loop(mysite.siteinfo.get(not_exists).iteritems())) @@ -1063,7 +1063,7 @@ self.mysite.loadrevisions(self.mainpage, total=15) self.assertTrue(hasattr(self.mainpage, "_revid")) self.assertTrue(hasattr(self.mainpage, "_revisions")) - self.assertTrue(self.mainpage._revid in self.mainpage._revisions) + self.assertIn(self.mainpage._revid, self.mainpage._revisions) self.assertEqual(len(self.mainpage._revisions), 15) self.assertEqual(self.mainpage._text, None)
@@ -1082,10 +1082,10 @@ self.assertTrue(all(rev in self.mainpage._revisions for rev in [139994, 139995])) # revids as int self.mysite.loadrevisions(self.mainpage, revids=140000) - self.assertTrue(140000 in self.mainpage._revisions) + self.assertIn(140000, self.mainpage._revisions) # revids as str self.mysite.loadrevisions(self.mainpage, revids='140001') - self.assertTrue(140001 in self.mainpage._revisions) + self.assertIn(140001, self.mainpage._revisions) # revids belonging to a different page raises Exception self.assertRaises(pywikibot.Error, self.mysite.loadrevisions, self.mainpage, revids=130000) @@ -1174,7 +1174,7 @@ # which forwards interwikis to wikipedia ll = next(self.site.pagelanglinks(self.mainpage)) self.assertIsInstance(ll, pywikibot.Link) - self.assertEquals(ll.site.family.name, 'wikipedia') + self.assertEqual(ll.site.family.name, 'wikipedia')
if __name__ == '__main__': diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index 8f33435..fafb515 100644 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -46,10 +46,10 @@ self.assertIsInstance(item, pywikibot.ItemPage) self.assertEqual(item.getID(), 'Q5296') self.assertEqual(item.title(), 'Q5296') - self.assertTrue('en' in item.labels) + self.assertIn('en', item.labels) self.assertTrue(item.labels['en'].lower().endswith('main page')) - self.assertTrue('en' in item.aliases) - self.assertTrue('HomePage' in item.aliases['en']) + self.assertIn('en', item.aliases) + self.assertIn('HomePage', item.aliases['en']) self.assertEqual(item.namespace(), 0) item2 = pywikibot.ItemPage(repo, 'q5296') self.assertEqual(item2.getID(), 'Q5296') @@ -160,30 +160,30 @@ """ def test_item_normal(self): item = pywikibot.ItemPage(wikidata, 'Q60') - self.assertEquals(item._link._title, 'Q60') - self.assertEquals(item.id, 'Q60') - self.assertEquals(hasattr(item, '_title'), False) - self.assertEquals(hasattr(item, '_site'), False) - self.assertEquals(item.title(), 'Q60') - self.assertEquals(item.getID(), 'Q60') - self.assertEquals(item.getID(numeric=True), 60) - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(item._link._title, 'Q60') + self.assertEqual(item.id, 'Q60') + self.assertEqual(hasattr(item, '_title'), False) + self.assertEqual(hasattr(item, '_site'), False) + self.assertEqual(item.title(), 'Q60') + self.assertEqual(item.getID(), 'Q60') + self.assertEqual(item.getID(numeric=True), 60) + self.assertEqual(hasattr(item, '_content'), False) item.get() - self.assertEquals(hasattr(item, '_content'), True) + self.assertEqual(hasattr(item, '_content'), True)
def test_load_item_set_id(self): """Test setting item.id attribute on empty item.""" item = pywikibot.ItemPage(wikidata, '-1') - self.assertEquals(item._link._title, '-1') + self.assertEqual(item._link._title, '-1') item.id = 'Q60' - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.getID(), 'Q60') - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.getID(), 'Q60') + self.assertEqual(hasattr(item, '_content'), False) item.get() - self.assertEquals(hasattr(item, '_content'), True) - self.assertTrue('en' in item.labels) - self.assertEquals(item.labels['en'], 'New York City') - self.assertEquals(item.title(), 'Q60') + self.assertEqual(hasattr(item, '_content'), True) + self.assertIn('en', item.labels) + self.assertEqual(item.labels['en'], 'New York City') + self.assertEqual(item.title(), 'Q60')
def test_reuse_item_set_id(self): """ @@ -195,19 +195,19 @@ """ item = pywikibot.ItemPage(wikidata, 'Q60') item.get() - self.assertEquals(item.labels['en'], 'New York City') + self.assertEqual(item.labels['en'], 'New York City')
# When the id attribute is modified, the ItemPage goes into # an inconsistent state. item.id = 'Q5296' # The title is updated correctly - self.assertEquals(item.title(), 'Q5296') + self.assertEqual(item.title(), 'Q5296')
# This del has no effect on the test; it is here to demonstrate that # it doesnt help to clear this piece of saved state. del item._content # The labels are not updated; assertion showing undesirable behaviour: - self.assertEquals(item.labels['en'], 'New York City') + self.assertEqual(item.labels['en'], 'New York City') # TODO: This is the assertion that this test should be using: # self.assertTrue(item.labels['en'].lower().endswith('main page'))
@@ -224,13 +224,13 @@ ucfirst_title = title[0].upper() + title[1:] else: ucfirst_title = title - self.assertEquals(item._link._title, ucfirst_title) - self.assertEquals(item.id, title.upper()) - self.assertEquals(item.title(), title.upper()) - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(item._link._title, ucfirst_title) + self.assertEqual(item.id, title.upper()) + self.assertEqual(item.title(), title.upper()) + self.assertEqual(hasattr(item, '_content'), False) self.assertRaises(exception, item.get) - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.title(), title.upper()) + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.title(), title.upper())
check('', KeyError)
@@ -240,57 +240,57 @@ def test_item_untrimmed_title(self): # spaces in the title cause an error item = pywikibot.ItemPage(wikidata, ' Q60 ') - self.assertEquals(item._link._title, 'Q60') - self.assertEquals(item.title(), ' Q60 ') + self.assertEqual(item._link._title, 'Q60') + self.assertEqual(item.title(), ' Q60 ') self.assertRaises(APIError, item.get)
def test_item_missing(self): # this item is deleted item = pywikibot.ItemPage(wikidata, 'Q404') - self.assertEquals(item._link._title, 'Q404') - self.assertEquals(item.title(), 'Q404') - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.id, 'Q404') - self.assertEquals(item.getID(), 'Q404') - self.assertEquals(item.getID(numeric=True), 404) - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(item._link._title, 'Q404') + self.assertEqual(item.title(), 'Q404') + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.id, 'Q404') + self.assertEqual(item.getID(), 'Q404') + self.assertEqual(item.getID(numeric=True), 404) + self.assertEqual(hasattr(item, '_content'), False) self.assertRaises(pywikibot.NoPage, item.get) - self.assertEquals(hasattr(item, '_content'), True) - self.assertEquals(item._link._title, 'Q404') - self.assertEquals(item.title(), 'Q404') - self.assertEquals(item.exists(), False) + self.assertEqual(hasattr(item, '_content'), True) + self.assertEqual(item._link._title, 'Q404') + self.assertEqual(item.title(), 'Q404') + self.assertEqual(item.exists(), False)
def test_fromPage_noprops(self): page = pywikibot.Page(pywikibot.page.Link("New York City", site)) item = pywikibot.ItemPage.fromPage(page) - self.assertEquals(item._link._title, 'Null') # not good - self.assertEquals(hasattr(item, 'id'), False) - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.title(), 'Q60') - self.assertEquals(hasattr(item, '_content'), True) - self.assertEquals(item.id, 'Q60') - self.assertEquals(item.getID(), 'Q60') - self.assertEquals(item.getID(numeric=True), 60) + self.assertEqual(item._link._title, 'Null') # not good + self.assertEqual(hasattr(item, 'id'), False) + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.title(), 'Q60') + self.assertEqual(hasattr(item, '_content'), True) + self.assertEqual(item.id, 'Q60') + self.assertEqual(item.getID(), 'Q60') + self.assertEqual(item.getID(numeric=True), 60) item.get() - self.assertEquals(item.exists(), True) + self.assertEqual(item.exists(), True)
def test_fromPage_props(self): page = pywikibot.Page(pywikibot.page.Link("New York City", site)) # fetch page properties page.properties() item = pywikibot.ItemPage.fromPage(page) - self.assertEquals(item._link._title, 'Q60') - self.assertEquals(item.id, 'Q60') - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.title(), 'Q60') - self.assertEquals(hasattr(item, '_content'), False) - self.assertEquals(item.id, 'Q60') - self.assertEquals(item.getID(), 'Q60') - self.assertEquals(item.getID(numeric=True), 60) - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(item._link._title, 'Q60') + self.assertEqual(item.id, 'Q60') + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.title(), 'Q60') + self.assertEqual(hasattr(item, '_content'), False) + self.assertEqual(item.id, 'Q60') + self.assertEqual(item.getID(), 'Q60') + self.assertEqual(item.getID(numeric=True), 60) + self.assertEqual(hasattr(item, '_content'), False) item.get() - self.assertEquals(hasattr(item, '_content'), True) - self.assertEquals(item.exists(), True) + self.assertEqual(hasattr(item, '_content'), True) + self.assertEqual(item.exists(), True)
def test_fromPage_invalid_title(self): page = pywikibot.Page(pywikibot.page.Link("[]", site)) @@ -313,15 +313,15 @@ page.properties()
item = pywikibot.ItemPage.fromPage(page) - self.assertEquals(hasattr(item, 'id'), False) - self.assertEquals(hasattr(item, '_title'), True) - self.assertEquals(hasattr(item, '_site'), True) - self.assertEquals(hasattr(item, '_content'), False) + self.assertEqual(hasattr(item, 'id'), False) + self.assertEqual(hasattr(item, '_title'), True) + self.assertEqual(hasattr(item, '_site'), True) + self.assertEqual(hasattr(item, '_content'), False)
- self.assertEquals(item._link._title, 'Null') + self.assertEqual(item._link._title, 'Null') # the method 'exists' does not raise an exception if method == 'exists': - self.assertEquals(item.exists(), False) + self.assertEqual(item.exists(), False) else: self.assertRaises(pywikibot.NoPage, getattr(item, method))
@@ -333,11 +333,11 @@ # local data is modified in this scenario. This case is # separately tested in test_fromPage_missing_lazy. if link.title != 'Test page': - self.assertEquals(item._link._title, '-1') + self.assertEqual(item._link._title, '-1')
- self.assertEquals(hasattr(item, '_content'), True) + self.assertEqual(hasattr(item, '_content'), True)
- self.assertEquals(item.exists(), False) + self.assertEqual(item.exists(), False)
def test_fromPage_redirect(self): # this is a redirect, and should not have a wikidata item @@ -378,29 +378,29 @@
def test_globe_coordinate(self): property_page = pywikibot.PropertyPage(wikidata, 'P625') - self.assertEquals(property_page.type, 'globe-coordinate') - self.assertEquals(property_page.getType(), 'globecoordinate') + self.assertEqual(property_page.type, 'globe-coordinate') + self.assertEqual(property_page.getType(), 'globecoordinate')
claim = pywikibot.Claim(wikidata, 'P625') - self.assertEquals(claim.type, 'globe-coordinate') - self.assertEquals(claim.getType(), 'globecoordinate') + self.assertEqual(claim.type, 'globe-coordinate') + self.assertEqual(claim.getType(), 'globecoordinate')
class TestClaimSetValue(PywikibotTestCase):
def test_set_website(self): claim = pywikibot.Claim(wikidata, 'P856') - self.assertEquals(claim.type, 'url') + self.assertEqual(claim.type, 'url') claim.setTarget('https://en.wikipedia.org/') - self.assertEquals(claim.target, 'https://en.wikipedia.org/') + self.assertEqual(claim.target, 'https://en.wikipedia.org/')
def test_set_date(self): claim = pywikibot.Claim(wikidata, 'P569') - self.assertEquals(claim.type, 'time') + self.assertEqual(claim.type, 'time') claim.setTarget(pywikibot.WbTime(year=2001, month=1, day=1, site=wikidata)) - self.assertEquals(claim.target.year, 2001) - self.assertEquals(claim.target.month, 1) - self.assertEquals(claim.target.day, 1) + self.assertEqual(claim.target.year, 2001) + self.assertEqual(claim.target.month, 1) + self.assertEqual(claim.target.day, 1)
def test_set_incorrect_target_value(self): claim = pywikibot.Claim(wikidata, 'P569') @@ -417,8 +417,8 @@ self.wdp = pywikibot.ItemPage(wikidatatest, 'Q6') self.assertRaises(pywikibot.PageNotSaved, self.wdp.save) self.wdp.previousRevision() - self.assertEquals(self.wdp.langlinks(), []) - self.assertEquals(self.wdp.templates(), []) + self.assertEqual(self.wdp.langlinks(), []) + self.assertEqual(self.wdp.templates(), []) self.assertFalse(self.wdp.isCategoryRedirect()) self.wdp.templatesWithParams()
@@ -436,14 +436,14 @@
def test_iterlinks_page_object(self): page = [pg for pg in self.wdp.iterlinks() if pg.site.language() == 'af'][0] - self.assertEquals(page, pywikibot.Page(pywikibot.Site('af', 'wikipedia'), u'New York Stad')) + self.assertEqual(page, pywikibot.Page(pywikibot.Site('af', 'wikipedia'), u'New York Stad'))
def test_iterlinks_filtering(self): wikilinks = list(self.wdp.iterlinks('wikipedia')) wvlinks = list(self.wdp.iterlinks('wikivoyage'))
- self.assertEquals(len(wikilinks), 3) - self.assertEquals(len(wvlinks), 2) + self.assertEqual(len(wikilinks), 3) + self.assertEqual(len(wvlinks), 2)
class TestWriteNormalizeLang(PywikibotTestCase): @@ -462,12 +462,12 @@ lang_in = {self.site: 'foo'}
response = WikibasePage._normalizeLanguages(lang_in) - self.assertEquals(response, self.lang_out) + self.assertEqual(response, self.lang_out)
def test_normalized_lang(self): response = WikibasePage._normalizeData( copy.deepcopy(self.lang_out)) - self.assertEquals(response, self.lang_out) + self.assertEqual(response, self.lang_out)
class TestWriteNormalizeData(PywikibotTestCase): @@ -501,12 +501,12 @@ }
response = WikibasePage._normalizeData(data_in) - self.assertEquals(response, self.data_out) + self.assertEqual(response, self.data_out)
def test_normalized_data(self): response = WikibasePage._normalizeData( copy.deepcopy(self.data_out)) - self.assertEquals(response, self.data_out) + self.assertEqual(response, self.data_out)
if __name__ == '__main__': diff --git a/tests/wikidataquery_tests.py b/tests/wikidataquery_tests.py index 52c8416..07d72de 100644 --- a/tests/wikidataquery_tests.py +++ b/tests/wikidataquery_tests.py @@ -245,8 +245,8 @@
self.assertTrue(os.path.exists(cacheFile))
- self.assertTrue('status' in data) - self.assertTrue('items' in data) + self.assertIn('status', data) + self.assertIn('items', data)
t1 = time.time() data = w.query(q) diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py index 955261c..2f9264c 100644 --- a/tests/xmlreader_tests.py +++ b/tests/xmlreader_tests.py @@ -24,22 +24,22 @@ xmlreader.XmlDump(os.path.join(self.path, 'data', "article-pear.xml"), allrevisions=True).parse()] - self.assertEquals(4, len(pages)) - self.assertEquals(u"Automated conversion", pages[0].comment) - self.assertEquals(u"Pear", pages[0].title) - self.assertEquals(u"24278", pages[0].id) + self.assertEqual(4, len(pages)) + self.assertEqual(u"Automated conversion", pages[0].comment) + self.assertEqual(u"Pear", pages[0].title) + self.assertEqual(u"24278", pages[0].id) self.assertTrue(pages[0].text.startswith('Pears are [[tree]]s of')) - self.assertEquals(u"Quercusrobur", pages[1].username) - self.assertEquals(u"Pear", pages[0].title) + self.assertEqual(u"Quercusrobur", pages[1].username) + self.assertEqual(u"Pear", pages[0].title)
def test_XmlDumpFirstRev(self): pages = [r for r in xmlreader.XmlDump(os.path.join(self.path, 'data', "article-pear.xml")).parse()] - self.assertEquals(1, len(pages)) - self.assertEquals(u"Automated conversion", pages[0].comment) - self.assertEquals(u"Pear", pages[0].title) - self.assertEquals(u"24278", pages[0].id) + self.assertEqual(1, len(pages)) + self.assertEqual(u"Automated conversion", pages[0].comment) + self.assertEqual(u"Pear", pages[0].title) + self.assertEqual(u"24278", pages[0].id) self.assertTrue(pages[0].text.startswith('Pears are [[tree]]s of')) self.assertTrue(not pages[0].isredirect)
pywikibot-commits@lists.wikimedia.org