pytest-config
npx machina-cli add skill athola/claude-night-market/pytest-config --openclawTable of Contents
Pytest Configuration Patterns
Standardized pytest configuration and patterns for consistent testing infrastructure across Claude Night Market plugins.
When To Use
- Setting up pytest configuration and fixtures
- Configuring conftest.py patterns for test infrastructure
When NOT To Use
- Non-Python projects or projects using other test frameworks
- Simple scripts that do not need test infrastructure
Quick Start
Basic pyproject.toml Configuration
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"-v",
"--cov=src",
"--cov-report=term-missing",
"--cov-fail-under=80",
"--strict-markers",
]
markers = [
"unit: marks tests as unit tests",
"integration: marks tests as integration tests",
"slow: marks tests as slow running",
]
[tool.coverage.run]
source = ["src"]
omit = ["*/tests/*", "*/migrations/*", "*/__pycache__/*"]
branch = true
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"def __str__",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
precision = 2
show_missing = true
Verification: Run pytest --collect-only to verify discovery, pytest -v --co -q for markers, and pytest --cov for coverage thresholds.
Detailed Patterns
For detailed implementation patterns, see:
- Conftest Patterns - Conftest.py templates, fixtures, test markers, and directory structure
- Git Testing Fixtures - GitRepository helper class for testing git workflows
- Mock Fixtures - Mock tool fixtures for Bash, TodoWrite, and other Claude Code tools
- CI Integration - GitHub Actions workflows and test commands for automated testing
- Module Index: See
modules/README.mdfor module organization overview
Integration with Other Skills
This skill provides foundational patterns referenced by:
parseltongue:python-testing- Uses pytest configuration and fixturespensive:test-review- Uses test quality standardssanctum:test-*- Uses conftest patterns and Git fixtures
Reference in your skill's frontmatter:
dependencies: [leyline:pytest-config, leyline:testing-quality-standards]
Exit Criteria
- pytest configuration standardized across plugins
- conftest.py provides reusable fixtures
- test markers defined and documented
- coverage configuration enforces quality thresholds
- CI/CD integration configured for automated testing
Troubleshooting
Common Issues
Tests not discovered
Ensure test files match pattern test_*.py or *_test.py. Run pytest --collect-only to verify.
Import errors
Check that the module being tested is in PYTHONPATH or install with pip install -e .
Async tests failing
Install pytest-asyncio and decorate test functions with @pytest.mark.asyncio
Source
git clone https://github.com/athola/claude-night-market/blob/master/plugins/leyline/skills/pytest-config/SKILL.mdView on GitHub Overview
Standardized pytest configuration and patterns for Claude Night Market plugins, enabling reusable fixtures, conftest templates, and CI integration. It promotes consistent test infrastructure across projects by providing modular templates and testing patterns.
How This Skill Works
The skill provides conftest-pattern templates, shared fixtures, and a pyproject.toml configuration for pytest and coverage. It links in modules for git testing fixtures, mock fixtures, and CI integration to enforce testing standards across plugins.
When to Use It
- Setting up pytest configuration and fixtures for a new plugin project
- Configuring conftest.py patterns and shared fixtures for test infrastructure
- Defining markers, coverage, and CI-related options in pyproject.toml
- Integrating pytest with GitHub Actions workflows for automated testing
- Validating test discovery and coverage thresholds during CI reviews
Quick Start
- Step 1: Add the pyproject.toml [tool.pytest.ini_options] block with testpaths, patterns, and markers
- Step 2: Enable coverage and strict markers, then run pytest --collect-only and pytest --cov
- Step 3: Integrate GitHub Actions CI workflows and verify with pytest commands
Best Practices
- Use a single pyproject.toml to configure pytest options
- Define and document clear test markers (unit, integration, slow)
- Place reusable fixtures in conftest.py and reference via modules/conftest-patterns.md
- Keep coverage thresholds under strict control (e.g., --cov-fail-under=80)
- Incorporate CI integration patterns (GitHub Actions) for automated test runs
Example Use Cases
- A plugin test suite that uses standardized pytest config for consistent results
- Conftest-patterns used to share fixtures across tests
- Git testing fixtures to simulate Git workflows in tests
- Mock fixtures for Bash and Claude Code tools in tests
- CI integration with GitHub Actions and pytest commands
Frequently Asked Questions
Related Skills
terraform
chaterm/terminal-skills
Terraform 基础设施即代码
makefile-generation
athola/claude-night-market
Generate language-specific Makefiles with testing, linting, and automation targets. Use for project initialization and workflow standardization. Skip if Makefile exists.
precommit-setup
athola/claude-night-market
Configure three-layer pre-commit system with linting, type checking, and testing hooks. Use for quality gate setup and code standards. Skip if pre-commit is optimally configured.
error-patterns
athola/claude-night-market
'Standardized error handling patterns with classification, recovery,
risk-classification
athola/claude-night-market
'Inline risk classification for agent tasks using a 4-tier model. Hybrid
quota-management
athola/claude-night-market
'Quota tracking, threshold monitoring, and graceful degradation for rate-limited