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

Method test_does_not_raise

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

Source from the content-addressed store, hash-verified

80 result.stdout.fnmatch_lines(["*3 passed*"])
81
82 def test_does_not_raise(self, pytester: Pytester) -> None:
83 pytester.makepyfile(
84 """
85 from contextlib import contextmanager
86 import pytest
87
88 @contextmanager
89 def does_not_raise():
90 yield
91
92 @pytest.mark.parametrize('example_input,expectation', [
93 (3, does_not_raise()),
94 (2, does_not_raise()),
95 (1, does_not_raise()),
96 (0, pytest.raises(ZeroDivisionError)),
97 ])
98 def test_division(example_input, expectation):
99 '''Test how much I know division.'''
100 with expectation:
101 assert (6 / example_input) is not None
102 """
103 )
104 result = pytester.runpytest()
105 result.stdout.fnmatch_lines(["*4 passed*"])
106
107 def test_does_not_raise_does_raise(self, pytester: Pytester) -> None:
108 pytester.makepyfile(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected