pytest
by pytest-dev team · Framework · also known as py.test
Python testing framework with plain assert statements, fixtures, parametrization and a large plugin ecosystem, the de facto standard for Python test suites
Overview
pytest is a testing framework for Python maintained by the pytest-dev team under the MIT license. Tests are ordinary functions that use the built-in assert statement; pytest rewrites assertions to produce detailed failure messages without a special assertion API. Fixtures provide dependency injection for setup and teardown with configurable scope, and parametrization generates test cases from data tables.
The plugin architecture is its ecosystem: pytest-cov adds coverage, pytest-xdist distributes tests across CPU cores or machines, pytest-asyncio supports coroutines, Hypothesis integrates property-based testing, and Playwright ships an official pytest plugin for browser tests. pytest also runs unittest and nose-style suites, so adoption in legacy codebases is incremental. It is the default runner in most scientific Python projects and in tooling such as uv-managed packages. Limitations are mostly conceptual: fixture resolution through function arguments can be opaque in large suites, and plugin interactions sometimes complicate configuration in pyproject.toml or pytest.ini.
Capabilities
- Plain assert statements with detailed introspection
- Fixtures with scopes and dependency injection
- Parametrized tests
- Plugin system (coverage, parallel execution, async, browsers)
- Compatibility with unittest suites
- Marker-based selection and configurable collection
Typical workflows
- Run a package's test suite in CI with coverage
- Parallelize slow tests across cores with pytest-xdist
- Drive browser tests through the Playwright plugin
Strengths
- Minimal boilerplate
- Very large plugin ecosystem
- MIT license
Limitations
- Fixture magic can be hard to trace in large suites
- Plugin interactions complicate configuration
Prerequisites
- Python; install with uv or pip
Who it is for
- Python developers
- Data scientists testing pipelines
- Package maintainers
Alternatives & comparison
The standard library's unittest module is the built-in alternative with a class-based, xUnit-style API; pytest runs those tests as well and is generally preferred for new code because of fixtures and assertion rewriting.
Sources & verification
Primary sources consulted for this record. Claims are tied to the fields each source supports; the automated link checker re-verifies every URL on a schedule.
- Licensehttps://github.com/pytest-dev/pytest/blob/main/LICENSEchecked Nov 1, 2026
Supports: license_spdx
- Official sitepytest documentationchecked Nov 1, 2026
https://docs.pytest.org/en/stable
Supports: name, summary, capabilities
pytest.org redirects to the documentation site
- Repositorychecked Nov 1, 2026
- Confidence
- High
- Reviewed
- Nov 1, 2026
- Links
- Verified · Nov 2, 2026
Spotted an error?
More in Testing & QA
Playwright
Microsoft · Testing & QA
Microsoft's browser automation and end-to-end testing framework driving Chromium, Firefox and WebKit from one API in TypeScript, Python, Java and .NET
Puppeteer
Google (Chrome DevTools team) · Data collection & crawling
Node.js library from the Chrome team for controlling Chrome and Firefox over the DevTools Protocol or WebDriver BiDi, used for scraping, screenshots, PDFs and testing
ESLint
OpenJS Foundation · Testing & QA
Pluggable static analysis tool for JavaScript and TypeScript that finds problems in code through configurable rules and can fix many automatically
Cypress
Cypress.io · Testing & QA
End-to-end and component testing framework that runs tests inside the browser with an interactive runner, paired with the commercial Cypress Cloud
Vitest
VoidZero / Vitest team · Testing & QA
Vite-native unit test framework for JavaScript and TypeScript with a Jest-compatible API, watch mode, coverage and browser mode
Biome
Biome project · Testing & QA
Rust-based formatter and linter for JavaScript, TypeScript, JSX, JSON, CSS and GraphQL that replaces Prettier and ESLint with one binary