Skip to main content

A plugin for nose to easily specify an initialization script

Project description

A nose plugin, enabled by default, which executes a user-defined initialization function prior to nose collecting or running any tests. The user specifies the python module that contains the initialization function, main, in an environment variable.

Use one of two environment variables to specify the module:

NOSE_INIT_MODULE=app.tests.nose_init
NOSE_INIT_PATH=/path/to/my/app/tests/nose_init.py

Then, run your nose tests as usual.

Example initialization module

Let’s assume that we’ve named our initialization module nose_init.py and saved it in /path/to/my/app/tests/nose_init.py. That file must contain a main function. For example:

"""
Initialization script which is imported when ``nosetests`` is run.
The main function will be executed before any other application code
is imported.
"""

def main():
    """nose_easy_init will call this before each ``nosetests`` run."""

    setup_my_test_environment()
    setup_my_test_database()
    etc()

Then, before running nosetests, set one of two environment variables to specify the module:

NOSE_INIT_MODULE=app.tests.nose_init
NOSE_INIT_PATH=/path/to/my/app/tests/nose_init.py

Note that if both the environment variables are defined, the filesystem path, NOSE_INIT_PATH, will take precedence over NOSE_INIT_MODULE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nose-easy-init-1.0.2.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file nose-easy-init-1.0.2.tar.gz.

File metadata

File hashes

Hashes for nose-easy-init-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fbc8496b21e12f086a55c527c3c1db443dbf55fb257214e8a33affad7dea7f83
MD5 a5bd8c2e980b807187d2c7cfd61d6973
BLAKE2b-256 0347334097e15695aa1f2dda8847b39c08037b675163d464f2ee6c7f652367f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page