# pytest-dev/pytest

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/pytest-dev-pytest).**

13,645 stars · 3,024 forks · Python · mit

## Links

- GitHub: https://github.com/pytest-dev/pytest
- Homepage: https://pytest.org
- awesome-repositories: https://awesome-repositories.com/repository/pytest-dev-pytest.md

## Topics

`hacktoberfest` `python` `test` `testing` `unit-testing`

## Description

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.

## Tags

### Testing & Quality Assurance

- [Test Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks.md) — Provides a testing framework for Python that uses standard language assertions and a modular fixture system to verify code correctness.
- [Data-Driven Parametrization](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-configuration/data-driven-parametrization.md) — Generates multiple test instances from a single function definition by injecting varied input datasets during the collection phase. ([source](https://docs.pytest.org/en/stable/explanation/fixtures.html))
- [Test Execution Runners](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-execution-runners.md) — Provides a command-line tool that automatically discovers and executes test suites based on naming conventions and configuration files.
- [Test Fixture Systems](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-infrastructure-configuration/test-fixture-systems.md) — Provides a powerful dependency injection system that automatically resolves and injects test resources as function arguments.
- [Fixture Definitions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-infrastructure-configuration/test-fixture-systems/fixture-definitions.md) — Creates setup and teardown logic that can be injected into test functions via dependency injection or automatic activation. ([source](https://pytest.org/reference/reference.html))
- [Execution Assertions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/assertion-validation-utilities/assertion-libraries/execution-assertions.md) — Uses standard language assertions to validate code behavior and automatically inspects intermediate values to provide detailed failure reports. ([source](https://docs.pytest.org/en/stable/getting-started.html))
- [CLI Test Runners](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-execution-runners/cli-test-runners.md) — Automatically identifies and executes test files and functions based on naming conventions within the project directory structure. ([source](https://pytest.org/explanation/goodpractices.html))
- [Test Configuration](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-configuration.md) — Centralizes project-wide testing settings and environment preferences within a dedicated configuration file. ([source](https://pytest.org/explanation/goodpractices.html))
- [Assertion Rewriting](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/assertion-extensions-modes/soft-assertions/assertion-rewriting.md) — Provides detailed failure reports by automatically inspecting expressions in standard language assertions. ([source](https://pytest.org/how-to/writing_plugins.html))
- [Test Lifecycle and Execution Control](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control.md) — Controls the scope and cleanup of test resources across functions, classes, modules, or entire sessions to ensure reliable execution. ([source](https://pytest.org/explanation/fixtures.html))
- [Test Case Generators](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/test-execution-orchestration/test-case-generators.md) — Implements dynamic test generation logic to determine test parameters or scopes based on runtime conditions or command-line options. ([source](https://pytest.org/how-to/parametrize.html))
- [Assertion Rewriters](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/assertion-aggregators/assertion-rewriters.md) — Modifies source code during import to inject detailed diagnostic information into standard language assertions for improved failure reporting.
- [Conditional Skipping](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/test-execution-controls/conditional-skipping.md) — Prevents execution of specific tests, classes, or modules based on runtime conditions, environment settings, or missing dependencies. ([source](https://pytest.org/how-to/skipping.html))
- [Parametrized Fixtures](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-infrastructure-configuration/test-fixture-systems/parametrized-fixtures.md) — Configures fixture functions to run multiple times with different parameters, allowing tests to consume varied setup states. ([source](https://pytest.org/how-to/parametrize.html))
- [Test Suite Filters](https://awesome-repositories.com/f/testing-quality-assurance/testing-infrastructure-management/test-execution-management/test-suite-filters.md) — Restricts test discovery by excluding specific modules, classes, or functions based on file patterns, markers, or explicit deselection criteria. ([source](https://docs.pytest.org/en/stable/changelog.html))
- [Test Annotations](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-metadata/test-annotations.md) — Attaches custom or built-in attributes to test functions, classes, or modules to organize them for selective execution. ([source](https://pytest.org/how-to/mark.html))
- [Expected Failure Markers](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/expected-failure-markers.md) — Identifies tests known to fail so they are reported separately from regressions while allowing them to run. ([source](https://pytest.org/explanation/flaky.html))
- [Legacy Framework Adapters](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-execution-runners/legacy-framework-adapters.md) — Executes existing test suites written for other frameworks natively without requiring code modifications or refactoring. ([source](https://pytest.org/how-to/existingtestsuite.html))
- [Project Root Definitions](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-infrastructure-configuration/test-configuration-suites/project-configurations/project-root-definitions.md) — Establishes a stable base directory for test discovery and plugin state storage to ensure consistent identification of test nodes. ([source](https://pytest.org/reference/customize.html))
- [Doctest Runners](https://awesome-repositories.com/f/testing-quality-assurance/doctest-runners.md) — Runs code examples embedded in documentation files or source code docstrings as part of the automated test suite. ([source](https://pytest.org/how-to/doctest.html))
- [Test Isolation](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-isolation.md) — Provides utilities to create temporary directories and execute tests in isolation for plugin development. ([source](https://pytest.org/reference/reference.html))
- [Subtest Reporters](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/subtest-reporters.md) — Supports running multiple assertions within a single test function and reporting each failure independently. ([source](https://docs.pytest.org/en/stable/changelog.html))
- [Test Grouping Utilities](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/test-grouping-utilities.md) — Groups related test functions into classes to improve structure and enable shared configuration or resource management. ([source](https://docs.pytest.org/en/stable/getting-started.html))
- [Transient Failure Reruns](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/transient-failure-reruns.md) — Re-executes tests that fail during a run to mitigate the impact of transient issues and improve build reliability. ([source](https://pytest.org/how-to/cache.html))

### Software Engineering & Architecture

- [Dependency Injection](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/dependency-injection.md) — Provides a mechanism for managing setup and teardown logic by injecting reusable resources and state into test functions as arguments.
- [Exception Verification](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/exception-logic-structures/exception-handling-strategies/exception-verification.md) — Ensures that specific code blocks raise the correct error types and provides access to exception details for inspection. ([source](https://docs.pytest.org/en/stable/getting-started.html))
- [Plugin Architectures](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures.md) — Provides a modular system that allows third-party extensions to customize test collection, execution, and reporting through hooks.
- [Lifecycle Hooks](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/plugin-architectures/hook-event-orchestration/hook-resolution-lifecycles/lifecycle-hooks.md) — Allows plugins to intercept and modify the test lifecycle, including directory collection, option parsing, and reporting. ([source](https://docs.pytest.org/en/stable/changelog.html))
- [Hook-Based Plugin Systems](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures/hook-based-plugin-systems.md) — Features a hook-based plugin architecture that allows deep customization of the test lifecycle through event-driven registration.
- [Framework Extensions](https://awesome-repositories.com/f/software-engineering-architecture/extensibility-frameworks/framework-extensions.md) — Implements hooks to customize command-line arguments, configuration parsing, and the overall test collection and execution lifecycle. ([source](https://pytest.org/reference/reference.html))
- [Plugin Integrations](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/extensibility/third-party-plugins/plugin-integrations.md) — Integrates third-party plugins automatically upon installation to add specialized functionality like coverage reporting or distributed execution. ([source](https://cdn.jsdelivr.net/gh/pytest-dev/pytest@main/README.md))
- [Plugin Distributions](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/plugin-module-systems/modular-plugin-architectures/plugin-based-architectures/plugin-based-architectures/plugin-distributions.md) — Registers plugins through package metadata so they are automatically discovered and loaded by the testing environment. ([source](https://pytest.org/how-to/writing_plugins.html))
- [Test State Persistence](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/reactive-messaging/reactive-event-driven-systems/global-state-managers/test-state-persistence.md) — Stores execution metadata and test results on disk to enable selective re-running of failed tests across sessions.
- [Warning Verification Utilities](https://awesome-repositories.com/f/software-engineering-architecture/warning-issuance-systems/warning-verification-utilities.md) — Verifies that specific code blocks trigger expected warnings, matching messages against literal strings or regular expressions. ([source](https://pytest.org/how-to/capture-warnings.html))
- [Test Patching Utilities](https://awesome-repositories.com/f/software-engineering-architecture/code-patching-engines/patch-generators/runtime-patching-engines/test-patching-utilities.md) — Modifies attributes, dictionary items, or environment variables temporarily during a test and automatically restores them afterward. ([source](https://pytest.org/reference/reference.html))
- [Local Plugin Implementations](https://awesome-repositories.com/f/software-engineering-architecture/plugin-architectures/local-plugin-implementations.md) — Defines directory-specific hook implementations in configuration files to customize test execution behavior for specific subdirectories. ([source](https://pytest.org/how-to/writing_plugins.html))
- [Warning Issuance Systems](https://awesome-repositories.com/f/software-engineering-architecture/warning-issuance-systems.md) — Confirms that specific code paths trigger expected warnings to ensure proper handling of deprecated or problematic features. ([source](https://docs.pytest.org/en/stable/how-to/assert.html))
- [Dependency Warning Filters](https://awesome-repositories.com/f/software-engineering-architecture/warning-issuance-systems/dependency-warning-filters.md) — Configures global or test-specific rules to ignore, display, or promote specific warnings to errors. ([source](https://pytest.org/how-to/capture-warnings.html))

### Programming Languages & Runtimes

- [Assertion Decomposition](https://awesome-repositories.com/f/programming-languages-runtimes/expression-sequencing/assertion-decomposition.md) — Inspects failing expressions automatically to provide descriptive error messages without requiring specialized assertion methods. ([source](https://pytest.org))

### Development Tools & Productivity

- [Recursive Discovery Engines](https://awesome-repositories.com/f/development-tools-productivity/search-discovery-tools/recursive-discovery-engines.md) — Automatically traverses directory structures to identify and collect test modules based on naming conventions.
- [Temporary Directory Managers](https://awesome-repositories.com/f/development-tools-productivity/temporary-directory-configuration/temporary-directory-managers.md) — Automates the creation and cleanup of temporary directories for tests, with configurable retention policies for debugging. ([source](https://pytest.org/how-to/tmp_path.html))
- [Test Logging Utilities](https://awesome-repositories.com/f/development-tools-productivity/debugging-profiling-testing/test-execution-management/test-logging-utilities.md) — Automatically captures log messages during test execution and displays them in the console output when a test fails. ([source](https://pytest.org/how-to/logging.html))
- [Plugin Lifecycle Management](https://awesome-repositories.com/f/development-tools-productivity/plugin-lifecycle-management/plugin-lifecycle-management.md) — Controls the activation and deactivation of plugins through command-line flags, environment variables, or configuration files. ([source](https://pytest.org/how-to/plugins.html))
- [Marker Registrations](https://awesome-repositories.com/f/development-tools-productivity/plugin-registration-systems/marker-registrations.md) — Declares metadata tags for tests to ensure they are recognized by the system and appear in documentation. ([source](https://pytest.org/how-to/writing_plugins.html))
- [TOML Configuration Support](https://awesome-repositories.com/f/development-tools-productivity/project-configuration/toml-configuration-support.md) — Supports project configuration using native TOML files for structured and readable settings. ([source](https://docs.pytest.org/en/stable/changelog.html))

### Data & Databases

- [State Persistence](https://awesome-repositories.com/f/data-databases/state-persistence.md) — Saves and retrieves execution metadata and test results on disk to enable selective re-running of failed tests across sessions. ([source](https://pytest.org/reference/reference.html))

### DevOps & Infrastructure

- [Runtime State Modifiers](https://awesome-repositories.com/f/devops-infrastructure/automation-orchestration/task-execution-frameworks/state-inspection-tools/runtime-state-modifiers.md) — Overrides attributes, environment variables, or system paths during test execution and automatically restores the original state afterward. ([source](https://pytest.org/how-to/monkeypatch.html))
