如何查看Python库的“Bundle”输出?(状态测试)

2024-05-16 03:27:45 发布

您现在位置:Python中文网/ 问答频道 /正文

当使用假设库并执行有状态测试时,如何查看或输出库在我的代码上尝试的捆绑包“服务”?你知道吗

示例

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

问题是:如何打印/查看库生成的Bundle“services”变量?你知道吗


Tags: integers代码fromimport示例value状态as
1条回答
网友
1楼 · 发布于 2024-05-16 03:27:45

在您给出的示例中,servicesbundle并没有在您的代码上进行尝试—您正在向其中添加内容,但从未将它们用作另一个规则的输入。你知道吗

如果是,在详细模式下运行假设将显示所有发生的输入;或者即使在正常模式下,失败的示例也将打印所有使用的值。你知道吗

相关问题 更多 >