【发布时间】:2021-01-09 17:40:42
【问题描述】:
对于单元测试,我想使用hypothesis 库生成float 的list。有一些重要的限制:
- 列表中的成分数量必须大于 1 且小于 15
- 最小值必须大于 0
- 最大值必须小于 1
- 所有成分的总和必须完全等于一 (1)
到目前为止,我能够满足前三个约束。
@given(
strategies.lists(
st.floats(min_value=0, max_value=1, exclude_min=True, exclude_max=True),
min_size=2,
max_size=15,
)
)
我怎样才能满足第四个约束?
【问题讨论】:
标签: python pytest hypothesis-test