本文整理汇总了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