【问题标题】:Disable shrinking in Hypothesis在假设中禁用收缩
【发布时间】:2021-08-19 11:44:18
【问题描述】:

我有一个测试,我想禁用收缩阶段。

我能做到

from hypothesis import given, settings, strategies as st
from hypothesis._settings import Phase

@settings(report_multiple_bugs=False, phases=list(Phase)[:-1])
@given(my_composite_generator())
def test_legacy_rack_conversion(input):
    assert_stuff_about(input)

但我不喜欢从第三方库导入以下划线开头的私有内容。

是否有更推荐的方法来禁用测试收缩?

【问题讨论】:

    标签: python python-hypothesis


    【解决方案1】:

    https://hypothesis.readthedocs.io/en/latest/settings.html#controlling-what-runs

    请注意,您应该 from hypothesis import Phase,因此不涉及私有 API,而且 list(Phase)[:-1] 不正确 - 它跳过了默认关闭的解释阶段,而不是缩小。最好明确列出您想要的阶段。

    【讨论】:

      猜你喜欢
      • 2022-09-30
      • 1970-01-01
      • 2022-12-17
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多