view tests/test_unique.py @ 60:38fe99071b11

[documentation] install editable instructions that work
author Jeff Hammel <k0scist@gmail.com>
date Sat, 02 Dec 2017 10:22:25 -0800
parents e1eb45c4763e
children 5916b04d0582
line wrap: on
line source

#!/usr/bin/env python

"""
test uniqueness of set elements
"""

import os
import unittest
from tvii.unique import unique
from tvii.unique import NotUnique

class TestUnique(unittest.TestCase):

    def test_positive(self):
        """ensure the unique functionality works as expected"""

        # true positive
        a_unique_value = [7] * 7
        assert unique(a_unique_value) == 7

    def test_negative(self):
        """what if a set is not unique?"""

        data = [1,2,3,4]
        try:
            unique(data)
            assert 1 == 0
        except NotUnique as e:
            assert (e is not None)
            assert isinstance(e, NotUnique)

if __name__ == '__main__':
    unittest.main()