Agent skill

Testing Pytest

by dzhalaevd in dzhalaevd/Donatello

Use as a supporting skill when the test level is known and the implementation should use pytest, fixtures, parametrization, mocks, dirty-equals, pytest-httpx, coverage, benchmark, or Allure

Apache-2.0Auto-check passedTesting & QA

Install Testing Pytest

skills CLI
$ npx skills add dzhalaevd/Donatello --skill testing-pytest -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dzhalaevd/Donatello testing-pytest --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dzhalaevd/Donatello.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/testing-pytest .claude/skills/testing-pytest && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
testing-pytest
GitHub stars
135
Token cost
~2.3k tokens
SKILL.md length
652 words
Files
1
Skills in repo
15
Repo updated
First seen
Licence
Apache-2.0

At a glance

Use as a supporting skill when the test level is known and the implementation should use pytest, fixtures, parametrization, mocks, dirty-equals, pytest-httpx, coverage, benchmark, or Allure

  • Works in 9 steps: Define the observable behavior. → Choose the smallest public interface… → Identify dependencies → …
  • Tasks that involve Unit testing
  • SKILL.md covers Purpose, Test Writing Algorithm, Arrange / Act / Assert and Naming, plus 12 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Testing Pytest is an agent skill from dzhalaevd/Donatello. Use as a supporting skill when the test level is known and the implementation should use pytest, fixtures, parametrization, mocks, dirty-equals, pytest-httpx, coverage, benchmark, or Allure

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing. It works with pytest and Python. The repository describes itself as: Make Dating Great Again. An open source dating platform. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Unit testing

Example prompts

  • “/testing-pytest”

Requirements

  • Python 3

Workflow steps

9 steps, taken from the first numbered list in SKILL.md.

  1. Define the observable behavior.
  2. Choose the smallest public interface that verifies it.
  3. Identify dependencies
  4. Mock only uncontrolled external dependencies.
  5. Prepare data explicitly.
  6. Perform one main action.
  7. Assert through a public effect
  8. Ensure the test is independent.
  9. Check that the test is not tied to incidental implementation details.

What it can do on your machine

Read from SKILL.md and the folder at commit b57816e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python and toml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Testing Pytest loads about 2.3k tokens when it runs. Until then it costs about 51 tokens; SKILL.md has 652 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~51
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dzhalaevd/Donatello at commit b57816e, republished under its Apache-2.0 licence (© dzhalaevd). 652 words, ~2,304 tokens.

Download SKILL.mdSave it as .claude/skills/testing-pytest/SKILL.md (or your agent's skills folder).
name
testing-pytest
description
Use as a supporting skill when the test level is known and the implementation should use pytest, fixtures, parametrization, mocks, dirty-equals, pytest-httpx, coverage, benchmark, or Allure

Pytest Backend Testing

Purpose

Guide to concrete pytest implementation for backend services.

Use this as a supporting/tooling skill after the lead testing skill is known:

  • unit-testing leads isolated Python behavior;
  • integration-testing leads database, repository, transaction, API, and multi-component behavior;
  • concurrency_fuzzing_testing leads scheduler/interleaving/race-condition behavior;
  • testing-test-strategy leads broad test planning;
  • test-driven-development leads the test-first workflow.

If the user simply asks for "pytest tests" and the level is unclear, first infer or state the lead level, then use this skill for pytest-specific syntax and fixtures.

Test Writing Algorithm

  1. Define the observable behavior.
  2. Choose the smallest public interface that verifies it.
  3. Identify dependencies:
    • controlled internal dependencies;
    • uncontrolled external dependencies.
  4. Mock only uncontrolled external dependencies.
  5. Prepare data explicitly.
  6. Perform one main action.
  7. Assert through a public effect:
    • API response;
    • database state;
    • return value;
    • published event;
    • external service call.
  8. Ensure the test is independent.
  9. Check that the test is not tied to incidental implementation details.

Arrange / Act / Assert

Write tests using AAA:

python
def test_create_user_fails_when_email_already_exists(client: Client) -> None:
    # Arrange
    client.post("/api/users", json={"name": "John", "email": "john@example.com"})

    # Act
    response = client.post(
        "/api/users",
        json={"name": "John2", "email": "john@example.com"},
    )

    # Assert
    assert response.status_code == 409
    assert "already exists" in response.json()["message"].lower()

Rules:

  • one test has one main Act;
  • avoid Act -> Assert -> Act -> Assert unless it is one coherent scenario;
  • do not use if inside tests;
  • do not hide important setup in unclear helpers;
  • a huge Arrange often signals the test or code design should be simplified.

Naming

Name tests in domain language.

Good:

python
def test_create_user_fails_when_email_already_exists() -> None: ...

Bad:

python
def test_create_user_409_case_2() -> None: ...

Prefer clarity over a rigid naming scheme.

Mocking

Mock external uncontrolled dependencies:

  • external HTTP;
  • SMTP;
  • third-party APIs and SDKs;
  • external brokers and queues;
  • filesystem access when it is not the subject of the test;
  • unstable time, randomness, and environment sources.

Do not mock by default:

  • internal application services;
  • repositories when a test database gives better confidence;
  • the database as a controlled dependency;
  • cache controlled entirely by the service;
  • private methods;
  • internal calls that are not part of the public contract.

Mocking internal implementation often makes tests brittle.

When creating mocks, prefer specs:

python
from unittest.mock import Mock, create_autospec

email_sender_mock = Mock(spec=EmailSender)
repository_mock = create_autospec(UserRepository)

Specs catch typos, wrong attributes, bad signatures, and contract drift.

Public Behavior

Avoid asserting internals:

python
def test_user_creation_internals(client, user_repository_mock, db_session) -> None:
    response = client.post("/api/users", json={"name": "John", "email": "john@example.com"})

    assert response.status_code == 201
    assert db_session.execute.call_count == 2
    user_repository_mock.create.assert_called_once()

Prefer public effects:

python
from dirty_equals import IsDatetime, IsInt


def test_create_user_successfully(client, email_service_mock) -> None:
    email_service_mock.send_welcome_email.return_value = True

    response = client.post(
        "/api/users",
        json={"name": "John", "email": "john@example.com"},
    )

    assert response.status_code == 201
    assert response.json() == {
        "id": IsInt,
        "name": "John",
        "email": "john@example.com",
        "created_at": IsDatetime,
        "updated_at": IsDatetime,
    }
    email_service_mock.send_welcome_email.assert_called_once()

DAMP Over Excessive DRY

In tests, readability matters more than removing every duplicate line.

Prefer DAMP: Descriptive And Meaningful Phrases.

Small duplication is acceptable when it makes the scenario obvious. Do not build complex helper classes or factories that hide the business meaning.

A helper is useful when it is:

  • short;
  • typed;
  • not hiding important business logic;
  • reducing noise rather than meaning;
  • reused by many similar tests.
Show full SKILL.md (257 more words)Show less

Independence

Each test should:

  • prepare its own data;
  • not depend on execution order;
  • avoid global mutable state;
  • not rely on data created by another test;
  • isolate or clean up side effects.

Bad:

python
created_user_id = None


def test_create_user(client) -> None:
    global created_user_id
    created_user_id = client.post("/api/users", json={...}).json()["id"]


def test_get_user(client) -> None:
    response = client.get(f"/api/users/{created_user_id}")
    assert response.status_code == 200

Good:

python
def test_get_user(client) -> None:
    create_response = client.post(
        "/api/users",
        json={"name": "John", "email": "john@example.com"},
    )
    user_id = create_response.json()["id"]

    response = client.get(f"/api/users/{user_id}")

    assert response.status_code == 200

Fixtures

Use fixtures for infrastructure and repeated preparation:

  • test client;
  • test DB/session;
  • external service mocks;
  • test data factories;
  • environment settings.

Rules:

  • type fixtures;
  • avoid magical fixtures;
  • do not create data in a fixture unless the fixture name makes that obvious;
  • keep important Arrange visible;
  • keep wrapper fixtures simple and local.

Typed factory example:

python
from collections.abc import Callable
from dataclasses import dataclass


@dataclass(slots=True)
class User:
    id: int | None
    name: str
    email: str


UserFactory = Callable[..., User]

Parametrization

Use pytest.mark.parametrize for meaningful scenarios:

python
import pytest


@pytest.mark.parametrize(
    ("email", "expected_status"),
    [
        ("john@example.com", 201),
        ("invalid-email", 422),
        ("", 422),
    ],
)
def test_create_user_email_validation(client, email: str, expected_status: int) -> None:
    response = client.post("/api/users", json={"name": "John", "email": email})

    assert response.status_code == expected_status

Avoid combinatorial explosions. Parametrize important equivalence classes, not every possible combination.

Errors and Edge Cases

Do not stop at happy paths. Check:

  • invalid input;
  • duplicates;
  • empty lists;
  • missing entities;
  • permissions;
  • idempotency when relevant;
  • external service timeouts and failures;
  • boundary values;
  • meaningful concurrency scenarios.

dirty-equals

Use dirty-equals for complex structures with dynamic values:

python
from dirty_equals import IsDatetime, IsInt, IsRegex

assert response.json() == {
    "id": IsInt,
    "email": "john@example.com",
    "created_at": IsDatetime,
    "request_id": IsRegex(r"^[a-f0-9-]{36}$"),
}

This is clearer than many tiny asserts for datetime formats, regexes, and types.

External HTTP

For httpx code, use pytest-httpx:

python
def test_get_user_from_external_api(httpx_mock) -> None:
    httpx_mock.add_response(
        method="GET",
        url="https://api.example.com/users/42",
        json={"id": 42, "name": "Ada"},
        status_code=200,
    )

    result = get_user(42)

    assert result == {"id": 42, "name": "Ada"}

For a large external API, create a thin mocker:

python
class ExternalApiMocker:
    def __init__(self, httpx_mock) -> None:
        self._httpx_mock = httpx_mock

    def add_user_response(self, user_id: int, name: str) -> None:
        self._httpx_mock.add_response(
            method="GET",
            url=f"https://api.example.com/users/{user_id}",
            json={"id": user_id, "name": name},
        )

The wrapper should simplify tests, not become another framework.

Benchmark Tests

For benchmark tests, pytest-benchmark is acceptable.

Recommended config:

toml
[tool.pytest.ini_options]
addopts = "--benchmark-skip"
python_functions = ["test_*", "bench_*"]

Normal tests should run in CI by default. Benchmarks should be explicit.

Allure

If the project uses Allure, add human-readable titles to important tests:

python
import allure


@allure.title("User cannot register with an already used email")
def test_create_user_fails_when_email_already_exists(client) -> None: ...

Do not duplicate obvious descriptions for every small unit test.

Response Format

When writing tests:

  1. Briefly explain the chosen test level.
  2. Provide the test code.
  3. State what is mocked and why.
  4. Mention useful edge cases that remain.

© dzhalaevd, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/testing-pytest of dzhalaevd/Donatello.

Open the folder on GitHubat commit b57816e

Compare with similar skills

Testing Pytest next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Testing Pytest compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Testing Pytest this skilldzhalaevd/Donatello135—~2.3kAutomated safety check: PassApache-2.0
Adk Verify Snippetsgoogle/adk-python22k—~1.4kAutomated safety check: PassApache-2.0
Hermetic Python Unit TestsdimensionalOS/dimos4.6k—~1.4kAutomated safety check: PassCustom licence
ONNX Runtime Test Runnermicrosoft/onnxruntime22k—~1.8kAutomated safety check: PassMIT
Simple Modern Uvjlevy/simple-modern-uv301—~1.9kAutomated safety check: PassMIT
Test Coverage Reviewareed1192/finance-news-aggregator149—~2.6kAutomated safety check: PassMIT

Similar skills

  • Adk Verify Snippets

    google/adk-python

    Official

    Checks that every Python code block in a Markdown file actually compiles and runs, by extracting each block to a temporary file, executing it in an isolated subprocess, and writing a pass/fail…

    22k GitHub stars~1.4k tokensUpdated today
    Testing & QAAuto-check passed
  • Hermetic Python Unit Tests

    dimensionalOS/dimos

    Rules for writing, fixing and reviewing pytest unit tests that are hermetic: behavior-focused, deterministic, isolated and cheap to run.

    4.6k GitHub stars~1.4k tokensUpdated today
    Testing & QAAuto-check passed
  • ONNX Runtime Test Runner

    microsoft/onnxruntime

    Official

    Runs and debugs ONNX Runtime tests: Google Test executables for C++ and unittest or pytest for Python, with filters and build-directory guidance.

    22k GitHub stars~1.8k tokensUpdated today
    Testing & QAAuto-check passed
  • Simple Modern Uv

    jlevy/simple-modern-uv

    Start, selectively modernize, fully migrate, or update Python projects using simple-modern-uv practices: uv, ruff, BasedPyright, pytest, GitHub Actions CI, and tag-driven PyPI publishing.

    301 GitHub stars~1.9k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Test Coverage Review

    areed1192/finance-news-aggregator

    Audit, plan, write, and verify unit tests for Python projects using pytest.

    149 GitHub stars~2.6k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Official

    Runs the ONNX Runtime transformers Python tests against a GPU wheel and proves the cuDNN flash attention path was used rather than a silent fallback.

    22k GitHub stars~2.9k tokensUpdated today
    Testing & QAAuto-check passed

More from dzhalaevd/Donatello

All 15 skills in this repo
  • API And Interface Design

    dzhalaevd/Donatello

    Guides stable API and interface design. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 9 repos~2.6k tokens
    Auto-check passed
  • Documentation And Adrs

    dzhalaevd/Donatello

    Records decisions and documentation. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 8 repos~2.4k tokens
    Auto-check: notes
  • CI CD And Automation

    dzhalaevd/Donatello

    Automates CI/CD pipeline setup. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 7 repos~2.7k tokens
    Auto-check: notes
  • Deprecation And Migration

    dzhalaevd/Donatello

    Manages deprecation and migration. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 7 repos~3.1k tokens
    Auto-check passed
  • Instruments code so production behavior is visible and diagnosable.

    135 GitHub starsUsed in 5 repos~2.7k tokens
    Auto-check passed
  • Shipping And Launch

    dzhalaevd/Donatello

    Prepares production launches. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 5 repos~2.5k tokens
    Auto-check passed

Works with

Categories

Questions about Testing Pytest

What does Testing Pytest do?

Use as a supporting skill when the test level is known and the implementation should use pytest, fixtures, parametrization, mocks, dirty-equals, pytest-httpx, coverage, benchmark, or Allure. Testing Pytest is an agent skill from dzhalaevd/Donatello.

When should I use Testing Pytest?

Testing Pytest fits situations like: tasks that involve Unit testing.

How do I install Testing Pytest in Claude Code?

Run `npx skills add dzhalaevd/Donatello --skill testing-pytest -a claude-code`. Or copy the skill folder (.agents/skills/testing-pytest in dzhalaevd/Donatello) into .claude/skills/testing-pytest in your project. Claude Code loads it when a task matches its description.

How do I install Testing Pytest in Codex?

Run `npx skills add dzhalaevd/Donatello --skill testing-pytest -a codex`. Or copy the skill folder (.agents/skills/testing-pytest in dzhalaevd/Donatello) into .agents/skills/testing-pytest in your project. Codex loads it when a task matches its description.

Can I use Testing Pytest in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dzhalaevd/Donatello --skill testing-pytest -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/testing-pytest, .gemini/skills/testing-pytest, .github/skills/testing-pytest and .opencode/skills/testing-pytest in your project.

What does Testing Pytest need to run?

SKILL.md names no scripts, command-line tools or credentials: Testing Pytest is instructions for the agent only. Our summary lists: Python 3.

Does Testing Pytest access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Testing Pytest safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Testing Pytest use?

Testing Pytest is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Testing Pytest use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Testing Pytest?

Skills that share tags, products or a category with Testing Pytest: Adk Verify Snippets (google/adk-python, 22k stars), Hermetic Python Unit Tests (dimensionalOS/dimos, 4.6k stars), ONNX Runtime Test Runner (microsoft/onnxruntime, 22k stars) and Simple Modern Uv (jlevy/simple-modern-uv, 301 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Testing Pytest?

dzhalaevd (a GitHub user) maintains it in dzhalaevd/Donatello, which has 135 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on October 3, 2026.

Source: dzhalaevd/Donatello on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.