1

I updated Python Hypothesis and it seems that choices() is now deprecated.

Documentation does some handwaving about data() and sampled_from(), but it's not clear how those should be used in place of choices().

My code looks something line this:

@precondition(lambda self: not self.flash_light.crossed)
@rule(choice=st.choices)
def make_forward_move(self, choice):
    persons = [x for x in self.persons if not x.crossed]
    pers1 = choice(persons)
    persons.remove(pers1)
    pers2 = choice(persons)
TylerH
  • 20,799
  • 66
  • 75
  • 101
sureshvv
  • 4,234
  • 1
  • 26
  • 32

1 Answers1

2

I was able to find this by trial-and-error. The needed changes are:

@rule(data=st.data())
...
  ...
   pers1 = data.draw(st.sampled_from(persons))

There are some subtle differences still in how my code functions but these changes were enough to get it to run.

sureshvv
  • 4,234
  • 1
  • 26
  • 32