pytest is a testing framework for Python that provides a command-line runner for discovering and executing test suites. It is built on a modular architecture that uses standard language assertions to verify code correctness, automatically inspecting expressions to provide detailed failure reports without requiring specialized assertion methods.
The framework distinguishes itself through a dependency injection system that manages setup and teardown logic by automatically resolving and injecting resources into test functions. It also features a hook-based plugin architecture that allows for deep customization of the test lifecycle, including collection, execution, and reporting. These capabilities are supported by dynamic parametrization, which generates multiple test instances from a single definition, and persistent state caching that enables selective re-running of failed tests across sessions.
Beyond its core execution model, the project offers a comprehensive suite of tools for managing test environments, including output capture, log management, and warning validation. It supports complex testing scenarios through features like temporary file management, object patching, and the ability to execute existing test suites from other frameworks natively. Configuration is handled through centralized files, allowing for fine-grained control over test discovery, filtering, and execution behavior.
The project is distributed as a standard Python package and includes extensive documentation on its configuration, plugin system, and command-line interface.