Skip to content

Commit 7edf528

Browse files
committed
cursor,windsurf(rules): Add pytest testing guidelines to project rules
why: Standardize pytest testing practices across the project. what: - Add section specifying use of fixtures over mocks - Example: libtmux-specific fixtures (server, session, window, pane) - Require documentation for exceptional test cases - Recommend tmp_path fixture over tempfile - Prefer monkeypatch fixture over unittest.mock refs: Improves consistency and maintainability of test suite
1 parent 5bab527 commit 7edf528

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.cursor/rules/dev-loop.mdc

+11
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,14 @@ For doctests in `src/**/*.py` files:
156156
# Watch specific modules for doctest changes
157157
uv run ptw . --now --doctest-modules src/path/to/module.py
158158
```
159+
160+
### Pytest Testing Guidelines
161+
162+
1. **Use existing fixtures over mocks**:
163+
- Use fixtures from conftest.py instead of `monkeypatch` and `MagicMock` when available
164+
- For instance, if using libtmux, use provided fixtures: `server`, `session`, `window`, and `pane`
165+
- Document in test docstrings why standard fixtures weren't used for exceptional cases
166+
167+
2. **Preferred pytest patterns**:
168+
- Use `tmp_path` (pathlib.Path) fixture over Python's `tempfile`
169+
- Use `monkeypatch` fixture over `unittest.mock`

.windsurfrules

+8
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@
111111
- Separate subject from body with a blank line
112112
- Mark breaking changes clearly: `BREAKING:`
113113
</git_commit_standards>
114+
115+
<pytest_testing_guidelines>
116+
- Use fixtures from conftest.py instead of monkeypatch and MagicMock when available
117+
- For instance, if using libtmux, use provided fixtures: server, session, window, and pane
118+
- Document in test docstrings why standard fixtures weren't used for exceptional cases
119+
- Use tmp_path (pathlib.Path) fixture over Python's tempfile
120+
- Use monkeypatch fixture over unittest.mock
121+
</pytest_testing_guidelines>

0 commit comments

Comments
 (0)