Best Python code snippet using Airtest
report.py
Source:report.py
...23def get_script_info(script_path):24 script_name = os.path.basename(script_path)25 result_json = {"name": script_name, "author": None, "title": script_name, "desc": None}26 return json.dumps(result_json)27def _make_export_dir(self):28 dirpath = self.script_root29 logpath = self.script_root30 # copy static files31 for subdir in ["css", "fonts", "image", "js"]:32 dist = os.path.join(dirpath, "static", subdir)33 shutil.rmtree(dist, ignore_errors=True)34 self.copy_tree(os.path.join(STATIC_DIR, subdir), dist)35 return dirpath, logpath36def report(self, template_name, output_file=None, record_list=None):37 """æ¿æ¢LogToHtmlä¸çreportæ¹æ³"""38 self._load()39 steps = self._analyse()40 # ä¿®æ¹infoè·åæ¹å¼41 info = json.loads(get_script_info(self.script_root))42 if self.export_dir:43 self.script_root, self.log_root = self._make_export_dir()44 output_file = os.path.join(self.script_root, HTML_FILE)45 self.static_root = "static/"46 if not record_list:47 record_list = [f for f in os.listdir(self.log_root) if f.endswith(".mp4")]48 records = [os.path.join(self.log_root, f) for f in record_list]49 if not self.static_root.endswith(os.path.sep):50 self.static_root = self.static_root.replace("\\", "/")51 self.static_root += "/"52 data = {}53 data['steps'] = steps54 data['name'] = os.path.basename(self.script_root)55 data['scale'] = self.scale56 data['test_result'] = self.test_result57 data['run_end'] = self.run_end...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!