Create a list of random objects with a hypothesis
I need to test a function in python that takes a list with any datatypes, from integers to strings to whatever the user is doing. Is there a way in the hypothesis to generate a list with random objects? I know that I could generate a list of random floats with
@given(strategies.lists(strategies.floats()))
And so on, etc. with integers, characters, etc. But how can I make it so that the random list has multiple data types with it?
+3
source to share
1 answer
" : return a strategy that generates values from any of the argument strategies. hypothesis.strategies.one_of(*args)
Will it work for you?
+2
source to share