Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wordy: update tests to v1.2.0 #1535

Merged
merged 3 commits into from
Oct 1, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions exercises/wordy/wordy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from wordy import calculate

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class WordyTest(unittest.TestCase):
def test_addition(self):
Expand Down Expand Up @@ -51,12 +51,14 @@ def test_multiple_division(self):
calculate("What is -12 divided by 2 divided by -3?"), 2)

def test_unknown_operation(self):
with self.assertRaisesWithMessage(ValueError):
with self.assertRaisesWithMessage(ValueError) as error:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this track, we don't test for actual exception message content, only that one is present. The reasoning for this is summarized well here: #1080 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Well should i check that the error message is not empty? Or is raising an error enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertRaisesWithMessage checks for a non-null, non-empty error message.

calculate("What is 52 cubed?")
self.assertEqual("unknown operation", str(error.exception))

def test_non_math_question(self):
with self.assertRaisesWithMessage(ValueError):
with self.assertRaisesWithMessage(ValueError) as error:
calculate("Who is the President of the United States?")
self.assertEqual("unknown operation", str(error.exception))

# Additional tests for this track

Expand Down