88
99from pyqtgraph import mkPen
1010
11- from Orange .widgets .tests .base import GuiTest
11+ from Orange .widgets .settings import SettingProvider
12+ from Orange .widgets .tests .base import WidgetTest
1213from Orange .widgets .utils .colorpalette import ColorPaletteGenerator , \
1314 ContinuousPaletteGenerator , NAN_GREY
1415from Orange .widgets .visualize .owscatterplotgraph import OWScatterPlotBase , \
@@ -34,14 +35,17 @@ class MockWidget(OWWidget):
3435 combined_legend = Mock (return_value = False )
3536 selection_changed = Mock (return_value = None )
3637
38+ GRAPH_CLASS = OWScatterPlotBase
39+ graph = SettingProvider (OWScatterPlotBase )
40+
3741 def get_palette (self ):
3842 if self .is_continuous_color ():
3943 return ContinuousPaletteGenerator (Qt .white , Qt .black , False )
4044 else :
4145 return ColorPaletteGenerator (12 )
4246
4347
44- class TestOWScatterPlotBase (GuiTest ):
48+ class TestOWScatterPlotBase (WidgetTest ):
4549 def setUp (self ):
4650 self .master = MockWidget ()
4751 self .graph = OWScatterPlotBase (self .master )
@@ -160,6 +164,8 @@ def test_sampling(self):
160164 master .get_label_data = lambda : \
161165 np .array ([str (x ) for x in d ], dtype = object )
162166 graph .reset_graph ()
167+ self .process_events (until = lambda : not (
168+ self .graph .timer is not None and self .graph .timer .isActive ()))
163169
164170 # Check proper sampling
165171 scatterplot_item = graph .scatterplot_item
@@ -187,6 +193,8 @@ def test_sampling(self):
187193
188194 # Check that sample is extended when sample size is changed
189195 graph .set_sample_size (4 )
196+ self .process_events (until = lambda : not (
197+ self .graph .timer is not None and self .graph .timer .isActive ()))
190198 scatterplot_item = graph .scatterplot_item
191199 x , y = scatterplot_item .getData ()
192200 data = scatterplot_item .data
@@ -226,6 +234,8 @@ def test_sampling(self):
226234
227235 # Enable sampling when data is already present and not sampled
228236 graph .set_sample_size (3 )
237+ self .process_events (until = lambda : not (
238+ self .graph .timer is not None and self .graph .timer .isActive ()))
229239 scatterplot_item = graph .scatterplot_item
230240 x , y = scatterplot_item .getData ()
231241 data = scatterplot_item .data
@@ -261,6 +271,8 @@ def test_sampling(self):
261271 np .arange (100 , 105 , dtype = float ))
262272 d = self .xy [0 ] - 100
263273 graph .reset_graph ()
274+ self .process_events (until = lambda : not (
275+ self .graph .timer is not None and self .graph .timer .isActive ()))
264276 scatterplot_item = graph .scatterplot_item
265277 x , y = scatterplot_item .getData ()
266278 self .assertEqual (len (x ), 3 )
@@ -365,6 +377,8 @@ def test_size_with_nans(self):
365377
366378 d [4 ] = np .nan
367379 graph .update_sizes ()
380+ self .process_events (until = lambda : not (
381+ self .graph .timer is not None and self .graph .timer .isActive ()))
368382 sizes2 = scatterplot_item .data ["size" ]
369383
370384 self .assertEqual (sizes [1 ] - sizes [0 ], sizes2 [1 ] - sizes2 [0 ])
0 commit comments