def mail_content_by_zip(self): dirname, file_path = os.path.split(self.smtp_file) report_zip_path = self.smtp_file + '/../../zip/' + file_path + '.zip' zip_utils.zip_dir(self.smtp_file, report_zip_path) self.smtp_file = report_zip_path # 压缩后修改为压缩路径 msg = self.mail_content() return msg
def mail_content_by_zip(self): report_zip_path = self.smtp_file + '/../禅道自动化测试报告.zip' zip_utils.zip_dir(self.smtp_file, report_zip_path) print(report_zip_path) self.smtp_file = report_zip_path #压缩后修改为压缩路径 msg = self.mail_content() return msg
def mail_content_by_zip(self): report_zip_path = self.smtp_file + '/../ìøµÀ×Ô¶¯»¯²âÊÔ±¨¸æ.zip' zip_utils.zip_dir(self.smtp_file, report_zip_path) self.smtp_file = report_zip_path # ѹËõºóÐÞ¸ÄΪѹËõ·¾¶ msg = self.mail_content() return msg
def mail_content_by_zip(self): report_zip_path = self.smtp_file + '/../禅道自动化测试报告.zip' zip_utils.zip_dir(self.smtp_file, report_zip_path) self.smtp_file = report_zip_path # 更新文件,文件变成 *.zip msg = self.mail_content() return msg
self.test_case_path = case_path self.report_path = report_path self.title = '自动化测试报告' self.description = '测试报告' def run(self): discover = unittest.defaultTestLoader.discover(start_dir=self.test_case_path, pattern='*_test.py', top_level_dir=self.test_case_path) main_suite = unittest.TestSuite() main_suite.addTest(discover) # 启动测试时创建文件夹并获取报告的名字 report_dir = HTMLTestReportCN.ReportDirectory(self.report_path) report_dir.create_dir(title=self.title) report_path = HTMLTestReportCN.GlobalMsg.get_value('report_path') dir_path = HTMLTestReportCN.GlobalMsg.get_value('dir_path') print(report_path) fp = open(report_path, "wb") runner = HTMLTestReportCN.HTMLTestRunner(stream=fp, title=self.title, description=self.description, tester=input('请输入你的名字:')) runner.run(main_suite) fp.close() return dir_path if __name__ == '__main__': dir_path = RunAllTests().run() reprot_zip_path = dir_path + '/../禅道自动化测试报告.zip' zip_utils.zip_dir(dir_path, reprot_zip_path) EmailUtils('自动化测试报告(正式版)', 'python自动化测试报告', reprot_zip_path)