Skip to content

Commit

Permalink
[Units] Remove asterisks when checking trivia answers
Browse files Browse the repository at this point in the history
[Tests] Add test for trivia answer with asterisks
  • Loading branch information
Harmon758 committed Nov 16, 2023
1 parent 66e60fb commit 1ae1d38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tests/test_trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def test_and_with_and_in_item(self):
def test_ampersand(self):
self.assertTrue(check_answer(answer = "AT&T", response = "at&t"))

def test_asterisks(self):
self.assertTrue(
check_answer(answer = "*a pine (**a fir)", response = "pine")
)

def test_clue_text_plural_subject_redundancy_in_answer(self):
for clue, answer, response in (
(
Expand Down
5 changes: 3 additions & 2 deletions units/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def check_answer(*, answer, response, clue = None, inflect_engine = None):
# Replace: & -> and
answer = answer.replace('&', "and")
response = response.replace('&', "and")
# Remove exclamation marks, periods, quotation marks, and interpuncts
for character in '!."·':
# Remove exclamation marks, quotation marks, asterisks, periods, and
# interpuncts
for character in '!"*.·':
if character in answer:
answer = answer.replace(character, "")
if character in response:
Expand Down

0 comments on commit 1ae1d38

Please sign in to comment.