示例#1
0
文件: doctest.py 项目: pakal/pytest
 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)
示例#2
0
 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)
示例#3
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)
示例#4
0
 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)