summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2020-01-23 13:42:14 +0100
committerGitHub <noreply@github.com>2020-01-23 13:42:14 +0100
commit6b13379f37b3beca878db8a5df11de4a9e048327 (patch)
tree0c990af584a194dafdab0ed4cfb102eef1a1f9eb /testing
parent863bab532608bc4cb2d55477f035d63c4679e1fa (diff)
parent9dcdea5de7a9d7f3d24a59182682fa6a0fd59bdb (diff)
downloadpytest-6b13379f37b3beca878db8a5df11de4a9e048327.tar.gz
Merge pull request #6521 from blueyed/harden-nose-raises
tests: improve test for `nose.raises`
Diffstat (limited to 'testing')
-rw-r--r--testing/test_nose.py41
1 files changed, 37 insertions, 4 deletions
diff --git a/testing/test_nose.py b/testing/test_nose.py
index 469c127af..b6200c6c9 100644
--- a/testing/test_nose.py
+++ b/testing/test_nose.py
@@ -377,15 +377,48 @@ def test_skip_test_with_unicode(testdir):
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*",
+ "*= 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 *",
+ ]
+ )