4 ms·
Hypothesis will generate a lot of things for you, it can be used for stuff like names, e-mail adresses, passwords, etc... . Instead of having to populate your t
by imp0cat 4y ago
Hypothesis will generate a lot of things for you, it can be used for stuff like names, e-mail adresses, passwords, etc... . Instead of having to populate your test data with stuff like John Doe, Doe street 1111, Doe City, you can just use it to generate stuff on the fly.
It will then tirelessly try different permutations in the neverending search for more bugs.
- chriswarbo 4y agoHypothesis also has two different ways to generate data: - One is to write things like in the article: accept data via arguments, and specify a strategy for each up-front. - Another is to be more ad-hoc: use the 'data' strategy to get a data generator which can be called on-the-fly at the point it's needed inside our test. This is useful if our test is complicated, e.g. with a bunch of conditional logic where each branch needs something different; or the data generation depends on some run-time values (e.g. the number of results we got from the database); etc. Hypothesis will still keep track of the random seeds, perform shrinking, etc. as usual. The latter approach is described at https://hypothesis.readthedocs.io/en/latest/data.html#drawing-interactively-in-tests https://hypothesis.readthedocs.io/en/latest/data.html#drawin...