本文整理汇总了Python中nose.plugins.doctests.Doctest方法的典型用法代码示例。如果您正苦于以下问题:Python doctests.Doctest方法的具体用法?Python doctests.Doctest怎么用?Python doctests.Doctest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.plugins.doctests
的用法示例。
在下文中一共展示了doctests.Doctest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadTestsFromModule
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def loadTestsFromModule(self, module):
if not self.matches(module.__name__):
npd.log.debug("Doctest doesn't want module %s", module)
return
try:
tests = self.finder.find(module)
except AttributeError:
# nose allows module.__test__ = False; doctest does not and
# throws AttributeError
return
if not tests:
return
tests.sort()
module_file = src(module.__file__)
for test in tests:
if not test.examples:
continue
if not test.filename:
test.filename = module_file
# Set test namespace; test altered in place
self.set_test_context(test)
yield self.doctest_case_class(test,
optionflags=self.doctest_optflags,
checker=self.out_check_class(),
result_var=self.doctest_result_var)
# Add an afterContext method to nose.plugins.doctests.Doctest in order
# to restore print options to the original state after each doctest
示例2: wantFile
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def wantFile(self, file):
bn = os.path.basename(file)
if bn in self.doctest_ignore:
return False
return npd.Doctest.wantFile(self, file)
示例3: loadTestsFromModule
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def loadTestsFromModule(self, module):
#print '*** ipdoctest - lTM',module # dbg
if not self.matches(module.__name__):
log.debug("Doctest doesn't want module %s", module)
return
tests = self.finder.find(module,globs=self.globs,
extraglobs=self.extraglobs)
if not tests:
return
# always use whitespace and ellipsis options
optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
tests.sort()
module_file = module.__file__
if module_file[-4:] in ('.pyc', '.pyo'):
module_file = module_file[:-1]
for test in tests:
if not test.examples:
continue
if not test.filename:
test.filename = module_file
yield DocTestCase(test,
optionflags=optionflags,
checker=self.checker)
示例4: configure
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def configure(self, options, config):
# it is overriden in order to fix doctest options discovery
Plugin.configure(self, options, config)
self.doctest_result_var = options.doctest_result_var
self.doctest_tests = options.doctest_tests
self.extension = tolist(options.doctestExtension)
self.fixtures = options.doctestFixtures
self.finder = doctest.DocTestFinder()
#super(DoctestPluginHelper, self).configure(options, config)
self.optionflags = 0
self.options = {}
if options.doctestOptions:
stroptions = ",".join(options.doctestOptions).split(',')
for stroption in stroptions:
try:
if stroption.startswith('+'):
self.optionflags |= doctest.OPTIONFLAGS_BY_NAME[stroption[1:]]
continue
elif stroption.startswith('-'):
self.optionflags &= ~doctest.OPTIONFLAGS_BY_NAME[stroption[1:]]
continue
try:
key,value=stroption.split('=')
except ValueError:
pass
else:
if not key in self.OPTION_BY_NAME:
raise ValueError()
self.options[key]=value
continue
except (AttributeError, ValueError, KeyError):
raise ValueError("Unknown doctest option {}".format(stroption))
else:
raise ValueError("Doctest option is not a flag or a key/value pair: {} ".format(stroption))
示例5: loadPlugins
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def loadPlugins(self):
for plug in builtin.plugins:
if plug != Doctest:
self.addPlugin(plug())
self.addPlugin(DoctestFix())
super(NltkPluginManager, self).loadPlugins()
示例6: loadPlugins
# 需要导入模块: from nose.plugins import doctests [as 别名]
# 或者: from nose.plugins.doctests import Doctest [as 别名]
def loadPlugins(self):
for plug in builtin.plugins:
if plug != Doctest:
self.addPlugin(plug())
self.addPlugin(DoctestFix())
if rednose_available:
self.addPlugin(RedNose())
super(NltkPluginManager, self).loadPlugins()