Page MenuHomePhabricator

script_tests fails due to unknown reason
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce :
Run the following command:

C:\pwb\GIT\core>pwb.py script_tests -v TestScriptHelp.test_basic

What happens?:

tests: max_retries reduced from 15 to 1
weblinkchecker depends on memento_client, which isn't available
test_basic (__main__.TestScriptHelp)
Test running basic -help. ... FAIL

======================================================================
FAIL: test_basic (__main__.TestScriptHelp)
Test running basic -help.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\script_tests.py", line 244, in testScript
    stderr_other)
AssertionError: 'Use -help for further information.' not found in ['Traceback (most recent call last):', '  File "<string>", line 1, in <module>', '  File "C:\\pwb\\GIT\\core\\pwb.py", line 408, in main', '    module)', '  File "C:\\pwb\\GIT\\core\\pwb.py", line 107, in run_python_file', '    main_mod.__dict__)', '  File ".\\scripts\\basic.py", line 174, in <module>', '    main()', '  File ".\\scripts\\basic.py", line 139, in main', '    local_args = pywikibot.handle_args(args)', '  File "C:\\pwb\\GIT\\core\\pywikibot\\bot.py", line 969, in handle_args', '    init_handlers()', '  File "C:\\pwb\\GIT\\core\\pywikibot\\tools\\_deprecate.py", line 487, in wrapper', '    return obj(*new_args, **new_kwargs)', '  File "C:\\pwb\\GIT\\core\\pywikibot\\bot.py", line 404, in init_handlers', '    throttle = site.throttle  # initialize a Throttle obj', "AttributeError: 'NoneType' object has no attribute 'throttle'", 'Error in atexit._run_exitfuncs:', 'Traceback (most recent call last):', '  File "C:\\pwb\\GIT\\core\\pywikibot\\__init__.py", line 1298, in _flush', "    debug('_flush() called', _logger)", '  File "C:\\pwb\\GIT\\core\\pywikibot\\logging.py", line 210, in debug', '    logoutput(text, decoder, newline, DEBUG, layer, **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\\tools\\_deprecate.py", line 487, in wrapper', '    return obj(*new_args, **new_kwargs)', '  File "C:\\pwb\\GIT\\core\\pywikibot\\bot.py", line 404, in init_handlers', '    throttle = site.throttle  # initialize a Throttle obj', "AttributeError: 'NoneType' object has no attribute 'throttle'", "CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>"]

----------------------------------------------------------------------
Ran 1 test in 0.701s

FAILED (failures=1)

C:\pwb\GIT\core>

What should have happened instead?:
Test should pass

Software version:

Pywikibot: [ssh] pywikibot-core (a737efa, g15337, 2021/08/17, 15:43:12, OUTDATED)
Release version: 6.6.0.dev0
setuptools version: 20.8.1
mwparserfromhell version: 0.6.2
wikitextparser version: n/a
requests version: 2.25.1
  cacerts: C:\Python35\lib\site-packages\certifi\cacert.pem
    certificate test: ok
Python: 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB:
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: C:\pwb\GIT\core

It fails for me with Python 3.5.0 and Python 3.9.0

An additional test in bot.py lets the Tests pass:

try:  # T286848
    print(2)
    site = pywikibot.Site()
    print(3, site)
except ValueError:
    print(4)
    pass
else:  # get PID
    print(5, site)
    if site is not None:  # this additional check let the test pass
       throttle = site.throttle  # initialize a Throttle obj

This is strange because site = pywikibot.Site() always gives a Site <> None; I confirmed it by print statements

Event Timeline

Xqt renamed this task from script_tests fails with Python 3.5.0 to script_tests fails due to unknown reason.Aug 22 2021, 12:23 PM
Xqt updated the task description. (Show Details)

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

[pywikibot/core@master] [bugfix] Ignore Site() results of None in script_tests

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

Change 714201 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Ignore Site() results of None in script_tests

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