macalbert/envilder/python-testing
Claude Code and agent skill by macalbert/envilder
- community
Checking that the SKILL.md file is still in the repository.
Mandatory testing conventions including AAA pattern, test naming, assertions, and mocks. Use for unit, integration, or E2E tests with pytest, unittest, pytest-asyncio, or Playwright.
Install
npx vskill@latest install macalbert/envilder/python-testingSKILL.md
Testing Conventions (Python)
This skill defines the MANDATORY testing conventions for Python projects. These are rules, not guidelines.
Documentation Rules
NO Docstrings, NO Comments
- Do NOT write docstrings - method/class names must be self-explanatory
- Do NOT write comments except for AAA markers (
# Arrange,# Act,# Assert) - The test name
Should_X_When_Yalready documents the intent
Exception: SDK public API: Code under src/sdks/*/ that is consumed by external developers (e.g. facade classes, public entry points) SHOULD have docstrings with usage examples. External users rely on IDE tooltips and help(). This exception does not apply to tests or internal helpers.
❌ FORBIDDEN
✅ CORRECT
Core Principles
1. AAA Pattern (Arrange – Act – Assert)
ALL tests MUST follow the AAA pattern, separated by inline comments.
Rules
- Each phase MUST be separated with comments
- Never mix phases
- Each comment (`# Arrange`, `# Act`, `# Assert`) appears AT MOST ONCE per test: if you need two actions
or two asserts, write two tests
- No `if`, `switch`, or conditional logic inside Arrange, Act, or Assert blocks
- No `try/catch/finally` inside tests: use pytest fixtures with
yieldfor teardown/cleanup - No `# Act & Assert` combined blocks: Act and Assert are ALWAYS separate
- For exception testing, extract the action into a
lambdabefore asserting - If no Arrange is needed, omit it
- If there is no Assert, the test is invalid
pytest Example
2. Test Naming Convention
Test names MUST follow exactly:
Test Rules
- PascalCase
- NO natural language
- NO vague names
- NO missing
Whenclause test_prefix is FORBIDDEN
pytest Discovery Configuration (MANDATORY)
If this config is missing → tests are wrong.
Variable Naming (MANDATORY)
| Purpose | Name | |
|---|---|---|
| Subject under test | sut | |
| Expected value | expected | |
| Actual result | actual |
No creativity allowed here.
Async Testing (pytest-asyncio)
Exception Testing
Act and Assert MUST be separate. Extract the action into a lambda in the Act phase.
✅ CORRECT: separate Act and Assert
❌ FORBIDDEN: combined Act & Assert
Teardown & Cleanup (MANDATORY pattern)
Never use `try/finally` in tests. Use pytest fixtures with yield for cleanup.
✅ CORRECT: fixture with yield
❌ FORBIDDEN: try/finally in test
Mocking & Verification (OBLIGATORY)
If you mock something, you MUST verify it.
Async:
No verification → test rejected.
Test Data Creation (RECOMMENDED)
Use Mother Pattern or Builder Pattern for creating test data. Both approaches are valid and recommended over inline object creation.
Mother Pattern
Usage:
Builder Pattern (polyfactory + shared Builder[T])
The shared test package provides a generic Builder[T] that wraps polyfactory to create type-safe builders for any Pydantic model. The with_* methods are generated dynamically via __getattr__.
Step 1: Define Factory + Builder
Step 2: Use in tests
Anti-Patterns (PROHIBITED)
❌ Missing AAA
❌ No mock verification
❌ Natural language / snake_case
❌ Combined Act & Assert
❌ try/catch/finally in tests
❌ Conditional logic (if/switch) in Arrange, Act, or Assert
Test Organization
Mirror Structure (MANDATORY)
Tests MUST mirror the production code structure using descriptive file naming.
Production code structure:
Test structure (hierarchical mirror):
Naming convention:
- Format:
{path}/test_{module}.py - Same folder structure as production code
- Test files prefixed with
test_ - Exact mirror of production code hierarchy
Why hierarchical structure
- Test files live in the same logical location as production code
- Easy to find corresponding test file
- Natural organization that mirrors the codebase structure
- Clear one-to-one mapping
pytest Configuration
REQUIRED configuration in pyproject.toml:
⚠️ Important: The pythonpath must point to your production code directory to ensure imports work correctly from test files.
Test Classes (Optional)
Tests can be grouped in classes prefixed with Test*:
Test Markers
Use markers to categorize tests and run them selectively:
Run specific markers: pytest -m "not acceptance" or pytest -m unit
Final Summary
This skill enforces:
- ✅ AAA pattern with explicit comments
- ✅ Strict naming:
Should_{ExpectedBehavior}_When_{Condition} - ✅
sut / actual / expectedvariables - ✅ Mock verification for all mocks
- ✅ Mother or Builder pattern for test data (recommended)
- ✅ Async support (pytest-asyncio)
- ✅ Mirror structure with hierarchical organization
- ✅ Enforceable pytest configuration
If a test doesn't follow this → it fails review.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/python-testing/SKILL.md
Popularity
- Repository stars
- 135
- Repository forks
- 4
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/macalbert/envilder/python-testing)