Generated by GPT-5-mini| pytest | |
|---|---|
![]() | |
| Name | pytest |
| Developer | Holger Krekel et al. |
| Released | 2004 |
| Programming language | Python |
| Operating system | Cross-platform |
| License | MIT License |
pytest pytest is a widely used testing framework for the Python programming language that emphasizes simple, readable tests and powerful fixtures for complex test setups. The framework was created to replace and extend earlier tools, offering concise syntax inspired by unit testing traditions while supporting modern practices from software engineering communities. It integrates with continuous integration services and development tools, enabling automated testing across projects for organizations and open-source ecosystems.
The framework originated in the mid-2000s, developed by Holger Krekel and contributors active in the Python community, with influences from earlier projects such as UnitTest-based tools and the culture around PEP 8 style guidance. Early adoption occurred among contributors to projects hosted on SourceForge and later GitHub, as the rise of distributed version control systems accelerated open-source collaboration. Significant milestones include integration with build and packaging tools like setuptools and pip, alignment with release engineering practices used by groups at Google and Microsoft, and broadening through contributions from engineers involved with Red Hat and Canonical Ltd..
The framework provides a concise assertion model leveraging Python's introspection and tracebacks, enabling expressive test functions that reduce boilerplate. Features include parameterized testing for combinatorial scenarios, scalable fixture mechanisms for dependency injection and resource management, and test discovery compatible with standard project layouts used by developers at Mozilla and Facebook. It supports detailed reporting formats consumed by continuous integration systems such as Jenkins (software), Travis CI, and GitLab CI/CD, and integrates with code coverage tools like coverage.py and static analysis tools from organizations such as PyCA and Mozilla. Advanced features encompass xfail/xpass markers for handling known failures, built-in support for test collection hooks used in large repositories at companies like Dropbox and Instagram, and compatibility with mocking libraries popularized by contributors affiliated with Python Software Foundation projects.
Typical usage involves writing plain test modules recognized by a test discovery algorithm consistent with naming conventions used in many open-source projects on GitHub and executing them with a command-line runner adapted for automation servers such as Jenkins (software). Tests often use fixtures defined in conftest files analogous to configuration patterns seen in Django projects and package layouts maintained by teams at NumPy and SciPy. Developers in data science stacks involving Pandas and scikit-learn use parametrization and markers to validate numerical code across environments like those provided by Anaconda (company). Integration examples include running tests in containerized environments orchestrated by Kubernetes and packaging releases via CI pipelines used by maintainers at Mozilla and Canonical Ltd..
The project maintains a rich plugin architecture with community-developed extensions facilitating integrations, mirroring ecosystems seen around Sphinx (software) and Jupyter Notebook. Notable plugins handle parallel test execution inspired by techniques from Apache Spark and Celery (software), continuous reporting adapters for systems such as Atlassian's offerings, and specialized plugins for web frameworks like Flask and Django. The plugin ecosystem is supported by contributors connected to foundations and companies like NumFOCUS and OpenStack Foundation, and many plugins are distributed via package indices managed by groups resembling PyPI maintainers and release engineers at Canonical Ltd..
Compared to earlier frameworks such as UnitTest (derived from JUnit) and alternative libraries like nose and frameworks used in other languages (for example RSpec in Ruby or JUnit in Java), the framework emphasizes simpler syntax, richer fixture semantics, and a plugin system that supports enterprise workflows at organizations like Google and Facebook. Its assertion rewriting and introspective failure reports contrast with the verbose setups required by some legacy frameworks used in enterprise projects at Oracle Corporation and IBM. In ecosystems centered on scientific computing—projects affiliated with NumPy and SciPy—the framework is often preferred for parametrization and marker-based selection over more opinionated tools.
The framework is widely adopted across open-source projects hosted on platforms such as GitHub and in corporate environments at companies including Dropbox, Instagram, and Mozilla. It has influenced testing practices in academic and industry settings, appearing in curricula and workshops run by organizations like Python Software Foundation and O'Reilly Media. Its extensibility has enabled integration into diverse stacks—from web applications built by teams at Red Hat to data science pipelines used by research groups at institutions like MIT and Stanford University—contributing to reproducible testing practices and continuous delivery workflows.
Category:Software testing