步骤:

1、conftest.py文件,重写pytest_terminal_summary(terminalreporter, exitstatus, config)

2、run执行pytest.main(),启动报错,提示填入的config,在hookspec找不到

错误提示如下:

pytest_terminal_summary  Argument(s) {'Config'} are declared in the hookimpl but can not be found in the hookspec

问题:当前版本的代码没有config的参数

1、导入_pytest.config一样启动失败

2、查看pytest关于这个方法的源码,查看到config参数是在pytest版本versionadded::
4.2,而当前的pytest版本低于4.2

解决方法

1、升级pytest的版本

Pip
install –upgrade pytest

2、 重启pycharm,在启动,启动成功,正确获取到config的配置信息

def pytest_terminal_summary(terminalreporter, exitstatus, config):
'''
重写【pytest_terminal_summary】收集测试结果方法,将测试结果保存,传到发送邮件使用,作为主要内容,最后发送邮件
:return:
'''
email = config.getoption('--sendemail')
# email = True
total = terminalreporter._numcollected
pass_num = len(terminalreporter.stats.get("passed", []))
failed_num = len(terminalreporter.stats.get("failed", []))
error_num = len(terminalreporter.stats.get("error", []))
skipped_num = len(terminalreporter.stats.get("skipped", []))
param_t = {}
param_t["total"] = total
param_t["pass"] = pass_num
param_t["failed"] = failed_num
param_t["error"] = error_num
param_t["skipped"] = skipped_num
param_t["rate"] = (CommunFun().decimal_round(number=Decimal(pass_num/total), len='3'))*Decimal('100')
# 将数量存放到com_obj,然后在发送邮件的时候,获取
DataManage().add_data_obj({"testresult": param_t})
if email:
file = CommunFun().get_new_file(r"D:\xxxx\reports")
sendEmail().send_email(email_to="xxx邮箱", filepath=file)

pytest_terminal_summary重写收集测试报告并发送邮件,报错"Argument(s) {'Config'} are declared in the hookimpl but can not be found in the hookspec"的更多相关文章

  1. 发送邮件报错javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed

    关于使用javaMail发送邮件报错:javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multip ...

  2. 使用 QQ 邮箱发送邮件报错:java.net.SocketTimeoutException: Read timed out. Failed messages: javax.mail.MessagingException: Exception reading response

    使用 QQ 邮箱发送邮件报错:java.net.SocketTimeoutException: Read timed out. Failed messages: javax.mail.Messagin ...

  3. Git报错 bad numeric config value '100000' for 'pack.windowmemory': out of range

    Git报错 bad numeric config value '10240M' for 'pack.windowmemory': out of range $ git config --edit -- ...

  4. webpack 报错 No PostCSS Config found 解决方案。

    webpack 报错 No PostCSS Config found  这个问题我在百度上找了好久,也没有找到解决方案,最后没有办法只能自己去啃官方文档,本案例在本人的webpack 学习感悟中已经写 ...

  5. webpack报错no postcss config...

    终端里运行的错误: 查了好多资料,最后找到解决办法,改为: const webpack = require('webpack'); // const autoprefixer = require('a ...

  6. 存储过程收集统计信息ORA-20000报错解决记录

    存储过程如下: create or replace procedure ad.table_analyse_bill( p_BillMonth in number,--bill_month p_tail ...

  7. jira发送邮件报错

    jira发送邮件的报错 1.安装完jira后,配置发送邮件出错具体报错如下: An error has occurred with sending the test email: com.atlass ...

  8. yii2 联系我们发送邮件报错

    为什么会报错,因为国内的邮件服务商要求发送邮件的人和设置的smtp服务器账号要相同,因为联系我们的是用户,也就是发件人是用户,而不是我们配置的邮箱,所有出错. 这里我用了个取巧的办法,发件人改为自己, ...

  9. jmeter+Jenkins 持续集成中发送邮件报错:MessagingException message: Exception reading response

    已经配置好了发送邮件的相关信息,但是执行完脚本出现报错:MessagingException message: Exception reading response 1.查看Jenkins本次构建的控 ...

  10. 使用SpringBoot + JavaMailSender 发送邮件报错 Mail server connection failed;Could not connect to SMTP host

    说明: 出于安全考虑,阿里云默认封禁 TCP 25 端口出方向的访问流量,无法在阿里云上的云服务器通过 TCP 25 端口连接外部地址. [官方提示]:如果您需要使用阿里云上的云服务器对外部发送邮件, ...

随机推荐

  1. 2018-7-15-WPF-在-DrawingContext-的-push-如何使用

    title author date CreateTime categories WPF 在 DrawingContext 的 push 如何使用 lindexi 2018-7-15 15:51:0 + ...

  2. 数据分析之pyecharts v1版本

    维护人员,感谢他们 https://github.com/chenjiandongx https://github.com/chfw https://github.com/kinegratii中文文档 ...

  3. EPAI手绘建模APP介绍

    ​        本软件是一个基于OpenCASCADE.android JNI开发的APP.底层用c++实现,UI层用android实现.底层和UI层之间通过JNI接口和json数据格式通信.    ...

  4. 记录一个解决固定定位内容不能滚动的方法(vant组件tab必用的css样式)

    vant组件下边是循环出来的,在开发中这部分必定是个单独的组件,内容溢出时添加滚动的样式,当然这个需要写在外部引入的自定义的vant组件样式当中 .van-tabs__content{ width: ...

  5. vim简明文档

    替换 替换当前行第一个 :s/vivian/sky/ 替换当前行第一个 vivian 为 sky 从当前行替换到最后一行 :%s/vivian/sky/g 替换所有行中 vivian 为 sky 查找 ...

  6. Rust 错误处理

    rust 处理错误,不使用 try catch, 而是使用 Result<T, E>. 简单的处理rust错误 在各种关于rust错误处理的文档中,为了解释清楚其背后的机制,看着内容很多, ...

  7. DP-Modeler三维修模软件简介

    图像快速建模系统DP-Modeler是天际航自主研发的一款集精细化单体建模及Mesh网格模型修饰于一体的新型软件.通过特有的摄影测量算法,支持航测摄影.无人机影像.地面影像.车载影像.激光点云等多数据 ...

  8. jquery中.html(),.text()和.val()的差异总结

    .html(),.text(),.val()三种方法都是用来读取选定元素的内容: .html()是用来读取元素的html内容(包括html标签): .text()用来读取元素的纯文本内容,包括其后代元 ...

  9. Teamviewer 再次涨价,太贵了,有没有平替软件?

    今天打开 Teamviewer 网站,吓一跳,商业版基础款价格直接翻倍. 作为行业龙头,又是德国产品,Teamviewer 一直保持着高价格的特色.这两年 Teamviewer 的价格还逐年上涨,从每 ...

  10. Vue3学习(二十四)- 文档页面功能开发

    写在前面 这部分真的感觉超级难,其实也不能说难,主要是真的想不到这个思路应该这么做,或者说他好厉害,他怎么知道该这么设计实现. 说下难点吧,我觉得后天逻辑还好,主要是前端部分真的需要点花点时间来思考, ...