在django单元测试中加载固定装置 [英] Loading fixtures in django unit tests
问题描述
我制作了整个项目db(不是某些应用程序),我想为每个测试加载它,因为它似乎只加载某些应用程序的夹具是不够的。
我想将夹具存储在/proj_folder/fixtures/proj_fixture.json中。
我设置了 FIXTURE_DIRS =('/ fixtures /',)
在我的settings.py中。
然后在我的测试用例中我正在尝试
fixtures = ['proj_fixture.json']
但我的装置不加载。
如何解决?
如何添加搜索装置的位置?
一般来说,是否可以为每个应用程序中的每个测试加载整个test_db的灯具(如果它相当小的话)?
谢谢!
你真的有一个文件夹 / fixtures / $ c您的硬盘上的$ c>
您可能打算使用:
FIXTURE_DIRS =('/ path / to / proj_folder / fixtures /',)
I'm trying to start writing unit tests for django and I'm having some questions about fixtures:
I made a fixture of my whole project db (not certain application) and I want to load it for each test, because it looks like loading only the fixture for certain app won't be enough.
I'd like to have the fixture stored in /proj_folder/fixtures/proj_fixture.json.
I've set the FIXTURE_DIRS = ('/fixtures/',)
in my settings.py.
Then in my testcase I'm trying
fixtures = ['proj_fixture.json']
but my fixtures don't load. How can this be solved? How to add the place for searching fixtures? In general, is it ok to load the fixture for the whole test_db for each test in each app (if it's quite small)? Thanks!
Do you really have a folder /fixtures/
on your hard disk?
You probably intended to use:
FIXTURE_DIRS = ('/path/to/proj_folder/fixtures/',)
这篇关于在django单元测试中加载固定装置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!