django-tdd

Solid

Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.

Testing & QA 196,640 stars 30253 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Django テスト駆動開発(TDD) pytest、factory_boy、Django REST Frameworkを使用したDjangoアプリケーションのテスト駆動開発。 ## いつ有効化するか - 新しいDjangoアプリケーションを書くとき - Django REST Framework APIを実装するとき - Djangoモデル、ビュー、シリアライザーをテストするとき - Djangoプロジェクトのテストインフラを設定するとき ## DjangoのためのTDDワークフロー ### Red-Green-Refactorサイクル ```python # ステップ1: RED - 失敗するテストを書く 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 # ステップ2: GREEN - テストを通す # Userモデルまたはファクトリーを作成 # ステップ3: REFACTOR - テストをグリーンに保ちながら改善 ``` ## セットアップ ### 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 ``` ### テスト設定 ```python # config/settings/test.py from .base import * DEBUG = True DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', } } # マイグレーションを無効化して高速化 class DisableMigrations: def __contains__(self, item): return True def __getitem__(self, item): return None MIGRATION_MODULES = DisableMigrations() # より高速なパスワードハッシング PASSWORD_HASHERS = [ 'django....

Details

Author
affaan-m
Repository
affaan-m/everything-claude-code
Created
4 months ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Integrates with

Related Skills