如何查看假设 Python 库的"Bundle"输出?(有状态测试)



使用假设库并执行状态测试时,如何查看或输出库正在对我的代码尝试的捆绑"服务"?

import hypothesis.strategies as st
from hypothesis.strategies import integers
from hypothesis.stateful import Bundle, RuleBasedStateMachine, rule, precondition
class test_servicediscovery(RuleBasedStateMachine):
services = Bundle('services')    
@rule(target=services, s=st.integers(min_value=0, max_value=2)) 
def add_service(self, s):
return s

问题是:如何打印/查看由库生成的捆绑"服务"变量?

在您给出的示例中,没有在您的代码上尝试services捆绑包 - 您正在向其添加内容,但从未将它们用作另一个规则的输入。

如果是,在详细模式下运行假设将在发生时显示所有输入;甚至在正常模式下失败的示例也会打印所有使用的值。

最新更新