jollyroger23
jollyroger23

Reputation: 765

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?

Upvotes: 7

Views: 2214

Answers (1)

9000
9000

Reputation: 40894

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

Will it work for you?

Upvotes: 7

Related Questions