Description
I recently updated to pytest 2.8 and noticed I got output which should be captured on stdout.
This is during tests which launch a subprocess via QProcess
which then does logging on stderr, which is printed during the tests (see testprocess.py / quteprocess.py).
I was able to reproduce this with this example:
import pytest
from PyQt5.QtCore import QTimer
@pytest.yield_fixture(scope='module')
def timer():
t = QTimer()
t.setInterval(10)
t.timeout.connect(lambda: print("foo"))
t.start()
yield t
t.stop()
@pytest.mark.parametrize('x', range(1000))
def test_foo(qtbot, timer, x):
qtbot.waitSignal(timer.timeout)
When running it with pytest 2.7.3:
============================================= test session starts ==============================================
platform linux -- Python 3.5.0 -- py-1.4.31 -- pytest-2.7.3
PyQt5 5.5.1 -- Qt runtime 5.5.1 -- Qt compiled 5.5.1
rootdir: /home/florian/proj/pytest, inifile: tox.ini
plugins: qt
collected 1000 items
testcap2.py ...[…]...
========================================= 1000 passed in 1.16 seconds ==========================================
with 2.8.2:
============================================= test session starts ==============================================
platform linux -- Python 3.5.0, pytest-2.8.2, py-1.4.31, pluggy-0.3.1
PyQt5 5.5.1 -- Qt runtime 5.5.1 -- Qt compiled 5.5.1
rootdir: /home/florian/proj/pytest, inifile: tox.ini
plugins: qt-1.9.0
collected 1000 items
testcap2.py .........foo
.........foo
.........foo
..........foo
...................foo
[…]
========================================= 1000 passed in 1.17 seconds ==========================================
I bisected this to pytest-dev/pytest@c54afbe ("deprecate and warn about __multicall__
usage in hooks, refine docs about hook ordering, make hookwrappers respect tryfirst/trylast").
I also tried reproducing it without pytest-qt but it only seems to happen with pytest-qt.
I'm guessing the event processing happens after pytest already has lifted the capturing, and that commit changed something about the order things are done?