Pytest----pytest-sugar 执行过程显示进度条
【原文链接】Pytest----pytest-sugar 执行过程中显示进度条
Pytest-sugar是一款用来改善控制台显示的插件,增加了进度条显示,使得在用例执行过程中可以看到进度条,而且进度条是根据用例是否通过标注不同颜色,用例通过标记为绿色,用例失败则标记为红色,非常醒目。
首先使用如下命令安装pytest-sugar插件
pip install pytest-sugar
然后准备比如如下测试脚本。
def test_1():
print("in test_1")
assert 1==1
def test_2():
print("in test_2")
assert 1==1
def test_3():
print("in test_3")
assert 1==1
def test_4():
print("in test_4")
assert 1==1
def test_5():
print("in test_5")
assert 1==1
def test_6():
print("in test_6")
assert 1==1
执行pytest命令结果如下,可以发现在test_demo.py 后面跟着打印了若干个对号,同时又一段条形图,在控制台根据用例是否通过显示为绿色或者红色。
(demo-HCIhX0Hq) E:\demo>pytest
Test session starts (platform: win32, Python 3.7.9, pytest 7.2.0, pytest-sugar 0.9.6)
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: E:\demo, configfile: pytest.ini
plugins: allure-pytest-2.12.0, assume-2.4.3, attrib-0.1.3, benchmark-4.0.0, rerunfailures-10.2, sugar-0.9.6
collecting ...
test_demo.py ✓✓✓✓✓✓ 100% ██████████
Results (0.10s):
6 passed
(demo-HCIhX0Hq) E:\demo>
当安装了pytest-sugar后默认情况下就是开启的,若不想使用pytest-sugar了可以直接卸载或者使用如下命令,也可以禁止使用pytest-sugar。如下所示。
(demo-HCIhX0Hq) E:\demo>pytest -p no:sugar
=================== test session starts ===================
platform win32 -- Python 3.7.9, pytest-7.2.0, pluggy-1.0.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: E:\demo, configfile: pytest.ini
plugins: allure-pytest-2.12.0, assume-2.4.3, attrib-0.1.3, benchmark-4.0.0, rerunfailures-10.2
collected 6 items
test_demo.py ...... [100%]
==================== 6 passed in 0.09s ====================
(demo-HCIhX0Hq) E:\demo>
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhggbiec
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13