forked from benevolentprof/inf1340_2014_asst1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_exercise3.py
54 lines (39 loc) · 1.57 KB
/
test_exercise3.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
#!/usr/bin/env python3
""" Module to test exercise3.py """
__author__ = 'Susan Sim, Jessica Mann and Juntian Wang'
__copyright__ = "2014 Susan Sim, Jessica Mann and Juntian Wang"
__license__ = "MIT License"
__status__ = "Final version"
# imports one per line
import pytest
from exercise3 import decide_rps
def test_checksum():
"""
Inputs that are valid
"""
assert decide_rps("Rock", "Paper") == 2
assert decide_rps("Scissors", "Scissors") == 0
assert decide_rps("Rock", "Scissors") == 1
assert decide_rps("Scissors", "Paper") == 1
assert decide_rps("Scissors", "Rock") == 2
assert decide_rps("Paper", "Scissors") == 2
assert decide_rps("Paper", "Paper") == 0
assert decide_rps("Paper", "Rock") == 1
assert decide_rps("Rock", "Rock") == 0
def test_invalid_input():
"""
Inputs that are invalid
"""
with pytest.raises(ValueError):
assert decide_rps("Spock", "Lizard")
with pytest.raises(ValueError):
assert decide_rps("Spock", "Scissors")
with pytest.raises(ValueError):
assert decide_rps("Rock", "Lizard")
with pytest.raises(ValueError):
assert decide_rps(1, 5) # testing integers
with pytest.raises(ValueError):
assert decide_rps(5.0, 3.141) # testing floats
with pytest.raises(ValueError):
assert decide_rps(False, "Different data type") # testing differing data types