当前位置: 首页>>代码示例>>Python>>正文


Python debug.minimal函数代码示例

本文整理汇总了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
    )
开发者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


注:本文中的tests.common.debug.minimal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。