File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1364,3 +1364,37 @@ def test_timeout_not_raising(self, qtbot):
1364
1364
assert not callback .called
1365
1365
assert callback .args is None
1366
1366
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 )
You can’t perform that action at this time.
0 commit comments