简体   繁体   English

如何使我的测试装置仅在Django中测试时加载?

[英]How to make my test fixtures loaded only while testing in Django?

I have a Django project with production fixtures and testing fixtures. 我有一个包含生产固定装置和测试固定装置的Django项目。 How to make testing fixtures loaded only while running tests? 如何使测试夹具仅在运行测试时加载?

You just need to put it into fixtures property of your testcase class. 您只需要将其放入测试用例类的固件属性即可。 Like this: 像这样:

  class AnimalTestCase(TestCase):
      fixtures = ['mammals.json', 'birds']

Docs can be found here 可以在这里找到文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM