Python doctest.DocFileSuite() Examples

The following are 30 code examples of doctest.DocFileSuite(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module doctest , or try the search function .
Example #1
Source File: __init__.py    From attention-lvcsr with MIT License 6 votes vote down vote up
def load_tests(loader, tests, ignore):
    # This function loads doctests from all submodules and runs them
    # with the __future__ imports necessary for Python 2
    for _, module, _ in pkgutil.walk_packages(path=fuel.__path__,
                                              prefix=fuel.__name__ + '.'):
        try:
            tests.addTests(doctest.DocTestSuite(
                module=importlib.import_module(module), setUp=setup,
                optionflags=doctest.IGNORE_EXCEPTION_DETAIL,
                checker=Py23DocChecker()))
        except:
            pass

    # This part loads the doctests from the documentation
    docs = []
    for root, _, filenames in os.walk(os.path.join(fuel.__path__[0],
                                                   '../docs')):
        for doc in fnmatch.filter(filenames, '*.rst'):
            docs.append(os.path.abspath(os.path.join(root, doc)))
    tests.addTests(doctest.DocFileSuite(
        *docs, module_relative=False, setUp=setup,
        optionflags=doctest.IGNORE_EXCEPTION_DETAIL,
        checker=Py23DocChecker()))

    return tests 
Example #2
Source File: __init__.py    From fuel with MIT License 6 votes vote down vote up
def load_tests(loader, tests, ignore):
    # This function loads doctests from all submodules and runs them
    # with the __future__ imports necessary for Python 2
    for _, module, _ in pkgutil.walk_packages(path=fuel.__path__,
                                              prefix=fuel.__name__ + '.'):
        try:
            tests.addTests(doctest.DocTestSuite(
                module=importlib.import_module(module), setUp=setup,
                optionflags=doctest.IGNORE_EXCEPTION_DETAIL,
                checker=Py23DocChecker()))
        except Exception:
            pass

    # This part loads the doctests from the documentation
    docs = []
    for root, _, filenames in os.walk(os.path.join(fuel.__path__[0],
                                                   '../docs')):
        for doc in fnmatch.filter(filenames, '*.rst'):
            docs.append(os.path.abspath(os.path.join(root, doc)))
    tests.addTests(doctest.DocFileSuite(
        *docs, module_relative=False, setUp=setup,
        optionflags=doctest.IGNORE_EXCEPTION_DETAIL,
        checker=Py23DocChecker()))

    return tests 
Example #3
Source File: test_interface.py    From python-for-android with Apache License 2.0 6 votes vote down vote up
def test_suite():
    suite = unittest.makeSuite(InterfaceTests)
    suite.addTest(doctest.DocTestSuite("zope.interface.interface"))
    if sys.version_info >= (2, 4):
        suite.addTest(doctest.DocTestSuite())
    suite.addTest(doctest.DocFileSuite(
        '../README.txt',
        globs={'__name__': '__main__'},
        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
        ))
    suite.addTest(doctest.DocFileSuite(
        '../README.ru.txt',
        globs={'__name__': '__main__'},
        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
        ))
    return suite 
Example #4
Source File: tests.py    From project-black with GNU General Public License v2.0 6 votes vote down vote up
def test_suite():
    """Simple tes suite"""

    globs = {}
    try:
        from pprint import pprint
        globs['pprint'] = pprint
    except Exception:
        pass
    try:
        from interlude import interact
        globs['interact'] = interact
    except Exception:
        pass

    return unittest.TestSuite([
        doctest.DocFileSuite(
            file,
            optionflags=optionflags,
            globs=globs,
        ) for file in TESTFILES
    ]) 
Example #5
Source File: suites.py    From dragonfly with GNU Lesser General Public License v3.0 6 votes vote down vote up
def build_suite(suite, names):
    # Determine the root directory of the source code files.  This is
    #  used for finding doctest files specified relative to that root.
    project_root = os.path.join(os.path.dirname(__file__), "..", "..")
    project_root = os.path.abspath(project_root)

    # Load test cases from specified names.
    loader = unittest.defaultTestLoader
    for name in names:
        if name.startswith("."):
            name = "dragonfly.test" + name
            suite.addTests(loader.loadTestsFromName(name))
        elif name.startswith("doc:"):
            path = name[4:]
            path = os.path.join(project_root, *path.split("/"))
            path = os.path.abspath(path)
            suite.addTests(doctest.DocFileSuite(path))
        else:
            raise Exception("Invalid test name: %r." % (name,))
    return suite 
Example #6
Source File: test_integration.py    From cr8 with MIT License 6 votes vote down vote up
def load_tests(loader, tests, ignore):
    env = os.environ.copy()
    env['CR8_NO_TQDM'] = 'True'
    node.start()
    assert node.http_host, "http_url must be available"
    tests.addTests(doctest.DocFileSuite(
        os.path.join('..', 'README.rst'),
        globs={
            'sh': functools.partial(
                subprocess.run,
                stdin=subprocess.PIPE,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                timeout=60,
                shell=True,
                env=env
            )
        },
        optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS,
        setUp=setup,
        tearDown=teardown,
        parser=Parser()
    ))
    return tests 
Example #7
Source File: __init__.py    From attention-lvcsr with MIT License 6 votes vote down vote up
def load_tests(loader, tests, ignore):
    # This function loads doctests from all submodules and runs them
    # with the __future__ imports necessary for Python 2
    for _, module, _ in pkgutil.walk_packages(path=blocks.__path__,
                                              prefix=blocks.__name__ + '.'):
        try:
            tests.addTests(doctest.DocTestSuite(
                module=importlib.import_module(module), setUp=setup,
                optionflags=doctest.IGNORE_EXCEPTION_DETAIL))
        except:
            pass

    # This part loads the doctests from the documentation
    docs = []
    for root, _, filenames in os.walk(os.path.join(blocks.__path__[0],
                                                   '../docs')):
        for doc in fnmatch.filter(filenames, '*.rst'):
            docs.append(os.path.abspath(os.path.join(root, doc)))
    tests.addTests(doctest.DocFileSuite(
        *docs, module_relative=False, setUp=setup,
        optionflags=doctest.IGNORE_EXCEPTION_DETAIL))

    return tests 
Example #8
Source File: tests.py    From BruteSploit with GNU General Public License v3.0 6 votes vote down vote up
def test_suite():
    """Simple tes suite"""

    globs = {}
    try:
        from pprint import pprint
        globs['pprint'] = pprint
    except Exception:
        pass
    try:
        from interlude import interact
        globs['interact'] = interact
    except Exception:
        pass

    return unittest.TestSuite([
        doctest.DocFileSuite(
            file,
            optionflags=optionflags,
            globs=globs,
        ) for file in TESTFILES
    ]) 
Example #9
Source File: __init__.py    From Tautulli with GNU General Public License v3.0 6 votes vote down vote up
def additional_tests(suite=None):
    import simplejson
    import simplejson.encoder
    import simplejson.decoder
    if suite is None:
        suite = unittest.TestSuite()
    try:
        import doctest
    except ImportError:
        if sys.version_info < (2, 7):
            # doctests in 2.6 depends on cStringIO
            return suite
        raise
    for mod in (simplejson, simplejson.encoder, simplejson.decoder):
        suite.addTest(doctest.DocTestSuite(mod))
    suite.addTest(doctest.DocFileSuite('../../index.rst'))
    return suite 
Example #10
Source File: tests.py    From Yuki-Chan-The-Auto-Pentest with MIT License 6 votes vote down vote up
def test_suite():
    """Simple tes suite"""

    globs = {}
    try:
        from pprint import pprint
        globs['pprint'] = pprint
    except Exception:
        pass
    try:
        from interlude import interact
        globs['interact'] = interact
    except Exception:
        pass

    return unittest.TestSuite([
        doctest.DocFileSuite(
            file,
            optionflags=optionflags,
            globs=globs,
        ) for file in TESTFILES
    ]) 
Example #11
Source File: test_docstrings.py    From pygsp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_docstrings(root, ext, setup=None):
    files = list(gen_recursive_file(root, ext))
    return doctest.DocFileSuite(*files, setUp=setup, module_relative=False) 
Example #12
Source File: __init__.py    From Flask with Apache License 2.0 5 votes vote down vote up
def additional_tests():
    import doctest, unittest
    suite = unittest.TestSuite((
        doctest.DocFileSuite(
            os.path.join('tests', 'api_tests.txt'),
            optionflags=doctest.ELLIPSIS, package='pkg_resources',
            ),
        ))
    if sys.platform == 'win32':
        suite.addTest(doctest.DocFileSuite('win_script_wrapper.txt'))
    return suite 
Example #13
Source File: __init__.py    From Flask with Apache License 2.0 5 votes vote down vote up
def additional_tests():
    import doctest, unittest
    suite = unittest.TestSuite((
        doctest.DocFileSuite(
            os.path.join('tests', 'api_tests.txt'),
            optionflags=doctest.ELLIPSIS, package='pkg_resources',
            ),
        ))
    if sys.platform == 'win32':
        suite.addTest(doctest.DocFileSuite('win_script_wrapper.txt'))
    return suite 
Example #14
Source File: test_verify.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_suite():
    loader=unittest.TestLoader()
    return unittest.TestSuite((
        doctest.DocFileSuite(
            '../verify.txt',
            optionflags=doctest.NORMALIZE_WHITESPACE),
        loader.loadTestsFromTestCase(Test),
        )) 
Example #15
Source File: test_adapter.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_suite():
    return unittest.TestSuite((
        doctest.DocFileSuite('../adapter.txt', '../adapter.ru.txt',
                                 '../human.txt', '../human.ru.txt',
                                 'foodforthought.txt',
                                 globs={'__name__': '__main__'}),
        doctest.DocTestSuite(),
        )) 
Example #16
Source File: test_math.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    suite.addTest(unittest.makeSuite(IsCloseTests))
    suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite) 
Example #17
Source File: test_doc.py    From ppci with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def load_tests(loader, tests, ignore):
    a = doctest.DocFileSuite('../readme.rst')
    tests.addTests(a)
    return tests 
Example #18
Source File: test_math.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite) 
Example #19
Source File: tests.py    From stopit with MIT License 5 votes vote down vote up
def suite():  # Func for setuptools.setup(test_suite=xxx)
    test_suite = unittest.TestSuite()
    test_suite.addTest(doctest.DocFileSuite('README.rst', globs=signaling_globs))
    if os.name == 'posix':  # Other OS have no support for signal.SIGALRM
        test_suite.addTest(doctest.DocFileSuite('README.rst', globs=threading_globs))
    return test_suite 
Example #20
Source File: __init__.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def additional_tests(suite=None):
    import simplejson
    import simplejson.encoder
    import simplejson.decoder
    if suite is None:
        suite = unittest.TestSuite()
    for mod in (simplejson, simplejson.encoder, simplejson.decoder):
        suite.addTest(doctest.DocTestSuite(mod))
    suite.addTest(doctest.DocFileSuite('../../index.rst'))
    return suite 
Example #21
Source File: test_math.py    From android_universal with MIT License 5 votes vote down vote up
def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    suite.addTest(unittest.makeSuite(IsCloseTests))
    suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite) 
Example #22
Source File: doctests.py    From Ciw with MIT License 5 votes vote down vote up
def load_tests(loader, tests, ignorex):
    for root, dirs, files in os.walk("."):
        for f in files:
            if f.endswith(".rst"):
                 tests.addTests(doctest.DocFileSuite(os.path.join(root, f),
                    optionflags=doctest.ELLIPSIS))

    return tests 
Example #23
Source File: test_doctest.py    From test_driven_python with MIT License 5 votes vote down vote up
def load_tests(loader, tests, pattern):
    tests.addTests(doctest.DocTestSuite(stock, globs={
        "datetime": datetime,
        "Stock": stock.Stock
    }, setUp=setup_stock_doctest))
    options = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
    tests.addTests(doctest.DocFileSuite("readme.txt", package="stock_alerter", optionflags=options))
    return tests 
Example #24
Source File: tests_extensions.py    From django-ca with GNU General Public License v3.0 5 votes vote down vote up
def load_tests(loader, tests, ignore):
    docs_path = os.path.join(settings.DOC_DIR, 'python', 'extensions.rst')
    tests.addTests(doctest.DocTestSuite('django_ca.extensions'))
    tests.addTests(doctest.DocFileSuite(docs_path, module_relative=False))
    return tests 
Example #25
Source File: all.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def additional_tests():
    # print "here-000000000000000"
    # print "-----", glob(os.path.join(os.path.dirname(__file__), '*.doctest'))
    dir = os.path.dirname(__file__)
    paths = glob(os.path.join(dir, '*.doctest'))
    files = [os.path.basename(path) for path in paths]
    return unittest.TestSuite([doctest.DocFileSuite(file) for file in files])


# if os.path.split(path)[-1] != 'index.rst'
# skips time-dependent doctest in index.rst 
Example #26
Source File: test_math.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite) 
Example #27
Source File: test_docstrings.py    From pyunlocbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_docstrings(root, ext):
    files = list(gen_recursive_file(root, ext))
    return doctest.DocFileSuite(*files, module_relative=False)


# Docstrings from reference documentation. 
Example #28
Source File: tests.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(doctest.DocFileSuite(
        'README.txt', checker=checker,
        setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown))
    suite.addTest(doctest.DocTestSuite(
        setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown,
        checker=checker))
    # Add unittest test cases from this module
    suite.addTest(unittest.defaultTestLoader.loadTestsFromName(__name__))
    return suite 
Example #29
Source File: test_math.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite) 
Example #30
Source File: __init__.py    From qgis-cartodb with GNU General Public License v2.0 5 votes vote down vote up
def additional_tests(suite=None):
    import simplejson
    import simplejson.encoder
    import simplejson.decoder
    if suite is None:
        suite = unittest.TestSuite()
    for mod in (simplejson, simplejson.encoder, simplejson.decoder):
        suite.addTest(doctest.DocTestSuite(mod))
    suite.addTest(doctest.DocFileSuite('../../index.rst'))
    return suite