pytest-code-review
Skill91 starsChanged 4 days agoApache-2.0View on GitHub
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.
In this repository85 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- agent-architecture-analysisSkill
- app-intents-code-reviewSkill
- artifact-analysisSkill
- axum-code-reviewSkill
- brainstorm-beagleSkill
- bubbletea-code-reviewSkill
- cloudkit-code-reviewSkill
- elixir-performance-reviewSkill
- elixir-security-reviewSkill
- elixir-writing-docsSkill
- exdoc-configSkill
- exunit-code-reviewSkill
- fastapi-code-reviewSkill
- fetch-pr-feedbackSkill
- ffi-code-reviewSkill
- fix-llm-artifactsSkill
- fowler-refactoringSkill
- gen-test-planSkill
- go-architectSkill
- go-code-reviewSkill
- go-data-persistenceSkill
- go-testing-code-reviewSkill
- healthkit-code-reviewSkill
- humanize-beagleSkill
- improve-docSkill
- ios-animation-code-reviewSkill
- liveview-code-reviewSkill
- llm-artifacts-detectionSkill
- llm-judgeSkill
- macros-code-reviewSkill
- phoenix-code-reviewSkill
- postgres-code-reviewSkill
- prfaq-beagleSkill
- prometheus-go-code-reviewSkill
- quick-planSkill
- react-flow-code-reviewSkill
- react-flowSkill
- react-router-code-reviewSkill
- react-router-v7Skill
- receive-feedbackSkill
- refactor-repoSkill
- resolve-beagleSkill
- respond-pr-feedbackSkill
- review-ai-writingSkill
- review-elixirSkill
- review-frontendSkill
- review-goSkill
- review-iosSkill
- review-llm-artifactsSkill
- review-planSkill
- review-pythonSkill
- review-remix-v2Skill
- review-rustSkill
- review-skillSkill
- review-structureSkill
- review-tuiSkill
- review-verification-protocolSkill
- run-test-planSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 59
Do patch() calls target the call-site namespace, use AsyncMock/spec_set, and verify arguments accurately?
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.iniAsyncMockused 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 casespatch()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?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

