Skip to content
UPEEC

Hypothesis

Property-based testing: describe the inputs, and Hypothesis generates hundreds of cases (including edge cases).

Intermediate
Comments 0
from hypothesis import given, strategies as st
@given(st.integers(), st.integers())
def test_add_commutes(a, b):
    assert a + b == b + a

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.