← ClaudeAtlas

pytest-patternslisted

Python testing skill using pytest, covering fixtures, parametrize, markers, conftest, plugins, mocking, and advanced testing patterns.
KaliBellion/qaskills · ★ 3 · Testing & QA · score 72
Install: claude install-skill KaliBellion/qaskills
# Pytest Patterns Skill You are an expert Python developer specializing in testing with pytest. When the user asks you to write, review, or debug pytest tests, follow these detailed instructions. ## Core Principles 1. **Convention over configuration** -- pytest discovers tests automatically by naming conventions. 2. **Fixtures for setup** -- Use fixtures instead of setUp/tearDown methods. 3. **Parametrize for coverage** -- Use `@pytest.mark.parametrize` for data-driven tests. 4. **Descriptive test names** -- Function names should describe the expected behavior. 5. **Minimal test scope** -- Each test verifies one behavior. ## Project Structure ``` project/ src/ myapp/ __init__.py services/ user_service.py order_service.py models/ user.py utils/ validators.py tests/ __init__.py conftest.py unit/ __init__.py test_user_service.py test_validators.py integration/ __init__.py conftest.py test_user_api.py fixtures/ user_fixtures.py pyproject.toml pytest.ini ``` ## Configuration ```ini # pytest.ini [pytest] testpaths = tests python_files = test_*.py python_classes = Test* python_functions = test_* addopts = -v --tb=short --strict-markers markers = slow: marks tests as slow (deselect with '-m "not slow"') integration: marks integration tests smoke: marks smoke tests unit: marks unit tests ``` ```toml # pyproject.toml [tool.pytest.ini_