@@ -1367,17 +1367,17 @@ def test_timeout_not_raising(self, qtbot):
13671367
13681368
13691369@pytest .mark .parametrize (
1370- "check_stderr , count" ,
1370+ "check_warnings , count" ,
13711371 [
1372- # Checking stderr messages
1372+ # Checking for warnings
13731373 pytest .param (
1374- True , # check stderr
1374+ True , # check warnings
13751375 200 , # gets output reliably even with only few runs (often the first)
13761376 id = "stderr" ,
13771377 ),
13781378 # Triggering AttributeError
13791379 pytest .param (
1380- False , # don't check stderr
1380+ False , # don't check warnings
13811381 # Hopefully enough to trigger the AttributeError race condition reliably.
13821382 # With 500 runs, only 1 of 5 Windows PySide6 CI jobs triggered it (but all
13831383 # Ubuntu/macOS jobs did). With 1500 runs, Windows jobs still only triggered
@@ -1392,7 +1392,11 @@ def test_timeout_not_raising(self, qtbot):
13921392)
13931393@pytest .mark .parametrize ("multi_blocker" , [True , False ])
13941394def test_signal_raised_from_thread (
1395- pytester : pytest .Pytester , check_stderr : bool , multi_blocker : bool , count : int
1395+ monkeypatch : pytest .MonkeyPatch ,
1396+ pytester : pytest .Pytester ,
1397+ check_warnings : bool ,
1398+ multi_blocker : bool ,
1399+ count : int ,
13961400) -> None :
13971401 """Wait for a signal with a thread.
13981402
@@ -1409,7 +1413,7 @@ class Worker(qt_api.QtCore.QObject):
14091413
14101414
14111415 @pytest.mark.parametrize("_", range({ count } ))
1412- def test_thread(qtbot, capfd, _):
1416+ def test_thread(qtbot, _):
14131417 worker = Worker()
14141418 thread = qt_api.QtCore.QThread()
14151419 worker.moveToThread(thread)
@@ -1425,25 +1429,23 @@ def test_thread(qtbot, capfd, _):
14251429 finally:
14261430 thread.quit()
14271431 thread.wait()
1428-
1429- if { check_stderr } : # check_stderr
1430- out, err = capfd.readouterr()
1431- assert not err
14321432 """
14331433 )
1434-
1434+ if check_warnings :
1435+ monkeypatch .setenv ("QT_FATAL_WARNINGS" , "1" )
14351436 res = pytester .runpytest_subprocess ("-x" , "-s" )
1436- outcomes = res .parseoutcomes ()
14371437
1438- if outcomes .get ("failed" , 0 ) and check_stderr and qt_api .pytest_qt_api == "pyside6" :
1439- # The test succeeds on PyQt (unsure why!), but we can't check
1440- # qt_api.pytest_qt_api at import time, so we can't use
1441- # pytest.mark.xfail conditionally.
1442- pytest .xfail (
1443- "Qt error: QObject::killTimer: "
1444- "Timers cannot be stopped from another thread"
1445- )
1438+ qtimer_message = "QObject::killTimer: Timers cannot be stopped from another thread"
1439+ if (
1440+ qtimer_message in res .stderr .str ()
1441+ and multi_blocker
1442+ and check_warnings
1443+ and qt_api .pytest_qt_api == "pyside6"
1444+ ):
1445+ # We haven't fixed MultiSignalBlocker yet...
1446+ pytest .xfail (f"Qt error: { qtimer_message } " )
14461447
1448+ outcomes = res .parseoutcomes ()
14471449 res .assert_outcomes (passed = outcomes ["passed" ]) # no failed/error
14481450
14491451
0 commit comments