diff --git a/tests/src/python/test_qgsrelationeditwidget.py b/tests/src/python/test_qgsrelationeditwidget.py index 492fc4452793..2e5be001c11a 100644 --- a/tests/src/python/test_qgsrelationeditwidget.py +++ b/tests/src/python/test_qgsrelationeditwidget.py @@ -34,7 +34,13 @@ ) from qgis.PyQt.QtCore import QTimer -from qgis.PyQt.QtWidgets import QToolButton, QTableView, QApplication +from qgis.PyQt.QtWidgets import ( + QToolButton, + QMessageBox, + QDialogButtonBox, + QTableView, + QApplication +) from qgis.testing import start_app, unittest start_app() @@ -108,6 +114,16 @@ def test_delete_feature(self): self.widget.featureSelectionManager().select([fid]) btn = self.widget.findChild(QToolButton, 'mDeleteFeatureButton') + + def clickOk(): + # Click the "Delete features" button on the confirmation message + # box + widget = self.widget.findChild(QMessageBox) + buttonBox = widget.findChild(QDialogButtonBox) + deleteButton = next((b for b in buttonBox.buttons() if buttonBox.buttonRole(b) == QDialogButtonBox.AcceptRole)) + deleteButton.click() + + QTimer.singleShot(1, clickOk) btn.click() # This is the important check that the feature is deleted