src/dot-agents/skills/python-testing/SKILL.md
Pytest-first Python testing with emphasis on fakes over mocks. Covers unit, integration, and async tests; fixture design; coverage setup; and debugging test failures. Use when writing tests, reviewing test quality, designing fixtures, setting up pytest, or debugging failures—e.g., "write unit tests for new feature", "fixture design patterns", "fakes vs mocks comparison", "fix failing tests".
npx skillsauth add jjjermiah/dotagents python-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Pytest-first testing emphasizing fakes over mocks and behavior-driven assertions. This skill applies to all Python testing work—always follow its guidance.
Bias toward business logic tests over fakes (Layer 4). Fakes track mutations without coupling to implementation. See references/test-doubles.md for details.
pytest, pytest-cov, pytest-asyncio, pytest-mock, hypothesis
project/
├── src/mypackage/
└── tests/
├── conftest.py
├── unit/
│ ├── fakes/ # Layer 1: Fake tests
│ └── services/ # Layer 4: Business logic
├── integration/ # Layer 2: Sanity tests
└── e2e/ # Layer 5: Real systems
See references/test-layers.md for layer distribution and decision tree.
YOU MUST use fakes for business logic tests. Never use mocks when testing behavior—mocks couple tests to implementation and break on every refactor.
# CORRECT: Fake tests behavior (use this approach)
def test_user_creation():
fake_db = FakeDatabaseAdapter()
service = UserService(database=fake_db)
user = service.create_user("[email protected]")
assert user.id == 1
assert "INSERT" in fake_db.executed_queries[0]
# WRONG: Mock couples to implementation—this pattern causes test breakage every time you refactor
def test_user_creation(mocker):
mock_db = mocker.patch("myapp.service.database")
# Breaks on refactor
@pytest.fixture
def make_user():
def _make(name="test", **kwargs):
return User(name=name, email=f"{name}@example.com", **kwargs)
return _make
@pytest.fixture
def capture_emails(monkeypatch):
sent = []
monkeypatch.setattr("myapp.email.send", lambda **kw: sent.append(kw))
return sent
test_<what>_<condition>_<expected>tmp_path for all file operations in tests—never hardcode pathstime.sleep() in unit tests (use monkeypatch or freezegun)development
Guides creation, validation, and packaging of AI agent skills with token-efficient design, progressive disclosure patterns, and YAML frontmatter best practices. Use when building new skills, updating existing skills, validating skill structure against standards, or packaging for distribution—e.g., "create skill", "validate SKILL.md", "package skill for sharing", "check description format".
tools
Investigate and integrate weakly documented SDK/library modules (especially Azure SDKs) into code. Use when asked to "investigate module", "SDK", "client class", or when docs are missing/weak and you need to discover APIs, models, or usage patterns to implement integration.
tools
Write production-ready one-off scripts and automation utilities with proper error handling and safety patterns. Use when developing bash automation, Python CLI tools, shell scripts, system administration scripts, or command-line batch processing—e.g., "write a script to process files", "python one-liner for data conversion", "bash automation for backups", "shell script with error handling".
development
R package testing with testthat 3rd edition. Use when writing R tests, fixing failing tests, debugging errors, or reviewing coverage—e.g., "write testthat tests", "fix failing R tests", "snapshot testing", "test coverage".