本文整理汇总了Python中doctest.DocFileSuite方法的典型用法代码示例。如果您正苦于以下问题:Python doctest.DocFileSuite方法的具体用法?Python doctest.DocFileSuite怎么用?Python doctest.DocFileSuite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doctest
的用法示例。
在下文中一共展示了doctest.DocFileSuite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_suite
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
])
示例2: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例3: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例4: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例5: build_suite
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例6: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例7: test_suite
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例8: additional_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例9: additional_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例10: additional_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例11: additional_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
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
示例12: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
def load_tests(loader, tests, ignore):
cd = ChdirTemp()
tests.addTests(
doctest.DocFileSuite(
"../README.md",
parser=ReadmeTestParser(),
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE,
setUp=cd.setUp,
tearDown=cd.tearDown,
)
)
return tests
示例13: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
def load_tests(loader, tests, ignore):
for root, dirs, files in os.walk("."):
if "venv" not in root:
for f in files:
if f.endswith(".rst") or f.endswith(".md"):
tests.addTests(
doctest.DocFileSuite(
os.path.join(root, f), optionflags=doctest.ELLIPSIS
)
)
return tests
示例14: test_main
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
def test_main():
from doctest import DocFileSuite
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MathTests))
suite.addTest(DocFileSuite("ieee754.txt"))
run_unittest(suite)
示例15: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import DocFileSuite [as 别名]
def load_tests(loader, tests, ignore):
tests.addTests(doctest.DocFileSuite('../../../../README.rst'))
return tests