我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用hypothesis.strategies.sets()。
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)))
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