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

Revision 10385:0abf613c460f, 814 bytes 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
5import Orange
6from Orange.misc import testing
7from Orange.misc.testing import datasets_driven, test_on_data
8from Orange.classification import knn
9from Orange.distance import Euclidean
10
11
12@testing.datasets_driven(datasets=testing.CLASSIFICATION_DATASETS + \
13                         testing.REGRESSION_DATASETS)
14class TestKNNLearner(testing.LearnerTestCase):
15    def setUp(self):
16        self.learner = knn.kNNLearner(distance_constructor=Euclidean())
17
18    @testing.test_on_data
19    def test_learner_on(self, dataset):
20        testing.LearnerTestCase.test_learner_on(self, dataset)
21        instance = dataset.random_instance()
22        self.assertEqual(len(self.classifier.find_nearest(3, instance)), 3)
23
24if __name__ == "__main__":
25    unittest.main()
Note: See TracBrowser for help on using the repository browser.