django-tdd

Automate Django testing workflows with pytest-django, factory_boy, and DRF API tests.

41|8|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/codelably/harmony-claude-code --skill django-tdd-codelably
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-tdd
Source: https://github.com/codelably/harmony-claude-code/tree/main/skills/django-tdd
Command: npx skills add https://github.com/codelably/harmony-claude-code --skill django-tdd-codelably

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

帮助开发者在 Django 项目中通过测试驱动开发(TDD)实现高质量、可维护的后端测试,覆盖模型、序列化器、视图和 API。

Core Features & Use Cases

  • Red-Green-Refactor 循环:通过明确的测试驱动开发流程快速验证功能实现。
  • 工厂模式与测试实用工具:引入 Factory Boy、pytest fixtures 和 DRF 流水线测试,提升测试数据创建与复用性。
  • DRF API 与模型测试:覆盖模型、序列化器、视图以及 API 流程的端到端测试。
  • 测试配置与最佳实践:提供统一的 pytest 配置、conftest 脚手架、以及覆盖率与 Mock 策略。

Quick Start

只需在 Django 项目中启用该工作流并运行测试,系统将自动执行从单元测试到集成测试的完整流程。

Frequently Asked Questions about django-tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up pytest and factory_boy for Django TDD workflows?

Configure pytest-django using conftest fixtures and factory_boy to automate test data creation for Django TDD. This establishes reusable test data, unified pytest configuration, and repeatable test runs across models and API endpoints.

What is the best way to test DRF API endpoints with pytest?

The best way to test DRF API endpoints is using pytest-django with TDD workflows. Validate serializers, views, and API pipelines through unit and integration tests, applying mocks and coverage reporting for reliable endpoint validation.

Can I use factory_boy to build mock data for Django model and serializer tests?

Yes, factory_boy is used to build mock data for Django model and serializer tests. It generates test fixtures within pytest conftest scripts, improving test data creation and reuse across unit and integration testing pipelines.

How does the Red-Green-Refactor cycle apply to Django testing?

The Red-Green-Refactor cycle drives Django feature implementation by writing failing tests, making them pass, then refactoring. This TDD workflow quickly validates models, views, and serializers using pytest-django.

Do I need pytest-django to run coverage reports for my Django app?

pytest-django is used to run unit and integration tests with coverage reporting for your Django app. It provides the necessary conftest scaffolding and test configuration to ensure reliable and repeatable coverage metrics.

Why do my Django integration tests fail when testing DRF API pipelines?

Django integration tests may fail due to incorrect pytest configuration or missing conftest fixtures. Applying unified pytest settings, factory_boy for data generation, and proper mocks ensures reliable DRF API pipeline validation.