11# Test methods with long descriptive names can omit docstrings
22# pylint: disable=missing-docstring, protected-access, unsubscriptable-object
3- import time
43import unittest
54from unittest .mock import patch , Mock
65
@@ -37,7 +36,7 @@ def setUp(self):
3736 def test_input_data_cont (self ):
3837 """Check correlation table for dataset with continuous attributes"""
3938 self .send_signal (self .widget .Inputs .data , self .data_cont )
40- time . sleep ( 0.1 )
39+ self . wait_until_finished ( )
4140 n_attrs = len (self .data_cont .domain .attributes )
4241 self .process_events ()
4342 self .assertEqual (self .widget .vizrank .rank_model .columnCount (), 3 )
@@ -60,7 +59,7 @@ def test_input_data_mixed(self):
6059 self .send_signal (self .widget .Inputs .data , self .data_mixed )
6160 domain = self .data_mixed .domain
6261 n_attrs = len ([a for a in domain .attributes if a .is_continuous ])
63- time . sleep ( 0.1 )
62+ self . wait_until_finished ( )
6463 self .process_events ()
6564 self .assertEqual (self .widget .vizrank .rank_model .columnCount (), 3 )
6665 self .assertEqual (self .widget .vizrank .rank_model .rowCount (),
@@ -69,7 +68,7 @@ def test_input_data_mixed(self):
6968 def test_input_data_one_feature (self ):
7069 """Check correlation table for dataset with one attribute"""
7170 self .send_signal (self .widget .Inputs .data , self .data_cont [:, [0 , 4 ]])
72- time . sleep ( 0.1 )
71+ self . wait_until_finished ( )
7372 self .process_events ()
7473 self .assertEqual (self .widget .vizrank .rank_model .columnCount (), 0 )
7574 self .assertTrue (self .widget .Warning .not_enough_vars .is_shown ())
@@ -79,7 +78,7 @@ def test_input_data_one_feature(self):
7978 def test_input_data_one_instance (self ):
8079 """Check correlation table for dataset with one instance"""
8180 self .send_signal (self .widget .Inputs .data , self .data_cont [:1 ])
82- time . sleep ( 0.1 )
81+ self . wait_until_finished ( )
8382 self .process_events ()
8483 self .assertEqual (self .widget .vizrank .rank_model .columnCount (), 0 )
8584 self .assertFalse (self .widget .Information .removed_cons_feat .is_shown ())
@@ -97,21 +96,21 @@ def test_input_data_with_constant_features(self):
9796 domain = Domain ([ContinuousVariable ("c1" ), ContinuousVariable ("c2" ),
9897 DiscreteVariable ("d1" )])
9998 self .send_signal (self .widget .Inputs .data , Table (domain , X ))
100- time . sleep ( 0.1 )
99+ self . wait_until_finished ( )
101100 self .process_events ()
102101 self .assertEqual (self .widget .vizrank .rank_model .rowCount (), 1 )
103102 self .assertFalse (self .widget .Information .removed_cons_feat .is_shown ())
104103
105104 domain = Domain ([ContinuousVariable (str (i )) for i in range (3 )])
106105 self .send_signal (self .widget .Inputs .data , Table (domain , X ))
107- time . sleep ( 0.1 )
106+ self . wait_until_finished ( )
108107 self .process_events ()
109108 self .assertEqual (self .widget .vizrank .rank_model .rowCount (), 1 )
110109 self .assertTrue (self .widget .Information .removed_cons_feat .is_shown ())
111110
112111 X = np .ones ((4 , 3 ), dtype = float )
113112 self .send_signal (self .widget .Inputs .data , Table (domain , X ))
114- time . sleep ( 0.1 )
113+ self . wait_until_finished ( )
115114 self .process_events ()
116115 self .assertEqual (self .widget .vizrank .rank_model .columnCount (), 0 )
117116 self .assertTrue (self .widget .Warning .not_enough_vars .is_shown ())
@@ -124,7 +123,7 @@ def test_input_data_cont_target(self):
124123 """Check correlation table for dataset with continuous class variable"""
125124 data = self .housing [:5 , 11 :]
126125 self .send_signal (self .widget .Inputs .data , data )
127- time . sleep ( 0.1 )
126+ self . wait_until_finished ( )
128127 self .process_events ()
129128 self .assertEqual (self .widget .vizrank .rank_model .rowCount (), 2 )
130129 self .assertEqual (self .widget .controls .feature .count (), 4 )
@@ -137,15 +136,15 @@ def test_input_data_cont_target(self):
137136 def test_output_data (self ):
138137 """Check dataset on output"""
139138 self .send_signal (self .widget .Inputs .data , self .data_cont )
140- time . sleep ( 0.1 )
139+ self . wait_until_finished ( )
141140 self .process_events ()
142141 output = self .get_output (self .widget .Outputs .data )
143142 self .assertEqual (self .data_cont , output )
144143
145144 def test_output_features (self ):
146145 """Check features on output"""
147146 self .send_signal (self .widget .Inputs .data , self .data_cont )
148- time . sleep ( 0.1 )
147+ self . wait_until_finished ( )
149148 self .process_events ()
150149 features = self .get_output (self .widget .Outputs .features )
151150 self .assertIsInstance (features , AttributeList )
@@ -154,7 +153,7 @@ def test_output_features(self):
154153 def test_output_correlations (self ):
155154 """Check correlation table on on output"""
156155 self .send_signal (self .widget .Inputs .data , self .data_cont )
157- time . sleep ( 0.1 )
156+ self . wait_until_finished ( )
158157 self .process_events ()
159158 correlations = self .get_output (self .widget .Outputs .correlations )
160159 self .assertIsInstance (correlations , Table )
@@ -170,27 +169,28 @@ def test_input_changed(self):
170169 """Check whether changing input emits commit"""
171170 self .widget .commit = Mock ()
172171 self .send_signal (self .widget .Inputs .data , self .data_cont )
173- time . sleep ( 0.1 )
172+ self . wait_until_finished ( )
174173 self .process_events ()
175174 self .widget .commit .assert_called_once ()
176175
177176 self .widget .commit .reset_mock ()
178177 self .send_signal (self .widget .Inputs .data , self .data_mixed )
179- time . sleep ( 0.1 )
178+ self . wait_until_finished ( )
180179 self .process_events ()
181180 self .widget .commit .assert_called_once ()
182181
183182 def test_saved_selection (self ):
184183 """Select row from settings"""
185184 self .send_signal (self .widget .Inputs .data , self .data_cont )
186- time . sleep ( 0.1 )
185+ self . wait_until_finished ( )
187186 self .process_events ()
188187 attrs = self .widget .cont_data .domain .attributes
189188 self .widget ._vizrank_selection_changed (attrs [3 ], attrs [1 ])
190189 settings = self .widget .settingsHandler .pack_data (self .widget )
191190
192191 w = self .create_widget (OWCorrelations , stored_settings = settings )
193192 self .send_signal (self .widget .Inputs .data , self .data_cont , widget = w )
193+ import time
194194 time .sleep (0.1 )
195195 self .process_events ()
196196 sel_row = w .vizrank .rank_table .selectionModel ().selectedRows ()[0 ].row ()
@@ -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