Mercurial > hg > numerics
comparison tests/test_conformity.py @ 188:100697f7c195
fix errors in testing and make exception a better marker
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 21 Jul 2017 12:58:40 -0700 |
parents | c2f545f32025 |
children |
comparison
equal
deleted
inserted
replaced
187:8aec5ebb2d19 | 188:100697f7c195 |
---|---|
11 """tests for ensuring data conformity""" | 11 """tests for ensuring data conformity""" |
12 | 12 |
13 def test_equal_lengths(self): | 13 def test_equal_lengths(self): |
14 | 14 |
15 data = [[1,2,3], | 15 data = [[1,2,3], |
16 [4,5,6] | 16 [4,5,6], |
17 [7,8,9]] | 17 [7,8,9]] |
18 | 18 |
19 assert conformity.ensure_row_length(data) == 3 | 19 assert conformity.ensure_row_length(data) == 3 |
20 | 20 |
21 def test_nonequal_lengths(self): | 21 def test_nonequal_lengths(self): |
22 data = [[1,2,3], | 22 data = [[1,2,3], |
23 [4,5,6] | 23 [4,5,6], |
24 [7,8,9, 10] # oops! | 24 [7,8,9, 10] # oops! |
25 ] | 25 ] |
26 | 26 |
27 e = None | 27 e = None |
28 try: | 28 try: |
29 conformity.ensure_row_length(data) | 29 conformity.ensure_row_length(data) |
30 except conformity.NonformantRowLengths as e: | 30 except conformity.NonConformantRowLengths as e: |
31 pass | 31 pass |
32 assert e is not None | 32 assert e is not None |
33 assert isinstance(e, NonConformantRowLengths) | 33 assert isinstance(e, conformity.NonConformantRowLengths) |
34 | 34 |
35 if __name__ == '__main__': | 35 if __name__ == '__main__': |
36 unittest.main() | 36 unittest.main() |