步骤:

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. [Go] go build 和 go install 的区别

    $ go build 源文件及其包依赖 编译成二进制. install 不仅执行build过程 而且会把编译的二进制放到 $GOPATH/bin/,包放到 $GOPATH/pkg/ Link:http ...

  2. dotnet C# 获取当前设备可移动磁盘

    本文告诉大家如何获取当前设备的可移动磁盘 在我的 WPF 应用里面,期望获取到 U 盘的所在盘进行一些有趣的逻辑.可以通过 DriveInfo 类的 GetDrives 获取当前所有的驱动器磁盘 再通 ...

  3. dotnet 读 WPF 源代码笔记 提升调试效率的 NamedObject 类型

    本文来聊聊 WPF 那些值得称赞的设计中的 NamedObject 类型.在 WPF 中,有很多值得我学习的设计开发思想,其中就包括本文将要介绍的 NamedObject 类型.此类型的定义仅仅只是为 ...

  4. 火山引擎ByteHouse:OLAP如何支持超高QPS点查?

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 在当今高速发展的互联网时代,信息传播迅速,用户数量激增.在面对如此庞大的用户群体和高频的访问需求时,系统高并发访问 ...

  5. js的几个截取

    jsfun(){         let str = '01234567'         let str1         str1 = str.slice(2,5)                 ...

  6. Codeforces Round 932 (Div. 2) ABCD

    A. Entertainment in MAC 题意:给定字符串 \(S\),有两种操作,每次操作其中之一: 把 \(S\) 变为 \(S\) 的翻转 \(T\). 把 \(S\) 变为 \(S + ...

  7. CentOS7部署Redis(离线单机)

    一.检查是否安装 ## 检查是否安装了Redis [root@localhost /]# ps -ef | grep redis ## 存在就删除 [root@localhost /]# sudo y ...

  8. sql审计平台部署

    其它数据库管理平台:Orchestrator部署 包链接:https://github.com/hhyo/Archery/tree/master 部署链接:https://github.com/hhy ...

  9. Linux下tail -f,tail -F,tailf的区别

    在Linux中,tail -f ,tail -F,tailf都是用来查看滚动日志的好方法,但是三者之间却有着细微的不同: ​ tail -f 等同于--follow=descriptor,动态显示数据 ...

  10. C# 数独 解法

    按照人的思维来做的. MyPos 就是 数组 行 列值. public class CalcShuDu { public int[][] IArrSd; public int IBlankCount; ...