6

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?

MackM
  • 2,906
  • 5
  • 31
  • 45
jollyroger23
  • 665
  • 1
  • 6
  • 19

1 Answers1

6

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

Will it work for you?

9000
  • 39,899
  • 9
  • 66
  • 104