Speeding Up Django Tests by Using SQLite

I know, I know. It’s a bad idea to run your tests using a different database than the one you use in production. But tests that involve the database can be soooo slow because it takes so long to setup the test database. I have one project that uses PostgreSQL and the test database setup takes 60 seconds!

Others have suggested that using SQLite for tests can dramatically speed things up. I have some smaller Django projects that use SQLite in production. Their tests are blazingly fast. Maybe there is some truth to this.

To test this, I temporarily changed my settings from PostgreSQL to SQLite for my big project. The results were underwhelming. Setup time dropped from 60 seconds to 45 seconds. Not worth the headaches of testing with a different DB in development and production.

Then again, I would never actually test with a different database because that would be wrong.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s