-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Pytest.raises custom error message #1616
Changes from 2 commits
d21886c
8ddbca3
e6ff01a
ca09367
c29130d
f8d4cad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,20 @@ def test_no_raise_message(self): | |
pytest.raises(ValueError, int, '0') | ||
except pytest.raises.Exception as e: | ||
assert e.msg == "DID NOT RAISE {0}".format(repr(ValueError)) | ||
try: | ||
with pytest.raises(ValueError): | ||
pass | ||
except pytest.raises.Exception as e: | ||
e.msg == "DID NOT RAISE {0}".format(repr(ValueError)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this missing an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
def test_costum_raise_message(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. costum -> custom, but I'll fix it up when merging |
||
message = "TEST_MESSAGE" | ||
try: | ||
pytest.raises(ValueError, int, '0', message=message) | ||
except pytest.raises.Exception as e: | ||
assert e.msg == message | ||
try: | ||
with pytest.raises(ValueError, message=message): | ||
pass | ||
except pytest.raises.Exception as e: | ||
e.msg == message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this missing an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accord -> occured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done