django-tdd

Automate Django TDD workflows using pytest-django, DRF, and Factory Boy.

6|Updated Mar 25, 2023
One-click install
npx skills add https://github.com/songkg7/dotfiles --skill django-tdd-songkg7
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-tdd
Source: https://github.com/songkg7/dotfiles/tree/main/dot_claude/skills/django-tdd
Command: npx skills add https://github.com/songkg7/dotfiles --skill django-tdd-songkg7

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Django testing can be verbose and brittle; this Skill provides a structured approach using pytest-django, TDD, and Factory Boy to improve reliability and speed.

Core Features & Use Cases

  • Test-driven Django development: Write tests first using pytest-django and implement models, views, and APIs accordingly.
  • Factory Boy integration: Create realistic test data with Factory Boy for users, products, and related models.
  • DRF API testing: Validate serializers and API endpoints for Django REST Framework.
  • Test infrastructure automation: Pre-configured pytest.ini and settings to speed up tests.

Quick Start

Install the required packages (pytest-django, factory_boy, pytest-cov) and run pytest to execute tests with coverage.

Frequently Asked Questions about django-tdd

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

FAQPage Schema
How do I get started with test-driven development in Django using pytest-django?

Test-driven development in Django with pytest-django involves writing tests first, then implementing models, views, and APIs. You need to install pytest-django, factory_boy, and pytest-cov, then run pytest to execute tests with coverage reports.

What's the best way to generate realistic test data in Django without brittle fixtures?

Generating realistic test data in Django is best handled through Factory Boy integration. Factory Boy creates dynamic, realistic test data for users, products, and related models, replacing brittle manual fixtures and automating test data creation.

Can I test Django REST Framework serializers and API endpoints using pytest-django?

Yes, you can validate serializers and API endpoints for Django REST Framework using pytest-django. The testing workflow supports DRF API testing, allowing you to validate models, views, serializers, and end-to-end flows.

Do I need pytest-cov and factory_boy installed to use this Django testing workflow?

Yes, this Django testing workflow requires pytest-django, factory_boy, and pytest-cov installed in your test environment. These dependencies are necessary to support coverage reports, automated fixtures, and Factory Boy data generation.

Why are my Django unit tests brittle and how does a structured TDD approach fix them?

Django unit tests become brittle due to verbose, manual fixture management. A structured TDD approach using pytest-django and Factory Boy improves reliability and speed by automating test data generation and pre-configuring test settings.

How do I configure pytest.ini and Django settings for automated test infrastructure?

Configuring automated test infrastructure involves setting up pre-configured pytest.ini and Django settings. This streamlines test execution by automatically configuring the environment, speeding up tests and integrating coverage reporting.