Skip to main content
PromptDailyDaily AI prompts, curated and verified
Everyday life

Django Unit Test Generator for Viewsets

Tested with:
GPT-4o
Effectiveness:
80/100
Prompt archive

English version

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.

Fill in and run

Opens in a new tab with the prompt already typed in. You may need to be signed in.

How to use this prompt

  • Replace anything in square brackets with your own details before sending.
  • Results differ between models. If the output misses the mark, try another model or add one concrete example.
  • Keep the prompt in one message. Splitting it across turns weakens the instructions.

Everyday life prompts