python-testing
Python testing patterns with pytest, fixtures, TDD, mocking, async and integration tests. Use when writing or auditing a Python test suite.
它会碰到什么
扫了多少7 个文本文件,25 KB
它会碰到什么不碰外部(只输出文字)
命中总数1 处
命中统计严重 0 · 高 0 · 中 0 · 低 0
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Python Testing Hub
Testing standards for pytest configuration, fixture management, and TDD implementation.
Table of Contents
- [Quick Start](#quick-start)
- [When to Use](#when-to-use)
- [Modules](#modules)
Quick Start
- Dependencies:
pip install pytest pytest-cov pytest-asyncio pytest-mock - Configuration: Add the following to
pyproject.toml:
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--cov=src"
- Verification: Run
pytestto confirm discovery of files matchingtest_*.py.
When To Use
- Constructing unit and integration tests for Python 3.9+ projects.
- Isolating external dependencies using
pytest-mockor custom monkeypatching. - Validating asynchronous logic with
pytest-asynciomarkers and event loop management. - Configuring project-wide coverage thresholds and reporting.
When NOT To Use
- Evaluating test
quality - use pensive:test-review instead
- Infrastructure test
config - use leyline:pytest-config
Modules
This skill uses modular loading to manage the system prompt budget.
Core Implementation
- See
modules/unit-testing.md- AAA (Arrange-Act-Assert) pattern, basic test structure, and exception validation. - See
modules/fixtures-and-mocking.md- Request-scoped fixtures, parameterization, and boundary mocking. - See
modules/async-testing.md- Coroutine testing, async fixtures, and concurrency validation.
Infrastructure & Workflow
- See
modules/test-infrastructure.md- Directory standards,conftest.pymanagement, and coverage tools. - See
modules/testing-workflows.md- Local execution patterns and GitHub Actions integration.
Standards
- See
modules/test-quality.md- Identification of common anti-patterns like broad exception catching or shared state between tests.
Exit Criteria
- Tests implement the AAA pattern.
- Coverage reaches the 80% project minimum.
- Individual tests are independent and do not rely on execution order.
- Fixtures are scoped appropriately (function, class, or session) to prevent side effects.
- Mocking is restricted to external system boundaries.
Troubleshooting
- Test Discovery: Verify filenames match the
test_*.pypattern. Usepytest --collect-onlyto debug discovery paths. - Import Errors: Ensure the local source directory is in the path, typically by installing in editable mode with
pip install -e .. - Async Failures: Confirm that
pytest-asynciois installed and that async tests use the@pytest.mark.asynciodecorator or corresponding auto-mode configuration.
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
星标★ 337
本站分层T2
该仓技能数227
原文件路径
plugins/parseltongue/skills/python-testing/SKILL.md同一个仓库里的其他技能
- claude-code-plugin-reference
- night-market-architecture-contract
- night-market-build-and-env
- night-market-change-control
- night-market-collective-memory
- night-market-completion-integrity-campaign
- night-market-config-catalog
- night-market-debugging-playbook
- night-market-diagnostics-toolkit
- night-market-docs-and-writing
- night-market-failure-archaeology
- night-market-model-and-harness-updates