clean-pytest
Write clean, maintainable pytest tests using Fake-based testing, contract testing, and dependency injection patterns.
Skill by youchangping2009-design
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/youchangping2009-design-clean-pytest
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: documents, testing, writing, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/clean-pytest
What's inside
- Skill name
clean-pytest- Description
- Write clean, maintainable pytest tests using Fake-based testing, contract testing, and dependency injection patterns. Use when setting up test suites for Python/MCP projects, creating Fakes for external dependencies, writing contract tests, or implementing test patterns with fixtures and parametrization.
- License
- MIT
- Metadata
- emoji: 🧪 · homepage: https://github.com/numinstante/skills
- Instructions
- 634 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- body: 634 lines (spec recommends under 500)
Files (1)
- SKILL.md
SKILL.md (first lines)
# Clean Pytest
Clean, maintainable pytest test patterns using Fake-based testing, contract testing, and dependency injection. Focuses on test isolation, reusability, and clarity through explicit AAA pattern and well-structured fixtures.
## When to Use
- Setting up test suites for Python/MCP projects
- Creating Fake implementations for external dependencies
- Writing contract tests for MCP tools/controllers
- Implementing test patterns with dependency injection
- Testing layered architectures (Controllers → Services → Repositories)
- Writing parametrized tests for multiple scenarios
## Core Principles
### 1. Fakes over Mocks
Use **Fake classes** instead of mocking with `unittest.mock`. Fakes are in-memory implementations that mimic real dependencies without external calls.
**Why Fakes?**
- More readable and maintainable
- Easier to debug
- Better test isolation
- No monkey-patching magic
- Self-documenting behavior
### 2. Explicit AAA Pattern
Structure every test into three clear phases with comments:
```python
# Arrange
# Set up test data and dependencies
# Act
# Execute the code under test
# Assert
# Verify the result
```
### 3. Dependency Injection in Fixtures
Inject dependencies between fixtures to maintain relationships and avoid duplication.
### 4. Contract Testing
Verify that components register tools/functions correctly and pass expected arguments.
## Architecture Pattern
```
Controller (MCP Tools)
↓
Service (Business Logic)
↓
Repository (Data Access)
↓
Fake (Test Implementation)
```
## Creating Fakes
### Basic Fake Structure
Create a Fake class that implements the same interface as the real dependency:
```python
# tests/fakes.py
from typing import Any, Dict, List, Optional
class FakeAuth:
"""Fake implementation of AuthProvider for testing."""
def __init__(self) -> None:
self.created: List[Dict[str, Any]] = []
self.deleted: List[str] = []
self._seq = 0
self.fail_on_create: bool = False
def create_user(self, email: str, password: str, display_name: str) -> str:
if self.fail_on_create:
raise RuntimeError("create_user failed (fake)")
self._seq += 1
uid = f"uid-{self._seq}"
rec = {"uid": uid, "email": email, "display_name": display_name}
self.created.append(rec)
return uid
def delete_user(self, uid: str) -> None:
self.deleted.append(uid)
```
### Repository Fake
```python
class FakeUsersRepo:
"""Fake implementation of UsersRepository."""
def __init__(self) -> None:
self.users: Dict[str, Dict[str, Any]] = {}
self.fail_on_upsert: bool = False
def upsert_user_doc(self, uid: str, data: Dict[str, Any]) -> None:
if self.fail_on_upsert:
raise RuntimeError("upsert_user_doc failed (fake)")
self.users[uid] = dict(data)
def list_users(self, limit: Optional[int] = None) -> List[Dict[str, Any]]:
items = list(self.users.values())
if limit and limit > 0:
items = items[:limit]
return [dict(it) for it in items]
```
### Controlled Failure Fakes
```python
class FakeAuth:
def __init__(self) -> None:
self.fail_on_create: bool = False # Control failure in testsFrom youchangping2009-design/ai-test-pipeline-v1, MIT.
More from youchangping2009-design/ai-test-pipeline-v1
- 0.524score
requirement-summary
youchangping2009-design
Project-scoped AI Test Pipeline skill for creating or refreshing a work item inputs/requirement_summary.md from local inputs, Feishu/Lark documents or group…
SkillBFreshness: BClaude Code +9 - 0.474score
prd-image-evidence-extractor
youchangping2009-design
Use when PRD input is mainly screenshots, mockups, or prototype images and you need a stable image-evidence layer before structuring.
SkillCFreshness: CClaude Code +9 - 0.466score
newman
youchangping2009-design
Automated API testing with Postman collections via Newman CLI.
SkillCFreshness: CClaude Code +9 - 0.460score
py-test-creator
youchangping2009-design
Automatically generates pytest-compatible unit test templates from Python function signatures and docstrings
SkillCFreshness: CClaude Code +9 - 0.281score
reasoning-analysis
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
review-gate
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
testability-gate
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
case-generation
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
coverage-planning
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
numbering-tagging
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.281score
prd-structuring
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9 - 0.278score
evidence-reviewer
youchangping2009-design
No description from the publisher yet.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 14, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from youchangping2009-design
- 0.524score
requirement-summary
youchangping2009-design
Project-scoped AI Test Pipeline skill for creating or refreshing a work item inputs/requirement_summary.md from local inputs, Feishu/Lark documents or group…
SkillBFreshness: BClaude Code +9 - 0.474score
prd-image-evidence-extractor
youchangping2009-design
Use when PRD input is mainly screenshots, mockups, or prototype images and you need a stable image-evidence layer before structuring.
SkillCFreshness: CClaude Code +9 - 0.466score
newman
youchangping2009-design
Automated API testing with Postman collections via Newman CLI.
SkillCFreshness: CClaude Code +9 - 0.460score
py-test-creator
youchangping2009-design
Automatically generates pytest-compatible unit test templates from Python function signatures and docstrings
SkillCFreshness: CClaude Code +9
Cite this page
clean-pytest skill. Agent Mart. https://agentmart.dev/skills/youchangping2009-design-clean-pytest (last updated 2026-10-24)