dj-pytest

dj-pytest is a skill for Claude Code from dvf/opinionated-django. It costs 114 tokens per session (3,864 once invoked), scanned A, original, MIT.

A set of project-specific instructions for writing pytest tests for Django applications. It divides tests into repository, service, and API layers, with different rules for database use and external task dispatch.

In plain words
What is it for?
Use it when configuring pytest, testing Django repositories or services, checking API behavior, testing Celery tasks, or handling time-dependent code.
Why use it?
It keeps business-logic tests fast and separates database and HTTP integration checks from unit-style tests.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it when configuring pytest, testing Django repositories or services, checking API behavior, testing Celery tasks, or handling time-dependent code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dvf/opinionated-django/dj-pytest
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add dvf/opinionated-django --skill dj-pytest
Clone the repo
git clone --depth 1 https://github.com/dvf/opinionated-django

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dj-pytest

README.md
[![agentmods](https://agentmods.dev/badge/skills/dvf/opinionated-django/dj-pytest/github.svg)](https://agentmods.dev/skills/dvf/opinionated-django/dj-pytest)
Your own site
<a href="https://agentmods.dev/skills/dvf/opinionated-django/dj-pytest"><img src="https://agentmods.dev/badge/skills/dvf/opinionated-django/dj-pytest/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dj-pytest

Your own site · 80×15
<a href="https://agentmods.dev/skills/dvf/opinionated-django/dj-pytest"><img src="https://agentmods.dev/badge/skills/dvf/opinionated-django/dj-pytest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,864 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00114 $0.03864
Opus 5 $0.00057 $0.01932
Sonnet 5 $0.00023 $0.00773
Haiku 4.5 $0.00011 $0.00386

Measured 9d ago against content hash a8df7c5dc1e9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

dj-pytest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/dj-pytest/SKILL.md · 379 lines

How it starts

The opening of the file, as written. The whole thing — 379 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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-xdist freezegun pytest-mock
  • pytest-django — the django_db marker, client fixture, settings integration, django_capture_on_commit_callbacks.
  • pytest-xdist-n auto parallel runs. Keep it out of addopts so debugger runs stay serial.
  • pytest-celery is deliberately absent — tasks are never executed through Celery machinery in tests (see Celery in Tests).
  • freezegun — freezes datetime.now(), time.time(), and friends. Required for any logic that touches timestamps, TTLs, scheduled work, or ULIDs whose sort order matters to the test.
  • pytest-mock — the mocker fixture (a thin wrapper around unittest.mock with autouse cleanup).

Configuration

Add to pyproject.toml:

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "project.settings"
python_files = ["test_*.py"]
pythonpath = ["src"]
addopts = [
    "-ra",
    "--strict-markers",
    "--strict-config",
]
markers = [
    "slow: deselect with '-m \"not slow\"'",
]

Notes:

  • pythonpath = ["src"] is what lets from project.services import get resolve without an editable install.
  • --strict-markers catches typos in @pytest.mark.xxx. --strict-config does the same for the config file.
  • Keep the markers list small and meaningful — one or two genuine custom markers maximum.

Read the full file on GitHub · 379 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 379 lines · 114 tokens per session scan A a8df7c5dc1e9

Subscribe to this mod's changes

dj-pytest is a skill published in the GitHub repository dvf/opinionated-django (110 stars, last pushed 26d ago), licensed MIT. It adds 114 tokens to every session and 3,864 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.