1- from Orange .data import Table
1+ # Test methods with long descriptive names can omit docstrings
2+ # pylint: disable=missing-docstring
3+ from Orange .data import Table , Domain
24from Orange .widgets .tests .base import WidgetTest
35from Orange .widgets .unsupervised .owpca import OWPCA
46
57
6- class TestOWDistanceMatrix (WidgetTest ):
7-
8+ class TestOWPCA (WidgetTest ):
89 def setUp (self ):
910 self .widget = self .create_widget (OWPCA ) # type: OWPCA
1011
@@ -21,3 +22,18 @@ def test_constant_data(self):
2122 self .assertTrue (self .widget .Warning .trivial_components .is_shown ())
2223 self .assertIsNone (self .get_output ("Transformed Data" ))
2324 self .assertIsNone (self .get_output ("Components" ))
25+
26+ def test_empty_data (self ):
27+ """ Check widget for dataset with no rows and for dataset with no attributes """
28+ data = Table ("iris" )
29+ self .send_signal ("Data" , data [:0 ])
30+ self .assertTrue (self .widget .Error .no_instances .is_shown ())
31+
32+ domain = Domain ([], None , data .domain .variables )
33+ new_data = Table .from_table (domain , data )
34+ self .send_signal ("Data" , new_data )
35+ self .assertTrue (self .widget .Error .no_features .is_shown ())
36+ self .assertFalse (self .widget .Error .no_instances .is_shown ())
37+
38+ self .send_signal ("Data" , None )
39+ self .assertFalse (self .widget .Error .no_features .is_shown ())
0 commit comments