Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def document(self, rst, plugin):
ssn = session.Session()
ssn.configClass = ssn.config = config = ConfigBucket()
ssn.pluginargs = opts = OptBucket()
plugin_name = plugin.__name__
config = ssn.config
obj = plugin(session=ssn)
try:
obj.pluginsLoaded(events.PluginsLoadedEvent([obj]))
except AttributeError:
pass
# config options
if config.vars:
self.add_config(rst, config, plugin)
# command-line options
if opts.opts:
self.headline(rst, u'Command-line options')
for opt in opts:
for line in opt.options():
rst.append(line, AD)
rst.append('', AD)
# class __doc__
def __init__(self, pluginsLoaded, **kw):
self.pluginsLoaded = pluginsLoaded
super(PluginsLoadedEvent, self).__init__(**kw)
ssn.testRunner = runner_
# load and register plugins, forcing multiprocess to the end
ssn.plugins = [
plugin(session=ssn) for plugin in session_export['pluginClasses']
if plugin is not MultiProcess
]
rlog.debug("Plugins loaded: %s", ssn.plugins)
for plugin in ssn.plugins:
plugin.register()
rlog.debug("Registered %s in subprocess", plugin)
# instantiating the plugin will register it.
ssn.plugins.append(MultiProcess(session=ssn))
rlog.debug("Registered %s in subprocess", MultiProcess)
ssn.plugins[-1].pluginsLoaded(events.PluginsLoadedEvent(ssn.plugins))
return ssn
# plugins set directly
if modules is None:
modules = []
if exclude is None:
exclude = []
# plugins mentioned in config file(s)
cfg = self.unittest
more_plugins = cfg.as_list('plugins', [])
cfg_exclude = cfg.as_list('exclude-plugins', [])
exclude.extend(cfg_exclude)
exclude = set(exclude)
all_ = (set(modules) | set(more_plugins)) - exclude
log.debug("Loading plugin modules: %s", all_)
for module in sorted(all_):
self.loadPluginsFromModule(util.module_from_name(module))
self.hooks.pluginsLoaded(events.PluginsLoadedEvent(self.plugins))