Page MenuHomePhabricator

family_tests.TestFamilyUrlRegex.test_each_family() fails if logging is not initialized
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):
run pwb family_tests

What happens?:

tests: max_retries reduced from 15 to 1
...........s.
======================================================================
ERROR: test_each_family (__main__.TestFamilyUrlRegex) (family='commons')
Test each family builds a working regex.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\family_tests.py", line 235, in test_each_family
    self.assertEqual(family.from_url(url), code)
  File "C:\pwb\GIT\core\pywikibot\family.py", line 862, in from_url
    pywikibot.log('Found candidate {}'.format(site))
  File "C:\pwb\GIT\core\pywikibot\logging.py", line 183, in log
    logoutput(text, decoder, newline, VERBOSE, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\logging.py", line 76, in logoutput
    _init()
  File "C:\pwb\GIT\core\pywikibot\logging.py", line 35, in _init
    init_routine()
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 353, in init_handlers
    throttle = pywikibot.Site().throttle  # initialize a Throttle object
TypeError: TestFamilyUrlRegex.Site() missing 2 required positional arguments: 'code' and 'fam'

----------------------------------------------------------------------
Ran 13 tests in 0.257s

FAILED (errors=1, skipped=1)

C:\pwb\GIT\core>

but test pass if logging is already initialized e.g. a site is given with pwb wrapper script:

pwb -lang:en family_tests

tests: max_retries reduced from 15 to 1
...........s.
----------------------------------------------------------------------
Ran 13 tests in 0.303s

OK (skipped=1)

C:\pwb\GIT\core>

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
The test passes with 6.1.0 but fails with Pywikibot 6.2.0 or newer

Event Timeline

Xqt triaged this task as High priority.Dec 29 2021, 7:07 PM

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

[pywikibot/core@master] [tests] Fix missing arguments wit family_tests.py

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

Change 750699 merged by jenkins-bot:

[pywikibot/core@master] [tests] Fix missing arguments with family_tests.py

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

Xqt claimed this task.