Skip to content

Commit

Permalink
Changed test error messages and touched up docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
BethanyG committed Nov 6, 2023
1 parent 6f87ae7 commit ca550ed
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 70 deletions.
4 changes: 3 additions & 1 deletion concepts/bools/about.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About

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

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

[bools]: https://docs.python.org/3/library/stdtypes.html#typebool
4 changes: 3 additions & 1 deletion concepts/bools/introduction.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction

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

Expand All @@ -21,3 +21,5 @@ We can evaluate Boolean expressions using the `and`, `or`, and `not` operators.
>>> true_variable = not False
>>> false_variable = not True
```

[bools]: https://docs.python.org/3/library/stdtypes.html#typebool
5 changes: 3 additions & 2 deletions exercises/concept/ghost-gobble-arcade-game/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## General

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

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

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

[boolean]: https://docs.python.org/3/library/stdtypes.html#truth
[Boolean-operators]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not

[boolean]: https://docs.python.org/3/library/stdtypes.html#truth
[stdlib-bools]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction

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

Expand All @@ -21,3 +21,5 @@ We can evaluate Boolean expressions using the `and`, `or`, and `not` operators:
>>> true_variable = not False
>>> false_variable = not True
```

[bools]: https://docs.python.org/3/library/stdtypes.html#typebool
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"contributors": [
"cmccandless",
"bethanyg"
"BethanyG"
],
"files": {
"solution": [
Expand Down
162 changes: 98 additions & 64 deletions exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,104 +7,138 @@ class GhostGobbleGameTest(unittest.TestCase):

@pytest.mark.task(taskno=1)
def test_ghost_gets_eaten(self):
self.assertIs(
eat_ghost(True, True),
True,
msg="ghost should get eaten"
)
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):
self.assertIs(
eat_ghost(False, True),
False,
msg="ghost does not get eaten because no power pellet active"
)
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):
self.assertIs(
eat_ghost(True, False),
False,
msg="ghost does not get eaten because not touching ghost"
)
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):
self.assertIs(
score(False, True),
True,
msg="score when eating dot"
)
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):
self.assertIs(
score(True, False),
True,
msg="score when eating power pellet"
)
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):
self.assertIs(
score(False, False),
False,
msg="no score when nothing eaten"
)
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(
lose(False, True),
True,
msg="lose if touching a ghost without a power pellet active"
)
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):
self.assertIs(
lose(True, True),
False,
msg="don't lose if touching a ghost with a power pellet active"
)
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):
self.assertIs(
lose(True, False),
False,
msg="don't lose if not touching a ghost"
)
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):
self.assertIs(
win(True, False, False),
True,
msg="win if all dots eaten"
)
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):
self.assertIs(
win(True, False, True),
False,
msg="don't win if all dots eaten, but touching a ghost"
)
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):
self.assertIs(
win(True, True, True),
True,
msg="win if all dots eaten and touching a ghost with a power pellet active"
)
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):
self.assertIs(
win(False, True, True),
False,
msg="don't win if not all dots eaten and touching a ghost with a power pellet active"
)
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)

0 comments on commit ca550ed

Please sign in to comment.