What's the best way to optimise the fixture-loading part of Django tests?
my Djan开发者_如何学Cgo tests run really slowly, but it's not the test's fault.
At the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures
.
What's the best way to deal with this? I think there is a way of specifying which fixtures
to load in each test, but I need most of them to do most tests...
A solution I think would work is if the tests didn't drop the tables after each run, that way there would be no need to create & populate the database each run-through of the tests. Most tests don't even write to the DB.
What's the best way to optimise the fixture
-loading part of Django tests?
Thanks!
(I'm using nose
, but otherwise just plain Django and sqlite
)
EDIT: I should have mentioned that I'm using an in-memory sqlite database. What I'm looking for - specifically - is an optimisation of the fixture-loading section of the test.
"but I need most of them to do most tests"...
Sorry about this, but to speed things up you're going to have to do some thinking.
"I think there is a way of specifying which fixtures to load in each test"
This is a disturbing thing to read. Have you looked at your tests recently?
Your tests do -- specifically -- list the fixtures. You need to minimize that list.
You may use sqlite in-memory database for tests - it really fast
精彩评论