我正在尝试使用fixed_dictionaries
其中两个键具有列表作为必须具有相同长度的值的策略来生成示例数据,例如:
{'ids': [1, 2, 3],
'words': ['foo', 'bar', 'baz']}
如何强制执行此约束?我想我也许可以将一个定义为另一个的组合,但我不知道该怎么做。就像是:
import hypothesis.strategies as st
ids = st.lists(elements=st.integers())
@st.composite
def words(draw, elements=st.text()):
draw(sample_ids) # ???