def METHOD_NAME(mocker, modal_dialog, key):
    modal_dialog.close = mocker.MagicMock()
    event = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier)
    modal_dialog.keyPressEvent(event)
    modal_dialog.close.assert_not_called()