valhallasw created this task. valhallasw added a subscriber: valhallasw. valhallasw added projects: pywikibot-core, Pywikibot-General. valhallasw changed Security from none to none.
TASK DESCRIPTION On both linux and windows.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: valhallasw Cc: pywikipedia-bugs, valhallasw, jayvdb
XZise added a subscriber: XZise.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: XZise Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
jayvdb added a subscriber: jayvdb.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: jayvdb Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
XZise added a comment.
Okay this might sound stupid, but you have to execute it via `tests/ui_tests.py`. Although it doesn't work because then the `tests` module isn't available.
If you use `python pwb.py tests/ui_tests.py` (which is what I've been doing until recently) `pywikibot` is imported in pwb.py and the `UI` class in `pywikibot.userinterfaces.terminal_interface_base` is already initialized before the test suite had a change to monkey patch it. And that `UI` class buffers the `std*` locally so if we monkeypatch `sys.std*` it after it is initialized `pywikibot.output()` and the likes are still using the buffered `stdout`.
Interestingly the tests are importing `pywikibot` after patching `sys.std*`, so wouldn't there be pwb.py it might work, although importing something in test is like importing `pywikibot` too.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: XZise Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
valhallasw added a comment.
Directly running
PYTHONPATH=. python tests/ui_tests.py
also doesn't work for me, so there's probably something else that loads pywikibot before everything is monkey-patched.
Obvious fix would be to not monkeypatch, and to shell out to a new interpreter instead...
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: valhallasw Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
XZise added a comment.
Importing something from `tests.utils` will also import `pywikibot`. If I move it above the first class which uses `unittest` it does execute.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: XZise Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
XZise added a comment.
Another problem is then, that the `std*` is a `StringIO` so only accepts strings but in Python 3, when we encode the colored messages in `pywikibot.userinterfaces.terminal_interface_unix.UnixUI.printColorized`, it's bytes. I'm not sure if we shouldn't encode it or if it needs to be `BytesIO`. But afaik `sys.__std*` are `str` based in Python 3 so I think they shouldn't be encoded, especially as `pywikibot.userinterfaces.terminal_interface_base.UI.printNonColorized` does that:
``` if sys.version_info[0] == 2: line = line.encode(self.encoding, 'replace') targetStream.write(line) ```
Although I'm wondering why it does work outside of the test and the logic in `printColorized` appears more complex so I'm currently not sure how that need to be changed.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: XZise Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
jayvdb edited the task description. jayvdb triaged this task as "Normal" priority. jayvdb added a project: Pywikibot-tests.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: jayvdb Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
jayvdb moved this task to Test failures on the Pywikibot-tests workboard.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
To: jayvdb Cc: pywikipedia-bugs, valhallasw, XZise, jayvdb
gerritbot added a subscriber: gerritbot. gerritbot added a project: Patch-For-Review. gerritbot added a comment.
Change 186336 had a related patch set uploaded (by John Vandenberg): Fix all but three of the ui_tests on unix
https://gerrit.wikimedia.org/r/186336
https://phabricator.wikimedia.org/tag/patch-for-review/
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: gerritbot Cc: gerritbot, jayvdb, valhallasw, XZise, pywikipedia-bugs
gerritbot added a comment.
Change 186336 merged by jenkins-bot: Update ui_tests expected values
https://gerrit.wikimedia.org/r/186336
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: gerritbot Cc: gerritbot, jayvdb, valhallasw, XZise, pywikipedia-bugs
jayvdb closed this task as "Resolved". jayvdb claimed this task. jayvdb added a comment.
@xzise fixed the remaining tests, and more.
TASK DETAIL https://phabricator.wikimedia.org/T76248
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: jayvdb Cc: gerritbot, jayvdb, valhallasw, XZise, pywikipedia-bugs
pywikipedia-bugs@lists.wikimedia.org