ワンクリックで
python-unit-tests
Use when writing, fixing, or reviewing Python pytest unit tests, fixtures, mocks, or test PR feedback.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when writing, fixing, or reviewing Python pytest unit tests, fixtures, mocks, or test PR feedback.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
| name | python-unit-tests |
| description | Use when writing, fixing, or reviewing Python pytest unit tests, fixtures, mocks, or test PR feedback. |
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.mddimos/core/foo.py gets dimos/core/test_foo.py. Completion: every new or changed test has a named behavior target and lives beside the code it covers.mocker.patch, mocker.patch.object, or monkeypatch; no direct method assignment or __new__ fixture shells remain.assert result == expected over shape-only checks.tmp_path for temporary files and directories.stop(), close(), or cleanup calls at the end of a test body after assertions; an earlier failure skips them.with.try/finally.if hasattr(...), it probably does not know what it is testing.threading.Event, then assert the final values. Do not use fixed time.sleep() waits.mocker.patch(...) or mocker.patch.object(...) for patches and call assertions.monkeypatch for environment variables, paths, and module attributes that should be restored automatically.__new__ and fill in fields by hand. Construct normally and patch the one side effect you need to avoid.For call assertions, use the standard pattern: patch the target with mocker.patch.object(...), run the behavior, then assert with assert_called_once_with(...) or another precise mock assertion.
monkeypatch.setenv, monkeypatch.delenv, or fixtures instead of direct os.environ[...] mutation.global_config or other shared state after changing it.Focused test edit:
uv run pytest dimos/path/to/test_file.py -k test_name
Explicit default marker filter:
uv run pytest dimos/path/to/test_file.py -k test_name -m 'not (self_hosted or mujoco or self_hosted_large)'
Broader local check:
./bin/pytest-fast
Do not run mypy for test-only edits. Run uv run mypy when production source typing changed or before a broader quality gate. Run pre-commit run --all-files for broad/autofix/final review work, not after every small unit-test edit.
mocker or monkeypatch?