本文整理汇总了Python中doctest.Tester方法的典型用法代码示例。如果您正苦于以下问题:Python doctest.Tester方法的具体用法?Python doctest.Tester怎么用?Python doctest.Tester使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doctest
的用法示例。
在下文中一共展示了doctest.Tester方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import Tester [as 别名]
def __init__(self, mod=None, globs=None, verbose=None,
isprivate=None, optionflags=0):
warnings.warn("class Tester is deprecated; "
"use class doctest.DocTestRunner instead",
DeprecationWarning, stacklevel=2)
if mod is None and globs is None:
raise TypeError("Tester.__init__: must specify mod or globs")
if mod is not None and not inspect.ismodule(mod):
raise TypeError("Tester.__init__: mod must be a module; %r" %
(mod,))
if globs is None:
globs = mod.__dict__
self.globs = globs
self.verbose = verbose
self.isprivate = isprivate
self.optionflags = optionflags
self.testfinder = DocTestFinder(_namefilter=isprivate)
self.testrunner = DocTestRunner(verbose=verbose,
optionflags=optionflags)
示例2: __init__
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import Tester [as 别名]
def __init__(self, mod=None, globs=None, verbose=None, optionflags=0):
warnings.warn("class Tester is deprecated; "
"use class doctest.DocTestRunner instead",
DeprecationWarning, stacklevel=2)
if mod is None and globs is None:
raise TypeError("Tester.__init__: must specify mod or globs")
if mod is not None and not inspect.ismodule(mod):
raise TypeError("Tester.__init__: mod must be a module; %r" %
(mod,))
if globs is None:
globs = mod.__dict__
self.globs = globs
self.verbose = verbose
self.optionflags = optionflags
self.testfinder = DocTestFinder()
self.testrunner = DocTestRunner(verbose=verbose,
optionflags=optionflags)
示例3: old_test2
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import Tester [as 别名]
def old_test2(): r"""
>>> from doctest import Tester
>>> t = Tester(globs={}, verbose=1)
>>> test = r'''
... # just an example
... >>> x = 1 + 2
... >>> x
... 3
... '''
>>> t.runstring(test, "Example")
Running string Example
Trying:
x = 1 + 2
Expecting nothing
ok
Trying:
x
Expecting:
3
ok
0 of 2 examples failed in string Example
TestResults(failed=0, attempted=2)
"""
示例4: test_main
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import Tester [as 别名]
def test_main():
# Check the doctest cases in doctest itself:
test_support.run_doctest(doctest, verbosity=True)
from test import test_doctest
# Ignore all warnings about the use of class Tester in this module.
deprecations = []
if __debug__:
deprecations.append(("class Tester is deprecated", DeprecationWarning))
if sys.py3kwarning:
deprecations += [("backquote not supported", SyntaxWarning),
("execfile.. not supported", DeprecationWarning)]
with test_support.check_warnings(*deprecations):
# Check the doctest cases defined here:
test_support.run_doctest(test_doctest, verbosity=True)
示例5: old_test2
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import Tester [as 别名]
def old_test2(): r"""
>>> from doctest import Tester
>>> t = Tester(globs={}, verbose=1)
>>> test = r'''
... # just an example
... >>> x = 1 + 2
... >>> x
... 3
... '''
>>> t.runstring(test, "Example")
Running string Example
Trying:
x = 1 + 2
Expecting nothing
ok
Trying:
x
Expecting:
3
ok
0 of 2 examples failed in string Example
(0, 2)
"""