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