def collect(self): import doctest if self.fspath.basename == "conftest.py": module = self.config._conftest._importconftest(self.fspath) else: try: module = self.fspath.pyimport() except ImportError: if self.config.getvalue('doctest_ignore_import_errors'): pytest.skip('unable to import module %r' % self.fspath) else: raise # satisfy `FixtureRequest` constructor... self.funcargs = {} self._fixtureinfo = FuncFixtureInfo((), [], {}) fixture_request = FixtureRequest(self) doctest_globals = dict(getfixture=fixture_request.getfuncargvalue) # uses internal doctest module parsing mechanism finder = doctest.DocTestFinder() optionflags = get_optionflags(self) runner = doctest.DebugRunner(verbose=0, optionflags=optionflags) for test in finder.find(module, module.__name__, extraglobs=doctest_globals): if test.examples: # skip empty doctests yield DoctestItem(test.name, self, runner, test)
def runtest(self): doctest = py.std.doctest # satisfy `FixtureRequest` constructor... self.funcargs = {} self._fixtureinfo = FuncFixtureInfo((), [], {}) fixture_request = FixtureRequest(self) failed, tot = doctest.testfile( str(self.fspath), module_relative=False, optionflags=doctest.ELLIPSIS, extraglobs=dict(getfixture=fixture_request.getfuncargvalue), raise_on_error=True, verbose=0)
def runtest(self): doctest = py.std.doctest if self.fspath.basename == "conftest.py": module = self.config._conftest.importconftest(self.fspath) else: module = self.fspath.pyimport() # satisfy `FixtureRequest` constructor... self.funcargs = {} self._fixtureinfo = FuncFixtureInfo((), [], {}) fixture_request = FixtureRequest(self) failed, tot = doctest.testmod( module, raise_on_error=True, verbose=0, extraglobs=dict(getfixture=fixture_request.getfuncargvalue), optionflags=doctest.ELLIPSIS)
def collect(self): import doctest if self.fspath.basename == "conftest.py": module = self.config._conftest.importconftest(self.fspath) else: module = self.fspath.pyimport() # satisfy `FixtureRequest` constructor... self.funcargs = {} self._fixtureinfo = FuncFixtureInfo((), [], {}) fixture_request = FixtureRequest(self) doctest_globals = dict(getfixture=fixture_request.getfuncargvalue) # uses internal doctest module parsing mechanism finder = doctest.DocTestFinder() runner = doctest.DebugRunner(verbose=0, optionflags=doctest.ELLIPSIS) for test in finder.find(module, module.__name__, extraglobs=doctest_globals): if test.examples: # skip empty doctests yield DoctestItem(test.name, self, runner, test)