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

Function mocked_doctest_runner

testing/python/approx.py:18–44  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

16
17@pytest.fixture
18def mocked_doctest_runner(monkeypatch):
19 import doctest
20
21 class MockedPdb:
22 def __init__(self, out):
23 pass
24
25 def set_trace(self):
26 raise NotImplementedError("not used")
27
28 def reset(self):
29 pass
30
31 def set_continue(self):
32 pass
33
34 monkeypatch.setattr("doctest._OutputRedirectingPdb", MockedPdb)
35
36 class MyDocTestRunner(doctest.DocTestRunner):
37 def report_failure(self, out, test, example, got):
38 raise AssertionError(
39 "'{}' evaluates to '{}', not '{}'".format(
40 example.source.strip(), got.strip(), example.want.strip()
41 )
42 )
43
44 return MyDocTestRunner()
45
46
47@contextmanager

Callers

nothing calls this directly

Calls 2

MyDocTestRunnerClass · 0.85
setattrMethod · 0.80

Tested by

no test coverage detected