I'm trying to generate sample data using the fixed_dictionaries
strategy where two of the keys have lists as values that must be of equal length, e.g.:
{'ids': [1, 2, 3],
'words': ['foo', 'bar', 'baz']}
How can I enforce this constraint? I thought I might be able to define one as a composite in terms of the other, but I'm not sure how to do that. Something like:
import hypothesis.strategies as st
ids = st.lists(elements=st.integers())
@st.composite
def words(draw, elements=st.text()):
draw(sample_ids) # ???