我想使用hypothesis
出色的功能为我的应用程序创建一些示例数据。我大致像这个一样使用它
from hypothesis import strategies as st
ints = st.integers() #simplified example
ints.example()
我收到这个警告:
NonInteractiveExampleWarning:
.example()
方法适用于探索策略,但只能交互式使用
有没有一种简单的方法可以禁用此警告?需要明确的是:我想在测试之外和非交互式环境中使用示例数据生成,我知道警告指的是什么。我只想摆脱它。
警告模块允许您选择性地忽略特定的警告;例如:
from hypothesis.errors import NonInteractiveExampleWarning
from hypothesis import strategies as st
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=NonInteractiveExampleWarning)
ints = st.integers()
print( ints.example() )