Python Testing Framework
docs.pytest.org
2
Leaving SiteNav
External Link Disclaimer
You are about to visit docs.pytest.org. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
A mature, full-featured Python testing framework that enables developers to write expressive, readable, and maintainable tests with minimal boilerplate. The framework uses a plain assert statement for test assertions, automatically introspecting failure messages to show exact values that differed, eliminating the need to learn dozens of specialized assertion methods. Test discovery automatically finds test files matching patterns like test_*.py and *_test.py, and identifies test functions and classes without requiring explicit registration or test suites. Fixtures provide a powerful dependency injection system where test functions declare their dependencies through parameter names, and the framework resolves them through fixture functions with flexible scopes including function, class, module, package, and session levels. Fixtures support setup and teardown through yield statements, parametrization for running the same test with different inputs, and fixture composition where fixtures depend on other fixtures. The parametrize decorator allows running a single test function with multiple input combinations, automatically generating descriptive test IDs for each case. Marker-based test selection enables running subsets of tests by category using command-line filters, with built-in markers for skipping, expecting failures, and parametrization, plus custom markers for project-specific categorization. The plugin system has over 1,000 community plugins extending functionality with coverage reporting, parallel test execution, HTML report generation, Django and Flask integration, async test support, and property-based testing. Detailed failure reports show the exact source line, variable values at each step of the assertion, and diffs for data structures.
Statistics
2
Views
0
Clicks
0
Like
0
Dislike