Strategies for Speeding Up Django 1.8 Tests?

49 views
Skip to first unread message

Robert F.

unread,
Sep 22, 2015, 1:22:51 PM9/22/15
to Django users
Does anyone have any strategies or techniques for running their unit tests faster in Django 1.8?  My project has seven model modules containing twenty-one models (none of which are very complex).  I run my tests using the default Django test runner on a 1.86 GHz Mac laptop with 4 GB of RAM against a local PostgreSQL 9.4.4 database.  I'm finding that after upgrading to Django 1.8, my test suite takes longer to start up (about 10-11 seconds) than it takes to run the 180+ tests themselves (about 9 seconds).  I know one strategy would be to use SQLite for testing but I'd prefer to run against my actual database server.  I'm also using the django-test-without-migrations package to avoid running migrations but that only speeds things up a little.  Is there anything else I can do?  The longer startup time for tests in Django 1.8 really makes it difficult to do true test-driven development.

Thanks.

Richard

unread,
Sep 22, 2015, 4:19:18 PM9/22/15
to Django users
If you're not changing the schema, you could try using the "-k" option to keep the database between tests. This way it doesn't have to recreate it and the indexes each time you run your tests.
Reply all
Reply to author
Forward
0 new messages