Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/nedcodes-ok/cursor-doctor/pytestgit clone --depth 1 https://github.com/nedcodes-ok/cursor-doctorWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00529 | $0.00529 |
| Opus 5 | $0.00264 | $0.00264 |
| Sonnet 5 | $0.00106 | $0.00106 |
| Haiku 4.5 | $0.00053 | $0.00053 |
Grade A, and why
pytest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 47 lines — stays where its author put it; the contents beside it link to each section on GitHub.
pytest Cursor Rules
You are an expert in pytest testing. Follow these rules:
Structure
- Name test files test_*.py or test.py. Name test functions test
- Group related tests in classes (class TestUserAuth:) — no init needed
- Use descriptive names: test_login_fails_with_expired_token over test_login_3
- One assertion concept per test — multiple asserts are fine if testing one behavior
Fixtures
- Define fixtures in conftest.py for shared setup — pytest discovers them automatically
- Use @pytest.fixture with appropriate scope: function (default), class, module, session
- Yield fixtures for setup/teardown: yield resource then cleanup after
- Use factory fixtures (fixture that returns a factory function) for parameterized setup
- Request fixtures by name in test parameters — no imports needed
Parametrize
- Use @pytest.mark.parametrize("input,expected", [...]) for data-driven tests
- Use ids parameter for readable test names: ids=["empty", "single", "overflow"]
- Stack multiple parametrize decorators for combinatorial testing
- Use pytest.param(..., marks=pytest.mark.xfail) for expected failures in param sets
Markers
- Use @pytest.mark.slow, @pytest.mark.integration — register in pytest.ini/pyproject.toml
- Run subsets with -m "not slow" or -m integration
- Use @pytest.mark.skipif(condition, reason="...") over bare skip
- Use @pytest.mark.usefixtures("db") when you need the fixture but not its value
Assertions & Patterns
- Use plain assert — pytest rewrites them for detailed failure output
- Use pytest.raises(ExceptionType, match="pattern") as context manager
- Use pytest.approx() for float comparisons: assert result == pytest.approx(3.14, abs=1e-2)
- Use tmp_path fixture for temp files, monkeypatch for env vars and attributes
Configuration
- Configure in pyproject.toml [tool.pytest.ini_options] — not pytest.ini or setup.cfg
- Set testpaths, markers, addopts (e.g., -ra --strict-markers)
- Use --strict-markers to catch typos in marker names
- Use conftest.py at project root for shared fixtures, in subdirs for scoped ones
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 47 lines · 529 tokens per session scan A b4e15391035b
pytest is a cursor rule published in the GitHub repository nedcodes-ok/cursor-doctor (9 stars, last pushed 5mo ago), licensed MIT. It adds 529 tokens to every session, about $0.0026 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular
Angular: signals, standalone components, RxJS patterns.
django
Django: models, views, ORM best practices.
java
Modern Java: records, sealed classes, streams, virtual threads.
javascript
Modern JavaScript: ES2023+, async patterns, common traps.
rust
Rust patterns: ownership, Result types, iterators.
accessibility
Accessibility: semantic HTML, ARIA, keyboard navigation, testing.