Testing
Python’s testing story centers on pytest, but the supporting cast — parallel runners, version matrices, and CI — is just as important. The handbook covers setup, day-to-day usage, and the orchestrators that wrap pytest in modern uv-based workflows.
Get started with pytest
Parallel and matrix testing
More Testing pages
Everything else tagged testing, grouped by section. Pages featured above are not repeated here.
Tutorial
Build and Publish a Python Package with uv, Ruff, Pyrefly, pytest, and GitHub Actions
Build a Python library with uv, Ruff, Pyrefly, and pytest. Set up CI/CD with GitHub Actions. Publish to PyPI with trusted publishing.
Set up a complete Python project with uv, Ruff, Pyrefly, pytest, and pre-commit
Tutorial: build a Python project from scratch with uv, Ruff, Pyrefly, pytest, and pre-commit. Set up linting, type checking, and testing.
Set up a Python project optimized for Claude Code
Build a Python CLI agent that understands your codebase and fixes bugs autonomously using Claude Code.
How To
How to Combine Coverage Across a CI Matrix
Aggregate coverage.py from GitHub Actions matrix jobs into one report, post to run summary, gate with single threshold.
How to configure Claude Code to run your pytest suite
Wire pytest into Claude Code with Stop hooks for fast feedback. Sparse tracebacks help agents fix failures efficiently.
How to configure Cursor for pytest
Enable pytest in Cursor's Testing sidebar, configure test discovery with pyproject.toml, and add a Cursor rule so the AI agent always runs tests via uv.
How to Fix Common pytest Errors with uv
Diagnose and fix ModuleNotFoundError, conftest issues, collection warnings, and other common pytest problems in uv-managed projects.
How to Measure Code Coverage with pytest-cov
Measure test coverage with pytest-cov and enforce minimum thresholds. Configure coverage reporting in pyproject.toml and integrate with CI pipelines.
How to Parameterize Tests with pytest
pytest.mark.parametrize: run same test logic across multiple inputs with custom IDs, stacked decorators, and indirect fixtures.
How to replace tox with uv and a Makefile
Replace tox with uv and Make for faster multi-Python testing. Parallel test runs with minimal configuration overhead.
How to use uv to speed up tox
Install the tox-uv plugin to replace pip and virtualenv with uv, making tox environment creation and dependency installation 10-100x faster.
Explanation
Essential pytest Plugins
pytest plugins for reliable test suites: detect test-order bugs, kill hangs, retry flakes, and track performance regressions.
pytest vs unittest: Which Should You Use?
pytest cuts unittest's boilerplate with plain assert and reusable fixtures, so tests are faster to write and easier to read.
Reference
nox
Nox: Python test automation tool using Python code for configuration. Supports uv backend, pyproject.toml, multi-version matrices.
tox-uv
tox-uv is a tox plugin that replaces pip and virtualenv with uv for faster environment creation and dependency installation.
tox
tox automates tests across Python versions. Isolate and test your library on 3.10–3.14 in one command for CI reliability.
From the blog
Posts tagged testing.
-
Blanket 1.0: An Early Look at Larry Hastings's Deterministic Threading Tests
Larry Hastings released Blanket 1.0 at PyCon US 2026. It lets test authors script the Python thread scheduler so that threaded tests stop being flaky.
-
Seven Claude Code Skills for Python from the Creator of spaCy
Matthew Honnibal's Claude Code skills collection covers type annotations, error handling, property-based testing, and mutation testing.
-
Flexible Python Version Management with uv and tox
Solve tox Python version mismatch errors by using uvx to run tox with any Python version on demand.
-
Effective Python Developer Tooling in December 2024
An opinionated guide to Python developer tooling covering uv, ruff, pytest, mypy, and principles for productive Python development.