pytest-code-review
БесплатноБез исполняемых скриптовНе проверенReviews pytest test code for pytest-asyncio configuration, async resource cleanup, fixture scoping, parametrize usage, and mock/patch correctness. Use when…
от existential-birds★ 92 звезды на GitHubОб этом скилле
Pytest Code Review
Quick Reference
| Issue Type | Reference |
|---|---|
pytest-asyncio strict/auto mode, AsyncMock, task cleanup |
references/async-testing.md |
conftest.py, tmp_path, fixture scope, async try/finally cleanup |
references/fixtures.md |
@pytest.mark.parametrize, pytest.param, indirect fixtures |
references/parametrize.md |
Call-site patch(), AsyncMock, spec_set, mocker |
references/mocking.md |
Review gates
Work in order. Do not assert pytest-specific problems until each applicable gate passes.
- Scoped files — Pass when: You list every
test_*.pyand anyconftest.pyyou will cite; no findings for files outside that list. - Async vs sync — Pass when: Per scoped file, you note whether it uses
async def test_*/awaitand check projectasyncio_mode(strictvsauto); if async, open references/async-testing.md before criticizing async usage. - Fixtures — Pass when: If shared setup matters, you name the
conftest.pypath(s) or state none; for yield fixtures, confirm cleanup exists before claiming resource leaks. - patch / mocks — Pass when: For any
patchor mock critique, you give the import path where the symbol is used (call site), or mark N/A; open references/mocking.md when mocking is central to the review. - Findings — Pass when: Each finding includes a file path and line(s) or test node id, not a generic rule restatement.
Review Checklist
- Async tests match configured
pytest-asynciomode (strictrequires@pytest.mark.asyncio+@pytest_asyncio.fixture;autodiscoversasync deftests/fixtures automatically) -
asyncio_default_fixture_loop_scopeconfigured explicitly inpyproject.toml/pytest.ini -
AsyncMockused for async dependencies (notMock) and all coroutines/async mocks awaited - Background tasks and async resources cleaned up in
finallyblocks - Fixture scope appropriate (
functionfor mutable state,module/sessiononly for immutable/isolated expensive setup) - Yield fixtures wrap cleanup in
try/finallyand usetmp_pathinstead of hardcoded/tmppaths -
@pytest.mark.parametrizeusespytest.param(..., id=...)/indirect=cleanly for similar cases -
patch()targets where the symbol is used (imported/looked up), not where defined - Mocks use
spec/spec_setand verify exact call arguments when behavior depends on them - Tests remain isolated (no shared module-level mock or mutable state)
Valid Patterns (Do NOT Flag)
assertwithout custom message —pytestrewritesassertstatements to render detailed diffs automatically@pytest.fixturewithout explicit scope — Defaultfunctionscope is correct for most fixtures, including those returning fresh mutable state per testmonkeypatchinstead ofunittest.mock— Simplerpytest-native patching with automatic teardownasync def test_*without@pytest.mark.asynciowhenasyncio_mode = "auto"— Intentional inautomode
When to Load References
- Reviewing async test functions or
pytest-asyncioconfig →references/async-testing.md - Reviewing fixtures or
conftest.py→references/fixtures.md - Reviewing parametrized tests →
references/parametrize.md - Reviewing mocks and patches →
references/mocking.md
Review Questions
- Does async test/fixture syntax match the project's
pytest-asyncioasyncio_mode(strictvsauto)? - Are fixtures properly scoped with
try/finallycleanup andtmp_path? - Can duplicated test cases be simplified with
@pytest.mark.parametrize? - Do
patch()calls target the call-site namespace, useAsyncMock/spec_set, and verify arguments accurately?
Установить pytest-code-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pytest-code-review?
Reviews pytest test code for pytest-asyncio configuration, async resource cleanup, fixture scoping, parametrize usage, and mock/patch correctness. Use when reviewing test_*.py or conftest.py files.
Как установить скилл pytest-code-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pytest-code-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic