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

Method collect

src/_pytest/doctest.py:423–448  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

421 obj = None
422
423 def collect(self) -> Iterable[DoctestItem]:
424 import doctest
425
426 # Inspired by doctest.testfile; ideally we would use it directly,
427 # but it doesn't support passing a custom checker.
428 encoding = self.config.getini("doctest_encoding")
429 text = self.path.read_text(encoding)
430 filename = str(self.path)
431 name = self.path.name
432 globs = {"__name__": "__main__"}
433
434 optionflags = get_optionflags(self.config)
435
436 runner = _get_runner(
437 verbose=False,
438 optionflags=optionflags,
439 checker=_get_checker(),
440 continue_on_failure=_get_continue_on_failure(self.config),
441 )
442
443 parser = doctest.DocTestParser()
444 test = parser.get_doctest(text, globs, name, filename, 0)
445 if test.examples:
446 yield DoctestItem.from_parent(
447 self, name=test.name, runner=runner, dtest=test
448 )
449
450
451def _check_all_skipped(test: doctest.DocTest) -> None:

Callers

nothing calls this directly

Calls 7

get_optionflagsFunction · 0.85
_get_runnerFunction · 0.85
_get_checkerFunction · 0.85
_get_continue_on_failureFunction · 0.85
read_textMethod · 0.80
getiniMethod · 0.45
from_parentMethod · 0.45

Tested by

no test coverage detected