【发布时间】:2018-06-15 21:36:15
【问题描述】:
此示例是docs 中的示例的变体:
import hypothesis.strategies as st
from hypothesis import given
@st.composite
def s(draw):
x = draw(st.text(), min_size=1)
y = draw(st.text(alphabet=x))
return (x, y)
@given(s1=s, s2=s)
def test_subtraction(s1, s2):
print(s1, s2)
assert 0
失败了:
E hypothesis.errors.InvalidArgument: Expected SearchStrategy but got <function accept.<locals>.s at 0x7fd7e5c05620> (type=function)
/mnt/work/unfuncat/software/anaconda/lib/python3.6/site-packages/hypothesis/internal/validation.py:40: InvalidArgument
我做错了什么?
【问题讨论】:
-
这里的
draw是什么?