Mercurial > hg > numerics
diff tests/test_conformity.py @ 186:c2f545f32025
move conformity ensurance to separate function
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 21 Jul 2017 12:46:55 -0700 |
parents | |
children | 100697f7c195 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_conformity.py Fri Jul 21 12:46:55 2017 -0700 @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +""" +test conformity +""" + +import unittest +from numerics import conformity + +class TestConformity(unittest.TestCase): + """tests for ensuring data conformity""" + + def test_equal_lengths(self): + + data = [[1,2,3], + [4,5,6] + [7,8,9]] + + assert conformity.ensure_row_length(data) == 3 + + def test_nonequal_lengths(self): + data = [[1,2,3], + [4,5,6] + [7,8,9, 10] # oops! + ] + + e = None + try: + conformity.ensure_row_length(data) + except conformity.NonformantRowLengths as e: + pass + assert e is not None + assert isinstance(e, NonConformantRowLengths) + +if __name__ == '__main__': + unittest.main()