Sunday, October 06, 2013

Skipping Test DB Creation in Django

One of my colleagues at Caktus Group, Mark, as written up one of the most useful tips for Django developers trying to make good test coverage easier to digest for you team. Test running time is often a barrier to getting teams to follow good testing practices.
Now what if you are running a set of tests which are only using SimpleTestCase or the base unittest.TestCase? Then you don't really need the test database creation at all. Depending on the backend you are using, the number of tables you have and the number of tests you are running the database creation can take many times longer than running the test themselves.
... we can skip the database creation/teardown.
I recommend any Django developers taking a look at the very simple solution he's come up with, which I'm planning to absorb into all of my projects quickly.

No comments:

I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive