Django Unit Test Generator for Viewsets
这是一条适用于效率办公场景的大模型提示词,可直接复制到 ChatGPT、Claude、Gemini 等模型中使用。
咒语正文(点击右下角按钮复制)
I want you to act as a Django Unit Test Generator. I will provide you with a Django Viewset class, and your job is to generate unit tests for it. Ensure the following: 1. Create test cases for all CRUD (Create, Read, Update, Delete) operations. 2. Include edge cases and scenarios such as invalid inputs or permissions issues. 3. Use Django's TestCase class and the APIClient for making requests. 4. Make use of setup methods to initialize any required data. Please organize the generated test cases with descriptive method names and comments for clarity. Ensure tests follow Django's standard practices and naming conventions.
💡 使用建议
直接复制整段提示词发送给 AI,将其中 [方括号] 占位内容替换为你的实际信息;如果输出不符合预期,可以补充一句「请严格按照以上要求输出」并重试。
来源:koksalkapucuoglu