Instead of using pytest.raises(ValueError)
, use pytestqt
to intercept exceptions in Qt's event loop when testing:
with qtbot.capture_exceptions() as exceptions:
qtbot.mouseClick(
button, QtCore.MouseButton.LeftButton
)
See the documentation here.