I was reading through some of the django test documentation and discovered that when your db backend is sqlite3, your test database is created in-memory. I don’t run my test suite as often as I should because it takes a long time (several minutes — I have a real short attention span). An in-memory database means that there’s no disk activity, which means it’s going to be fast.
I almost hacked the django.core.management.commands.test to add a command line switch to flip to the sqlite database backend, but luckily I found this discussion http://groups.google.com/group/django-developers/browse_thread/thread/210a3d91aec17141/6177289b341c8100 (someone alread thought of this idea about 2 years ago )
The solution is this:
Create a new test-settings.py file next to your app’s settings.py containing:
from projectname.settings import *
DATABASE_ENGINE = 'sqlite3'
Then when you want to run tests real fast, instead of manage.py test, you run
manage.py test --settings=test-settings
This runs my test suite in less than 5 seconds.
Obviously you still want to run tests on your real db backend, but this is awesome for sanity checks, and while you’re doing test development.