| Dalba created this task. Dalba added projects: Pywikibot-tests, Pywikibot-core. Herald added subscribers: pywikibot-bugs-list, Aklapper. |
TASK DESCRIPTION
https://travis-ci.org/wikimedia/pywikibot-core/jobs/225869300#L2110 (LANGUAGE=wikidata FAMILY=wikidata)
______________________ TestSiteGenerators.testLinkMethods ______________________
self = <tests.site_tests.TestSiteGenerators testMethod=testLinkMethods> def testLinkMethods(self): """Test site methods for getting links to and from a page.""" if self.site.family.name == 'wpbeta': raise unittest.SkipTest('Test fails on betawiki; T69931') mysite = self.get_site() mainpage = self.get_mainpage() backlinks = set(mysite.pagebacklinks(mainpage, namespaces=[0])) # only non-redirects: filtered = set(mysite.pagebacklinks(mainpage, namespaces=0, filterRedirects=False)) # only redirects: redirs = set(mysite.pagebacklinks(mainpage, namespaces=0, filterRedirects=True)) # including links to redirect pages (but not the redirects): indirect = set(mysite.pagebacklinks(mainpage, namespaces=[0], followRedirects=True, filterRedirects=False)) self.assertEqual(filtered & redirs, set([])) self.assertEqual(indirect & redirs, set([])) self.assertLessEqual(filtered, indirect) self.assertLessEqual(filtered, backlinks) self.assertLessEqual(redirs, backlinks) self.assertLessEqual( backlinks, set(self.site.pagebacklinks(mainpage, namespaces=[0, 2]))) # pagereferences includes both backlinks and embeddedin embedded = set(mysite.page_embeddedin(mainpage, namespaces=[0])) refs = set(mysite.pagereferences(mainpage, namespaces=[0])) self.assertTrue(backlinks.issubset(refs)) self.assertTrue(embedded.issubset(refs)) for bl in backlinks: self.assertIsInstance(bl, pywikibot.Page) self.assertIn(bl, refs) for ei in embedded: self.assertIsInstance(ei, pywikibot.Page) self.assertIn(ei, refs) for ref in refs: self.assertIn(ref, backlinks | embedded) # test embeddedin arguments self.assertTrue(embedded.issuperset( set(mysite.page_embeddedin(mainpage, filterRedirects=True, namespaces=[0])))) self.assertTrue(embedded.issuperset( set(mysite.page_embeddedin(mainpage, filterRedirects=False, namespaces=[0])))) self.assertTrue(embedded.issubset( set(mysite.page_embeddedin(mainpage, namespaces=[0, 2])))) links = set(mysite.pagelinks(mainpage)) for pl in links: self.assertIsInstance(pl, pywikibot.Page) # test links arguments # TODO: There have been build failures because the following assertion # wasn't true. Bug: T92856 # Example: https://travis-ci.org/wikimedia/pywikibot-core/jobs/54552081#L505 namespace_links = set(mysite.pagelinks(mainpage, namespaces=[0, 1])) if namespace_links - links: unittest_print( 'FAILURE wrt T92856:\nSym. difference: "{0}"'.format( '", "'.join( '{0}@{1}'.format(link.namespace(), link.title(withNamespace=False)) for link in namespace_links ^ links))) self.assertCountEqual( set(mysite.pagelinks(mainpage, namespaces=[0, 1])) - links, []) for target in mysite.preloadpages(mysite.pagelinks(mainpage, follow_redirects=True, total=5)): self.assertIsInstance(target, pywikibot.Page) self.assertFalse(target.isRedirectPage()) # test pagecategories for cat in mysite.pagecategories(mainpage): self.assertIsInstance(cat, pywikibot.Category) for cm in mysite.categorymembers(cat): self.assertIsInstance(cat, pywikibot.Page) # test pageimages self.assertTrue(all(isinstance(im, pywikibot.FilePage) for im in mysite.pageimages(mainpage))) # test pagetemplates self.assertTrue(all(isinstance(te, pywikibot.Page) for te in mysite.pagetemplates(mainpage))) self.assertTrue(set(mysite.pagetemplates(mainpage)).issuperset( set(mysite.pagetemplates(mainpage, namespaces=[10])))) # test pagelanglinks > for ll in mysite.pagelanglinks(mainpage): tests/site_tests.py:556: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pywikibot/site.py:4009: in pagelanglinks source=self) pywikibot/page.py:5603: in langlinkUnsafe link._site = pywikibot.Site(lang, source.family.interwiki_forward) pywikibot/__init__.py:1050: in Site _sites[key] = interface(code=code, fam=fam, user=user, sysop=sysop) pywikibot/site.py:1857: in __init__ BaseSite.__init__(self, code, fam, user, sysop) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = APISite("dty", "wikipedia"), code = 'dty', fam = Family("wikipedia") user = None, sysop = None def __init__(self, code, fam=None, user=None, sysop=None): """ Constructor. @param code: the site's language code @type code: str @param fam: wiki family name (optional) @type fam: str or Family @param user: bot user name (optional) @type user: str @param sysop: sysop account user name (optional) @type sysop: str """ if code.lower() != code: # Note the Site function in __init__ also emits a UserWarning # for this condition, showing the callers file and line no. pywikibot.log(u'BaseSite: code "%s" converted to lowercase' % code) code = code.lower() if not all(x in pywikibot.family.CODE_CHARACTERS for x in str(code)): pywikibot.log(u'BaseSite: code "%s" contains invalid characters' % code) self.__code = code if isinstance(fam, basestring) or fam is None: self.__family = pywikibot.family.Family.load(fam) else: self.__family = fam self.obsolete = False # if we got an outdated language code, use the new one instead. if self.__code in self.__family.obsolete: if self.__family.obsolete[self.__code] is not None: self.__code = self.__family.obsolete[self.__code] # Note the Site function in __init__ emits a UserWarning # for this condition, showing the callers file and line no. pywikibot.log(u'Site %s instantiated using code %s' % (self, code)) else: # no such language anymore self.obsolete = True pywikibot.log(u'Site %s instantiated and marked "obsolete" ' u'to prevent access' % self) elif self.__code not in self.languages(): if self.__family.name in list(self.__family.langs.keys()) and \ len(self.__family.langs) == 1: self.__code = self.__family.name if self.__family == pywikibot.config.family \ and code == pywikibot.config.mylang: pywikibot.config.mylang = self.__code warn(u'Global configuration variable "mylang" changed to ' u'"%s" while instantiating site %s' % (self.__code, self), UserWarning) else: raise UnknownSite(u"Language '%s' does not exist in family %s" > % (self.__code, self.__family.name)) E UnknownSite: Language 'dty' does not exist in family wikipedia
Code dty has been recently added to wikidata: https://www.wikidata.org/w/index.php?title=Q5296&diff=478497603&oldid=478131784
This is almost the same error as T163871.
TASK DETAIL
EMAIL PREFERENCES
To: Dalba
Cc: Aklapper, pywikibot-bugs-list, Dalba, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Sn1per, jayvdb, Masti, Alchimista, Rxy
Cc: Aklapper, pywikibot-bugs-list, Dalba, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Sn1per, jayvdb, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
