annotate tests/test_unique.py @ 51:e1eb45c4763e

[compat] fix variable scoping for py3
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Sep 2017 18:08:55 -0700
parents 4b20694b8a16
children 5916b04d0582
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
51
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
3 """
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
4 test uniqueness of set elements
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
5 """
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
6
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import unittest
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 from tvii.unique import unique
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 from tvii.unique import NotUnique
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class TestUnique(unittest.TestCase):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def test_positive(self):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 """ensure the unique functionality works as expected"""
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 # true positive
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 a_unique_value = [7] * 7
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 assert unique(a_unique_value) == 7
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 def test_negative(self):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 """what if a set is not unique?"""
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 data = [1,2,3,4]
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 try:
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 unique(data)
51
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
27 assert 1 == 0
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 except NotUnique as e:
51
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
29 assert (e is not None)
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
30 assert isinstance(e, NotUnique)
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32 if __name__ == '__main__':
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33 unittest.main()