Exemplo n.º 1
0
    def tearDownClass(cls):
        cls.end_time = datetime.datetime.now()
        report_summary = cls.report_data['report_summary']
        report_summary['duration'] = (cls.end_time -
                                      cls.start_time).total_seconds()
        report_summary['suite_count'] = len(cls.results)

        summary = cls.warp_results()
        report_summary['status'] = summary['status']
        cls.report_data['report_detail'] = summary['detail']

        report_name = '618_VR_API_Report.html'
        with open(report_name, 'wb') as fp:
            make_report(fp, cls.report_data)

        image_name = report_name.replace('.html', '.png')
        cls.make_image(report_name, image_name)

        send_mail = SendMail(to=[
            "*****@*****.**", "*****@*****.**",
            "*****@*****.**", "*****@*****.**",
            "*****@*****.**"
        ],
                             cc=["*****@*****.**"])
        attaches = [(report_name, 'text', 'html', report_name, 1)]
        send_mail.send_as_image('618_VR_API_Report',
                                image_name,
                                attaches=attaches)
Exemplo n.º 2
0
    def _save_report(self, report_content, theme=None, stylesheet=None, htmltemplate=None, javascript=None):
        dir_name = os.path.dirname(self.html_file)
        if not os.path.exists(dir_name):
            os.makedirs(dir_name)

        with open(self.html_file, 'wb') as fp:
            make_report(fp, report_content, theme=theme, stylesheet=stylesheet, htmltemplate=htmltemplate,
                        javascript=javascript)
Exemplo n.º 3
0
 def test_api_report(self):
     data = {
         "generator": "PyTestReport 0.1.4",
         "title": "默认主题",
         "description": "默认主题描述",
         "report_summary": {
             "start_time": "2019-05-12 23:07:49",
             "duration": "0:00:00.002000",
             "status": {
                 "pass": 1,
                 "fail": 0,
                 "error": 0,
                 "skip": 0
             }
         },
         "report_detail": {
             "tests": [{
                 "summary": {
                     "desc": "utDemo.UTestPass",
                     "count": 1,
                     "pass": 1,
                     "fail": 0,
                     "error": 0,
                     "skip": 0,
                     "cid": "c1",
                     "status": "pass"
                 },
                 "detail": [{
                     "has_output": False,
                     "tid": "pt1.1",
                     "desc": "testTrue",
                     "output": "",
                     "status": "pass",
                     "status_code": 0
                 }]
             }],
             "count":
             "1",
             "pass":
             "******",
             "fail":
             "0",
             "error":
             "0",
             "skip":
             "0"
         }
     }
     with open('API_Report.html', 'wb') as fp:
         make_report(fp, data)