def test_get_confirmation(sentry_reporter: SentryReporter): # test that `get_confirmation` calls `QApplication` and `QMessageBox` from `PyQt5.QtWidgets` mocked_QApplication = Mock() mocked_QMessageBox = MagicMock() with patch_import('PyQt5.QtWidgets', strict=True, QApplication=mocked_QApplication, QMessageBox=mocked_QMessageBox): sentry_reporter.get_confirmation(Exception('test')) mocked_QApplication.assert_called() mocked_QMessageBox.assert_called()
def test_get_confirmation_no_qt(sentry_reporter: SentryReporter): assert not sentry_reporter.get_confirmation(Exception('test'))