當前位置: 首頁>>代碼示例>>Python>>正文


Python ParameterSource.examples方法代碼示例

本文整理匯總了Python中hypothesis.internal.examplesource.ParameterSource.examples方法的典型用法代碼示例。如果您正苦於以下問題:Python ParameterSource.examples方法的具體用法?Python ParameterSource.examples怎麽用?Python ParameterSource.examples使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hypothesis.internal.examplesource.ParameterSource的用法示例。


在下文中一共展示了ParameterSource.examples方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_negative_is_not_too_far_off_mean

# 需要導入模塊: from hypothesis.internal.examplesource import ParameterSource [as 別名]
# 或者: from hypothesis.internal.examplesource.ParameterSource import examples [as 別名]
def test_negative_is_not_too_far_off_mean():
    source = ParameterSource(
        random=random.Random(),
        strategy=integers(),
    )
    positive = 0
    i = 0
    for example in source.examples():
        if example >= 0:
            positive += 1
        i += 1
        if i >= N_EXAMPLES:
            break
    assert 0.3 <= float(positive) / N_EXAMPLES <= 0.7
開發者ID:subsetpark,項目名稱:hypothesis,代碼行數:16,代碼來源:test_examplesource.py

示例2: test_tries_each_parameter_at_least_min_index_times

# 需要導入模塊: from hypothesis.internal.examplesource import ParameterSource [as 別名]
# 或者: from hypothesis.internal.examplesource.ParameterSource import examples [as 別名]
def test_tries_each_parameter_at_least_min_index_times():
    source = ParameterSource(
        context=BuildContext(random.Random()),
        strategy=strategy(int),
        min_tries=5
    )
    i = 0
    for x in source.examples():
        i += 1
        if i > 500:
            break
        if i % 2:
            source.mark_bad()
    # The last index may not have been fully populated
    assert all(c >= 5 for c in source.counts[:-1])
開發者ID:AlbertoPeon,項目名稱:hypothesis,代碼行數:17,代碼來源:test_examplesource.py

示例3: test_marking_negative_avoids_similar_examples

# 需要導入模塊: from hypothesis.internal.examplesource import ParameterSource [as 別名]
# 或者: from hypothesis.internal.examplesource.ParameterSource import examples [as 別名]
def test_marking_negative_avoids_similar_examples():
    positive = 0
    k = 10

    for _ in hrange(k):
        source = ParameterSource(
            random=random.Random(),
            strategy=integers(),
        )
        n = N_EXAMPLES // k
        for example in islice(source.examples(), n):
            if example >= 0:
                positive += 1
            else:
                source.mark_bad()
    assert float(positive) / N_EXAMPLES >= 0.7
開發者ID:subsetpark,項目名稱:hypothesis,代碼行數:18,代碼來源:test_examplesource.py

示例4: test_marking_negative_avoids_similar_examples

# 需要導入模塊: from hypothesis.internal.examplesource import ParameterSource [as 別名]
# 或者: from hypothesis.internal.examplesource.ParameterSource import examples [as 別名]
def test_marking_negative_avoids_similar_examples():
    source = ParameterSource(
        context=BuildContext(random.Random()),
        strategy=strategy(int),
    )
    positive = 0
    i = 0
    for example in source.examples():
        if example >= 0:
            positive += 1
        else:
            source.mark_bad()
        i += 1
        if i >= N_EXAMPLES:
            break
    assert float(positive) / N_EXAMPLES >= 0.8
開發者ID:AlbertoPeon,項目名稱:hypothesis,代碼行數:18,代碼來源:test_examplesource.py

示例5: test_can_grow_the_set_of_available_parameters_if_doing_badly

# 需要導入模塊: from hypothesis.internal.examplesource import ParameterSource [as 別名]
# 或者: from hypothesis.internal.examplesource.ParameterSource import examples [as 別名]
def test_can_grow_the_set_of_available_parameters_if_doing_badly():
    runs = 10
    number_grown = 0
    for _ in hrange(runs):
        source = ParameterSource(
            context=BuildContext(random.Random()),
            strategy=strategy(int),
            min_parameters=1,
        )
        i = 0
        for example in source.examples():
            if example < 0:
                source.mark_bad()
            i += 1
            if i >= 100:
                break
        if len(source.parameters) > 1:
            number_grown += 1
        assert len(source.parameters) < 100
開發者ID:AlbertoPeon,項目名稱:hypothesis,代碼行數:21,代碼來源:test_examplesource.py


注:本文中的hypothesis.internal.examplesource.ParameterSource.examples方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。