Skip to content

Commit cb35445

Browse files
authored
Changed test error messages and touched up docs. (#3544)
[no important files changed]
1 parent f4d59b7 commit cb35445

File tree

6 files changed

+111
-70
lines changed

6 files changed

+111
-70
lines changed

concepts/bools/about.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# About
22

3-
Python represents True and False values with the [bool][bool] type.
3+
Python represents true and false values with the [`bool`][bools] type, which is a subtype of `int`.
44
There are only two Boolean values in this type: `True` and `False`.
55
These values can be assigned to a variable and combined with the [Boolean operators][boolean-operators] (`and`, `or`, `not`):
66

@@ -139,3 +139,5 @@ It is considered a [Python anti-pattern][comparing to true in the wrong way] to
139139
[Boolean-operators]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
140140
[comparing to true in the wrong way]: https://docs.quantifiedcode.com/python-anti-patterns/readability/comparison_to_true.html
141141
[comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons
142+
143+
[bools]: https://docs.python.org/3/library/stdtypes.html#typebool

concepts/bools/introduction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
Python represents true and false values with the `bool` type.
3+
Python represents true and false values with the [`bool`][bools] type, which is a subtype of `int`.
44
There are only two values under that type: `True` and `False`.
55
These values can be bound to a variable:
66

@@ -21,3 +21,5 @@ We can evaluate Boolean expressions using the `and`, `or`, and `not` operators.
2121
>>> true_variable = not False
2222
>>> false_variable = not True
2323
```
24+
25+
[bools]: https://docs.python.org/3/library/stdtypes.html#typebool

exercises/concept/ghost-gobble-arcade-game/.docs/hints.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## General
44

5+
- For an overview, this section of the Python documentation: [Truth Value Testing][stdlib-bools] might help.
56
- Don't worry about how the arguments are _derived_, focus on combining the arguments to return the intended result.
67

78
## 1. Define if Pac-Man can eat a ghost
@@ -20,6 +21,6 @@
2021

2122
- You can use the [Boolean][boolean] [operators][Boolean-operators] to combine arguments for a result.
2223

23-
[boolean]: https://docs.python.org/3/library/stdtypes.html#truth
2424
[Boolean-operators]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
25-
25+
[boolean]: https://docs.python.org/3/library/stdtypes.html#truth
26+
[stdlib-bools]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing

exercises/concept/ghost-gobble-arcade-game/.docs/introduction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
Python represents true and false values with the `bool` type.
3+
Python represents true and false values with the [`bool`][bools] type, which is a subtype of `int`.
44
There are only two values in this type: `True` and `False`.
55
These values can be bound to a variable:
66

@@ -21,3 +21,5 @@ We can evaluate Boolean expressions using the `and`, `or`, and `not` operators:
2121
>>> true_variable = not False
2222
>>> false_variable = not True
2323
```
24+
25+
[bools]: https://docs.python.org/3/library/stdtypes.html#typebool

exercises/concept/ghost-gobble-arcade-game/.meta/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"contributors": [
66
"cmccandless",
7-
"bethanyg"
7+
"BethanyG"
88
],
99
"files": {
1010
"solution": [

exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py

Lines changed: 98 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)