Pre-compile fixtures for unit tests.
Review Request #4564 — Created Sept. 13, 2013 and submitted — Latest diff uploaded
Pre-compile fixtures for unit tests.
Django's fixture support is extraordinarily inefficient. For every
single unit test, it does the following:
- Recalculates the list of possible fixture directories
- Locates each fixture file within those directories
- Tries to figure out how to deserialize them
- Deserializes them
- Saves them
That's done per-test. Most of those operations are things that could be
easily cached, including the deserialized fixture content.
Our TestCase rewrites fixture loading to do just this. When we see a new
fixture, we precompile it, getting the list of objects and storing it.
We then use that precompiled version whenever the fixture is requested
for future tests.
This saves 10 seconds on the test suite.
Ran 746 tests in 80.604s