Skip to content

Commit fd742d6

Browse files
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
1 parent 9d1b48a commit fd742d6

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

  • skills/writing-integration-tests

skills/writing-integration-tests/SKILL.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ This variant is the simplest of the four — no `real_fetch` definition needed.
252252

253253
Tests that **create, update, or delete** real data must be marked `@pytest.mark.destructive`. This prevents accidental data mutation when running integration tests.
254254

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+
255261
```python
256262
@pytest.mark.destructive
257263
class TestCreateItem:
@@ -279,17 +285,43 @@ markers = [
279285

280286
### Running Commands
281287

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+
282296
```bash
283-
# Read-only integration tests only
284297
pytest myintegration/tests/test_myintegration_integration.py -m "integration and not destructive"
298+
```
285299

286-
# Destructive tests only
300+
**Destructive only (run deliberately, never by reviewers):**
301+
302+
```bash
287303
pytest myintegration/tests/test_myintegration_integration.py -m "integration and destructive"
304+
```
288305

289-
# All integration tests
306+
**Everything (only after verifying destructive tests are safe on the target account):**
307+
308+
```bash
290309
pytest myintegration/tests/test_myintegration_integration.py -m integration
291310
```
292311

312+
### Documenting How to Run
313+
314+
When the integration has any destructive tests, the PR description and any
315+
README "How to run" section must:
316+
317+
1. List the **safe command first** (`-m "integration and not destructive"`)
318+
2. Show the destructive command second, with an explicit warning that it
319+
mutates real data on the connected account
320+
3. Never recommend the bare `-m integration` form as the primary command
321+
322+
This keeps the safe command on the path of least resistance — reviewers
323+
copy-paste the first command and run only read-only tests.
324+
293325
## Test Organization
294326

295327
### Section Headers by Domain
@@ -434,6 +466,10 @@ Write actions (create/update/delete) need at least:
434466
```bash
435467
pytest <integration>/tests/test_*_integration.py -m "integration and destructive"
436468
```
469+
9. **Document the run commands** in the PR description and the integration's
470+
README — safe (`-m "integration and not destructive"`) command first,
471+
destructive command second with a warning. Never recommend the bare
472+
`-m integration` form as the primary command.
437473

438474
## Common Gotchas
439475

0 commit comments

Comments
 (0)