annotate tests/test_conformity.py @ 187:8aec5ebb2d19

whitespace
author Jeff Hammel <k0scist@gmail.com>
date Fri, 21 Jul 2017 12:50:17 -0700
parents c2f545f32025
children 100697f7c195
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
186
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 test conformity
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import unittest
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 from numerics import conformity
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 class TestConformity(unittest.TestCase):
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 """tests for ensuring data conformity"""
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 def test_equal_lengths(self):
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 data = [[1,2,3],
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 [4,5,6]
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 [7,8,9]]
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 assert conformity.ensure_row_length(data) == 3
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 def test_nonequal_lengths(self):
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 data = [[1,2,3],
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 [4,5,6]
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 [7,8,9, 10] # oops!
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 ]
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 e = None
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 try:
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29 conformity.ensure_row_length(data)
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 except conformity.NonformantRowLengths as e:
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 pass
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32 assert e is not None
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33 assert isinstance(e, NonConformantRowLengths)
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
34
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
35 if __name__ == '__main__':
c2f545f32025 move conformity ensurance to separate function
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
36 unittest.main()