【发布时间】:2015-07-28 07:57:03
【问题描述】:
我想在 Django 中启动一个测试服务器,以便能够通过 Jasmine/FrisbyJs 测试我的 API。
为此,我发现python3 manage.py testserver 会创建一个测试数据库并加载夹具中提供的所有测试数据,这听起来正是我所需要的。我没有运行 Django-Testcases ATM。
我创建了一个名为 testdata.json 的 Fixture 并将其存储在 ./fixtures 中。
我也这样设置了我的./projname/settings.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Fixture Dir
FIXTURE_DIRS = (
os.path.join(BASE_DIR, 'fixtures'),
)
我还确保 python3 manage.py loaddata testdata 可以正常工作:
Installed 1 object(s) from 1 fixture(s)
但是,运行 python3 manage.py testserver testdata.json 或 python3 manage.py testserver testdata 会导致此错误:
CommandError: Error: No database fixture specified. Please provide the path of at least one fixture in the command line.
对此我能做些什么?
【问题讨论】:
标签: python django django-admin django-fixtures