Created
October 7, 2015 11:54
-
-
Save nottrobin/1e665048e4ff698c3da2 to your computer and use it in GitHub Desktop.
An example of how Hypothesis can generate test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from hypothesis.strategies import lists, floats | |
| @given(lists(floats())) | |
| def test_average(float_list): | |
| ave = reduce(lambda x, y: x + y, float_list) / len(float_list) | |
| assert average(float_list) == ave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment