Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
astaric committed Sep 13, 2017
1 parent 9ed8b9c commit 445dfd1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Orange/tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# pylint: disable=missing-docstring

import unittest
from unittest.mock import Mock

import numpy as np
import sklearn.tree as skl_tree
from sklearn.tree._tree import TREE_LEAF

from Orange.data import Table
from Orange.classification import SklTreeLearner
from Orange.classification import SklTreeLearner, TreeLearner
from Orange.regression import SklTreeRegressionLearner


class TestTreeLearner(unittest.TestCase):
class TestSklTreeLearner(unittest.TestCase):
def test_classification(self):
table = Table('iris')
learn = SklTreeLearner()
Expand All @@ -28,6 +29,16 @@ def test_regression(self):
self.assertTrue(np.all(table.Y.flatten() == pred))


class TestTreeLearner(unittest.TestCase):
def test_uses_preprocessors(self):
iris = Table('iris')
mock_preprocessor = Mock(return_value=iris)

tree = TreeLearner(preprocessors=[mock_preprocessor])
tree(iris)
mock_preprocessor.assert_called_with(iris)


class TestDecisionTreeClassifier(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down

0 comments on commit 445dfd1

Please sign in to comment.