(self, pytester: Pytester)
| 52 | raise E() |
| 53 | |
| 54 | def test_raises_as_contextmanager(self, pytester: Pytester) -> None: |
| 55 | pytester.makepyfile( |
| 56 | """ |
| 57 | import pytest |
| 58 | import _pytest._code |
| 59 | |
| 60 | def test_simple(): |
| 61 | with pytest.raises(ZeroDivisionError) as excinfo: |
| 62 | assert isinstance(excinfo, _pytest._code.ExceptionInfo) |
| 63 | 1/0 |
| 64 | print(excinfo) |
| 65 | assert excinfo.type == ZeroDivisionError |
| 66 | assert isinstance(excinfo.value, ZeroDivisionError) |
| 67 | |
| 68 | def test_noraise(): |
| 69 | with pytest.raises(pytest.raises.Exception): |
| 70 | with pytest.raises(ValueError): |
| 71 | int() |
| 72 | |
| 73 | def test_raise_wrong_exception_passes_by(): |
| 74 | with pytest.raises(ZeroDivisionError): |
| 75 | with pytest.raises(ValueError): |
| 76 | 1/0 |
| 77 | """ |
| 78 | ) |
| 79 | result = pytester.runpytest() |
| 80 | result.stdout.fnmatch_lines(["*3 passed*"]) |
| 81 | |
| 82 | def test_does_not_raise(self, pytester: Pytester) -> None: |
| 83 | pytester.makepyfile( |
nothing calls this directly
no test coverage detected