我想在 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.
我能做些什么呢?