步骤:

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. [FAQ] swagger-php @OA\JsonContent 与 @MediaType @OA\Schema 的用法

    @OA\JsonContent 是对 @MediaType @OA\Schema 两者的封装,类似于 laravel 中 JsonResponse 对 Response 的封装. @OA\JsonCo ...

  2. [Go] 结构体成员的第三个位置上标签的作用

    结构体成员加了第三个位置的标签,在转换指定类型时,key 会使用指定的名字. package main import ( "encoding/json" "log&quo ...

  3. WPF 已知问题 BitmapDecoder.Create 不支持传入 Asynchronous 的文件流

    这是在 GitHub 上有小伙伴报的问题,在 WPF 中,不支持调用 BitmapDecoder.Create 方法,传入的 FileStream 是配置了 FileOptions.Asynchron ...

  4. R3_Elasticsearch Index Setting

    索引的配置项按是否可以更改分为static属性与动态配置,所谓的静态配置即索引创建后不能修改.目录如下:生产环境中某索引结构(7.X后有变化) 索引静态配置 1.分片与压缩 index.number_ ...

  5. WEB服务与NGINX(6)-location使用详解

    目录 1. location的详细用法 1.1 精确匹配 1.2 区分大小写 1.3 不区分大小写 1.4 匹配URI开始 1.5 测试location的优先级 1.6 location的生产使用示例 ...

  6. mac本地搭建ollama

    mac本地搭建ollama webUI *简介:ollama-webUI是一个开源项目,简化了安装部署过程,并能直接管理各种大型语言模型(LLM).本文将介绍如何在你的macOS上安装Ollama服务 ...

  7. 瑞亚时间管理大师,基于 .NET 6 和 Angular 构建的在线任务管理协作平台

    瑞亚时间管理大师 瑞亚时间管理大师, 是一个在线的任务管理.项目管理. 团队协作平台.瑞亚 拥有现代化的页面风格,高效.简便,同时适合个人和团队使用. 瑞亚对个人免费,提供了无限制的任务,列表,和空间 ...

  8. Unity Visual Scripting 使用随记

    1.Wait Until并不会再执行前面的代码,而是反复执行获取bool变量的代码:需自己拆出来写. 2.yield return null对应Wait For Next Frame,多用这个避免协程 ...

  9. JDK源码阅读-------自学笔记(十五)(java.lang.Math数学类)

    Math类简介 用于常见的数学方法 如果需要更加强大的数学运算能力,计算高等数学中的相关内容,可以使用apache commons下面的Math类库 常用方法及实战 abs 绝对值 实例: 1 //绝 ...

  10. C 编程异常 — implicit declaration of function 'free' is invalid in C99

    环境:MAC pro 问题:在编译程序的触发异常. main.c:17:9: warning: implicit declaration of function 'free' is invalid i ...