MCPcopy
hub / github.com/pytest-dev/pytest / test_doctest_unexpected_exception

Method test_doctest_unexpected_exception

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

Source from the content-addressed store, hash-verified

205 result.stdout.fnmatch_lines(["*1 passed*"])
206
207 def test_doctest_unexpected_exception(self, pytester: Pytester):
208 pytester.maketxtfile(
209 """
210 >>> i = 0
211 >>> 0 / i
212 2
213 """
214 )
215 result = pytester.runpytest("--doctest-modules")
216 result.stdout.fnmatch_lines(
217 [
218 "test_doctest_unexpected_exception.txt F *",
219 "",
220 "*= FAILURES =*",
221 "*_ [[]doctest[]] test_doctest_unexpected_exception.txt _*",
222 "001 >>> i = 0",
223 "002 >>> 0 / i",
224 "UNEXPECTED EXCEPTION: ZeroDivisionError*",
225 "Traceback (most recent call last):",
226 *(
227 (' File "*/doctest.py", line *, in __run', " *")
228 if sys.version_info <= (3, 14)
229 else ()
230 ),
231 *((" *^^^^*", " *", " *") if sys.version_info[:2] == (3, 13) else ()),
232 ' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
233 "ZeroDivisionError: division by zero",
234 "*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
235 ],
236 consecutive=True,
237 )
238
239 def test_doctest_outcomes(self, pytester: Pytester):
240 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