dj-pytest

Installation
SKILL.md

Pytest for op-django

Testing in this project is layered the same way the code is. Each layer has its own rules, its own fixtures, and its own performance characteristics. The goal is to keep the fast tests fast — service tests should never touch a database — and to isolate the slow tests at the edges.

The Three Layers

File What it covers DB? Speed
test_repo.py ORM ↔ DTO conversion, prefetches, transactions, ID prefixes ✅ real slow
test_service.py Business logic, validation, orchestration ❌ mocked fast
test_api.py HTTP integration — request → view → service → repo ✅ real slow

Service tests are the most valuable layer and should outnumber the others. If a service test needs @pytest.mark.django_db, something has leaked — find the ORM call and push it into a repository.

Dependencies

uv add --dev pytest pytest-django pytest-celery freezegun pytest-mock
Related skills

More from dvf/opinionated-django

Installs
11
GitHub Stars
105
First Seen
Apr 15, 2026