Skip to content

Commit 7dc0065

Browse files
Gordon J. Köhnclaude
andcommitted
docs: improve Hypothesis slides with better selling points
- Add "flip the playbook" intro to Property-Based Testing slide - Contrast example-based (❌ you pick) vs property-based (✓ computer picks) - Add concrete command for Demo slide with --hypothesis-show-statistics - Emphasize 600 test cases generated automatically Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9443a1f commit 7dc0065

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

docs/slides.qmd

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,13 @@ class SimulationResult(BaseModel):
555555

556556
## Hypothesis: Property-Based Testing
557557

558+
**Flip the playbook:** Don't write examples. Describe *properties* that must always hold.
559+
558560
::: {.columns}
559561
::: {.column width="50%"}
560-
### The problem with example-based tests
562+
### ❌ Example-based: You pick the cases
561563

562564
```python
563-
# You pick the examples
564565
def test_sort():
565566
assert sort([3, 1, 2]) == [1, 2, 3]
566567
assert sort([]) == []
@@ -572,7 +573,7 @@ You test what you think of. Bugs hide in what you don't.
572573
:::
573574

574575
::: {.column width="50%"}
575-
### Hypothesis generates test cases
576+
### ✓ Property-based: Computer picks the cases
576577

577578
```python
578579
from hypothesis import given, strategies as st
@@ -584,9 +585,9 @@ def test_sort_properties(xs):
584585
assert len(result) == len(xs)
585586
# Property: sorted order
586587
assert all(a <= b for a, b in zip(result, result[1:]))
587-
# Property: same elements
588-
assert sorted(xs) == result
589588
```
589+
590+
Hypothesis generates **hundreds of random inputs** and finds the **minimal failing case**.
590591
:::
591592
:::
592593

@@ -979,7 +980,11 @@ def test_remove_duplicates(items):
979980
assert all(items.index(y) > original_idx for y in result[i+1:] if y != x)
980981
```
981982

982-
Run: `pixi run pytest -v` — Hypothesis generates hundreds of test cases automatically.
983+
```bash
984+
pixi run pytest demos/demo_hypothesis.py -v --hypothesis-show-statistics
985+
```
986+
987+
Watch Hypothesis generate **600 test cases** (200 per property) in under a second.
983988

984989
# Summary {background-color="#2E86AB"}
985990

0 commit comments

Comments
 (0)