Skip to content

Commit 0087db6

Browse files
committed
tests: improve test for nose.raises
This should probably get transferred into a `pytest.fail` really, but tests/documents the current behavior.
1 parent a52f791 commit 0087db6

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

testing/test_nose.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,45 @@ def test_io(self):
377377
result.stdout.fnmatch_lines(["* 1 skipped *"])
378378

379379

380-
def test_issue_6517(testdir):
380+
def test_raises(testdir):
381381
testdir.makepyfile(
382382
"""
383383
from nose.tools import raises
384384
385385
@raises(RuntimeError)
386-
def test_fail_without_tcp():
386+
def test_raises_runtimeerror():
387387
raise RuntimeError
388+
389+
@raises(Exception)
390+
def test_raises_baseexception_not_caught():
391+
raise BaseException
392+
393+
@raises(BaseException)
394+
def test_raises_baseexception_caught():
395+
raise BaseException
388396
"""
389397
)
390398
result = testdir.runpytest()
391-
result.stdout.fnmatch_lines(["* 1 passed *"])
399+
result.stdout.fnmatch_lines(
400+
[
401+
"*= FAILURES =*",
402+
"*_ test_raises_baseexception_not_caught _*",
403+
"",
404+
"arg = (), kw = {}",
405+
"",
406+
" def newfunc(*arg, **kw):",
407+
" try:",
408+
"> func(*arg, **kw)",
409+
"",
410+
"*/nose/*: ",
411+
"_ _ *",
412+
"",
413+
" @raises(Exception)",
414+
" def test_raises_baseexception_not_caught():",
415+
"> raise BaseException",
416+
"E BaseException",
417+
"",
418+
"test_raises.py:9: BaseException",
419+
"* 1 failed, 2 passed *",
420+
]
421+
)

0 commit comments

Comments
 (0)