source: orange/Orange/testing/unit/tests/test_linregression.py @ 10777:546aa4c30fdc

Revision 10777:546aa4c30fdc, 1.0 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

BUGFIX: Fixed 'to_string' method to work even if model statistics are not available.

Line 
1from Orange.testing import testing
2from Orange.testing.testing import datasets_driven, test_on_data, test_on_datasets
3from Orange.regression import linear
4import Orange
5try:
6    import unittest2 as unittest
7except:
8    import unittest
9
10@datasets_driven(datasets=testing.REGRESSION_DATASETS)
11class TestLinearRegressionLearner(testing.LearnerTestCase):
12
13    def setUp(self):
14        self.learner = linear.LinearRegressionLearner()
15
16    @test_on_data
17    def test_learner_on(self, dataset):
18        testing.LearnerTestCase.test_learner_on(self, dataset)
19        self.assertTrue(isinstance(self.classifier.to_string(), str))
20
21@datasets_driven(datasets=testing.REGRESSION_DATASETS)
22class TestRidgeRegressionLearner(testing.LearnerTestCase):
23
24    def setUp(self):
25        self.learner = linear.LinearRegressionLearner(ridge_lambda=2)
26
27    @test_on_data
28    def test_learner_on(self, dataset):
29        testing.LearnerTestCase.test_learner_on(self, dataset)
30        self.assertTrue(isinstance(self.classifier.to_string(), str))
31
32
33if __name__ == "__main__":
34    unittest.main()
Note: See TracBrowser for help on using the repository browser.