对于基于属性的测试,给定一个固定的值列表,我需要生成一个可变大小的列表,其中顺序很重要并且允许重复。例如,如果我的固定列表是
texts = ['t1', 't2', 't3', 't4']
我想生成不同的变体,例如
['t2']
['t4', 't1'] # Subset and different order
[]
['t3', 't1', 't2'] # Different order
['t4', 't4', 't4', 't1'] # Repetition of t4
['t1', 't2', 't1'] # Repetition but at different location
['t1', 't2']
['t2', 't1'] # different order from the one above and considered different.
我目前设法使用的是permutations策略
from hypothesis import given, strategies as st
@given(st.permutations(texts))
def test_x(some_text):
...
pass
但这并没有给我可变大小,重复
其他需求:
如何指定最大变量列表为 20?
幕布斯6054654
米琪卡哇伊
相关分类