Page MenuHomePhabricator

userinterface is not properly set if bot.py has a ModuleDeprecationWrapper
Open, LowPublicBUG REPORT

Description

List of steps to reproduce:

  1. switch/checkout to rPWBCa2b9ddae
  2. add pywikibot.tools.ModuleDeprecationWrapper(__name__) at the bottom of bot.py
  3. run pwb replacebot_tests -v TestReplacementsMain

What happens?:
All 12 tests fails. As the exception shows the pywikibot.bot.ui is not a buffered UI but a Win32UI in Windows machines and I guess an UnixUI for Linux.

C:\pwb\GIT\core>pwb replacebot_tests -v TestReplacementsMain
tests: max_retries reduced from 15 to 1
EEEEEEEEEEEE
======================================================================
ERROR: test_cmd_and_fix (__main__.TestReplacementsMain)
Test command line and fix replacements together.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\replacebot_tests.py", line 74, in setUp
    pywikibot.bot.ui.clear()
AttributeError: 'Win32UI' object has no attribute 'clear'
----------------------------------------------------------------------
… < trunctated >
----------------------------------------------------------------------

Ran 12 tests in 2.551s

FAILED (errors=12)

C:\pwb\GIT\core>

If using set_interface('buffer') the line above, tests will still fail with wrapper (but pass without) due to an empty buffer.

What should have happened instead?:
without ModuleDeprecationWrapper tests passes as expected:

C:\pwb\GIT\core>pwb replacebot_tests TestReplacementsMain
tests: max_retries reduced from 15 to 1
............
----------------------------------------------------------------------
Ran 12 tests in 2.893s

OK

C:\pwb\GIT\core>

The previous commit rPWBC1607677a works fine with and without ModuleDeprecationWrapper

Event Timeline

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

[pywikibot/core@master] [doc] Add a note about T286348 to pywikibot.bot module

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

Xqt lowered the priority of this task from High to Low.Jul 10 2021, 11:39 AM

Change 703883 merged by jenkins-bot:

[pywikibot/core@master] [doc] Add a note about T286348 to pywikibot.bot module

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