-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
tests: improve test for nose.raises
#6521
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
Changes from all commits
8fa57c8
ef112fd
1350c60
9c7b3c5
0b6258a
9dcdea5
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 |
|---|---|---|
|
|
@@ -377,15 +377,48 @@ def test_io(self): | |
| result.stdout.fnmatch_lines(["* 1 skipped *"]) | ||
|
|
||
|
|
||
| def test_issue_6517(testdir): | ||
| def test_raises(testdir): | ||
| testdir.makepyfile( | ||
| """ | ||
| from nose.tools import raises | ||
|
|
||
| @raises(RuntimeError) | ||
| def test_fail_without_tcp(): | ||
| def test_raises_runtimeerror(): | ||
| raise RuntimeError | ||
|
|
||
| @raises(Exception) | ||
| def test_raises_baseexception_not_caught(): | ||
| raise BaseException | ||
|
|
||
| @raises(BaseException) | ||
| def test_raises_baseexception_caught(): | ||
| raise BaseException | ||
| """ | ||
| ) | ||
| result = testdir.runpytest() | ||
| result.stdout.fnmatch_lines(["* 1 passed *"]) | ||
| result = testdir.runpytest("-vv") | ||
| result.stdout.fnmatch_lines( | ||
| [ | ||
| "test_raises.py::test_raises_runtimeerror PASSED*", | ||
| "test_raises.py::test_raises_baseexception_not_caught FAILED*", | ||
| "test_raises.py::test_raises_baseexception_caught PASSED*", | ||
|
Contributor
Author
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. Without the cast here it would display "test_raises.py::test_raises_runtimeerror <- /…/test_raises0/test_raises.py PASSED` here.
Member
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. Hmm sorry, what "cast" you mean?
Contributor
Author
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. @nicoddemus https://github.com/blueyed/pytest/blob/156a41a855d28ae9f6d83545af69b51fb26f199e/src/_pytest/terminal.py#L747-L752 Since |
||
| "*= FAILURES =*", | ||
| "*_ test_raises_baseexception_not_caught _*", | ||
| "", | ||
| "arg = (), kw = {}", | ||
| "", | ||
| " def newfunc(*arg, **kw):", | ||
| " try:", | ||
| "> func(*arg, **kw)", | ||
| "", | ||
| "*/nose/*: ", | ||
| "_ _ *", | ||
| "", | ||
| " @raises(Exception)", | ||
| " def test_raises_baseexception_not_caught():", | ||
| "> raise BaseException", | ||
| "E BaseException", | ||
| "", | ||
| "test_raises.py:9: BaseException", | ||
| "* 1 failed, 2 passed *", | ||
| ] | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.