How to use the nose2.events.PluginsLoadedEvent function in nose2

To help you get started, we’ve selected a few nose2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nose-devs / nose2 / nose2 / sphinxext.py View on Github external
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__
github nose-devs / nose2 / nose2 / events.py View on Github external
def __init__(self, pluginsLoaded, **kw):
        self.pluginsLoaded = pluginsLoaded
        super(PluginsLoadedEvent, self).__init__(**kw)
github nose-devs / nose2 / nose2 / plugins / mp.py View on Github external
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
github nose-devs / nose2 / nose2 / session.py View on Github external
# 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))