JJMC89 created this task.
JJMC89 added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
18:43:44 _____ TestLinktrails.test_has_linktrail (site=APISite('hr',
'wikipedia')) ______
18:43:44
18:43:44 obj = APISite('hr', 'wikipedia')
18:43:44
18:43:44 @wraps(fn)
18:43:44 def wrapper(obj: object, *, force=False) -> Any:
18:43:44 cache_name = '_' + fn.__name__
18:43:44 if force:
18:43:44 with suppress(AttributeError):
18:43:44 delattr(obj, cache_name)
18:43:44 try:
18:43:44 > return getattr(obj, cache_name)
18:43:44
18:43:44 pywikibot/tools/__init__.py:771:
18:43:44 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:43:44
18:43:44 self = APISite('hr', 'wikipedia'), name = '_linktrail'
18:43:44
18:43:44 def __getattr__(self, name: str):
18:43:44 """Delegate undefined methods calls to the Family object.
18:43:44
18:43:44 .. versionchanged:: 9.0
18:43:44 Only delegate to public Family methods which have
``code`` as
18:43:44 first parameter.
18:43:44 """
18:43:44 if not name.startswith('_'):
18:43:44 obj = getattr(self.family, name, None)
18:43:44 if inspect.ismethod(obj):
18:43:44 params = inspect.signature(obj).parameters
18:43:44 if params:
18:43:44 parameter = next(iter(params))
18:43:44 if parameter == 'code':
18:43:44 method = functools.partial(obj, self.code)
18:43:44 if hasattr(obj, '__doc__'):
18:43:44 method.__doc__ = obj.__doc__
18:43:44 return method
18:43:44
18:43:44 > raise AttributeError(f'{type(self).__name__} instance has
no '
18:43:44 f'attribute {name!r}') from None
18:43:44 E AttributeError: APISite instance has no attribute
'_linktrail'. Did you mean: 'linktrail'?
18:43:44
18:43:44 pywikibot/site/_basesite.py:217: AttributeError
18:43:44
18:43:44 During handling of the above exception, another exception occurred:
18:43:44
18:43:44 self = <tests.site_tests.TestLinktrails
testMethod=test_has_linktrail>
18:43:44
18:43:44 def test_has_linktrail(self):
18:43:44 """Verify that every code has a linktrail.
18:43:44
18:43:44 Test all smallest wikis and the others randomly.
18:43:44 """
18:43:44 size = 20
18:43:44 small_wikis = self.site.family.languages_by_size[-size:]
18:43:44 great_wikis = self.site.family.languages_by_size[:-size]
18:43:44 great_wikis = random.sample(great_wikis, size)
18:43:44 for code in sorted(small_wikis + great_wikis):
18:43:44 site = pywikibot.Site(code, self.family)
18:43:44 with self.subTest(site=site):
18:43:44 > self.assertIsInstance(site.linktrail(), str)
18:43:44
18:43:44 tests/site_tests.py:1021:
18:43:44 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:43:44 pywikibot/tools/__init__.py:773: in wrapper
18:43:44 val = fn(obj)
18:43:44 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:43:44
18:43:44 self = APISite('hr', 'wikipedia')
18:43:44
18:43:44 @cached
18:43:44 def linktrail(self) -> str:
18:43:44 """Build linktrail regex from siteinfo linktrail.
18:43:44
18:43:44 Letters that can follow a wikilink and are regarded as
part of
18:43:44 this link. This depends on the linktrail setting in
LanguageXx.php
18:43:44
18:43:44 .. versionadded:: 7.3
18:43:44
18:43:44 :return: The linktrail regex.
18:43:44 """
18:43:44 unresolved_linktrails = {
18:43:44 'br': '(?:[a-zA-ZàâçéèêîôûäëïöüùñÇÉÂÊÎÔÛÄËÏÖÜÀÈÙÑ]'
18:43:44 "|[cC]['’]h|C['’]H)*",
18:43:44 'ca': "(?:[a-zàèéíòóúç·ïü]|'(?!'))*",
18:43:44 'kaa': "(?:[a-zıʼ’“»]|'(?!'))*",
18:43:44 }
18:43:44 linktrail = self.siteinfo['general']['linktrail']
18:43:44 if linktrail == '/^()(.*)$/sD': # empty linktrail
18:43:44 return ''
18:43:44
18:43:44 match = re.search(r'\((?:\:\?|\?\:)?\[(?P<pattern>.+?)\]'
18:43:44 r'(?P<letters>(\|.)*)\)?\+\)', linktrail)
18:43:44 if not match:
18:43:44 with suppress(KeyError):
18:43:44 return unresolved_linktrails[self.code]
18:43:44 > raise KeyError(f'"{self.code}": No linktrail pattern
extracted '
18:43:44 f'from "{linktrail}"')
18:43:44 E KeyError: '"hr": No linktrail pattern extracted from
"/^(\\p{L}+)(.*)$/sDu"'
18:43:44
18:43:44 pywikibot/site/_apisite.py:880: KeyError
Source:
https://integration.wikimedia.org/ci/job/pywikibot-core-tox-deeptest-py312/138/console
TASK DETAIL
https://phabricator.wikimedia.org/T378787
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: JJMC89
Cc: Aklapper, pywikibot-bugs-list, JJMC89, mevo, PotsdamLamb, Jyoo1011,
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho,
MayS, Mdupont, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx, Xqt,
jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]