gpt4 book ai didi

python - 如何使 pytest 因警告而崩溃?

转载 作者:太空宇宙 更新时间:2023-11-03 21:14:22 25 4
gpt4 key购买 nike

这是 How do I find where a "Sorting because non-concatenation" warning is coming from? 的扩展。

在我的 pytest 中,我仍然收到相同的警告。我在这里查看了几个问题并完成了:

import warnings
warnings.filterwarnings('error')

How do I catch a numpy warning like it's an exception (not just for testing)? 中建议的

但是,当我运行 pytest 时,它仍然给我错误,但实际上没有任何错误......

最佳答案

尝试传递-W当你运行 pytest 时标记,如下所示:

pytest -W error::RuntimeWarning

指定您想要转为错误的警告类型,例如弃用警告、 future 警告、用户警告。

关于python - 如何使 pytest 因警告而崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54831333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com