Skip to main content

nose2django

A plugin pair for nose2 that runs your django (>=1.4) tests through the nose2 command and also supports django-configurations settings management. It lets django initialise the test environment and setup the order of the test suite, but nose2/unittest2 handles the test discovery and execution.

There is another project called django-nose which is authored by one of the nose2 devs. It uses the standard django approach of setting an alternative test runner and running via manage.py. I was interested with the move to shift setup.py configuration into setup.cfg and wanted to try that pattern for running tests rather that wrapping configuration into a custom test runner. Modern django has refactored the way a project is initialised which means there is less dependency on using manage.py and django-admin.py as the only possible entry points into your django project.

Installation

$ pip install nose2django

Create a nose2.cfg file in your project’s root directory (where manage.py is) and register the plugins in the correct order:

[unittest]
plugins = nose2django.config
        nose2django.nose2django

[django-config]
always-on = True

# optional settings
settings = yourproject.settings
configuration = YourTestConfiguration

[django-runner]
always-on = True

You can optionally set the settings and configuration to a django settings module and a django-configurations configuration. It takes precedence over any existing environment.

Usage

As per nose2, optionally with either of the django-runner options.

$ nose2 --settings=example.settings.test --configuration=TestSettings

Patterns

For django app test driven development of apps you want only as much django settings as required. Create a tests folder in your top level directory (avoid using the name tests - use something like test_yourapp to avoid name clashes), and put a minimal settings file in there and an __init__.py file to make it importable. Something like:

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3' }
}

    INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'yourapp',
)
    ROOT_URLCONF='yourapp.urls', # if you have urls
    SECRET_KEY = '1234'

Acknowledgements

nose2django re-uses parts of the existing django test runner code as licensed by django.

Changelog

v0.1.2 (2013-4-13)

  • Add South compatibility.

v0.1.1 (2013-4-6)

  • Fix issue with django logging setup when nose -v.

v0.1 (2013-03-29)

  • Initial public (correctly packaged) release. Thanks tox.

Metadata

Release files for nose2django 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nose2django 0.1.2
File Size Uploaded
nose2django-0.1.2.tar.gz 4.8 kB Details

Release files / nose2django-0.1.2.tar.gz

Download URL nose2django-0.1.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2bef1861830459d48e37338f7a404b684934baf4235fb1b81cb8c39c62adda3a
BLAKE2b-256 checksum
How to use checksums
97859de984e2b873ba5b8d76b34eb648950211244a73c8703d02cad332bb4682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page