我想在Django中启动一个测试服务器,这样我就可以通过Jasmine/FrisbyJs测试我的API。
为此,我发现python3 manage.py testserver会创建一个test-db并加载fixture中提供的所有测试数据,这听起来就是我需要的。我没有运行Django-Testcase自动取款机。
我创建了一个名为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.对此我能做些什么呢?
发布于 2016-02-02 03:59:00
python manage.py测试服务器装置名称
例如:
python manage.py testserver SampleDataSampleData.json文件将位于app/fixture/中
https://stackoverflow.com/questions/30275650
复制相似问题