Speed up Django tests (PostgreSQL database)

Speed up Django tests (PostgreSQL database)

15. siječnja 2016. 12:18 drazen Django

 

Changing following options in PostgreSQL configuration (postgres.conf) will, to a small degree, speed up tests:

fsync = off
synchronous_commit = off
full_page_writes = off

Do not use that configuration on production server!

Ref: Postgres Non-Durable Settings

Django tests are running slow since every time test is run, test database is newly created.

Most important speed up is gained with argument --keepdb when running Django tests.

$ python manage.py test app.tests --keepdb

--keepdb will create test database if not exists, so every following test run will use existing test database :)

It is introduced in Django version 1.8 (older versions do not have --keepdb option)

Ref: django-admin --keepdb