Hi Folks,
I've been working on speeding up a django-1.7 applications unit tests to encourage developers to write more of them. Currently, django's strategy for ensuring that its database is fresh for each test run is to create a new test database and run all of the migrations on it. I've noticed that the bulk of the time is spent on spinning up the test database. This was also the case in a previous project that I worked on that ran django-1.4.
I recently had an idea: why not, after running the migrations on the newly-spun-up database, store a representation of that database somewhere that could be more quickly loaded? I suspect this would be particularly useful for an in-memory test database like sqlite, especially if someone was using a tool like
watchdog to automatically run their tests each time they changed one of their applications' files. This cache could be accompanied by a hash of all of the migrations that needed to be run and would only need to change when one of the applications listed in settings.INSTALLED_APPS had a change to its migrations.
This is of course going to be running up against one of the 2 hard things in computer science: cache invalidation. So, I wanted to get y'alls opinions on whether this was worth attempting.
cheers,
Andrew