以邮件方式发送测试报告
import smtplibfrom email.mime.text import MIMETextclass SendEmail: """邮件方式发送报告""" global send_user global email_host global password send_user = "[email protected]" email_host = "smtp.163.com" password = ‘XXXXXX‘ def send_mail(self,user_List,sub,content): """ 发送邮件 :param user_List: 收件人列表 :param sub: 主题 :param content: 内容 :return: """ user = "[email protected]" + "<" + send_user + ">" message = MIMEText(content,_subtype="plain",_charset="utf-8") message[‘Subject‘] = sub message[‘From‘] = user message[‘To‘] = ";".join(user_List) server = smtplib.SMTP() server.connect(email_host) server.login(send_user,password) server.sendmail(user,message.as_string()) server.close() def send_main(self,pass_List,fail_List): """ 发送报告 :param pass_List: :param fail_List: :return: """ pass_num = float(len(pass_List)) fail_num = float(len(fail_List)) count_num = pass_num + fail_num pass_result = "%.2f%%" % (pass_num / count_num * 100) fail_result = "%.2f%%" % (fail_num / count_num * 100) user_List = [‘[email protected]‘] sub = ‘接口自动化测试报告‘ content = f"此次接口测试一共运行用例为:{count_num},通过个数为:{pass_num},失败个数为:{fail_num},通过率为:{pass_result}" self.send_mail(user_List,content)if __name__ == ‘__main__‘: send = SendEmail() send.send_main([1,2,3,4],[6,2])总结
以上是内存溢出为你收集整理的python3 邮件方式发送测试报告全部内容,希望文章能够帮你解决python3 邮件方式发送测试报告所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)