故事:
目前,我有一个测试功能,需要一个包含以下规则的整数列表:
N)可以是1到50N样本有效输入:
[[0]]
[[2, 1], [2, 0], [3, 1], [1, 0]]
[[1], [0]]
Run Code Online (Sandbox Code Playgroud)
示例无效输入:
[[2]] # 2 is more than N=1 (total number of sublists)
[[0, 1], [2, 0]] # 2 is equal to N=2 (total number of sublists)
Run Code Online (Sandbox Code Playgroud)
我试图用接近它基于属性的测试,并产生不同的有效输入hypothesis库,并试图绕到我的头lists()和integers(),但不能使其工作:
lists()和min_size和max_size参数Chaining strategies togetherrectangle_lists上面的例子,我们没有引用里面的"父"列表的长度integers() …python testing unit-testing property-based-testing python-hypothesis