comparison tests/test_unique.py @ 50:4b20694b8a16

add module + test for uniqueness
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Sep 2017 14:28:36 -0700
parents
children e1eb45c4763e
comparison
equal deleted inserted replaced
49:111997fa04d1 50:4b20694b8a16
1 #!/usr/bin/env python
2
3 import os
4 import unittest
5 from tvii.unique import unique
6 from tvii.unique import NotUnique
7
8 class TestUnique(unittest.TestCase):
9
10 def test_positive(self):
11 """ensure the unique functionality works as expected"""
12
13 # true positive
14 a_unique_value = [7] * 7
15 assert unique(a_unique_value) == 7
16
17 def test_negative(self):
18 """what if a set is not unique?"""
19
20 data = [1,2,3,4]
21 e = None
22 try:
23 unique(data)
24 except NotUnique as e:
25 pass
26 assert e is not None
27 assert isinstance(e, NotUnique)
28
29 if __name__ == '__main__':
30 unittest.main()