Django TDD

Django 测试策略,包括 pytest-django、TDD 方法、factory_boy、模拟、覆盖率以及测试 Django REST Framework API。

2,037 stars 332 forksSoftware Development Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add xu-xiang/everything-claude-code-zh

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add xu-xiang/everything-claude-code-zh --skill django-tdd
Manual install
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh.git /tmp/everything-claude-code-zh
mkdir -p ~/.claude/skills
cp -r /tmp/everything-claude-code-zh/docs/zh-CN/skills/django-tdd ~/.claude/skills/django-tdd

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# 使用 TDD 进行 Django 测试

使用 pytest、factory\_boy 和 Django REST Framework 进行 Django 应用程序的测试驱动开发。

## 何时激活

* 编写新的 Django 应用程序时
* 实现 Django REST Framework API 时
* 测试 Django 模型、视图和序列化器时
* 为 Django 项目设置测试基础设施时

## Django 的 TDD 工作流

### 红-绿-重构循环

```python
# Step 1: RED - Write failing test
def test_user_creation():
    user = User.objects.create_user(email='test@example.com', password='testpass123')
    assert user.email == 'test@example.com'
    assert user.check_password('testpass123')
    assert not user.is_staff

# Step 2: GREEN - Make test pass
# Create User model or factory

# Step 3: REFACTOR - Improve while keeping tests green
```

## 设置

### pytest 配置

```ini
# pytest.ini
[pytest]
DJANGO_SETTINGS_MODULE = config.settings.test
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts =
    --reuse-db
    --nomigrations
    --cov=apps
    --cov-report=html
    --cov-report=term-missing
    --strict-markers
markers =
    slow: marks tests as slow
    integration: marks tests as integration tests
```

### 测试设置
Read the full skill on GitHub

Details

Skill name
django-tdd
Path
docs/zh-CN/skills/django-tdd/SKILL.md
License
MIT
Repo updated
5 March 2026

FAQ

What does the Django TDD skill do?

Django 测试策略,包括 pytest-django、TDD 方法、factory_boy、模拟、覆盖率以及测试 Django REST Framework API。

How do I install the Django TDD skill?

Claude Code plugin: /plugin marketplace add xu-xiang/everything-claude-code-zh. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Django TDD popular?

It lives in xu-xiang/everything-claude-code-zh, which has 2,037 GitHub stars and 332 forks.

Related skills

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.