comparison 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
comparison
equal deleted inserted replaced
185:411db53cb9fb 186:c2f545f32025
1 #!/usr/bin/env python
2
3 """
4 test conformity
5 """
6
7 import unittest
8 from numerics import conformity
9
10 class TestConformity(unittest.TestCase):
11 """tests for ensuring data conformity"""
12
13 def test_equal_lengths(self):
14
15 data = [[1,2,3],
16 [4,5,6]
17 [7,8,9]]
18
19 assert conformity.ensure_row_length(data) == 3
20
21 def test_nonequal_lengths(self):
22 data = [[1,2,3],
23 [4,5,6]
24 [7,8,9, 10] # oops!
25 ]
26
27 e = None
28 try:
29 conformity.ensure_row_length(data)
30 except conformity.NonformantRowLengths as e:
31 pass
32 assert e is not None
33 assert isinstance(e, NonConformantRowLengths)
34
35 if __name__ == '__main__':
36 unittest.main()