-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_game.py
More file actions
41 lines (35 loc) · 1.27 KB
/
test_game.py
File metadata and controls
41 lines (35 loc) · 1.27 KB
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
import pytest
from game import game
# False is when choice1 looses or input is invalid
# True is when choice1 wins
# NOTE : All the input need to be in upper case for a vlaid o/p
@pytest.mark.parametrize("choice1, choice2, start, expected", [
("YES","ROCK", "ROCK", "Tie!"),
("YES","ROCK", "PAPER", False),
("YES","ROCK", "SCISSORS", True),
("YES","PAPER", "SCISSORS", False),
("YES","PAPER", "ROCK", True),
("YES","PAPER", "PAPER", "Tie!"),
("YES","SCISSORS", "ROCK", False),
("YES","SCISSORS", "PAPER", True),
("YES","SCISSORS", "SCISSORS", "Tie!"),
("NO","SCISSORS", "xyz", False),
("YES","SCISSORS", "A", False),
("NO", "SCISSORS", "ROCK", False),
("qw", "SCISSORS", "SCISSORS", False),
("", "","", False),
("YES","scissor", "SCISSORS", "False"),
])
def test_game(start, choice1, choice2, expected):
if start == "YES":
if choice1 and choice1 not in ("ROCK", "PAPER", "SCISSORS"):
print("Invalid choice")
return False
else:
print(choice1, choice2)
dec = game(choice1, choice2, start)
assert dec == expected
return True
elif start == "NO":
dec = game(choice1, choice2, start)
assert dec == expected