@@ -1367,17 +1367,17 @@ def test_timeout_not_raising(self, qtbot):
1367
1367
1368
1368
1369
1369
@pytest .mark .parametrize (
1370
- "check_stderr , count" ,
1370
+ "check_warnings , count" ,
1371
1371
[
1372
- # Checking stderr messages
1372
+ # Checking for warnings
1373
1373
pytest .param (
1374
- True , # check stderr
1374
+ True , # check warnings
1375
1375
200 , # gets output reliably even with only few runs (often the first)
1376
1376
id = "stderr" ,
1377
1377
),
1378
1378
# Triggering AttributeError
1379
1379
pytest .param (
1380
- False , # don't check stderr
1380
+ False , # don't check warnings
1381
1381
# Hopefully enough to trigger the AttributeError race condition reliably.
1382
1382
# With 500 runs, only 1 of 5 Windows PySide6 CI jobs triggered it (but all
1383
1383
# Ubuntu/macOS jobs did). With 1500 runs, Windows jobs still only triggered
@@ -1392,7 +1392,11 @@ def test_timeout_not_raising(self, qtbot):
1392
1392
)
1393
1393
@pytest .mark .parametrize ("multi_blocker" , [True , False ])
1394
1394
def 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 ,
1396
1400
) -> None :
1397
1401
"""Wait for a signal with a thread.
1398
1402
@@ -1409,7 +1413,7 @@ class Worker(qt_api.QtCore.QObject):
1409
1413
1410
1414
1411
1415
@pytest.mark.parametrize("_", range({ count } ))
1412
- def test_thread(qtbot, capfd, _):
1416
+ def test_thread(qtbot, _):
1413
1417
worker = Worker()
1414
1418
thread = qt_api.QtCore.QThread()
1415
1419
worker.moveToThread(thread)
@@ -1425,25 +1429,23 @@ def test_thread(qtbot, capfd, _):
1425
1429
finally:
1426
1430
thread.quit()
1427
1431
thread.wait()
1428
-
1429
- if { check_stderr } : # check_stderr
1430
- out, err = capfd.readouterr()
1431
- assert not err
1432
1432
"""
1433
1433
)
1434
-
1434
+ if check_warnings :
1435
+ monkeypatch .setenv ("QT_FATAL_WARNINGS" , "1" )
1435
1436
res = pytester .runpytest_subprocess ("-x" , "-s" )
1436
- outcomes = res .parseoutcomes ()
1437
1437
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 } " )
1446
1447
1448
+ outcomes = res .parseoutcomes ()
1447
1449
res .assert_outcomes (passed = outcomes ["passed" ]) # no failed/error
1448
1450
1449
1451
0 commit comments