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.
当我运行这些测试用例时,我已经为我的项目编写了一些测试用例,它每次创建别名'default'的测试数据库,然后给出消息然后销毁数据库。我只关心消息,所以如何避免创建测试数据库,因为它需要很多时间。
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'...
1 个解决方案
#1
9
python manage.py test -k
In Django 1.8, you can use -k command.
在Django 1.8中,您可以使用-k命令。
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.
Django 1.8中的新增功能:您可以通过向test命令添加--keepdb标志来防止测试数据库被破坏。这将在运行之间保留测试数据库。如果数据库不存在,将首先创建它。还将应用任何迁移以使其保持最新。
You can read this for more details: https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database
您可以阅读此内容以获取更多详细信息:https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database
#1
9
python manage.py test -k
In Django 1.8, you can use -k command.
在Django 1.8中,您可以使用-k命令。
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.
Django 1.8中的新增功能:您可以通过向test命令添加--keepdb标志来防止测试数据库被破坏。这将在运行之间保留测试数据库。如果数据库不存在,将首先创建它。还将应用任何迁移以使其保持最新。
You can read this for more details: https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database
您可以阅读此内容以获取更多详细信息:https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database