[Django]-Accelerate unittest in Django

2👍

What I do is switch to SQLite when I want to run tests. It takes a lot less time to setup the test database in SQLite.

You can easily accomplish this by using a modified settings file:

$ python manage.py test my_app --settings=test_settings

Or in my case,

$ python manage.py test my_app --settings=settings.test

as I use the “settings as a package” scheme.

2👍

You can accelerate tests runing them in sqlite db stored in memory

    DATABASES['default'] = {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':memory:'
    }

0👍

Take a look at this article. It has many useful tips like:

  • Changing the password hashing function to MD5 (made huge improvement for me).
  • Using a faster in-memory DB.
  • Disabling unneeded apps and middleware.
👤Tzach

Leave a comment