Best Python code snippet using avocado_python
__init__.py
Source:__init__.py
...115 fail_reason = astring.to_text(fail_reason)116 formatted['fail_reason'] = fail_reason117 test_info.append(formatted)118 return test_info119 def _sysinfo_phase(self, phase):120 """121 Returns a list of system information for a given sysinfo phase122 :param section: a valid sysinfo phase, such as pre, post or profile123 """124 sysinfo_list = []125 base_path = os.path.join(self.results_dir(False), 'sysinfo', phase)126 try:127 sysinfo_files = os.listdir(base_path)128 except OSError:129 return sysinfo_list130 sysinfo_files.sort()131 s_id = 1132 for s_f in sysinfo_files:133 sysinfo_dict = {}134 sysinfo_path = os.path.join(base_path, s_f)135 sysinfo_dict['file'] = s_f136 sysinfo_dict['element_id'] = '%s_heading_%s' % (phase, s_id)137 sysinfo_dict['collapse_id'] = '%s_collapse_%s' % (phase, s_id)138 try:139 with codecs.open(sysinfo_path, 'r',140 encoding="utf-8") as sysinfo_file:141 sysinfo_dict['contents'] = sysinfo_file.read()142 except (OSError, UnicodeDecodeError) as details:143 path = os.path.relpath(sysinfo_path, self.html_output_dir)144 sysinfo_dict['err'] = "Error reading sysinfo file"145 sysinfo_dict['err_file'] = path146 sysinfo_dict['err_details'] = details147 sysinfo_list.append(sysinfo_dict)148 s_id += 1149 return sysinfo_list150 @property151 def sysinfo_pre(self):152 return self._sysinfo_phase('pre')153 @property154 def sysinfo_profile(self):155 return self._sysinfo_phase('profile')156 @property157 def sysinfo_post(self):158 return self._sysinfo_phase('post')159class HTMLResult(Result):160 """161 HTML Test Result class.162 """163 name = 'html'164 description = 'HTML result support'165 @staticmethod166 def _open_browser(html_path):167 # if possible, put browser in separate process168 # group, so keyboard interrupts don't affect169 # browser as well as Python170 setsid = getattr(os, 'setsid', None)171 if not setsid:172 setsid = getattr(os, 'setpgrp', None)...
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!!