gpt4 book ai didi

python - 如何在 pytest 中设置每个测试超时的默认值?

转载 作者:行者123 更新时间:2023-12-04 19:31:11 52 4
gpt4 key购买 nike

我想强制执行在 pytest 中没有测试需要超过 3 秒。

pytest-timeout ( https://pypi.python.org/pypi/pytest-timeout ) 几乎可以做我想要的......但它似乎允许我设置全局超时(即确保测试套件需要少于 10 分钟),或者能够设置装饰器每个测试手动。

期望的行为:
使用单个设置配置 pytest 以使任何超过 3 秒的单个测试失败。

最佳答案

来自 pytest-timeout page :

You can set a global timeout in the py.test configuration file using the timeout option. E.g.:

[pytest]
timeout = 300

关于python - 如何在 pytest 中设置每个测试超时的默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43598985/

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