Send pytest execution result email
Project description
pytest-send-email
Pytest发送Email邮件插件
特性
- SMTP服务器及用户密码信息支持写到环境变量或pytest.ini中,也可以命令行参数传入
- 支持选择使用SMTP或SMTP_SSL,支持自定义SMTP端口
- 支持在pytest.ini或命令行参数中定制邮件主题,邮件正文,邮件正文HTML模板
- 支持添加多个附件,文件路径以逗号隔开
- 支持多个收件人,文件路径以逗号隔开
如何使用
- 安装
pytest-send-email
使用pip安装
pip pytest-send-email
- 使用方法 在环境变量中添加SMTP_HOST, SMTP_USER,SMTP_PWD并source
export SMTP_HOST=<smtp-server>
export SMTP_USER=<your-email-user>
export SMTP_PWD=<your-password or token>
使用以下参数运行pytest
pytest --send-email --email-receivers=abc@gmail.com,abc@hotmail.com
也可以将参数配置到pytest.ini中
[pytest]
addopts = --send-email --html=report.html
smtp_host = <smtp-server>
smtp_port = <smtp-port>
smtp_user = <your-email-user>
smtp_pwd = <your-password or token>
smtp_ssl = False
email_receivers = superhin@126.com
email_subject = Pytest Test Report
email_body =
Hi, this is the test report
email_attachments=test_a.py,report.html
或在配置在pytest.ini[email]段中
[pytest]
addopts = --send-email --html=report.html
[email]
host = <smtp-server>
port = <smtp-port>
user = <your-email-user>
password = <your-password or token>
ssl = False
receivers = superhin@126.com
subject = Pytest Test Report
body =
Hi, this is the test report
attachments=test_a.py,report.html
然后运行pytest命令即可
- 支持的命令行参数
- --send-email: 是否发送邮件
- --email-receivers: 邮件收件人,逗号分隔
- --smtp-host: SMTP服务器地址
- --smtp-port: SMTP端口号
- --smtp-user: 邮箱用户
- --smtp-pwd: 邮箱密码
- --smtp-ssl: 是否使用SMTP_SSL
- --email-subject: 邮件主题
- --email-body: 邮件内容,支持HTML
- --email-template: 邮件模板文件路径
- --email-attachments: 邮件附件,逗号分隔
- 支持的pytest.ini选项
- --smtp_host: SMTP服务器地址
- --smtp_port: SMTP端口号
- --smtp_user: 邮箱用户
- --smtp_pwd: 邮箱密码
- --smtp_ssl: 是否使用SMTP_SSL
- --email_subject: 邮件主题
- --email_body: 邮件内容,支持HTML
- --email_receivers: Email receivers, comma-separated
- --email_template: 邮件模板文件路径
- --email_attachments: 邮件附件,逗号分隔
如果你想发邮件,最少要配置--send-email和--email-receivers或email_receivers
报告示例
报告信息
- Total: 用例总数
- Passed:成功用例总数
- Failed:失败用例总数
- Skipped:跳过用例总数
- Error:出错用例总数
- XPassed:非期望成功用例总数
- XFailed:期望失败总数
Todo
- 增加执行时间,时长,用例失败信息,日志,图表等更多的信息
- 支持JinJa2渲染模板
- 支持对用例标记失败时发邮件给谁
- Email:
superhin@126.com - Blog:
博客园 韩志超 - 简书:
简书 韩志超
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytest_send_email-0.1.1.tar.gz.
File metadata
- Download URL: pytest_send_email-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
271649e141bd03deb1371dcdfaa2543a7e3f4bcd9917696bbf33fc4b495db006
|
|
| MD5 |
eafa350307f08c6a9117390e07e3c3b9
|
|
| BLAKE2b-256 |
15fe3654e7e1b86a378756537f8b100d5390939ba8e36a535a3f972b4de606d9
|