File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 22# pylint: disable=missing-docstring
33
44import unittest
5+ from unittest .mock import Mock
56
67import numpy as np
78import sklearn .tree as skl_tree
89from sklearn .tree ._tree import TREE_LEAF
910
1011from Orange .data import Table
11- from Orange .classification import SklTreeLearner
12+ from Orange .classification import SklTreeLearner , TreeLearner
1213from Orange .regression import SklTreeRegressionLearner
1314
1415
15- class TestTreeLearner (unittest .TestCase ):
16+ class TestSklTreeLearner (unittest .TestCase ):
1617 def test_classification (self ):
1718 table = Table ('iris' )
1819 learn = SklTreeLearner ()
@@ -28,6 +29,16 @@ def test_regression(self):
2829 self .assertTrue (np .all (table .Y .flatten () == pred ))
2930
3031
32+ class TestTreeLearner (unittest .TestCase ):
33+ def test_uses_preprocessors (self ):
34+ iris = Table ('iris' )
35+ mock_preprocessor = Mock (return_value = iris )
36+
37+ tree = TreeLearner (preprocessors = [mock_preprocessor ])
38+ tree (iris )
39+ mock_preprocessor .assert_called_with (iris )
40+
41+
3142class TestDecisionTreeClassifier (unittest .TestCase ):
3243 @classmethod
3344 def setUpClass (cls ):
You can’t perform that action at this time.
0 commit comments