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.
精彩评论