基于假设的策略的示例测试用例?

Example test cases for hypothesis based strategies?

什么被认为是当前测试基于 hypothesis? There are e.g. tests about how good examples shrink HypothesisWorks/hypothesis-python/tests/quality/test_shrink_quality.py 的策略的最佳实践。但是,到目前为止,我找不到测试策略的数据生成功能(一般而言,性能等)的示例。

假设对您使用的每个策略运行一系列 health checks,包括生成数据所花费的时间和成功生成尝试的比例 - 例如尝试none().map(lambda x: time.sleep(2)).example()integers().map(lambda x: x % 17 == 0).example() 观看他们的表演!

在大多数情况下,除了使用这些健康检查之外,您不需要测试自己的策略。相反,我会使用 a code coverage library.

检查您的 测试 是否足够