本文整理匯總了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
示例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])
示例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
示例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
示例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