How to avoid creating a test database for testing in django?

I wrote some test cases for my project, when I run these test cases, it creates a test database each time for the default alias after sending the message, and then destroys the database. I am only worried with the message . So, how to avoid creating a test database because it takes a lot of time.

username$ ./manage.py test ............... Some message, I Want only this message ............... Creating test database for alias 'default'... ---------------------------------------------------------------------- Ran 0 tests in 0.000s OK Destroying test database for alias 'default'... 
+6
source share
1 answer
 python manage.py test -k 

In Django 1.8, you can use the -k command.

New in Django 1.8: you can disable test databases destroyed by adding the -keepdb flag to the test command. This will save the test database between runs. If the database does not exist, it will be created first. Any migrations will also be applied to keep it up to date.

You can read this for more information: https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database

+7
source

All Articles