本文整理匯總了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()