pytest
Powerful Python testing framework with fixtures, parameterisation, and a rich plugin ecosystem.
Pricing
Free / Open source
Type
Automation
Languages
Python
// VERDICT
Reach for pytest for essentially all Python testing - simple assertions, fixtures and parametrization with a vast plugin ecosystem. Skip it only when you must stick to stdlib unittest or aren't using Python.
Best for
The de-facto Python testing framework - concise assert-based tests, powerful fixtures, parametrization and a huge plugin ecosystem, for unit through integration testing.
Avoid when
You're not in Python, you want a built-in-only stdlib approach (unittest), or a no-code tool.
CI/CD fit
pytest CLI · plugins (coverage, xdist) · CI runner
Languages
Python
Team fit
Python teams · Unit + integration testing · QA/SDETs in Python
Setup
Maintenance
Learning
Licence
// BEST FOR
- Concise assert-based tests (no boilerplate)
- Powerful fixtures for setup/teardown and DI
- Parametrization for data-driven tests
- A huge plugin ecosystem (coverage, parallel, etc.)
- Unit through integration testing
- The Python community standard
// AVOID WHEN
- You're not using Python
- You must use stdlib unittest only
- A no-code tool is needed
- You want a GUI runner
- Your tests aren't code-based
- Minimal dependencies are mandated
// QUICK START
pip install pytest
pytest # add pytest-cov for coverage, pytest-xdist for parallel; run in CI// ALTERNATIVES TO CONSIDER
| Tool | Choose it when |
|---|---|
| AVA | You want a concurrent JS test runner instead. |
| Testcontainers | You need real dependencies for integration tests. |
| Robot Framework | You want keyword-driven acceptance tests in Python. |
// FEATURES
- Plain assert-based test functions — no boilerplate
- Fixture system with scope, parametrisation, and auto-use
- Marks for tagging, skipping, and conditional execution
- Massive plugin ecosystem (pytest-asyncio, pytest-django, pytest-bdd)
- Detailed introspection on assertion failures
// PROS
- De facto Python testing standard
- Fixtures scale better than xUnit-style setUp/tearDown
- Plugins cover virtually every Python testing need
- Massive community and decades of stability
// CONS
- Magic of fixtures and conftest.py confuses newcomers
- Plugin sprawl — easy to over-depend on community plugins
- Not a fit outside the Python ecosystem
// EXAMPLE QA WORKFLOW
Install pytest
Write test_*.py with plain asserts
Add fixtures for setup/teardown
Parametrize for data-driven cases
Run with coverage/parallel plugins in CI
Gate on failures and coverage
// RELATED QA.CODES RESOURCES
Cheat sheets
Glossary
Practice
Interview