Skip to content

Commit 0d23d91

Browse files
committed
Add tests
1 parent cdcf294 commit 0d23d91

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Orange/tests/test_value.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import unittest
66
import numpy as np
77

8-
from Orange.data import Table, Domain, DiscreteVariable
8+
from Orange.data import Table, Domain, Value,\
9+
DiscreteVariable, ContinuousVariable, StringVariable, TimeVariable
910

1011

1112
class TestValue(unittest.TestCase):
@@ -50,3 +51,16 @@ def test_compare_string(self):
5051
zoo2 = zoo[1]['name'] # antelope
5152
self.assertTrue(zoo1 < zoo2)
5253
self.assertTrue(zoo1 >= "aardvark")
54+
55+
def test_hash(self):
56+
v = 1234.5
57+
val = Value(ContinuousVariable("var"), v)
58+
self.assertTrue(val == v and hash(val) == hash(v))
59+
v = "test"
60+
val = Value(StringVariable("var"), v)
61+
self.assertTrue(val == v and hash(val) == hash(v))
62+
v = 1234.5
63+
val = Value(TimeVariable("var"), v)
64+
self.assertTrue(val == v and hash(val) == hash(v))
65+
val = Value(DiscreteVariable("var", ["red", "green", "blue"]), 1)
66+
self.assertRaises(Exception, hash, val)

0 commit comments

Comments
 (0)