source: orange/Orange/testing/unit/tests/test_selection.py @ 10385:0abf613c460f

Revision 10385:0abf613c460f, 1.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Added missing if name == "main" part to tests.

Line 
1try:
2    import unittest2 as unittest
3except:
4    import unittest
5
6from Orange.misc import selection
7
8
9class TestBestOnTheFly(unittest.TestCase):
10    def test_compare_on_1st(self):
11        best = selection.BestOnTheFly(call_compare_on_1st=True)
12        test = [1, 2, 0, 5, 4, 5, 4]
13        # Test on integers
14        for t in test:
15            best.candidate((t, str(t)))
16
17        winner = best.winner()
18        self.assertTrue(winner == (5, "5"))
19        self.assertIsInstance(winner, tuple)
20
21        index = best.winner_index()
22        self.assertIsInstance(index, int)
23
24
25    def test_compare_first_bigger(self):
26        best = selection.BestOnTheFly(selection.compare_first_bigger)
27        test = [1, 2, 0, 5, 4, 5, 4]
28        # Test on integers
29        for t in test:
30            best.candidate((t, str(t)))
31
32        winner = best.winner()
33        self.assertTrue(winner == (5, "5"))
34        self.assertIsInstance(winner, tuple)
35
36        index = best.winner_index()
37        self.assertIsInstance(index, int)
38
39
40if __name__ == "__main__":
41    unittest.main()
Note: See TracBrowser for help on using the repository browser.