Loader: Egg Test discovery

What is Egg Discovery

Sometimes Python Eggs are marked as zip-safe and they can be installed zipped, instead of unzipped in an .egg folder. See http://peak.telecommunity.com/DevCenter/PythonEggs for more details. The normal nose2.plugins.loader.discovery plugin ignores modules located inside zip files.

The Egg Discovery plugin allows nose2 to discover tests within these zipped egg files.

This plugin requires pkg_resources (from setuptools) to work correctly.

Usage

To activate the plugin, include the plugin module in the plugins list in [unittest] section in a config file:

[unittest]
plugins = nose2.plugins.loader.eggdiscovery

Or pass the module with the --plugin command-line option:

nose2 --plugin=nose2.plugins.loader.eggdiscovery module_in_egg

Reference

Egg-based discovery test loader.

This plugin implements nose2’s automatic test module discovery inside Egg Files. It looks for test modules in packages whose names start with test, then fires the loadTestsFromModule() hook for each one to allow other plugins to load the actual tests.

It also fires handleFile() for every file that it sees, and matchPath() for every Python module, to allow other plugins to load tests from other kinds of files and to influence which modules are examined for tests.

Enable this Plugin

This plugin is built-in, but not loaded by default.

Even if you specify always-on = True in the configuration, it will not run unless you also enable it. You can do so by putting the following in a unittest.cfg or nose2.cfg file

[unittest]
plugins = nose2.plugins.loader.eggdiscovery

The plugins parameter may contain a list of plugin names, including nose2.plugins.loader.eggdiscovery

Configuration [discovery]

always-on
Default

True

Type

boolean

Sample configuration

The default configuration is equivalent to including the following in a unittest.cfg file.

[discovery]
always-on = True

Plugin class reference: EggDiscoveryLoader

class nose2.plugins.loader.eggdiscovery.EggDiscoveryLoader(*args, **kwargs)[source]

Loader plugin that can discover tests inside Egg Files

loadTestsFromName(event)[source]

Load tests from module named by event.name

loadTestsFromNames(event)[source]

Discover tests if no test names specified