AI coding/AI Short
A

AI Short

按场景分类的 AI 提示词库,复制后即可用于 ChatGPT、Claude 等对话工具。

Django Unit Test Generator for Viewsets

This is a ready-to-copy Coding prompt, “Django Unit Test Generator for Viewsets”. Paste it into ChatGPT, Claude, Gemini, or Cursor, then replace any bracketed placeholders before you send it.

CodingAwesome Prompts0 copies

Prompt

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.

More Coding prompts