Mercurial > hg > numerics
annotate tests/test_conformity.py @ 193:dc495f0b5ee8 default tip
[testing] toxify
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 13 Aug 2017 15:52:01 -0700 |
parents | 100697f7c195 |
children |
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], |
188
100697f7c195
fix errors in testing and make exception a better marker
Jeff Hammel <k0scist@gmail.com>
parents:
186
diff
changeset
|
16 [4,5,6], |
186
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], |
188
100697f7c195
fix errors in testing and make exception a better marker
Jeff Hammel <k0scist@gmail.com>
parents:
186
diff
changeset
|
23 [4,5,6], |
186
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) |
188
100697f7c195
fix errors in testing and make exception a better marker
Jeff Hammel <k0scist@gmail.com>
parents:
186
diff
changeset
|
30 except conformity.NonConformantRowLengths as e: |
186
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 |
188
100697f7c195
fix errors in testing and make exception a better marker
Jeff Hammel <k0scist@gmail.com>
parents:
186
diff
changeset
|
33 assert isinstance(e, conformity.NonConformantRowLengths) |
186
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() |