Python Unit Tests
Use when writing, fixing, or reviewing Python pytest unit tests, fixtures, mocks, or...
Install
npx skills add dimensionalOS/dimos --skill python-unit-tests -g -a claude-code -y- Repository
- dimensionalOS/dimos4.7k
- Category
- Testing
- Updated
- 3d ago
- License
- See repository
- Context cost
- Lightabout 1,398 tokens
- Runs scripts
- No, instructions only
What it does
Use when writing, fixing, or reviewing Python pytest unit tests, fixtures, mocks, or test PR feedback.
Python Unit Tests
Use this skill before adding, changing, or reviewing Python unit tests. The goal is hermetic tests: behavior-focused, deterministic, isolated, and cheap to run.
Consult these only when the branch needs more context:
docs/coding-agents/testing.mddocs/coding-agents/code-quality-rules.mddocs/development/testing.mdmisc/auto-fixes/fix_template.md
Steps
- Scope the behavior. Identify the code under test, the caller-visible outcome, and the smallest test file next to it:
dimos/core/foo.pygetsdimos/core/test_foo.py. Completion: every new or changed test has a named behavior target and lives beside the code it covers. - Build a hermetic setup. Use module-level imports, Arrange-Act-Assert structure, fixtures for shared or resource-owning setup, and context managers for one-test local resources. Completion: setup owns all cleanup, restores global state, reuses existing fixtures when they match, and contains no fixed sleeps.
- Assert the contract. Use small examples and exact expected values. Completion: every test has an unconditional assertion that proves behavior a caller depends on.
- Mock the boundary. Mock only slow, nondeterministic, or external boundaries. Completion: patches use
mocker.patch,mocker.patch.object, ormonkeypatch; no direct method assignment or__new__fixture shells remain. - Validate tightly. Run the smallest command that can fail for the change, then broaden only when the edit justifies it. Completion: the relevant pytest command has run, and mypy/pre-commit have run only when production source typing or broad quality gates changed.


