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

Method test_doctest_outcomes

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

Source from the content-addressed store, hash-verified

237 )
238
239 def test_doctest_outcomes(self, pytester: Pytester):
240 pytester.maketxtfile(
241 test_skip="""
242 >>> 1
243 1
244 >>> import pytest
245 >>> pytest.skip("")
246 >>> 2
247 3
248 """,
249 test_xfail="""
250 >>> import pytest
251 >>> pytest.xfail("xfail_reason")
252 >>> foo
253 bar
254 """,
255 test_importorskip="""
256 >>> import pytest
257 >>> pytest.importorskip("doesnotexist")
258 >>> foo
259 bar
260 """,
261 )
262 result = pytester.runpytest("--doctest-modules")
263 result.stdout.fnmatch_lines(
264 [
265 "collected 3 items",
266 "",
267 "test_importorskip.txt s *",
268 "test_skip.txt s *",
269 "test_xfail.txt x *",
270 "",
271 "*= 2 skipped, 1 xfailed in *",
272 ]
273 )
274
275 def test_docstring_partial_context_around_error(self, pytester: Pytester):
276 """Test that we show some context before the actual line of a failing

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
maketxtfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected