pytest-service

pytest-service is a skill for Claude Code from robhowley/py-pit-skills. It costs 79 tokens per session (1,444 once invoked), scanned A, original, MIT.

A set of instructions for writing backend tests for FastAPI, a Python web framework, using pytest, a Python testing tool. It covers asynchronous code, database fixtures, dependency overrides, and mocked external services.

In plain words
What is it for?
For adding or improving tests for FastAPI endpoints and services, including async SQLAlchemy database setup, HTTP client tests, dependency injection, and external-client mocks.
Why use it?
It provides consistent testing rules so tests stay readable, repeatable, and independent of outside infrastructure.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the py-pit plugin — 16 skills, 1 hook shipped together

Good fit For adding or improving tests for FastAPI endpoints and services, including async SQLAlchemy database setup, HTTP client tests, dependency injection, and external-client mocks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/robhowley/py-pit-skills/pytest-service
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 robhowley/py-pit-skills --skill pytest-service
Clone the repo
git clone --depth 1 https://github.com/robhowley/py-pit-skills

Made for: Claude Code.

Or install py-pit, the plugin that ships this one along with the rest of its 16 skills, 1 hook.

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 pytest-service

README.md
[![agentmods](https://agentmods.dev/badge/skills/robhowley/py-pit-skills/pytest-service.svg)](https://agentmods.dev/skills/robhowley/py-pit-skills/pytest-service)
Your own site
<a href="https://agentmods.dev/skills/robhowley/py-pit-skills/pytest-service"><img src="https://agentmods.dev/badge/skills/robhowley/py-pit-skills/pytest-service.svg" alt="Measured on agentmods" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,444 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.
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.00079 $0.01444
Opus 5 $0.00039 $0.00722
Sonnet 5 $0.00016 $0.00289
Haiku 4.5 $0.00008 $0.00144

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

Security

Grade A, and why

pytest-service 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 7d 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/pytest-service/SKILL.md · 222 lines

How it starts

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

Skill: pytest-service

Core position

This skill establishes clean, reliable backend testing using pytest.

The goal is to produce tests that are:

  • fast
  • deterministic
  • easy to read
  • easy to extend
  • free of infrastructure dependencies

Tests should optimize for scanability and maintainability, not clever abstractions.

Core testing stance

Prefer simple local tests with minimal infrastructure.

Rules:

  • Use httpx.AsyncClient with ASGITransport for FastAPI endpoint tests
  • All test functions are async def; asyncio_mode = "auto" eliminates per-test markers
  • Use pytest_asyncio fixtures for async setup/teardown
  • Default test databases to async SQLite via SQLAlchemy async fixtures
  • Do not introduce Docker databases unless the repository already uses them for testing
  • External clients must be mocked, not called
  • No test classes — top-level test_* functions only; fixtures handle all setup
  • Each test covers a distinct behavior — no redundant assertions across tests
  • Avoid mutable default arguments in fixtures and helpers
  • Dev deps assumed: pytest, pytest-asyncio, httpx

Tests must run reliably with a simple pytest. No external services required.

Project structure

Tests should live in a tests/ directory.

tests/
  conftest.py
  test_health.py
  test_users.py
  factories/
    user_factory.py
  • conftest.py holds shared fixtures
  • test files mirror application modules when possible
  • factory fixtures may live in tests/factories/ or conftest.py

Fixture discipline

Shared setup belongs in pytest fixtures, not duplicated code.

  • Use @pytest.fixture for reusable setup
  • Inspect existing fixtures before creating new ones
  • Prefer composing fixtures instead of duplicating setup logic
  • Keep fixture responsibilities narrow and clearly named

Avoid inline setup repeated across tests.

Fixture scope

Read the full file on GitHub · 222 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. 7d ago First seen · 222 lines · 79 tokens per session scan A 2ab29c22a653

Subscribe to this mod's changes

pytest-service is a skill published in the GitHub repository robhowley/py-pit-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 79 tokens to every session and 1,444 once invoked, about $0.0004 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-31.

Related

Other skills, from other repositories

python-backend

Production Python async patterns including asyncio TaskGroup, FastAPI dependency injection and middleware, SQLAlchemy 2.0 async sessions, and database connection pool tuning. Python 3.11+ runtime concerns such as ExceptionGroup, cancellation semantics, and session rollback. Use when building async services, wiring…

yonatangross/orchestkit · 82 tokens

python

Use when building FastAPI applications, implementing async endpoints, setting up Pydantic schemas, working with SQLAlchemy, or writing pytest tests for Python backend services.

MadAppGang/claude-code · 34 tokens

pytest

Advanced Python unit testing framework for customer support tech enablement, covering FastAPI, SQLAlchemy, PostgreSQL, async operations, mocking, fixtures, parametrization, coverage, and comprehensive testing strategies for backend support systems.

manutej/luxor-claude-marketplace · 44 tokens

FastAPI Customer Support Tech Enablement

Comprehensive FastAPI skill for building modern Python web APIs with focus on customer support systems, ticket management, real-time chat, and backend operations.

manutej/luxor-claude-marketplace · 36 tokens

fastapi-expert

Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.

personamanagmentlayer/pcl · 49 tokens

asyncio

Python asyncio - Modern concurrent programming with async/await, event loops, tasks, coroutines, primitives, aiohttp, and FastAPI async patterns.

bobmatnyc/claude-mpm-skills · 32 tokens