pytest / Testing Skill
Test generation and coverage improvement - an Agent Skill for Python 3.14 and pytest.
Search across all documentation pages
Test generation and coverage improvement - an Agent Skill for Python 3.14 and pytest.
Audits a module and adds tests: tests/ layout, conftest.py fixtures, parametrized edge cases, pytest.mark integration/slow, httpx.MockTransport or pytest-httpx for HTTP, database transaction rollbacks, and CI pytest --cov with sensible threshold.
| Input | Why |
|---|---|
| Target package | Which modules to cover first |
| External deps | DB, Redis, HTTP to fake vs testcontainers |
| Coverage goal | Line vs branch; minimum percent |
| Markers | slow, integration, no_ci |
| Async code | pytest-asyncio mode auto |
tests/conftest.py with shared fixturespyproject.toml [tool.pytest.ini_options]coverage omit patterns for if TYPE_CHECKINGuv run pytest commandsleep in tests.pytest -m "not integration" fast.uv sync --extra dev
uv run pytest -q
uv run pytest --cov=app --cov-report=term-missing --cov-fail-under=80
uv run ruff check tests/import pytest
from app.pricing import discount
@pytest.mark.parametrize(
"amount,coupon,expected",
[
(100, "SAVE10", 90),
(100, "INVALID", 100),
(0, "SAVE10", 0),
],
)
def test_discount(amount, coupon, expected):
assert discount(amount, coupon) == expectedpytest default for new code - unittest compatibility OK during migration.
Use for integration marker tests - unit tests use SQLite or mocked session.
Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 16, 2026