16

I have written some test cases for my project when I run these test cases, it creates test database for alias 'default' every time, after giving message then destroy database. I am concern only with message, So How to avoid creating test database, because it takes lots 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'...
Paulo Pessoa
  • 2,509
  • 19
  • 30
Neelabh Singh
  • 2,600
  • 12
  • 51
  • 88

2 Answers2

17
python manage.py test -k

In Django 1.8, you can use -k command.

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

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

Paulo Pessoa
  • 2,509
  • 19
  • 30
  • 2
    I get it, so, in this case, i think this solution maybe can help you http://stackoverflow.com/questions/5917587/django-unit-tests-without-a-db. You have tried it? – Paulo Pessoa Sep 18 '15 at 05:26
8

Well, it's just a comment, not an answer yet - so I'll repeat the comment of Rahul Gupta:

Just subclass from SimpleTestCase instead of TestCase, see Django Testing Tools Documentation.

OBu
  • 4,977
  • 3
  • 29
  • 45