Skip to content

Commit 4760b13

Browse files
committed
WIP: Run thread signal test on CI
1 parent 9ccd999 commit 4760b13

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/test_wait_signal.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,3 +1364,37 @@ def test_timeout_not_raising(self, qtbot):
13641364
assert not callback.called
13651365
assert callback.args is None
13661366
assert callback.kwargs is None
1367+
1368+
1369+
def test_signal_raised_from_thread(pytester: pytest.Pytester) -> None:
1370+
"""Wait for a signal with a thread.
1371+
1372+
Extracted from https://github.com/pytest-dev/pytest-qt/issues/586
1373+
"""
1374+
count = 500 # hopefully enough to trigger the bug reliably
1375+
pytester.makepyfile(f"""
1376+
import pytest
1377+
from pytestqt.qt_compat import qt_api
1378+
1379+
1380+
class Worker(qt_api.QtCore.QObject):
1381+
signal = qt_api.Signal()
1382+
1383+
1384+
@pytest.mark.parametrize("_", range({count}))
1385+
def test_thread(qtbot, _):
1386+
worker = Worker()
1387+
thread = qt_api.QtCore.QThread()
1388+
worker.moveToThread(thread)
1389+
thread.start()
1390+
1391+
try:
1392+
with qtbot.waitSignal(worker.signal, timeout=500) as blocker:
1393+
worker.signal.emit()
1394+
finally:
1395+
thread.quit()
1396+
thread.wait()
1397+
""")
1398+
1399+
res = pytester.runpytest_subprocess()
1400+
res.assert_outcomes(passed=count)

0 commit comments

Comments
 (0)