Python hypothesis.strategies 模块,sets() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用hypothesis.strategies.sets()

项目:cattrs    作者:Tinche    | 项目源码 | 文件源码
def enums_of_primitives(draw):
    """Generate enum classes with primitive values."""
    if is_py2:
        names = draw(st.sets(st.text(alphabet=string.ascii_letters,
                                     min_size=1),
                             min_size=1))
    else:
        names = draw(st.sets(st.text(min_size=1), min_size=1))
    n = len(names)
    vals = draw(st.one_of(st.sets(st.one_of(
            st.integers(),
            st.floats(allow_nan=False),
            st.text(min_size=1)),
        min_size=n, max_size=n)))
    return Enum('HypEnum', list(zip(names, vals)))
项目:pyta    作者:pyta-uoft    | 项目源码 | 文件源码
def set_node(draw, elt=const_node(), **kwargs):
    """Return a Set node with elements drawn from elt.
    """
    node = astroid.Set()
    node.postinit(draw(hs.sets(elt, **kwargs)))
    return node