本文整理汇总了Python中tests.common.debug.minimal函数的典型用法代码示例。如果您正苦于以下问题:Python minimal函数的具体用法?Python minimal怎么用?Python minimal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了minimal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
)
示例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
示例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,
)
示例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
示例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
示例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 == {"": []}
示例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
示例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]
示例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
示例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
示例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
示例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)
示例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)
示例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)
示例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)