打印测试执行时间并用py.tes固定慢速测试

2024-04-26 04:10:30 发布

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


Tags: python
2条回答

你可以用--durations传递这个号码

pytest --durations=0 — Show all times for tests and setup and teardown

pytest --durations=1 — Just show me the slowest

pytest --durations=50 — Slowest 50, with times, … etc

引用:https://medium.com/@brianokken/pytest-durations-0-show-all-times-for-tests-and-setup-and-teardown-848dccac85db

或:https://docs.pytest.org/en/latest/usage.html#profiling-test-execution-duration

我不确定这是否能解决您的问题,但是您可以在测试套件完成后通过--durations=N来打印最慢的N测试。

相关问题 更多 >