def collect(self):
import doctest
if self.fspath.basename == "conftest.py":
module = self.config.pluginmanager._importconftest(self.fspath)
else:
try:
# XXX patch pyimport in pytest._pytest.doctest.DoctestModule
module = _patch_pyimport(self.fspath)
except ImportError:
if self.config.getoption('--cython-ignore-import-errors'):
pytest.skip('unable to import module %r' % self.fspath)
else:
raise
# uses internal doctest module parsing mechanism
finder = doctest.DocTestFinder()
optionflags = get_optionflags(self)
checker = None if _get_checker is None else _get_checker()
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags,
checker=checker)
for test in finder.find(module, module.__name__):
if test.examples: # skip empty doctests
yield DoctestItem(test.name, self, runner, test)
评论列表
文章目录