← Back to context

Comment by eru

14 hours ago

> Which means that possibly problematic strings are tested first.

Hypothesis uses a the same probability distribution for all the 200 (or so) random cases it generates for a test. The first case has the same distribution as the 200th.

However, Hypothesis gives a pretty large weight in the probability distribution to inputs that are generally 'problematic'. Of course, that's just a heuristic: eg empty lists and 0 and empty strings or strings with apostrophes in them and NaN or infinity often are problematic, but that's just a guess: hypothesis doesn't know anything specific about your code.

The heuristics work remarkably well in practice, though.

Once Hypothesis has found a failing test case, then it tries to shrink it down.