Fixtures with nose

So, I’ve finally started working on the database and ran into the biggest problem yet with my nose setup. Specifically, django needs a test database setup before tests of the model object.

To do this, I first tried to find a modern django plugin for nose (with no luck). I then found nose fixtures, which allowed me to setup and teardown the test database for my tests package.

Here’s the __init__.py file for it:

from django.test import utils
from django.conf import settings
from django.db import connection

database_name = None

def setup():
    """Setup the various django fixtures."""
    database_name = settings.DATABASE_NAME
    utils.setup_test_environment()
    connection.creation.create_test_db()

def teardown():
    """Tear down the fixtures and database."""
    connection.creation.destroy_test_db(database_name)
    utils.teardown_test_environment()

Comments are closed.