Page MenuHomePhabricator

page_tests.TestPageObject.testLinks sometimes fails due to missing namespace
Open, MediumPublic

Description

======================================================================
ERROR: testLinks (tests.page_tests.TestPageObject)
Test the different types of links from a page.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\pywikibot\pywikibot\tools\__init__.py", line 767, in wrapper
    return getattr(obj, cache_name)
  File "C:\projects\pywikibot\pywikibot\site\_basesite.py", line 208, in __getattr__
    raise AttributeError(f'{type(self).__name__} instance has no '
AttributeError: APISite instance has no attribute '_namespaces'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\projects\pywikibot\tests\page_tests.py", line 525, in testLinks
    iw = list(mainpage.interwiki(expand=True))
  File "C:\projects\pywikibot\pywikibot\page\_basepage.py", line 1495, in interwiki
    if link.site != self.site \
  File "C:\projects\pywikibot\pywikibot\page\_links.py", line 502, in site
    self.parse()
  File "C:\projects\pywikibot\pywikibot\page\_links.py", line 487, in parse
    elif self._site.namespaces[self._namespace].case == 'first-letter':
  File "C:\projects\pywikibot\pywikibot\tools\__init__.py", line 769, in wrapper
    val = fn(obj)
  File "C:\projects\pywikibot\pywikibot\site\_basesite.py", line 254, in namespaces
    return NamespacesDict(self._build_namespaces())
  File "C:\projects\pywikibot\pywikibot\site\_apisite.py", line 1178, in _build_namespaces
    for nsdata in self.siteinfo.get('namespaces', cache=False).values():
  File "C:\projects\pywikibot\pywikibot\site\_siteinfo.py", line 273, in get
    preloaded = self._get_general(key, expiry)
  File "C:\projects\pywikibot\pywikibot\site\_siteinfo.py", line 213, in _get_general
    self._cache[prop] = default_info[prop]
KeyError: 'namespaces'
----------------------------------------------------------------------
Ran 3196 tests in 1259.196s
FAILED (errors=1, skipped=85, expected failures=44)

This test fails on wikipedia:en but passes for wikipedia:es, wikipedia:de, wikisourch:zh. The failing test can be produced by

pwb -site:wikipedia:en page_tests -v TestPageObject.testLinks

Event Timeline

Xqt triaged this task as High priority.Jan 28 2024, 9:15 AM
Xqt updated the task description. (Show Details)

I guess there is a problem with wikimediafoundation family. The Family is created with AutoFamily constructor. unfortunately its https://wikimediafoundation.org/w/api.php is redirected to https://foundation.wikimedia.org/w/api.php. When redirecting the url the "|" delimiters of the query are lost.

Change 993250 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [tests] Skip interwiki link test until the problem is solved upstream

https://gerrit.wikimedia.org/r/993250

Change 993250 merged by jenkins-bot:

[pywikibot/core@master] [tests] Skip interwiki link test until the problem is solved upstream

https://gerrit.wikimedia.org/r/993250

Xqt lowered the priority of this task from High to Medium.Jan 28 2024, 1:05 PM