(pytester: Pytester)
| 433 | |
| 434 | |
| 435 | def test_raises(pytester: Pytester) -> None: |
| 436 | pytester.makepyfile( |
| 437 | """ |
| 438 | from nose.tools import raises |
| 439 | |
| 440 | @raises(RuntimeError) |
| 441 | def test_raises_runtimeerror(): |
| 442 | raise RuntimeError |
| 443 | |
| 444 | @raises(Exception) |
| 445 | def test_raises_baseexception_not_caught(): |
| 446 | raise BaseException |
| 447 | |
| 448 | @raises(BaseException) |
| 449 | def test_raises_baseexception_caught(): |
| 450 | raise BaseException |
| 451 | """ |
| 452 | ) |
| 453 | result = pytester.runpytest("-vv") |
| 454 | result.stdout.fnmatch_lines( |
| 455 | [ |
| 456 | "test_raises.py::test_raises_runtimeerror PASSED*", |
| 457 | "test_raises.py::test_raises_baseexception_not_caught FAILED*", |
| 458 | "test_raises.py::test_raises_baseexception_caught PASSED*", |
| 459 | "*= FAILURES =*", |
| 460 | "*_ test_raises_baseexception_not_caught _*", |
| 461 | "", |
| 462 | "arg = (), kw = {}", |
| 463 | "", |
| 464 | " def newfunc(*arg, **kw):", |
| 465 | " try:", |
| 466 | "> func(*arg, **kw)", |
| 467 | "", |
| 468 | "*/nose/*: ", |
| 469 | "_ _ *", |
| 470 | "", |
| 471 | " @raises(Exception)", |
| 472 | " def test_raises_baseexception_not_caught():", |
| 473 | "> raise BaseException", |
| 474 | "E BaseException", |
| 475 | "", |
| 476 | "test_raises.py:9: BaseException", |
| 477 | "* 1 failed, 2 passed *", |
| 478 | ] |
| 479 | ) |
| 480 | |
| 481 | |
| 482 | def test_nose_setup_skipped_if_non_callable(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected