MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_does_not_raise_does_raise

Method test_does_not_raise_does_raise

testing/python/raises.py:107–128  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

105 result.stdout.fnmatch_lines(["*4 passed*"])
106
107 def test_does_not_raise_does_raise(self, pytester: Pytester) -> None:
108 pytester.makepyfile(
109 """
110 from contextlib import contextmanager
111 import pytest
112
113 @contextmanager
114 def does_not_raise():
115 yield
116
117 @pytest.mark.parametrize('example_input,expectation', [
118 (0, does_not_raise()),
119 (1, pytest.raises(ZeroDivisionError)),
120 ])
121 def test_division(example_input, expectation):
122 '''Test how much I know division.'''
123 with expectation:
124 assert (6 / example_input) is not None
125 """
126 )
127 result = pytester.runpytest()
128 result.stdout.fnmatch_lines(["*2 failed*"])
129
130 def test_noclass(self) -> None:
131 with pytest.raises(TypeError):

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected