7

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?

1 Answer 1

7

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

Will it work for you?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.