Malcolm Box wrote: > Has anyone got any ideas on how to speed this up - for instance, is there a > way to say "use an existing test database"?
Per my other advice to use fab and a fabfile with a test() target in it, you should set its (local()) target to something like python manage.py test --settings=test_settings You can also look up my _three_most_recently_changed_applications, which looks a little bit like this: http://permalink.gmane.org/gmane.comp.python.fab.user/1093 to test only 3 apps. But I suspect that's not your problem. Do not use production fixtures for test fixtures, and if you must use the spew of dumpdata for fixtures you should manually trim them down to the minimum needed. Name them different from production fixtures. We have, naturally, a "countries.json", for all the regions we are allowed to sell to, and it takes forever to load. I pushed all our tests to use "sample_countries.json", instead, containing only countries that Sarah Palin could name on the spot. This made our tests much faster. And, finally, your test_settings.py file should use a sqlite3, in- memory database: from settings import * DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = ":memory:" >From there, I have only been able to reduce test time down from hours to minutes. Tests ought to run in seconds - so fast that you can run them after every few edits - TDD. The LAMP architectures are spectacularly broke for this endeavor, for a variety of reasons. One of Django's particular sins is it drags all the data from your JSON fixtures into fully resolved models.py objects before saving them. This runs tons of Python code for no reason - you are not testing your models' validations or save routines. The test runner should instead push the JSON contents directly into the database as bulk import statements. The final benefit of ":memory:" is SQLite3 is very fast when it does not save anything to disk, so it's the fastest backend possible for test. -- Phlip http://penbird.tumblr.com/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.