def loadTestsFromDir(self, path):
        """Load tests from Sphinx subdirectory in the given directory.

        Overriden from Plugin.
        """
        # We only run for directories we really want.
        if not self.wantDirectory(path):
            return

        groups = collect_sphinx_doctests(**self._get_sphinx_dirs(path))

        for docname, group in groups:
            # All tests in a group share their global context.
            group.globs = {}

            def build_setup_teardown(fname, group, before=False, after=False):

                def func(test):
                    # All tests in a group share their global context.
                    test.globs = group.globs

                    # Set type for the monkey-patched compile function.
                    executor.compile_type = test.compile_type

                    # Run setup/cleanup in the current context.
                    for setup_code in group.setup:
                        code_name = '<{kind} {docname}:{name}>'.format(
                            kind=fname, docname=docname, name=group.name,
                        )
                        six.exec_(
                            compile(setup_code.code, code_name, 'exec', 0, 1),
                            test.globs,
                        )

                func.__name__ = fname
                return func

            try:
                suite = doctest.DocTestSuite(
                    test_finder=SphinxDocTestFinder(docname, group),
                    setUp=build_setup_teardown('setup', group),
                    tearDown=build_setup_teardown('teardown', group),
                )
            except ValueError:  # No docstring. Ignore.
                continue
            yield suite
def loadTestsFromDir ( self , path ) : if not self . wantDirectory ( path ) : return groups = collect_sphinx_doctests ( ** self . _get_sphinx_dirs ( path ) ) for docname , group in groups : group . globs = { } def build_setup_teardown ( fname , group , before = False , after = False ) : def func ( test ) : test . globs = group . globs executor . compile_type = test . compile_type for setup_code in group . setup : code_name = '<{kind} {docname}:{name}>' . format ( kind = fname , docname = docname , name = group . name , ) six . exec_ ( compile ( setup_code . code , code_name , 'exec' , 0 , 1 ) , test . globs , ) func . __name__ = fname return func try : suite = doctest . DocTestSuite ( test_finder = SphinxDocTestFinder ( docname , group ) , setUp = build_setup_teardown ( 'setup' , group ) , tearDown = build_setup_teardown ( 'teardown' , group ) , ) except ValueError : continue yield suite
Load tests from Sphinx subdirectory in the given directory.

        Overriden from Plugin.