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

Method test_doctest_unexpected_exception

testing/test_doctest.py:182–208  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

180 result.stdout.fnmatch_lines(["*1 passed*"])
181
182 def test_doctest_unexpected_exception(self, pytester: Pytester):
183 pytester.maketxtfile(
184 """
185 >>> i = 0
186 >>> 0 / i
187 2
188 """
189 )
190 result = pytester.runpytest("--doctest-modules")
191 result.stdout.fnmatch_lines(
192 [
193 "test_doctest_unexpected_exception.txt F *",
194 "",
195 "*= FAILURES =*",
196 "*_ [[]doctest[]] test_doctest_unexpected_exception.txt _*",
197 "001 >>> i = 0",
198 "002 >>> 0 / i",
199 "UNEXPECTED EXCEPTION: ZeroDivisionError*",
200 "Traceback (most recent call last):",
201 ' File "*/doctest.py", line *, in __run',
202 " *",
203 ' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
204 "ZeroDivisionError: division by zero",
205 "*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
206 ],
207 consecutive=True,
208 )
209
210 def test_doctest_outcomes(self, pytester: Pytester):
211 pytester.maketxtfile(

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
maketxtfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected