33import numpy as np
44import pytest
55from PyQt6 .QtCore import Qt , QTimer
6- from PyQt6 .QtWidgets import QMessageBox , QTableWidget
6+ from PyQt6 .QtWidgets import (
7+ QDialog ,
8+ QDialogButtonBox ,
9+ QLabel ,
10+ QTableWidget ,
11+ QTextEdit ,
12+ )
713from pytestqt .qtbot import QtBot
814
915from ert .analysis .event import DataSection
@@ -85,12 +91,20 @@ def verify_disabled_observations_dialog_shows_on_click(
8591 qtbot , report_table , nan_message , row , column
8692):
8793 def handle_disabled_observations_blocking_dialog (qtbot , report_table , nan_message ):
88- message_box = report_table .findChild (QMessageBox )
94+ dialog = report_table .findChild (QDialog )
95+ assert dialog is not None
8996 try :
90- assert message_box .text () == nan_message
97+ label = dialog .findChild (QLabel )
98+ assert label is not None
99+ assert label .text () == "Missing responses from active realizations:"
100+
101+ text_edit = dialog .findChild (QTextEdit )
102+ assert text_edit is not None
103+ assert text_edit .toPlainText () == nan_message
91104 finally :
105+ button_box = dialog .findChild (QDialogButtonBox )
92106 qtbot .mouseClick (
93- message_box .button (QMessageBox .StandardButton .Ok ),
107+ button_box .button (QDialogButtonBox .StandardButton .Ok ),
94108 Qt .MouseButton .LeftButton ,
95109 )
96110
@@ -118,7 +132,7 @@ def test_that_report_log_table_only_shows_message_on_nan_status_click(qtbot: QtB
118132 ]
119133
120134 nan_rows = [1 ]
121- nan_message = "Missing responses from active realizations: \n \n 1 , 3"
135+ nan_message = "1 , 3"
122136
123137 report_table = ReportLogTable (DataSection (header = headers , data = observations ))
124138 qtbot .addWidget (report_table )
@@ -132,16 +146,22 @@ def verify_that_status_column_click_shows_dialog_for_missing_observations_only(
132146 )
133147 else :
134148 click_on_table_cell (qtbot , report_table , row , column )
135- assert report_table .findChild (QMessageBox ) is None
149+ dialog = report_table .findChild (QDialog )
150+ assert dialog is None or not dialog .isVisible ()
136151
137152 def verify_that_data_column_click_does_not_produce_dialog (row , column ):
138153 click_on_table_cell (qtbot , report_table , row , column )
139- assert report_table .findChild (QMessageBox ) is None
154+ dialog = report_table .findChild (QDialog )
155+ assert dialog is None or not dialog .isVisible ()
140156
141- assert report_table .horizontalHeader ().isSectionHidden (hidden_column )
157+ header = report_table .horizontalHeader ()
158+ assert header is not None
159+ assert header .isSectionHidden (hidden_column )
142160
143161 for row in range (len (observations )):
144- assert report_table .item (row , status_column ).text () == observations [row ][0 ]
162+ item = report_table .item (row , status_column )
163+ assert item is not None
164+ assert item .text () == observations [row ][0 ]
145165
146166 verify_that_status_column_click_shows_dialog_for_missing_observations_only (
147167 row , status_column
@@ -164,8 +184,8 @@ def test_that_report_log_table_matches_data_on_sort(qtbot: QtBot):
164184 row100 = 0
165185 row200 = 1
166186
167- nan_message100 = "Missing responses from active realizations: \n \n 10 "
168- nan_message200 = "Missing responses from active realizations: \n \n 11 "
187+ nan_message100 = "10 "
188+ nan_message200 = "11 "
169189
170190 verify_disabled_observations_dialog_shows_on_click (
171191 qtbot , report_table , nan_message100 , row100 , status_column
0 commit comments