Skip to content

Commit 6ba278c

Browse files
committed
Test OWCorrelations: sleep replaced with wait_until_finished
1 parent 213de4a commit 6ba278c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Orange/widgets/data/tests/test_owcorrelations.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def setUp(self):
3737
def test_input_data_cont(self):
3838
"""Check correlation table for dataset with continuous attributes"""
3939
self.send_signal(self.widget.Inputs.data, self.data_cont)
40-
time.sleep(0.1)
40+
self.wait_until_finished()
4141
n_attrs = len(self.data_cont.domain.attributes)
4242
self.process_events()
4343
self.assertEqual(self.widget.vizrank.rank_model.columnCount(), 3)
@@ -60,7 +60,7 @@ def test_input_data_mixed(self):
6060
self.send_signal(self.widget.Inputs.data, self.data_mixed)
6161
domain = self.data_mixed.domain
6262
n_attrs = len([a for a in domain.attributes if a.is_continuous])
63-
time.sleep(0.1)
63+
self.wait_until_finished()
6464
self.process_events()
6565
self.assertEqual(self.widget.vizrank.rank_model.columnCount(), 3)
6666
self.assertEqual(self.widget.vizrank.rank_model.rowCount(),
@@ -69,7 +69,7 @@ def test_input_data_mixed(self):
6969
def test_input_data_one_feature(self):
7070
"""Check correlation table for dataset with one attribute"""
7171
self.send_signal(self.widget.Inputs.data, self.data_cont[:, [0, 4]])
72-
time.sleep(0.1)
72+
self.wait_until_finished()
7373
self.process_events()
7474
self.assertEqual(self.widget.vizrank.rank_model.columnCount(), 0)
7575
self.assertTrue(self.widget.Warning.not_enough_vars.is_shown())
@@ -79,7 +79,7 @@ def test_input_data_one_feature(self):
7979
def test_input_data_one_instance(self):
8080
"""Check correlation table for dataset with one instance"""
8181
self.send_signal(self.widget.Inputs.data, self.data_cont[:1])
82-
time.sleep(0.1)
82+
self.wait_until_finished()
8383
self.process_events()
8484
self.assertEqual(self.widget.vizrank.rank_model.columnCount(), 0)
8585
self.assertFalse(self.widget.Information.removed_cons_feat.is_shown())
@@ -97,21 +97,21 @@ def test_input_data_with_constant_features(self):
9797
domain = Domain([ContinuousVariable("c1"), ContinuousVariable("c2"),
9898
DiscreteVariable("d1")])
9999
self.send_signal(self.widget.Inputs.data, Table(domain, X))
100-
time.sleep(0.1)
100+
self.wait_until_finished()
101101
self.process_events()
102102
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 1)
103103
self.assertFalse(self.widget.Information.removed_cons_feat.is_shown())
104104

105105
domain = Domain([ContinuousVariable(str(i)) for i in range(3)])
106106
self.send_signal(self.widget.Inputs.data, Table(domain, X))
107-
time.sleep(0.1)
107+
self.wait_until_finished()
108108
self.process_events()
109109
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 1)
110110
self.assertTrue(self.widget.Information.removed_cons_feat.is_shown())
111111

112112
X = np.ones((4, 3), dtype=float)
113113
self.send_signal(self.widget.Inputs.data, Table(domain, X))
114-
time.sleep(0.1)
114+
self.wait_until_finished()
115115
self.process_events()
116116
self.assertEqual(self.widget.vizrank.rank_model.columnCount(), 0)
117117
self.assertTrue(self.widget.Warning.not_enough_vars.is_shown())
@@ -124,7 +124,7 @@ def test_input_data_cont_target(self):
124124
"""Check correlation table for dataset with continuous class variable"""
125125
data = self.housing[:5, 11:]
126126
self.send_signal(self.widget.Inputs.data, data)
127-
time.sleep(0.1)
127+
self.wait_until_finished()
128128
self.process_events()
129129
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 2)
130130
self.assertEqual(self.widget.controls.feature.count(), 4)
@@ -137,15 +137,15 @@ def test_input_data_cont_target(self):
137137
def test_output_data(self):
138138
"""Check dataset on output"""
139139
self.send_signal(self.widget.Inputs.data, self.data_cont)
140-
time.sleep(0.1)
140+
self.wait_until_finished()
141141
self.process_events()
142142
output = self.get_output(self.widget.Outputs.data)
143143
self.assertEqual(self.data_cont, output)
144144

145145
def test_output_features(self):
146146
"""Check features on output"""
147147
self.send_signal(self.widget.Inputs.data, self.data_cont)
148-
time.sleep(0.1)
148+
self.wait_until_finished()
149149
self.process_events()
150150
features = self.get_output(self.widget.Outputs.features)
151151
self.assertIsInstance(features, AttributeList)
@@ -154,7 +154,7 @@ def test_output_features(self):
154154
def test_output_correlations(self):
155155
"""Check correlation table on on output"""
156156
self.send_signal(self.widget.Inputs.data, self.data_cont)
157-
time.sleep(0.1)
157+
self.wait_until_finished()
158158
self.process_events()
159159
correlations = self.get_output(self.widget.Outputs.correlations)
160160
self.assertIsInstance(correlations, Table)
@@ -170,28 +170,28 @@ def test_input_changed(self):
170170
"""Check whether changing input emits commit"""
171171
self.widget.commit = Mock()
172172
self.send_signal(self.widget.Inputs.data, self.data_cont)
173-
time.sleep(0.1)
173+
self.wait_until_finished()
174174
self.process_events()
175175
self.widget.commit.assert_called_once()
176176

177177
self.widget.commit.reset_mock()
178178
self.send_signal(self.widget.Inputs.data, self.data_mixed)
179-
time.sleep(0.1)
179+
self.wait_until_finished()
180180
self.process_events()
181181
self.widget.commit.assert_called_once()
182182

183183
def test_saved_selection(self):
184184
"""Select row from settings"""
185185
self.send_signal(self.widget.Inputs.data, self.data_cont)
186-
time.sleep(0.1)
186+
self.wait_until_finished()
187187
self.process_events()
188188
attrs = self.widget.cont_data.domain.attributes
189189
self.widget._vizrank_selection_changed(attrs[3], attrs[1])
190190
settings = self.widget.settingsHandler.pack_data(self.widget)
191191

192192
w = self.create_widget(OWCorrelations, stored_settings=settings)
193193
self.send_signal(self.widget.Inputs.data, self.data_cont, widget=w)
194-
time.sleep(0.1)
194+
self.wait_until_finished()
195195
self.process_events()
196196
sel_row = w.vizrank.rank_table.selectionModel().selectedRows()[0].row()
197197
self.assertEqual(sel_row, 4)
@@ -227,12 +227,12 @@ def test_heuristic_get_states(self):
227227
def test_correlation_type(self):
228228
c_type = self.widget.controls.correlation_type
229229
self.send_signal(self.widget.Inputs.data, self.data_cont)
230-
time.sleep(0.1)
230+
self.wait_until_finished()
231231
self.process_events()
232232
pearson_corr = self.get_output(self.widget.Outputs.correlations)
233233

234234
simulate.combobox_activate_item(c_type, "Spearman correlation")
235-
time.sleep(0.1)
235+
self.wait_until_finished()
236236
self.process_events()
237237
sperman_corr = self.get_output(self.widget.Outputs.correlations)
238238
self.assertFalse((pearson_corr.X == sperman_corr.X).all())
@@ -253,23 +253,23 @@ def test_select_feature(self):
253253
"""Test feature selection"""
254254
feature_combo = self.widget.controls.feature
255255
self.send_signal(self.widget.Inputs.data, self.data_cont)
256-
time.sleep(0.1)
256+
self.wait_until_finished()
257257
self.process_events()
258258
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 6)
259259
self.assertListEqual(["petal length", "petal width"],
260260
[a.name for a in self.get_output(
261261
self.widget.Outputs.features)])
262262

263263
simulate.combobox_activate_index(feature_combo, 1)
264-
time.sleep(0.1)
264+
self.wait_until_finished()
265265
self.process_events()
266266
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 3)
267267
self.assertListEqual(["petal length", "sepal length"],
268268
[a.name for a in self.get_output(
269269
self.widget.Outputs.features)])
270270

271271
simulate.combobox_activate_index(feature_combo, 0)
272-
time.sleep(0.1)
272+
self.wait_until_finished()
273273
self.process_events()
274274
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 6)
275275
self.assertListEqual(["petal length", "sepal length"],
@@ -279,7 +279,7 @@ def test_select_feature(self):
279279
@patch("Orange.widgets.data.owcorrelations.SIZE_LIMIT", 2000)
280280
def test_vizrank_use_heuristic(self):
281281
self.send_signal(self.widget.Inputs.data, self.data_cont)
282-
time.sleep(0.1)
282+
self.wait_until_finished()
283283
self.process_events()
284284
self.assertTrue(self.widget.vizrank.use_heuristic)
285285
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 6)
@@ -290,7 +290,7 @@ def test_select_feature_against_heuristic(self):
290290
feature_combo = self.widget.controls.feature
291291
self.send_signal(self.widget.Inputs.data, self.data_cont)
292292
simulate.combobox_activate_index(feature_combo, 2)
293-
time.sleep(0.1)
293+
self.wait_until_finished()
294294
self.process_events()
295295
self.assertEqual(self.widget.vizrank.rank_model.rowCount(), 3)
296296

0 commit comments

Comments
 (0)