pytest_terminal_summary重写收集测试报告并发送邮件,报错"Argument(s) {'Config'} are declared in the hookimpl but can not be found in the hookspec"
步骤:
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"的更多相关文章
- 发送邮件报错javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed
关于使用javaMail发送邮件报错:javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multip ...
- 使用 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 ...
- 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 -- ...
- webpack 报错 No PostCSS Config found 解决方案。
webpack 报错 No PostCSS Config found 这个问题我在百度上找了好久,也没有找到解决方案,最后没有办法只能自己去啃官方文档,本案例在本人的webpack 学习感悟中已经写 ...
- webpack报错no postcss config...
终端里运行的错误: 查了好多资料,最后找到解决办法,改为: const webpack = require('webpack'); // const autoprefixer = require('a ...
- 存储过程收集统计信息ORA-20000报错解决记录
存储过程如下: create or replace procedure ad.table_analyse_bill( p_BillMonth in number,--bill_month p_tail ...
- jira发送邮件报错
jira发送邮件的报错 1.安装完jira后,配置发送邮件出错具体报错如下: An error has occurred with sending the test email: com.atlass ...
- yii2 联系我们发送邮件报错
为什么会报错,因为国内的邮件服务商要求发送邮件的人和设置的smtp服务器账号要相同,因为联系我们的是用户,也就是发件人是用户,而不是我们配置的邮箱,所有出错. 这里我用了个取巧的办法,发件人改为自己, ...
- jmeter+Jenkins 持续集成中发送邮件报错:MessagingException message: Exception reading response
已经配置好了发送邮件的相关信息,但是执行完脚本出现报错:MessagingException message: Exception reading response 1.查看Jenkins本次构建的控 ...
- 使用SpringBoot + JavaMailSender 发送邮件报错 Mail server connection failed;Could not connect to SMTP host
说明: 出于安全考虑,阿里云默认封禁 TCP 25 端口出方向的访问流量,无法在阿里云上的云服务器通过 TCP 25 端口连接外部地址. [官方提示]:如果您需要使用阿里云上的云服务器对外部发送邮件, ...
随机推荐
- [FAQ] pdf 无法导入 adobe AI, 分辨率 or 颜色缺失 or 字体缺失
属于Adoge软件不支持问题, 可能是分辨率.字体等多种原因. https://www.codebye.com/adobe-reader-or-acrobat-opens-pdf-file-drawi ...
- C#类型后加问号?
C# 可空类型(Nullable)说明_w3cschool 细说Nullable<T>类型 - Sweet-Tang - 博客园 (cnblogs.com) 值类型变量不能null,加问号 ...
- net core下链路追踪skywalking安装和简单使用
当我们用很多服务时,各个服务间的调用关系是怎么样的?各个服务单调用的顺序\时间性能怎么样?服务出错了,到底是哪个服务引起的?这些问题我们用什么方案解决呢,以前的方式是各个系统自己单独做日志,出了问题从 ...
- ITIL4 服务价值系统(SVS):一场服务管理的革新之旅
在这个数字化时代,每一家企业都在追求高效的服务管理和卓越的客户体验.今天,我们就来聊一聊ITIL4中的服务价值系统(Service Value System, SVS)--一个让服务管理变得更加直观和 ...
- sqli-labs-master 第十一关
本关为POST请求: 输入:admin'# 密码:随意 爆出当前数据库: 用户名:payload1:admin' and extractvalue(1,concat(0x7e,database(),0 ...
- rbenv 使用指南
https://github.com/rbenv/rbenv https://www.cnblogs.com/yiluhuakai/p/9414730.html https://ruby-china. ...
- laravel-cms学习笔记
学习地址: https://www.houdunren.com/edu/video/12045 laravel 文档地址: https://gitee.com/houdunren/code/blob/ ...
- 技术书籍 — EffectiveMordenCpp 研读
一.类型推导 PROs: 源码某处的类型修改,可以自动传播其他地方 Cons: 会让代码更复杂(How?) 在模板类型推导时,有引用的实参会被视为无引用,他们的引用会被忽略 template<t ...
- P3667 Bovine Genomics Hash+二分题解
砂金听说了你在学字符串,于是在CLOI里出了道题给你 P3667 Bovine Genomics 题链:洛谷 hzoi提高 \(hash\)基础题. 思路是二分答案,\(check\)中比较每一个区间 ...
- UE4 C++调用手柄震动
近期封装输入相关逻辑,简单归纳下. 蓝图实现 内容界面右键Miscellaneous->Force Feedback Effect,创建力反馈对象并填写相关参数: 然后在蓝图中用Spawn Fo ...