本文整理汇总了Python中doctest.IGNORE_EXCEPTION_DETAIL属性的典型用法代码示例。如果您正苦于以下问题:Python doctest.IGNORE_EXCEPTION_DETAIL属性的具体用法?Python doctest.IGNORE_EXCEPTION_DETAIL怎么用?Python doctest.IGNORE_EXCEPTION_DETAIL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类doctest
的用法示例。
在下文中一共展示了doctest.IGNORE_EXCEPTION_DETAIL属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [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
示例2: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [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
示例3: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def load_tests(loader, tests, ignore):
module_doctests = [
urwid.widget,
urwid.wimp,
urwid.decoration,
urwid.display_common,
urwid.main_loop,
urwid.monitored_list,
urwid.raw_display,
'urwid.split_repr', # override function with same name
urwid.util,
urwid.signals,
]
for m in module_doctests:
tests.addTests(doctest.DocTestSuite(m,
optionflags=doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL))
return tests
示例4: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [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
示例5: _run_doctest_for_content
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def _run_doctest_for_content(self, name, content):
optionflags = (
doctest.ELLIPSIS
| doctest.NORMALIZE_WHITESPACE
| doctest.IGNORE_EXCEPTION_DETAIL
| _get_allow_unicode_flag()
)
runner = doctest.DocTestRunner(
verbose=None,
optionflags=optionflags,
checker=_get_unicode_checker(),
)
globs = {"print_function": print_function}
parser = doctest.DocTestParser()
test = parser.get_doctest(content, globs, name, name, 0)
runner.run(test)
runner.summarize()
assert not runner.failures
示例6: _get_flag_lookup
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def _get_flag_lookup():
import doctest
return dict(
DONT_ACCEPT_TRUE_FOR_1=doctest.DONT_ACCEPT_TRUE_FOR_1,
DONT_ACCEPT_BLANKLINE=doctest.DONT_ACCEPT_BLANKLINE,
NORMALIZE_WHITESPACE=doctest.NORMALIZE_WHITESPACE,
ELLIPSIS=doctest.ELLIPSIS,
IGNORE_EXCEPTION_DETAIL=doctest.IGNORE_EXCEPTION_DETAIL,
COMPARISON_FLAGS=doctest.COMPARISON_FLAGS,
ALLOW_UNICODE=_get_allow_unicode_flag(),
ALLOW_BYTES=_get_allow_bytes_flag(),
)
示例7: testsuite
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def testsuite():
import doctest
return doctest.DocTestSuite(optionflags=doctest.IGNORE_EXCEPTION_DETAIL)
示例8: test
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def test():
import doctest
fails, tests = doctest.testmod(optionflags=doctest.IGNORE_EXCEPTION_DETAIL)
sys.exit(min(1, fails))
示例9: _get_flag_lookup
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def _get_flag_lookup() -> Dict[str, int]:
import doctest
return dict(
DONT_ACCEPT_TRUE_FOR_1=doctest.DONT_ACCEPT_TRUE_FOR_1,
DONT_ACCEPT_BLANKLINE=doctest.DONT_ACCEPT_BLANKLINE,
NORMALIZE_WHITESPACE=doctest.NORMALIZE_WHITESPACE,
ELLIPSIS=doctest.ELLIPSIS,
IGNORE_EXCEPTION_DETAIL=doctest.IGNORE_EXCEPTION_DETAIL,
COMPARISON_FLAGS=doctest.COMPARISON_FLAGS,
ALLOW_UNICODE=_get_allow_unicode_flag(),
ALLOW_BYTES=_get_allow_bytes_flag(),
NUMBER=_get_number_flag(),
)
示例10: test
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def test(args):
"""Run tests (--test)."""
return test_suite(args, unittest.TestSuite((
TestLoader().load_tests_from_subclass(UnitTestCase),
doctest.DocTestSuite(optionflags=(
doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL)),
)))
示例11: load_tests
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def load_tests(loader, tests, ignore):
flags = (doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL)
tests.addTests(doctest.DocTestSuite(fake_providers, optionflags=flags))
return tests
示例12: test_main
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import IGNORE_EXCEPTION_DETAIL [as 别名]
def test_main(arith=None, verbose=None, todo_tests=None, debug=None):
""" Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py
"""
init(C)
init(P)
global TEST_ALL, DEBUG
TEST_ALL = arith if arith is not None else is_resource_enabled('decimal')
DEBUG = debug
if todo_tests is None:
test_classes = all_tests
else:
test_classes = [CIBMTestCases, PyIBMTestCases]
# Dynamically build custom test definition for each file in the test
# directory and add the definitions to the DecimalTest class. This
# procedure insures that new files do not get skipped.
for filename in os.listdir(directory):
if '.decTest' not in filename or filename.startswith("."):
continue
head, tail = filename.split('.')
if todo_tests is not None and head not in todo_tests:
continue
tester = lambda self, f=filename: self.eval_file(directory + f)
setattr(CIBMTestCases, 'test_' + head, tester)
setattr(PyIBMTestCases, 'test_' + head, tester)
del filename, head, tail, tester
try:
run_unittest(*test_classes)
if todo_tests is None:
from doctest import IGNORE_EXCEPTION_DETAIL
savedecimal = sys.modules['decimal']
if C:
sys.modules['decimal'] = C
run_doctest(C, verbose, optionflags=IGNORE_EXCEPTION_DETAIL)
sys.modules['decimal'] = P
run_doctest(P, verbose)
sys.modules['decimal'] = savedecimal
finally:
if C: C.setcontext(ORIGINAL_CONTEXT[C])
P.setcontext(ORIGINAL_CONTEXT[P])
if not C:
warnings.warn('C tests skipped: no module named _decimal.',
UserWarning)
if not orig_sys_decimal is sys.modules['decimal']:
raise TestFailed("Internal error: unbalanced number of changes to "
"sys.modules['decimal'].")