@@ -7,104 +7,138 @@ class GhostGobbleGameTest(unittest.TestCase):
77
88 @pytest .mark .task (taskno = 1 )
99 def test_ghost_gets_eaten (self ):
10- self .assertIs (
11- eat_ghost (True , True ),
12- True ,
13- msg = "ghost should get eaten"
14- )
10+ actual_result = eat_ghost (True , True )
11+ error_message = ('Called eat_ghost(True, True).'
12+ f'The function returned { actual_result } , but the '
13+ f'tests expected that the ghost gets eaten (True).' )
14+
15+ self .assertIs (actual_result , True , msg = error_message )
1516
1617 @pytest .mark .task (taskno = 1 )
1718 def test_ghost_does_not_get_eaten_because_no_power_pellet_active (self ):
18- self .assertIs (
19- eat_ghost (False , True ),
20- False ,
21- msg = "ghost does not get eaten because no power pellet active"
22- )
19+ actual_result = eat_ghost (False , True )
20+ error_message = ('Called eat_ghost(False, True).'
21+ f'The function returned { actual_result } , but the '
22+ f'tests expected that the '
23+ 'ghost **does not** get eaten because '
24+ 'no power pellet was active.' )
25+
26+ self .assertIs (actual_result , False , msg = error_message )
2327
2428 @pytest .mark .task (taskno = 1 )
2529 def test_ghost_does_not_get_eaten_because_not_touching_ghost (self ):
26- self .assertIs (
27- eat_ghost (True , False ),
28- False ,
29- msg = "ghost does not get eaten because not touching ghost"
30- )
30+ actual_result = eat_ghost (True , False )
31+ error_message = ('Called eat_ghost(True, False).'
32+ f'The function returned { actual_result } , but the '
33+ f'tests expected that the '
34+ 'ghost **does not** get eaten because '
35+ 'the player was not touching the ghost.' )
36+
37+ self .assertIs (actual_result , False , msg = error_message )
3138
3239 @pytest .mark .task (taskno = 2 )
3340 def test_score_when_eating_dot (self ):
34- self .assertIs (
35- score (False , True ),
36- True ,
37- msg = "score when eating dot"
38- )
41+ actual_result = score (False , True )
42+ error_message = ('Called score(False, True).'
43+ f'The function returned { actual_result } , but the '
44+ f'tests expected that the '
45+ 'player scores because they were touching a dot.' )
46+
47+ self .assertIs (actual_result , True , msg = error_message )
3948
4049 @pytest .mark .task (taskno = 2 )
4150 def test_score_when_eating_power_pellet (self ):
42- self .assertIs (
43- score (True , False ),
44- True ,
45- msg = "score when eating power pellet"
46- )
51+ actual_result = score (True , False )
52+ error_message = ('Called score(True, False).'
53+ f'The function returned { actual_result } , but the '
54+ f'tests expected that the '
55+ 'player scores because they '
56+ 'were touching a power pellet.' )
57+
58+ self .assertIs (actual_result ,True ,msg = error_message )
4759
4860 @pytest .mark .task (taskno = 2 )
4961 def test_no_score_when_nothing_eaten (self ):
50- self .assertIs (
51- score (False , False ),
52- False ,
53- msg = "no score when nothing eaten"
54- )
62+ actual_result = score (False , False )
63+ error_message = ('Called score(False, False).'
64+ f'The function returned { actual_result } , but the '
65+ f'tests expected that the '
66+ 'player **does not** score because they '
67+ 'were not touching anything.' )
68+ self .assertIs (actual_result , False ,msg = error_message )
5569
5670 @pytest .mark .task (taskno = 3 )
5771 def test_lose_if_touching_a_ghost_without_a_power_pellet_active (self ):
72+ actual_result = lose (False , True )
73+ error_message = ('Called lose(False, True).'
74+ f'The function returned { actual_result } , but the '
75+ f'tests expected that the '
76+ 'player loses because they touched a '
77+ 'ghost without a power pellet activated.' )
5878 self .assertIs (
59- lose (False , True ),
60- True ,
61- msg = "lose if touching a ghost without a power pellet active"
62- )
79+ actual_result , True , msg = error_message )
6380
6481 @pytest .mark .task (taskno = 3 )
6582 def test_dont_lose_if_touching_a_ghost_with_a_power_pellet_active (self ):
66- self .assertIs (
67- lose (True , True ),
68- False ,
69- msg = "don't lose if touching a ghost with a power pellet active"
70- )
83+ actual_result = lose (True , True )
84+ error_message = ('Called lose(True, True).'
85+ f'The function returned { actual_result } , but the '
86+ f'tests expected that the '
87+ 'player **does not** lose because when they touched a '
88+ 'ghost, a power pellet was active.' )
89+
90+ self .assertIs (actual_result , False , msg = error_message )
7191
7292 @pytest .mark .task (taskno = 3 )
7393 def test_dont_lose_if_not_touching_a_ghost (self ):
74- self .assertIs (
75- lose (True , False ),
76- False ,
77- msg = "don't lose if not touching a ghost"
78- )
94+ actual_result = lose (True , False )
95+ error_message = ('Called lose(True, False).'
96+ f'The function returned { actual_result } , but the '
97+ f'tests expected that the '
98+ 'player **does not** lose because they were '
99+ 'not touching a ghost.' )
100+
101+ self .assertIs (actual_result , False , msg = error_message )
79102
80103 @pytest .mark .task (taskno = 4 )
81104 def test_win_if_all_dots_eaten (self ):
82- self .assertIs (
83- win (True , False , False ),
84- True ,
85- msg = "win if all dots eaten"
86- )
105+ actual_result = win (True , False , False )
106+ error_message = ('Called win(True, False, False).'
107+ f'The function returned { actual_result } , but the '
108+ f'tests expected that the '
109+ 'player wins because all the dots were eaten.' )
110+
111+ self .assertIs (actual_result , True , msg = error_message )
87112
88113 @pytest .mark .task (taskno = 4 )
89114 def test_dont_win_if_all_dots_eaten_but_touching_a_ghost (self ):
90- self .assertIs (
91- win (True , False , True ),
92- False ,
93- msg = "don't win if all dots eaten, but touching a ghost"
94- )
115+ actual_result = win (True , False , True )
116+ error_message = ('Called win(True, False, True).'
117+ f'The function returned { actual_result } , but the '
118+ f'tests expected that the '
119+ 'player **does not** win, because '
120+ 'the player was touching a ghost.' )
121+
122+ self .assertIs (actual_result , False , msg = error_message )
95123
96124 @pytest .mark .task (taskno = 4 )
97125 def test_win_if_all_dots_eaten_and_touching_a_ghost_with_a_power_pellet_active (self ):
98- self .assertIs (
99- win (True , True , True ),
100- True ,
101- msg = "win if all dots eaten and touching a ghost with a power pellet active"
102- )
126+ actual_result = win (True , True , True )
127+ error_message = ('Called win(True, True, True).'
128+ f'The function returned { actual_result } , but the '
129+ f'tests expected that the player wins, '
130+ f'because a power pellet was active when they '
131+ f'touched a ghost.' )
132+
133+ self .assertIs (actual_result , True , msg = error_message )
103134
104135 @pytest .mark .task (taskno = 4 )
105136 def test_dont_win_if_not_all_dots_eaten (self ):
106- self .assertIs (
107- win (False , True , True ),
108- False ,
109- msg = "don't win if not all dots eaten and touching a ghost with a power pellet active"
110- )
137+ actual_result = win (False , True , True )
138+ error_message = ('Called win(False, True, True).'
139+ f'The function returned { actual_result } , but the '
140+ f'tests expected that the player **does not** win, '
141+ f'because the player did not eat all of the dots.' )
142+
143+ self .assertIs (actual_result , False , msg = error_message )
144+
0 commit comments