Skip to content

Commit 445dfd1

Browse files
committed
Add test
1 parent 9ed8b9c commit 445dfd1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Orange/tests/test_tree.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
# pylint: disable=missing-docstring
33

44
import unittest
5+
from unittest.mock import Mock
56

67
import numpy as np
78
import sklearn.tree as skl_tree
89
from sklearn.tree._tree import TREE_LEAF
910

1011
from Orange.data import Table
11-
from Orange.classification import SklTreeLearner
12+
from Orange.classification import SklTreeLearner, TreeLearner
1213
from 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+
3142
class TestDecisionTreeClassifier(unittest.TestCase):
3243
@classmethod
3344
def setUpClass(cls):

0 commit comments

Comments
 (0)