【发布时间】:2016-09-23 23:24:35
【问题描述】:
在假设中,有一个corresponding sampled_from() strategy 到random.choice():
In [1]: from hypothesis import find, strategies as st
In [2]: find(st.sampled_from(('ST', 'LT', 'TG', 'CT')), lambda x: True)
Out[2]: 'ST'
但是,有没有办法让random.sample()-like 策略从序列中产生长度为 N 的子序列?
In [3]: import random
In [4]: random.sample(('ST', 'LT', 'TG', 'CT'), 2)
Out[4]: ['CT', 'TG']
【问题讨论】:
标签: python unit-testing testing random python-hypothesis