pytest的计时器插件
pytest-timer的Python项目详细描述
pytest计时器
为pytest移植nose-timer插件。pytest的计时器插件(每个测试需要多少时间?)。在
安装
要从PyPI安装最新版本:
pip install pytest-timer
要使用termcolor
安装pytest-timer
,请执行以下操作:
要使用colorama
安装pytest-timer
,请执行以下操作:
pip install pytest-timer[colorama]
或者从Git安装最新的开发版本:
pip install git+git://github.com/skudriashev/pytest-timer.git
或从源安装最新版本:
git clone https://github.com/skudriashev/pytest-timer.git
cd pytest-timer
pip install .
如果计划修改 频繁来源:
pip install -e .
使用
安装pytest-timer
插件后,将添加以下报告:
========================== pytest-timer ==========================
[success] tests/test_plugin.py::TestPlugin::test_loaded2: 0.0002s
[success] tests/test_plugin.py::TestPlugin::test_loaded: 0.0002s
如何只显示n
最慢的测试?
例如,要只显示10最慢的测试,请使用--timer-top-n
标志运行pytest:
pytest --with-timer --timer-top-n 10
我怎么才能关掉漂亮的颜色?
在某些情况下,您可能需要完全禁用颜色。这是通过使用--timer-no-color
标志来完成的。
在无头控制台中运行测试时,这很有用。在
如何按颜色筛选结果?
可以按颜色过滤结果。为此,可以使用--timer-filter
标志:
pytest --with-timer --timer-filter ok
pytest --with-timer --timer-filter warning
pytest --with-timer --timer-filter error
或同时应用多个过滤器:
pytest --with-timer --timer-filter warning,error
许可证
pytest-timer
是麻省理工学院授权的图书馆。在
贡献
- 检查是否有未解决的问题,或者打开一个新的问题,围绕某个特性想法或bug展开讨论。在
- 在GitHub上分叉存储库,开始对主分支(或其分支)进行更改。在
- 编写一个测试,测试该错误是否已修复,或者该功能是否按预期工作。在
- 发送一个pull请求并对维护者进行bug,直到它被合并和发布。在
- 请确保将自己添加到作者的文件中设置.py以及下面的贡献者部分:)
贡献者
- 项目
标签: