pytest
Installation
SKILL.md
Pytest
Pytest is the dominant testing framework for Python. It is loved for its no-boilerplate syntax (assert x == y), powerful fixture system, and rich plugin ecosystem.
When to Use
- Python Standard Testing Framework: The most widely adopted, powerful testing framework for Python web backends, data science, and ML.
- Clean Fixture Dependency Injection: Managing test setup, database connections, and teardown cleanly with
@pytest.fixture. - Parameterized Testing: Running test functions across multi-dimensional input sets with
@pytest.mark.parametrize. - Rich Plugin Ecosystem: Extending capabilities via
pytest-asyncio,pytest-cov,pytest-xdist, andpytest-mock.
Quick Start
# content of test_sample.py
def inc(x):
return x + 1