Property Based Testing the Python Way
summary
Compares pytest parameterize (explicit input/output lists) with Hypothesis property-based tests that use given/strategies to auto-generate inputs, shrinking failures to a minimal case and storing reproducing examples in a database. Uses a two-dice game rule set (any die of 1 → score 1; prime sum → bump to next prime) and shows Hypothesis immediately finds the missed 1,1 edge case. Claims: much shorter tests, finds surprising edge cases, shrinks failing case, integrates with pytest but can be slow and needs carefully stated properties.
AI-written summary · about
chapters (6)
- 0:00Start
- 2:59Pytest's parametrize examples
- 5:11Cons of traditional testing approach
- 8:18Hypothesis approach
- 10:22Why Hypothesis
- 13:40Cons of Property-based approach
related talks
41mProperty Based Testing in Python with Hypothesis
27mHypothesis: Simpler Powerful Test Cases
27mTesting Beyond Examples: Property Based Testing with Hypothesis
50mProperty based testing with Hypothesis
01h 23mIntroduction to Property-Based Testing
41mProperty Based Testing with Hypothesis: Stronger Tests, Less Work
01h 24mIntroduction to Property Based Testing
01h 31mIntroduction to Property-Based Testing
