forked from benevolentprof/inf1340_2014_asst1
/
test_exercise2.py
59 lines (46 loc) · 1.41 KB
/
test_exercise2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
""" Module to test exercise2.py """
__author__ = 'Curtis McCord and Ryan Prance '
__email__ = "curtis.mccord@utoronto.ca; ryan.prance@mail.utoronto.ca"
__copyright__ = "2014 Susan Sim"
__license__ = "INF1340"
__status__ = "Tested Prototype"
# imports one per line
# imports one per line
import pytest
import exercise2
from exercise2 import checksum
def test_checksum():
"""
Inputs that are the correct format and length
"""
assert checksum("786936224306") is True
assert checksum("085392132225") is True
assert checksum("717951000841") is False
assert checksum("065743240502") is True
assert checksum("811138000202") is True
assert checksum("888888888888") is False
assert checksum("134087934837") is False
# other tests
def test_input():
"""
Inputs that are the incorrect format or length
"""
with pytest.raises(TypeError):
checksum(1.0)
with pytest.raises(TypeError):
checksum(786936224306)
with pytest.raises(TypeError):
checksum([1,2])
with pytest.raises(TypeError):
checksum(True)
with pytest.raises(ValueError):
checksum("1")
with pytest.raises(ValueError):
checksum("1234567890")
with pytest.raises(ValueError):
checksum("noteven")
with pytest.raises(ValueError):
checksum("thisonehastobetoolong")
# other tests
# add functions for any other tests