本文整理汇总了Python中tests.common.debug.find_any函数的典型用法代码示例。如果您正苦于以下问题:Python find_any函数的具体用法?Python find_any怎么用?Python find_any使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_any函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_exclude_characters_of_specific_groups
def test_exclude_characters_of_specific_groups():
st = characters(blacklist_categories=("Lu", "Nd"))
find_any(st, lambda c: unicodedata.category(c) != "Lu")
find_any(st, lambda c: unicodedata.category(c) != "Nd")
assert_no_examples(st, lambda c: unicodedata.category(c) in ("Lu", "Nd"))
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:7,代码来源:test_simple_characters.py
示例2: test_may_fill_with_nan_when_unique_is_set
def test_may_fill_with_nan_when_unique_is_set():
find_any(
nps.arrays(
dtype=float, elements=st.floats(allow_nan=False), shape=10,
unique=True, fill=st.just(float('nan'))),
lambda x: np.isnan(x).any()
)
开发者ID:sunito,项目名称:hypothesis,代码行数:7,代码来源:test_gen_data.py
示例3: test_groups
def test_groups(pattern, is_unicode, invert):
if u'd' in pattern.lower():
group_pred = is_digit
elif u'w' in pattern.lower():
group_pred = is_word
else:
# Special behaviour due to \x1c, INFORMATION SEPARATOR FOUR
group_pred = is_unicode_space if is_unicode else is_space
if invert:
pattern = pattern.swapcase()
_p = group_pred
def group_pred(s):
return not _p(s)
pattern = u'^%s\\Z' % (pattern,)
compiler = unicode_regex if is_unicode else ascii_regex
strategy = st.from_regex(compiler(pattern))
find_any(strategy.filter(group_pred), is_ascii)
if is_unicode:
find_any(strategy, lambda s: group_pred(s) and not is_ascii(s))
assert_all_examples(strategy, group_pred)
开发者ID:rboulton,项目名称:hypothesis,代码行数:26,代码来源:test_regex.py
示例4: test_can_use_recursive_data_in_sets
def test_can_use_recursive_data_in_sets(rnd):
nested_sets = st.recursive(
st.booleans(),
lambda js: st.frozensets(js, average_size=2.0),
max_leaves=10
)
find_any(nested_sets, random=rnd)
def flatten(x):
if isinstance(x, bool):
return frozenset((x,))
else:
result = frozenset()
for t in x:
result |= flatten(t)
if len(result) == 2:
break
return result
assert rnd is not None
x = find(
nested_sets, lambda x: len(flatten(x)) == 2, random=rnd,
settings=settings(database=None, max_shrinks=1000, max_examples=1000))
assert x in (
frozenset((False, True)),
frozenset((False, frozenset((True,)))),
frozenset((frozenset((False, True)),))
)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:27,代码来源:test_recursive.py
示例5: test_different_keys_are_not_shared
def test_different_keys_are_not_shared():
find_any(
st.tuples(
st.shared(st.integers(), key=1),
st.shared(st.integers(), key=2)),
lambda x: x[0] != x[1]
)
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_sharing.py
示例6: test_characters_of_specific_groups
def test_characters_of_specific_groups():
st = characters(whitelist_categories=("Lu", "Nd"))
find_any(st, lambda c: unicodedata.category(c) == "Lu")
find_any(st, lambda c: unicodedata.category(c) == "Nd")
assert_no_examples(st, lambda c: unicodedata.category(c) not in ("Lu", "Nd"))
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:7,代码来源:test_simple_characters.py
示例7: test_keys_and_default_are_not_shared
def test_keys_and_default_are_not_shared():
find_any(
st.tuples(
st.shared(st.integers(), key=1),
st.shared(st.integers())),
lambda x: x[0] != x[1]
)
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_sharing.py
示例8: test_characters_of_specific_groups
def test_characters_of_specific_groups():
st = characters(whitelist_categories=('Lu', 'Nd'))
find_any(st, lambda c: unicodedata.category(c) == 'Lu')
find_any(st, lambda c: unicodedata.category(c) == 'Nd')
assert_no_examples(
st, lambda c: unicodedata.category(c) not in ('Lu', 'Nd'))
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:8,代码来源:test_simple_characters.py
示例9: test_can_draw_sets_of_hard_to_find_elements
def test_can_draw_sets_of_hard_to_find_elements(rnd):
rarebool = floats(0, 1).map(lambda x: x <= 0.05)
find_any(
sets(rarebool, min_size=2),
lambda x: True,
random=rnd,
settings=settings(database=None),
)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_sets.py
示例10: test_uniqueness_does_not_affect_other_rows_2
def test_uniqueness_does_not_affect_other_rows_2():
data_frames = pdst.data_frames([
pdst.column('A', dtype=int, unique=False),
pdst.column('B', dtype=int, unique=True)],
rows=st.tuples(st.integers(0, 10), st.integers(0, 10)),
index=pdst.range_indexes(2, 2)
)
find_any(data_frames, lambda x: x['A'][0] == x['A'][1])
开发者ID:sunito,项目名称:hypothesis,代码行数:8,代码来源:test_data_frame.py
示例11: test_whitelisted_characters_override
def test_whitelisted_characters_override():
good_characters = u'teтестst'
st = characters(min_codepoint=ord('0'), max_codepoint=ord('9'),
whitelist_characters=good_characters)
find_any(st, lambda c: c in good_characters)
find_any(st, lambda c: c in '0123456789')
assert_no_examples(st, lambda c: c not in good_characters + '0123456789')
开发者ID:doismellburning,项目名称:hypothesis,代码行数:9,代码来源:test_simple_characters.py
示例12: test_can_generate_ignored_tokens
def test_can_generate_ignored_tokens():
list_grammar = r"""
list : "[" [STRING ("," STRING)*] "]"
STRING : /"[a-z]*"/
WS : /[ \t\r\n]+/
%ignore WS
"""
strategy = from_lark(Lark(list_grammar, start="list"))
# A JSON list of strings in canoncial form which does not round-trip,
# must contain ignorable whitespace in the initial string.
find_any(strategy, lambda s: "\t" in s)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:11,代码来源:test_grammar.py
示例13: test_whitelisted_characters_override
def test_whitelisted_characters_override():
good_characters = u"teтестst"
st = characters(
min_codepoint=ord("0"),
max_codepoint=ord("9"),
whitelist_characters=good_characters,
)
find_any(st, lambda c: c in good_characters)
find_any(st, lambda c: c in "0123456789")
assert_no_examples(st, lambda c: c not in good_characters + "0123456789")
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:12,代码来源:test_simple_characters.py
示例14: test_can_use_recursive_data_in_sets
def test_can_use_recursive_data_in_sets(rnd):
nested_sets = st.recursive(st.booleans(), st.frozensets, max_leaves=3)
find_any(nested_sets, random=rnd)
def flatten(x):
if isinstance(x, bool):
return frozenset((x,))
else:
result = frozenset()
for t in x:
result |= flatten(t)
if len(result) == 2:
break
return result
assert rnd is not None
x = minimal(nested_sets, lambda x: len(flatten(x)) == 2, random=rnd)
assert x in (
frozenset((False, True)),
frozenset((False, frozenset((True,)))),
frozenset((frozenset((False, True)),)),
)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:22,代码来源:test_recursive.py
示例15: test_subpattern_flags
def test_subpattern_flags():
strategy = st.from_regex(u"(?i)\\Aa(?-i:b)\\Z")
# "a" is case insensitive
find_any(strategy, lambda s: s[0] == u"a")
find_any(strategy, lambda s: s[0] == u"A")
# "b" is case sensitive
find_any(strategy, lambda s: s[1] == u"b")
assert_no_examples(strategy, lambda s: s[1] == u"B")
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:10,代码来源:test_regex.py
示例16: test_can_generate_naive_datetime
def test_can_generate_naive_datetime():
find_any(datetimes(allow_naive=True), lambda d: d.tzinfo is None)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:2,代码来源:test_datetime.py
示例17: test_can_find_on_the_minute
def test_can_find_on_the_minute():
find_any(datetimes(), lambda x: x.second == 0)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:2,代码来源:test_datetime.py
示例18: test_can_find_each_month
def test_can_find_each_month():
for month in hrange(1, 13):
find_any(datetimes(), lambda x: x.month == month)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:3,代码来源:test_datetime.py
示例19: test_shared_union
def test_shared_union():
# This gets parsed as [(ANY, None), (BRANCH, (None, [[], []]))], the
# interesting feature of which is that it contains empty sub-expressions
# in the branch.
find_any(st.from_regex('.|.'))
开发者ID:rboulton,项目名称:hypothesis,代码行数:5,代码来源:test_regex.py
示例20: test_bare_dollar_can_produce
def test_bare_dollar_can_produce():
find_any(st.from_regex(u'$'), bool)
开发者ID:rboulton,项目名称:hypothesis,代码行数:2,代码来源:test_regex.py
注:本文中的tests.common.debug.find_any函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论