-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharcade_game_test.py
144 lines (117 loc) · 6.42 KB
/
arcade_game_test.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import unittest
import pytest
from arcade_game import eat_ghost, score, lose, win
class GhostGobbleGameTest(unittest.TestCase):
@pytest.mark.task(taskno=1)
def test_ghost_gets_eaten(self):
actual_result = eat_ghost(True, True)
error_message = ('Called eat_ghost(True, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the ghost gets eaten (True).')
self.assertIs(actual_result, True, msg=error_message)
@pytest.mark.task(taskno=1)
def test_ghost_does_not_get_eaten_because_no_power_pellet_active(self):
actual_result = eat_ghost(False, True)
error_message = ('Called eat_ghost(False, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'ghost **does not** get eaten because '
'no power pellet was active.')
self.assertIs(actual_result, False, msg=error_message)
@pytest.mark.task(taskno=1)
def test_ghost_does_not_get_eaten_because_not_touching_ghost(self):
actual_result = eat_ghost(True, False)
error_message = ('Called eat_ghost(True, False).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'ghost **does not** get eaten because '
'the player was not touching the ghost.')
self.assertIs(actual_result, False, msg=error_message)
@pytest.mark.task(taskno=2)
def test_score_when_eating_dot(self):
actual_result = score(False, True)
error_message = ('Called score(False, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player scores because they were touching a dot.')
self.assertIs(actual_result, True, msg=error_message)
@pytest.mark.task(taskno=2)
def test_score_when_eating_power_pellet(self):
actual_result = score(True, False)
error_message = ('Called score(True, False).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player scores because they '
'were touching a power pellet.')
self.assertIs(actual_result,True,msg=error_message)
@pytest.mark.task(taskno=2)
def test_no_score_when_nothing_eaten(self):
actual_result = score(False, False)
error_message = ('Called score(False, False).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player **does not** score because they '
'were not touching anything.')
self.assertIs(actual_result, False,msg=error_message)
@pytest.mark.task(taskno=3)
def test_lose_if_touching_a_ghost_without_a_power_pellet_active(self):
actual_result = lose(False, True)
error_message = ('Called lose(False, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player loses because they touched a '
'ghost without a power pellet activated.')
self.assertIs(
actual_result, True, msg=error_message)
@pytest.mark.task(taskno=3)
def test_dont_lose_if_touching_a_ghost_with_a_power_pellet_active(self):
actual_result = lose(True, True)
error_message = ('Called lose(True, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player **does not** lose because when they touched a '
'ghost, a power pellet was active.')
self.assertIs(actual_result, False, msg=error_message)
@pytest.mark.task(taskno=3)
def test_dont_lose_if_not_touching_a_ghost(self):
actual_result = lose(True, False)
error_message = ('Called lose(True, False).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player **does not** lose because they were '
'not touching a ghost.')
self.assertIs(actual_result, False, msg=error_message)
@pytest.mark.task(taskno=4)
def test_win_if_all_dots_eaten(self):
actual_result = win(True, False, False)
error_message = ('Called win(True, False, False).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player wins because all the dots were eaten.')
self.assertIs(actual_result, True, msg=error_message)
@pytest.mark.task(taskno=4)
def test_dont_win_if_all_dots_eaten_but_touching_a_ghost(self):
actual_result = win(True, False, True)
error_message = ('Called win(True, False, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the '
'player **does not** win, because '
'the player was touching a ghost.')
self.assertIs(actual_result, False, msg=error_message)
@pytest.mark.task(taskno=4)
def test_win_if_all_dots_eaten_and_touching_a_ghost_with_a_power_pellet_active(self):
actual_result = win(True, True, True)
error_message = ('Called win(True, True, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the player wins, '
f'because a power pellet was active when they '
f'touched a ghost.')
self.assertIs(actual_result, True, msg=error_message)
@pytest.mark.task(taskno=4)
def test_dont_win_if_not_all_dots_eaten(self):
actual_result = win(False, True, True)
error_message = ('Called win(False, True, True).'
f'The function returned {actual_result}, but the '
f'tests expected that the player **does not** win, '
f'because the player did not eat all of the dots.')
self.assertIs(actual_result, False, msg=error_message)