def __init__(self): # 获取配置信息 self.config = Tool().get_config self.tester = self.config.get('tester') self.device_type = self.config.get('device_type') # 获取到所有的手机信息 self.devices = self.config.get('devices') self.device = self.devices.get(self.device_type)[0] # port 用于校验服务是否启动 self.port = self.device.get('port') self.name = self.device.get('name')
def _generate_report(self, result): rows = [] sortedResult = self.sortResult(result.result) for cid, (cls, cls_results) in enumerate(sortedResult): # subtotal for a class np = nf = ne = 0 for n, t, o, e in cls_results: if n == 0: np += 1 elif n == 1: nf += 1 else: ne += 1 # format class description if cls.__module__ == "__main__": name = cls.__name__ else: name = "%s.%s" % (cls.__module__, cls.__name__) doc = cls.__doc__ and cls.__doc__.split("\n")[0] or "" desc = doc and '%s: %s' % (name, doc) or name row = self.REPORT_CLASS_TMPL % dict( style=ne > 0 and 'errorClass' or nf > 0 and 'failClass' or 'passClass', desc=desc, count=np + nf + ne, Pass=np, fail=nf, error=ne, cid='c%s' % (cid + 1), ) rows.append(row) from lib.tools import Tool import os pnglist = Tool().app_error_picture() if len(pnglist) > 0: Rewrite_results = [] for cls_p in cls_results: name = cls_p[1].id().split('.')[-1] for png in pnglist: png_name = png[0].split('.')[2] png_name = png_name.split('/')[-1] if png_name == name: tmp = cls_p + png Rewrite_results.append(tmp) break else: tmp = cls_p + ('',) Rewrite_results.append(tmp) for tid, (n, t, o, e, png) in enumerate(Rewrite_results): self._generate_report_test(rows, cid, tid, n, t, o, e, png) else: for tid, (n, t, o, e) in enumerate(cls_results): self._generate_report_test(rows, cid, tid, n, t, o, e) report = self.REPORT_TMPL % dict( test_list=''.join(rows), count=str(result.success_count + result.failure_count + result.error_count), Pass=str(result.success_count), fail=str(result.failure_count), error=str(result.error_count), ) return report
def setUpClass(cls): cls.page = Page() cls.tool = Tool() # 重点!!! 每次测试之前需要删除报错的截图,不然成功的用例也会将错误图片放进去 cls.tool.clear_picture()