I have a function which returns the divisors of a number num
. The function raises an error if number is negative
.
I am using the hypothesis library to test this function but I am not sure how I can make it a property-based test.
This is my test:
@given(strategies.integers())
def test_valid(num):
with pytest.raises(ValueError):
divisors(-3)
This code works but how can I change it so that the argument is "num" instead of being hardcoded. Similarly how can I assert that one is an element of the set, for any number num.