pytest-fixtures
pytest fixtures, parametrize, tmp_path and monkeypatch — the idioms that replace setUp boilerplate and shared mutable state.
Skill by UnicoLab
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/unicolab-pytest-fixtures
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: testing
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/pytest-fixtures
What's inside
- Skill name
pytest-fixtures- Description
- pytest fixtures, parametrize, tmp_path and monkeypatch — the idioms that replace setUp boilerplate and shared mutable state.
- License
- MIT
- Instructions
- 60 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# pytest fixtures and parametrize
## Parametrize instead of looping
```python
import pytest
from app.parse import parse, ParseError
@pytest.mark.parametrize(
("raw", "expected"),
[
pytest.param("a=1", {"a": 1}, id="single"),
pytest.param("a=1,b=2", {"a": 1, "b": 2}, id="multiple"),
],
)
def test_parse_ok(raw, expected):
assert parse(raw) == expected
def test_parse_rejects_empty():
with pytest.raises(ParseError, match="empty input"):
parse("")
```
A `for` loop inside one test stops at the first failure and reports one result;
`parametrize` reports each case separately and names it in the output.
## Fixtures
```python
@pytest.fixture
def store(tmp_path): # tmp_path is per-test and auto-removed
s = Store(tmp_path / "db.sqlite")
yield s # yield, not return, when teardown is needed
s.close()
```
- **Scope is the whole contract.** The default `function` scope re-runs per test;
`session`/`module` scope makes tests share state — only for genuinely
read-only or expensive setup, and never for anything a test mutates.
- **`conftest.py`** holds fixtures shared across a directory. No import needed;
no import is possible either — fixtures are resolved by name.
- **`monkeypatch`** for environment and attributes; it undoes itself:
`monkeypatch.setenv("API_KEY", "x")`, `monkeypatch.setattr(mod, "now", fake)`.
Setting `os.environ` directly leaks into every later test.
- **`tmp_path`** (a `pathlib.Path`) for files. Never write into the repo.
## Facts that decide pass/fail
- pytest only collects `test_*.py` / `*_test.py` files and `test_*` functions in
them. A perfectly good test in `helpers.py` never runs.
- Exit code **5 means "no tests ran"** — that is a failure of the task, not a
pass. Check the collected count.
- An `ImportError` during collection is reported as an ERROR, not a failure, and
usually means a missing `__init__.py` or an uninstalled package.
- `python -m pytest` puts the current directory on `sys.path`; a bare `pytest`
does not. That is the difference behind most "works locally" import failures.
- Mock where the name is **used**, not where it is defined:
`monkeypatch.setattr("app.service.requests.get", fake)`.From UnicoLab/smlcode, MIT.
More from UnicoLab/smlcode
- 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
openshift-manifests
UnicoLab
OpenShift deployment specs that pass the restricted SCC on the first apply — kustomize base/overlays, probes, limits, secrets done safely, and how to explain…
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
python-typing
UnicoLab
Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-ux-design
UnicoLab
Design Thinking (DFV) and UX architecture for user flows, component hierarchy, and interactive state matrices.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
go-concurrency
UnicoLab
Goroutine lifetime, context cancellation, channel direction and the mistakes that make Go concurrency leak or race.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
honest-verification
UnicoLab
Prove the objective was met, not merely that nothing is red — a suite that was already green is not evidence.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-requirements
UnicoLab
BRD 3-phase discovery, PRD 7-phase specification, Epic/Story/Task decomposition, and Socratic ADR coaching.
SkillAFreshness: A★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 23, 2026 (2 months ago)
- Last release
- Oct 20, 2026 (8 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/UnicoLab/smlcode
- Website
- unicolab.github.io/smlcode/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from UnicoLab
- 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9
Cite this page
pytest-fixtures skill. Agent Mart. https://agentmart.dev/skills/unicolab-pytest-fixtures (last updated 2026-10-24)