77from AnyQt .QtCore import QRectF , Qt
88from AnyQt .QtWidgets import QToolTip
99from AnyQt .QtGui import QColor , QFont
10+ from orangewidget .tests .base import DEFAULT_TIMEOUT
1011
1112from Orange .data import (
1213 Table , Domain , ContinuousVariable , DiscreteVariable , TimeVariable
@@ -139,17 +140,17 @@ def test_data_column_infs(self):
139140 attr_x = self .widget .controls .attr_x
140141 simulate .combobox_activate_item (attr_x , "b" )
141142
142- def test_regression_line (self ):
143+ def test_regression_line_pair (self ):
143144 """It is possible to draw the line only for pair of continuous attrs"""
144145 self .send_signal (self .widget .Inputs .data , self .data )
145146 self .assertTrue (self .widget .cb_reg_line .isEnabled ())
146- self .assertIsNone ( self .widget .graph .reg_line_item )
147+ self .assertListEqual ([], self .widget .graph .reg_line_items )
147148 self .widget .cb_reg_line .setChecked (True )
148- self .assertIsNotNone ( self .widget .graph .reg_line_item )
149+ self .assertEqual ( 4 , len ( self .widget .graph .reg_line_items ) )
149150 self .widget .cb_attr_y .activated .emit (4 )
150151 self .widget .cb_attr_y .setCurrentIndex (4 )
151152 self .assertFalse (self .widget .cb_reg_line .isEnabled ())
152- self .assertIsNone ( self .widget .graph .reg_line_item )
153+ self .assertListEqual ([], self .widget .graph .reg_line_items )
153154
154155 def test_points_combo_boxes (self ):
155156 """Check Point box combo models and values"""
@@ -277,7 +278,7 @@ def test_points_selection(self):
277278 self .assertIsNone (selected_data )
278279
279280 def test_migrate_selection (self ):
280- settings = dict ( selection = list (range (2 )))
281+ settings = { " selection" : list (range (2 ))}
281282 OWScatterPlot .migrate_settings (settings , 0 )
282283 self .assertEqual (settings ["selection_group" ], [(0 , 1 ), (1 , 1 )])
283284
@@ -371,7 +372,7 @@ def test_vizrank(self):
371372 vizrank = ScatterPlotVizRank (self .widget )
372373 n_states = len (data .domain .attributes )
373374 n_states = n_states * (n_states - 1 ) / 2
374- states = [ state for state in vizrank .iterate_states (None )]
375+ states = list ( vizrank .iterate_states (None ))
375376 self .assertEqual (len (states ), n_states )
376377 self .assertEqual (len (set (states )), n_states )
377378 self .assertIsNotNone (vizrank .compute_score (states [0 ]))
@@ -381,8 +382,7 @@ def test_vizrank(self):
381382 data = Table ("housing" )[::10 ]
382383 self .send_signal (self .widget .Inputs .data , data )
383384 vizrank = ScatterPlotVizRank (self .widget )
384- states = [state for state in vizrank .iterate_states (None )]
385- self .assertIsNotNone (vizrank .compute_score (states [0 ]))
385+ self .assertIsNotNone (vizrank .compute_score (next (vizrank .iterate_states (None ))))
386386
387387 def test_vizrank_class_nan (self ):
388388 """
@@ -505,7 +505,7 @@ def test_auto_send_selection(self):
505505
506506 def test_color_is_optional (self ):
507507 zoo = Table ("zoo" )
508- backbone , breathes , airborne , type = \
508+ backbone , breathes , airborne , type_ = \
509509 [zoo .domain [x ] for x in ["backbone" , "breathes" , "airborne" , "type" ]]
510510 default_x , default_y , default_color = \
511511 zoo .domain [0 ], zoo .domain [1 ], zoo .domain .class_var
@@ -524,23 +524,23 @@ def test_color_is_optional(self):
524524 simulate .combobox_activate_item (attr_color , airborne .name )
525525
526526 # Send compatible dataset, values should not change
527- zoo2 = zoo [:, (backbone , breathes , airborne , type )]
527+ zoo2 = zoo [:, (backbone , breathes , airborne , type_ )]
528528 self .send_signal (self .widget .Inputs .data , zoo2 )
529529 self .assertEqual (attr_x .currentText (), backbone .name )
530530 self .assertEqual (attr_y .currentText (), breathes .name )
531531 self .assertEqual (attr_color .currentText (), airborne .name )
532532
533533 # Send dataset without color variable
534534 # x and y should remain, color reset to default
535- zoo3 = zoo [:, (backbone , breathes , type )]
535+ zoo3 = zoo [:, (backbone , breathes , type_ )]
536536 self .send_signal (self .widget .Inputs .data , zoo3 )
537537 self .assertEqual (attr_x .currentText (), backbone .name )
538538 self .assertEqual (attr_y .currentText (), breathes .name )
539539 self .assertEqual (attr_color .currentText (), default_color .name )
540540
541541 # Send dataset without x
542542 # y and color should be the same as with zoo
543- zoo4 = zoo [:, (default_x , default_y , breathes , airborne , type )]
543+ zoo4 = zoo [:, (default_x , default_y , breathes , airborne , type_ )]
544544 self .send_signal (self .widget .Inputs .data , zoo4 )
545545 self .assertEqual (attr_x .currentText (), default_x .name )
546546 self .assertEqual (attr_y .currentText (), default_y .name )
@@ -549,11 +549,11 @@ def test_color_is_optional(self):
549549 # Send dataset compatible with zoo2 and zoo3
550550 # Color should reset to one in zoo3, as it was used more
551551 # recently
552- zoo5 = zoo [:, (default_x , backbone , breathes , airborne , type )]
552+ zoo5 = zoo [:, (default_x , backbone , breathes , airborne , type_ )]
553553 self .send_signal (self .widget .Inputs .data , zoo5 )
554554 self .assertEqual (attr_x .currentText (), backbone .name )
555555 self .assertEqual (attr_y .currentText (), breathes .name )
556- self .assertEqual (attr_color .currentText (), type .name )
556+ self .assertEqual (attr_color .currentText (), type_ .name )
557557
558558 def test_handle_metas (self ):
559559 """
@@ -646,29 +646,29 @@ def test_tooltip(self):
646646 widget .tooltip_shows_all = False
647647 self .assertTrue (graph .help_event (event ))
648648 (_ , text ), _ = show_text .call_args
649- self .assertIn ("age = {}" . format ( data [42 , " age" ]) , text )
650- self .assertIn ("gender = {}" . format ( data [42 , " gender" ]) , text )
651- self .assertNotIn ("max HR = {}" . format ( data [42 , " max HR" ]) , text )
649+ self .assertIn (f "age = { data [42 , ' age' ] } " , text )
650+ self .assertIn (f "gender = { data [42 , ' gender' ] } " , text )
651+ self .assertNotIn (f "max HR = { data [42 , ' max HR' ] } " , text )
652652 self .assertNotIn ("others" , text )
653653
654654 # Show all attributes
655655 widget .tooltip_shows_all = True
656656 self .assertTrue (graph .help_event (event ))
657657 (_ , text ), _ = show_text .call_args
658- self .assertIn ("age = {}" . format ( data [42 , " age" ]) , text )
659- self .assertIn ("gender = {}" . format ( data [42 , " gender" ]) , text )
660- self .assertIn ("max HR = {}" . format ( data [42 , " max HR" ]) , text )
658+ self .assertIn (f "age = { data [42 , ' age' ] } " , text )
659+ self .assertIn (f "gender = { data [42 , ' gender' ] } " , text )
660+ self .assertIn (f "max HR = { data [42 , ' max HR' ] } " , text )
661661 self .assertIn ("... and 4 others" , text )
662662
663663 # Two points hovered
664664 with patch .object (scatterplot_item , "pointsAt" ,
665665 return_value = [all_points [42 ], all_points [100 ]]):
666666 self .assertTrue (graph .help_event (event ))
667667 (_ , text ), _ = show_text .call_args
668- self .assertIn ("age = {}" . format ( data [42 , " age" ]) , text )
669- self .assertIn ("gender = {}" . format ( data [42 , " gender" ]) , text )
670- self .assertIn ("age = {}" . format ( data [100 , " age" ]) , text )
671- self .assertIn ("gender = {}" . format ( data [100 , " gender" ]) , text )
668+ self .assertIn (f "age = { data [42 , ' age' ] } " , text )
669+ self .assertIn (f "gender = { data [42 , ' gender' ] } " , text )
670+ self .assertIn (f "age = { data [100 , ' age' ] } " , text )
671+ self .assertIn (f "gender = { data [100 , ' gender' ] } " , text )
672672
673673 # No points hovered
674674 with patch .object (scatterplot_item , "pointsAt" ,
@@ -694,10 +694,10 @@ def prepare_data():
694694 data .Y = np .array (values * 10 , dtype = float )
695695 return data
696696
697- def assert_equal (data , max ):
697+ def assert_equal (data , max_ ):
698698 self .send_signal (self .widget .Inputs .data , data )
699- pen_data , brush_data = self .widget .graph .get_colors ()
700- self .assertEqual (max , len (np .unique ([id (p ) for p in pen_data ])), )
699+ pen_data , _ = self .widget .graph .get_colors ()
700+ self .assertEqual (max_ , len (np .unique ([id (p ) for p in pen_data ])), )
701701
702702 assert_equal (prepare_data (), MAX_COLORS )
703703 # data with nan value
@@ -1156,7 +1156,7 @@ def test_clear_plot(self):
11561156 with excepthook_catch ():
11571157 self .send_signal (self .widget .Inputs .data , self .data )
11581158
1159- def test_visual_settings (self ):
1159+ def test_visual_settings (self , timeout = DEFAULT_TIMEOUT ):
11601160 super ().test_visual_settings ()
11611161
11621162 graph = self .widget .graph
0 commit comments