Nicolas Le Manchet

Testing reusable Django apps

I added a Django integration to Spinach, my Redis task queue for Python. It comes in the form of a small Django application. Naturally I wanted to write automated tests to make sure I don't break it by mistake in the future.

Since the code lives in the main Spinach repository, I didn't want to setup a full Django project just for the sake of testing. It turns out this is not needed, Django can be bootstrapped right from the test suite:

import django
import django.conf

def test_django_app():
    django.conf.settings.configure(
        INSTALLED_APPS=('spinach.contrib.spinachd',),
    )
    django.setup()

    # Start testing here