Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate List of Random Objects with Hypothesis

I need to test a function in python that takes a list with any type of data, from integers to strings to any object a user makes up. Is there a way in 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 and so forth with integers, chars, etc. But how can I make it so a random list has more than one data type with it?

like image 469
jollyroger23 Avatar asked Apr 07 '17 15:04

jollyroger23


1 Answers

"hypothesis.strategies.one_of(*args): Return a strategy which generates values from any of the argument strategies."

Will it work for you?

like image 105
9000 Avatar answered Oct 21 '22 02:10

9000