本文整理汇总了Python中nose.plugins.builtin.plugins方法的典型用法代码示例。如果您正苦于以下问题:Python builtin.plugins方法的具体用法?Python builtin.plugins怎么用?Python builtin.plugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.plugins.builtin
的用法示例。
在下文中一共展示了builtin.plugins方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeCall
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def makeCall(self, call):
if call == 'loadTestsFromNames':
# special case -- load tests from names behaves somewhat differently
# from other chainable calls, because plugins return a tuple, only
# part of which can be chained to the next plugin.
return self._loadTestsFromNames
meth = self.method
if getattr(meth, 'generative', False):
# call all plugins and yield a flattened iterator of their results
return lambda *arg, **kw: list(self.generate(*arg, **kw))
elif getattr(meth, 'chainable', False):
return self.chain
else:
# return a value from the first plugin that returns non-None
return self.simple
示例2: generate
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def generate(self, *arg, **kw):
"""Call all plugins, yielding each item in each non-None result.
"""
for p, meth in self.plugins:
result = None
try:
result = meth(*arg, **kw)
if result is not None:
for r in result:
yield r
except (KeyboardInterrupt, SystemExit):
raise
except:
exc = sys.exc_info()
yield Failure(*exc)
continue
示例3: __init__
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def __init__(self, call, plugins):
try:
self.method = getattr(self.interface, call)
except AttributeError:
raise AttributeError("%s is not a valid %s method"
% (call, self.interface.__name__))
self.call = self.makeCall(call)
self.plugins = []
for p in plugins:
self.addPlugin(p, call)
示例4: addPlugin
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def addPlugin(self, plugin, call):
"""Add plugin to my list of plugins to call, if it has the attribute
I'm bound to.
"""
meth = getattr(plugin, call, None)
if meth is not None:
if call == 'loadTestsFromModule' and \
len(inspect.getargspec(meth)[0]) == 2:
orig_meth = meth
meth = lambda module, path, **kwargs: orig_meth(module)
self.plugins.append((plugin, meth))
示例5: chain
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def chain(self, *arg, **kw):
"""Call plugins in a chain, where the result of each plugin call is
sent to the next plugin as input. The final output result is returned.
"""
result = None
# extract the static arguments (if any) from arg so they can
# be passed to each plugin call in the chain
static = [a for (static, a)
in zip(getattr(self.method, 'static_args', []), arg)
if static]
for p, meth in self.plugins:
result = meth(*arg, **kw)
arg = static[:]
arg.append(result)
return result
示例6: _loadTestsFromNames
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def _loadTestsFromNames(self, names, module=None):
"""Chainable but not quite normal. Plugins return a tuple of
(tests, names) after processing the names. The tests are added
to a suite that is accumulated throughout the full call, while
names are input for the next plugin in the chain.
"""
suite = []
for p, meth in self.plugins:
result = meth(names, module=module)
if result is not None:
suite_part, names = result
if suite_part:
suite.extend(suite_part)
return suite, names
示例7: addPlugins
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def addPlugins(self, plugins):
raise NotImplementedError()
示例8: __iter__
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def __iter__(self):
return iter(self.plugins)
示例9: configure
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def configure(self, options, config):
"""Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.
"""
log.debug("Configuring plugins")
self.config = config
cfg = PluginProxy('configure', self._plugins)
cfg(options, config)
enabled = [plug for plug in self._plugins if plug.enabled]
self.plugins = enabled
self.sort()
log.debug("Plugins enabled: %s", enabled)
示例10: _set_plugins
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def _set_plugins(self, plugins):
self._plugins = []
self.addPlugins(plugins)
示例11: loadPlugins
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def loadPlugins(self):
"""Load plugins by iterating the `nose.plugins` entry point.
"""
from pkg_resources import iter_entry_points
loaded = {}
for entry_point, adapt in self.entry_points:
for ep in iter_entry_points(entry_point):
if ep.name in loaded:
continue
loaded[ep.name] = True
log.debug('%s load plugin %s', self.__class__.__name__, ep)
try:
plugcls = ep.load()
except KeyboardInterrupt:
raise
except Exception, e:
# never want a plugin load to kill the test run
# but we can't log here because the logger is not yet
# configured
warn("Unable to load plugin %s: %s" % (ep, e),
RuntimeWarning)
continue
if adapt:
plug = adapt(plugcls())
else:
plug = plugcls()
self.addPlugin(plug)
super(EntryPointPluginManager, self).loadPlugins()
示例12: loadPlugins
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [as 别名]
def loadPlugins(self):
for plug in builtin.plugins:
if plug != Doctest:
self.addPlugin(plug())
self.addPlugin(DoctestFix())
super(NltkPluginManager, self).loadPlugins()
示例13: loadPlugins
# 需要导入模块: from nose.plugins import builtin [as 别名]
# 或者: from nose.plugins.builtin import plugins [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()