开发者

Persisting test data across apps

My Django site has two apps — Authors and Books. My Books app has a model which开发者_JAVA技巧 has a foreign key to a model in Authors. I have some tests for the Authors app which tests all my models and managers and this works fine. However, my app Books require some data from the Authors app in order to function.

Can I specify the order in which my tests are run and make the generated test data from app Authors persist so that I can test my Books app whithout having to copy over the test which generate data from the Authors app.

I might be doing this all wrong. Am I?

Thanks.


Create a fixture containing the test data you need. You can then load the same data for both your Authors and Books tests.

For details, see docs on Testcase.fixures and Introduction to Python/Django tests: Fixtures.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜