本文整理汇总了Python中tests.common.debug.minimal函数的典型用法代码示例。如果您正苦于以下问题:Python minimal函数的具体用法?Python minimal怎么用?Python minimal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了minimal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_overflow_in_simplify
def test_overflow_in_simplify():
"""This is a test that we don't trigger a pytz bug when we're simplifying
around MINYEAR where valid dates can produce an overflow error."""
minimal(
datetimes(max_year=MINYEAR),
lambda x: x.tzinfo != pytz.UTC
)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:7,代码来源:test_datetime.py
示例2: test_minimizes_ints_from_down_to_boundary
def test_minimizes_ints_from_down_to_boundary(boundary):
def is_good(x):
assert x >= boundary - 10
return x >= boundary
assert minimal(integers(min_value=boundary - 10), is_good) == boundary
assert minimal(integers(min_value=boundary), lambda x: True) == boundary
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_simple_numbers.py
示例3: test_overflow_in_simplify
def test_overflow_in_simplify():
# we shouldn't trigger a pytz bug when we're simplifying
minimal(
datetimes(
min_value=dt.datetime.max - dt.timedelta(days=3), timezones=timezones()
),
lambda x: x.tzinfo != pytz.UTC,
)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_pytz_timezones.py
示例4: test_intervals_shrink_to_center
def test_intervals_shrink_to_center(inter):
lower, center, upper = inter
s = interval(lower, upper, center)
assert minimal(s, lambda x: True) == center
if lower < center:
assert minimal(s, lambda x: x < center) == center - 1
if center < upper:
assert minimal(s, lambda x: x > center) == center + 1
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_integer_ranges.py
示例5: test_does_not_simplify_into_surrogates
def test_does_not_simplify_into_surrogates():
f = minimal(text(), lambda x: x >= u"\udfff")
assert f == u"\ue000"
size = 5
f = minimal(text(min_size=size), lambda x: sum(t >= u"\udfff" for t in x) >= size)
assert f == u"\ue000" * size
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_simple_strings.py
示例6: test_non_trivial_json
def test_non_trivial_json():
json = st.deferred(lambda: st.none() | st.floats() | st.text() | lists | objects)
lists = st.lists(json)
objects = st.dictionaries(st.text(), json)
assert minimal(json) is None
small_list = minimal(json, lambda x: isinstance(x, list) and x)
assert small_list == [None]
x = minimal(json, lambda x: isinstance(x, dict) and isinstance(x.get(""), list))
assert x == {"": []}
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:14,代码来源:test_deferred_strategies.py
示例7: test_dictionary
def test_dictionary(dict_class):
assert minimal(dictionaries(
keys=integers(), values=text(),
dict_class=dict_class)) == dict_class()
x = minimal(
dictionaries(keys=integers(), values=text(), dict_class=dict_class),
lambda t: len(t) >= 3)
assert isinstance(x, dict_class)
assert set(x.values()) == set((u'',))
for k in x:
if k < 0:
assert k + 1 in x
if k > 0:
assert k - 1 in x
开发者ID:doismellburning,项目名称:hypothesis,代码行数:15,代码来源:test_shrink_quality.py
示例8: test_can_delete_in_middle_of_a_binding
def test_can_delete_in_middle_of_a_binding(n):
bool_lists = integers(1, 100).flatmap(
lambda k: lists(booleans(), min_size=k, max_size=k))
assert minimal(
bool_lists, lambda x: x[0] and x[-1] and x.count(False) >= n
) == [True] + [False] * n + [True]
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_flatmap.py
示例9: test_can_shrink_through_a_binding
def test_can_shrink_through_a_binding(n):
bool_lists = integers(0, 100).flatmap(
lambda k: lists(booleans(), min_size=k, max_size=k))
assert minimal(
bool_lists, lambda x: len(list(filter(bool, x))) >= n
) == [True] * n
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_flatmap.py
示例10: test_minimizes_lists_of_negative_ints_up_to_boundary
def test_minimizes_lists_of_negative_ints_up_to_boundary():
result = minimal(
lists(integers(), min_size=10),
lambda x: len([t for t in x if t <= -1]) >= 10,
timeout_after=60,
)
assert result == [-1] * 10
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:7,代码来源:test_simple_numbers.py
示例11: test_can_find_unique_lists_of_non_set_order
def test_can_find_unique_lists_of_non_set_order():
ls = minimal(
lists(text(), unique=True),
lambda x: list(set(reversed(x))) != x
)
assert len(set(ls)) == len(ls)
assert len(ls) == 2
开发者ID:doismellburning,项目名称:hypothesis,代码行数:7,代码来源:test_simple_collections.py
示例12: test_mutual_recursion
def test_mutual_recursion():
t = st.deferred(lambda: a | b)
a = st.deferred(lambda: st.none() | st.tuples(st.just("a"), b))
b = st.deferred(lambda: st.none() | st.tuples(st.just("b"), a))
for c in ("a", "b"):
assert minimal(t, lambda x: x is not None and x[0] == c) == (c, None)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:7,代码来源:test_deferred_strategies.py
示例13: test_can_minimize_large_arrays
def test_can_minimize_large_arrays():
x = minimal(
nps.arrays(u'uint32', 100), lambda x: np.any(x) and not np.all(x),
timeout_after=60
)
assert np.logical_or(x == 0, x == 1).all()
assert np.count_nonzero(x) in (1, len(x) - 1)
开发者ID:sunito,项目名称:hypothesis,代码行数:7,代码来源:test_gen_data.py
示例14: test_containment
def test_containment(n):
iv = minimal(
tuples(lists(integers()), integers()),
lambda x: x[1] in x[0] and x[1] >= n,
timeout_after=60
)
assert iv == ([n], n)
开发者ID:doismellburning,项目名称:hypothesis,代码行数:7,代码来源:test_shrink_quality.py
示例15: test_can_find_nested
def test_can_find_nested():
x = minimal(
st.recursive(st.booleans(), lambda x: st.tuples(x, x)),
lambda x: isinstance(x, tuple) and isinstance(x[0], tuple),
)
assert x == ((False, False), False)
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:7,代码来源:test_recursive.py
示例16: test_simplify_shared_linked_to_size
def test_simplify_shared_linked_to_size():
xs = minimal(
st.lists(st.shared(st.integers())),
lambda t: sum(t) >= 1000
)
assert sum(xs[:-1]) < 1000
assert (xs[0] - 1) * len(xs) < 1000
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_sharing.py
示例17: test_can_find_mixed_ascii_and_non_ascii_strings
def test_can_find_mixed_ascii_and_non_ascii_strings():
s = minimal(
text(), lambda x: (
any(t >= u'☃' for t in x) and
any(ord(t) <= 127 for t in x)))
assert len(s) == 2
assert sorted(s) == [u'0', u'☃']
开发者ID:Wilfred,项目名称:hypothesis-python,代码行数:7,代码来源:test_simple_strings.py
示例18: test_can_shrink_matrices_with_length_param
def test_can_shrink_matrices_with_length_param():
@st.composite
def matrix(draw):
rows = draw(st.integers(1, 10))
columns = draw(st.integers(1, 10))
return [
[draw(st.integers(0, 10000)) for _ in range(columns)]
for _ in range(rows)
]
def transpose(m):
rows = len(m)
columns = len(m[0])
result = [
[None] * rows
for _ in range(columns)
]
for i in range(rows):
for j in range(columns):
result[j][i] = m[i][j]
return result
def is_square(m):
return len(m) == len(m[0])
value = minimal(matrix(), lambda m: is_square(m) and transpose(m) != m)
assert len(value) == 2
assert len(value[0]) == 2
assert sorted(value[0] + value[1]) == [0, 0, 0, 1]
开发者ID:doismellburning,项目名称:hypothesis,代码行数:29,代码来源:test_composite.py
示例19: test_sets_of_fixed_length
def test_sets_of_fixed_length(n):
x = minimal(sets(integers(), min_size=n, max_size=n), lambda x: True)
assert len(x) == n
if not n:
assert x == set()
else:
assert x == set(range(min(x), min(x) + n))
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_simple_collections.py
示例20: test_list_of_fractional_float
def test_list_of_fractional_float():
assert set(
minimal(
lists(floats(), min_size=5),
lambda x: len([t for t in x if t >= 1.5]) >= 5,
timeout_after=60,
)
).issubset([1.5, 2.0])
开发者ID:HypothesisWorks,项目名称:hypothesis-python,代码行数:8,代码来源:test_simple_numbers.py
注:本文中的tests.common.debug.minimal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论