Esempio n. 1
0
    def collect(self):
        import doctest

        module = self._getobj()
        # uses internal doctest module parsing mechanism
        finder = doctest.DocTestFinder()
        optionflags = _pytest.doctest.get_optionflags(self)
        runner = doctest.DebugRunner(verbose=0, optionflags=optionflags)

        try:
            for test in finder.find(module, self.name[:-len('.py')]):
                if test.examples:  # skip empty doctests
                    yield getattr(_pytest.doctest.DoctestItem, 'from_parent',
                                  _pytest.doctest.DoctestItem)(name=test.name,
                                                               parent=self,
                                                               runner=runner,
                                                               dtest=test)
        except Exception:
            import logging
            logging.exception(
                'DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make'
            )
            etype, exc, tb = sys.exc_info()
            msg = 'DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make'
            reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb)
Esempio n. 2
0
 def collect(self):
     import doctest
     finder = doctest.DocTestFinder()
     module = self._getobj()
     optionflags = _pytest.doctest.get_optionflags(self)
     runner = doctest.DebugRunner(verbose=0, optionflags=optionflags)
     for test in finder.find(module, self.name[:-(len(".py"))]):
         if test.examples:  # skip empty doctests
             yield DoctestItem(test.name, self, runner, test)