【发布时间】:2016-05-29 01:54:47
【问题描述】:
我阅读了Q&A why django create test database,但没有一个问题的答案。
我有 django 1.8.4 版本。
我的设置.py
if 'test' in sys.argv or 'test_coverage' in sys.argv:
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
运行
time ./manage.py test
Raven is not configured (logging is disabled). Please see the documentation for more information.
/Users/ioganegambaputi/work/foobd/foobd/core/forms.py:7: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
from django.forms.util import ErrorList
/Users/ioganegambaputi/work/env/foobd/lib/python2.7/site-packages/templated_email/__init__.py:2: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
from django.utils.importlib import import_module
/Users/ioganegambaputi/work/foobd/foobd/core/utils.py:50: RemovedInDjango19Warning: 'get_cache' is deprecated in favor of 'caches'.
self.cache = cache.get_cache(cache_alias or cache.DEFAULT_CACHE_ALIAS)
Creating test database for alias 'default'...
real 0m53.102s
user 0m47.976s
sys 0m1.544s
测试工作大约 2-3 秒,所有其他时间都挂在为别名“默认”创建测试数据库...
我认为我的数据库应该非常快地在内存中创建。我没有加载 json 转储。我怎样才能让它更快?看来我错过了什么……
更新
如果我使用--keepdb 标志(如在答案中注意到的那样,它保留了我的数据库结构,而不是数据),无论如何,它都会以相同的方式挂起,但使用别名'default'的现有测试数据库.. .标签(
【问题讨论】:
标签: python django sqlite unit-testing testng