source: orange/Orange/testing/unit/tests/test_knn.py @ 10655:a228b55811a4

Revision 10655:a228b55811a4, 820 bytes checked in by markotoplak, 2 years ago (diff)

Moved testing from utils into testing.

Line 
1try:
2    import unittest2 as unittest
3except:
4    import unittest
5import Orange
6from Orange.testing import testing
7from Orange.testing.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.