python-testing
Skill2 starsChanged 4 months agoMITView on GitHub
Design and write pytest tests with clear fixtures, parametrization, and coverage expectations. Use when writing Python tests, fixing failing tests, adding fixtures, or when the user mentions pytest, unit tests, or test coverage in Python.
33 other projects use a version of this.
Adopted by
Most recently taken up by
- fmind/dottheir own version, first seen Oct 5, 2026
- ComposioHQ/composiotheir own version, first seen Sep 29, 2026
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- IAbuElRuzz/AgentSkillstheir own version, first seen Sep 16, 2026
- Paldom/python-skillstheir own version, first seen Sep 10, 2026
- konstruktoid/agent-instructions-skillstheir own version, first seen Aug 24, 2026
Used with
Projects with it also use swift-protocol-di-testing, springboot-tdd and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 6 projects that use this
FaisalAlqarniSkillspringboot-tdd
Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
Also in 9 projects that use this
FaisalAlqarniSkilldjango-verification
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Also in 9 projects that use this
InfopibeSkillswift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
Also in 6 projects that use this
johnrtiptonSkilldjango-security
This skill should be used when conducting security reviews, auditing Django applications, hardening security settings, implementing OWASP Top 10 protections, managing secrets, or ensuring multi-tenant security isolation. Provides automated security auditor that scans settings, code, dependencies, and multi-tenant configurations with auto-fix capabilities.
Also in 9 projects that use this
joneqianSkillpostgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
Also in 12 projects that use this
- +1 more from FaisalAlqarni
- +3 more from Infopibe
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 33
- ComposioHQ/composio★ 30ksame name
- microsoft/agent-framework★ 14ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- Mindrally/skills★ 266same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- Jamkris/everything-gemini-code★ 87same name
- codelably/harmony-claude-code★ 43same name
- noah-sheldon/ai-dev-kit★ 13same name
23 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- debuggingSkill
- javascript-best-practicesSkill
- nextjs-app-routerSkill
- nextjs-data-fetchingSkill
- python-best-practicesSkill
- react-best-practicesSkill
- tagged-code-commentsSkill
- typescript-best-practicesSkill
- create-skillSkill
- revise-skillSkill
- academic-paperSkill
- latex-scientific-writingSkill
- paper-abstractSkill
- paper-conclusionSkill
- paper-discussionSkill
- paper-introductionSkill
- paper-literature-reviewSkill
- paper-methodsSkill
- paper-peer-reviewSkill
- paper-related-workSkill
- paper-resultsSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 28 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Arrange → Act → Assert: Keep each test focused on one behavior.
- Very specific: line 28
Use fixtures for shared setup: Prefer function-scoped fixtures.
- Very specific: line 29
Parametrize similar cases: Use @pytest.mark.parametrize for input tables instead of copy-pasted tests.
- Very specific: line 30
Mark slow / integration tests: Use markers (@pytest.mark.slow, @pytest.mark.integration) when the project defines them.
- Very specific: line 32
Fail loudly: Prefer raising / expecting exceptions with pytest.raises over returning magic error codes in tests.
- Very specific: line 33
Tag gaps: If you skip coverage for a path you touched, leave 🟠 TEST(P1): via tagged-code-comments and list it in Open follow-ups so the …
- Distinctive: line 53
Prefer critical-path and edge-case coverage over 100% line chasing
- Distinctive: line 54
Do not weaken assertions just to make coverage green
“Common” is measured: kept by at least 6 in 10 of the 28 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Testing (pytest)
Defaults
- Framework: pytest
- Layout:
tests/mirroring the package, or colocatedtest_*.pyif the repo already does that - Naming:
test_<behavior>, filestest_<module>.py - Assertions: plain
assertwith readable messages when helpful
Instructions
- Test behavior, not implementation. Assert outcomes users care about (return values, side effects, errors). Avoid brittle private-API tests.
- Arrange → Act → Assert. Keep each test focused on one behavior.
- Use fixtures for shared setup. Prefer function-scoped fixtures; use
yieldfor teardown. Avoid fixture pyramids — extract helpers when fixtures nest deeply. - Parametrize similar cases. Use
@pytest.mark.parametrizefor input tables instead of copy-pasted tests. - Mark slow / integration tests. Use markers (
@pytest.mark.slow,@pytest.mark.integration) when the project defines them; keep the default suite fast. - Mock at boundaries. Mock network, clock, and filesystem edges — not the unit under test. Prefer
unittest.mockorpytest-mockas the project already uses. - Fail loudly. Prefer raising / expecting exceptions with
pytest.raisesover returning magic error codes in tests. - Tag gaps. If you skip coverage for a path you touched, leave
🟠 TEST(P1):viatagged-code-commentsand list it in Open follow-ups so the developer must check before ship.
Minimal example
import pytest
from mypkg.mathutil import divide
@pytest.mark.parametrize("a,b,expected", [(6, 3, 2), (5, 2, 2.5)])
def test_divide(a, b, expected):
assert divide(a, b) == expected
def test_divide_by_zero():
with pytest.raises(ZeroDivisionError):
divide(1, 0)Coverage expectations
- New logic should have tests unless the user says otherwise
- Prefer critical-path and edge-case coverage over 100% line chasing
- Do not weaken assertions just to make coverage green
Anti-patterns
- One giant test that asserts everything
- Sleeping for timing instead of controlling time
- Snapshotting entire large objects when a few fields matter
- Tests that depend on run order or shared mutable module state
Additional resources
- references/checklist.md
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.

