You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(skills): make destructive-test invocation safer by default (#41)
Pytest's -m flag is additive, so 'pytest -m integration' selects every
test marked 'integration' — including those also marked 'destructive'.
The previous skill text presented all three invocations equally, which
encouraged PR descriptions and READMEs to recommend the bare
'-m integration' form (the dangerous one).
This change:
- Adds a callout in 'When to Use' explaining that the destructive
marker does NOT auto-exclude tests from -m integration
- Reframes 'Running Commands' so the safe command is the documented
default, with a leading warning
- Adds a new 'Documenting How to Run' subsection prescribing PR
description / README conventions
- Appends a step 9 to the workflow checklist for documenting the
run commands
Copy file name to clipboardExpand all lines: skills/writing-integration-tests/SKILL.md
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -252,6 +252,12 @@ This variant is the simplest of the four — no `real_fetch` definition needed.
252
252
253
253
Tests that **create, update, or delete** real data must be marked `@pytest.mark.destructive`. This prevents accidental data mutation when running integration tests.
254
254
255
+
> Marking a test `@pytest.mark.destructive` does **not** exclude it from
256
+
> `-m integration` runs. Pytest markers are additive: a test carrying both
257
+
> `integration` and `destructive` matches `-m integration`. The marker is a
258
+
> filter target — the protection comes from how you document and invoke the
259
+
> test commands (see "Running Commands" and "Documenting How to Run" below).
260
+
255
261
```python
256
262
@pytest.mark.destructive
257
263
classTestCreateItem:
@@ -279,17 +285,43 @@ markers = [
279
285
280
286
### Running Commands
281
287
288
+
> ⚠️ **`-m integration` runs destructive tests too.** Always default to the
289
+
> read-only command below in PR descriptions, READMEs, and reviewer
290
+
> instructions. Reach for the bare `-m integration` form only when you have
291
+
> manually verified the destructive tests are safe to run on the target
292
+
> account.
293
+
294
+
**Default (safe — use this everywhere by default):**
295
+
282
296
```bash
283
-
# Read-only integration tests only
284
297
pytest myintegration/tests/test_myintegration_integration.py -m "integration and not destructive"
298
+
```
285
299
286
-
# Destructive tests only
300
+
**Destructive only (run deliberately, never by reviewers):**
301
+
302
+
```bash
287
303
pytest myintegration/tests/test_myintegration_integration.py -m "integration and destructive"
304
+
```
288
305
289
-
# All integration tests
306
+
**Everything (only after verifying destructive tests are safe on the target account):**
0 commit comments