前言

pytest 运行全部用例的时候,在控制台会先显示用例的运行结果(.或F), 用例全部运行完成后最后把报错信息全部一起抛出到控制台。

这样我们每次都需要等用例运行结束,才知道为什么报错,不方便实时查看报错信息。

pytest-instafail 插件可以在运行用例的时候,需实时查看用例报错内容,这样方便跟踪问题。

--instafail

执行全部用例,报错内容等用例运行完成才显示出来

>pytest
============================= test session starts ============================= collected 11 items test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F.F [ 81%]
test_y.py .. [100%] ================================== FAILURES ===================================
___________________________________ test_02 ___________________________________ def test_02():
a = "hello"
b = "hello world"
> assert a == b
E AssertionError: assert 'hello' == 'hello world'
E - hello
E + hello world test_x.py:12: AssertionError
___________________________________ test_04 ___________________________________ def test_04():
a = "hello"
b = "hello world"
> assert a not in b
E AssertionError: assert 'hello' not in 'hello world'
E 'hello' is contained here:
E hello world test_x.py:24: AssertionError
===================== 2 failed, 9 passed in 1.32 seconds ======================

当用例很多的时候,不方便我们查看具体哪个报错对应哪条用例,加上--instafail参数,方便实时查看报错内容

>pytest --instafail
============================= test session starts ============================= collected 11 items test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F ___________________________________ test_02 ___________________________________ def test_02():
a = "hello"
b = "hello world"
> assert a == b
E AssertionError: assert 'hello' == 'hello world'
E - hello
E + hello world test_x.py:12: AssertionError test_x.py .F ___________________________________ test_04 ___________________________________ def test_04():
a = "hello"
b = "hello world"
> assert a not in b
E AssertionError: assert 'hello' not in 'hello world'
E 'hello' is contained here:
E hello world test_x.py:24: AssertionError test_y.py .. [100%] ===================== 2 failed, 9 passed in 1.37 seconds ======================

结合--tb=line参数,看起来更直观

>pytest --instafail --tb=line
============================= test session starts =============================
collected 11 items test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F D:\test_x.py:12: AssertionError: assert 'hello' == 'hello world' test_x.py .F D:\test_x.py:24: AssertionError: assert 'hello' not in 'hello world' test_y.py .. [100%] ===================== 2 failed, 9 passed in 1.30 seconds ======================

pytest文档53-命令行实时输出错误信息(pytest-instafail)的更多相关文章

  1. pytest文档52-命令行参数--setup-show查看fixture的执行过程

    前言 使用命令行运行 pytest 用例的时候,看不到 fixture 的执行过程. 如果我们想知道fixture的执行过程和先后顺序,可以加上 --setup-show 命令行参数,帮助查看 fix ...

  2. pytest文档49-命令行参数--tb的使用

    前言 pytest 使用命令行执行用例的时候,有些用例执行失败的时候,屏幕上会出现一大堆的报错内容,不方便快速查看是哪些用例失败. --tb=style 参数可以设置报错的时候回溯打印内容,可以设置参 ...

  3. Scrapy 1.4 文档 05 命令行工具

    在系统命令行中,使用 scrapy 命令可以创建工程或启动爬虫,它控制着 Scrapy 的行为,我们称之为 Scrapy 命令行工具(command-line tool)或 Scrapy 工具(Scr ...

  4. pytest文档28-重复执行用例(pytest-repeat)

    前言 平常在做功能测试的时候,经常会遇到某个模块不稳定,偶然会出现一些bug,对于这种问题我们会针对此用例反复执行多次,最终复现出问题来. 自动化运行用例时候,也会出现偶然的bug,可以针对单个用例, ...

  5. pytest文档10-命令行传参

    前言 命令行参数是根据命令行选项将不同的值传递给测试函数,比如平常在cmd执行"pytest --html=report.html",这里面的"--html=report ...

  6. pytest文档50-命令行参数--durations统计用例运行时间

    前言 写完一个项目的自动化用例之后,发现有些用例运行较慢,影响整体的用例运行速度,于是领导说找出运行慢的那几个用例优化下. --durations 参数可以统计出每个用例运行的时间,对用例的时间做个排 ...

  7. 【Python】【自动化测试】【pytest】【常用命令行选项】

    https://www.cnblogs.com/cnkemi/p/9989019.html http://www.cnblogs.com/cnkemi/p/10002788.html pytest 常 ...

  8. pytest文档7-pytest-html生成html报告

    前言 pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 pytest-html 1.github上源码地址[https://github. ...

  9. Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作

    Oracle 远程访问配置   服务端配置 如果不想自己写,可以通过 Net Manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置 ...

随机推荐

  1. flag在index里

    题目:http://123.206.87.240:8005/post/ 我们来看这一题 首先打开题目 他让点击就点击呗 跳转到另一个新的界面 这就没了??? ... 没思路就对了    //假装证明自 ...

  2. pwnable.kr之input

    连接到远程服务器:ssh input2@pwnable.kr -p2222 查看题目所给的代码,根据题目的要求我们要给出所有符合条件的输入才能拿到flag,本来想在输入上动点歪脑筋,结果输入有字节数的 ...

  3. 解决 Mac 上 Docker 无法直接 ping 通的问题

    解决 Mac 上 Docker 无法直接 ping 通的问题 原文连接 一.背景 Mac os Mojave 10.14.3 Docker Desktop community 2.3.0.4 二.问题 ...

  4. Linux下vim的安装及配置

    目录 一.vim的下载 二.vim的基本知识 三.vim的基本配置 四.vim与外部文件的复制粘贴 一.vim的下载 Ubuntu系统,输入命令: sudo apt install vim Cento ...

  5. 没有修改getModel()方法的返回值导致的Hibernate接收不到页面数据

    异常1.通过id进行查询,但id为null,就出现这个异常!java.lang.IllegalArgumentException: id to load is required for loading ...

  6. Javaweb应用中配置错误跳转页面

    关于在Javaweb应用中配置错误跳转页面 应用场景,比如服务器的出现404错误,我们想让它返回跳转到我们自定义的错误页面 解决方法: 主要在web.xml文件中进行配置,这里玩的错误页面都单独放在e ...

  7. Oracle闪回flashback

    参考资料:Using Oracle Flashback Technology Oracle 11g的新特性闪回操作 闪回查询 闪回查询 闪回版本查询 闪回事务查询 闪回数据 闪回表 闪回删除 闪回数据 ...

  8. 基于Socket的编程

    2020/7/5 客户端步骤: 1.创建Socket. 根据指定服务端的IP地址或者端口号构造Socket类对象: Socket socket  =  new  Socket(InetAddress. ...

  9. P1295 [TJOI2011]书架 线段树优化dp,单调栈

    P1295 [TJOI2011]书架 本题思路比较好想(对我来说不是),但代码细节很多,奈何洛谷的题解只有思路,然后就是 没有丝毫解释的代码,让人看起来很头疼(~~ 尤其是像我这样的蒟蒻~~),所以便 ...

  10. tagCould3d 移动端优化版

    针对https://github.com/bitjjj/JS-3D-TagCloud这个版本的做了移动端性能优化(使用transform做偏移及缩放,优化帧).基本原理一致. class TagCou ...