How to use test_fail_reason method in avocado

Best Python code snippet using avocado_python


Source:测试tts失败原因.py Github


Full Screen

...59def writeFile(file, content):60 with open(file, 'wb') as f:61 f.write(content)62 f.close()63def test_fail_reason(txt_file_path):64 # txt_file_path = r"C:\Dpan\python-script\pdf_convert\数据\10人以下小团队管理手册-堀之内克彦_image_ocr_result.txt"65 # 待合成文本内容66 with open(txt_file_path, 'r', encoding='utf-8') as f:67 text ='\n', "")68 # print('总字数:',len(text))69 # text_length = 33370 # text_list = re.findall(r".{%d}" % text_length, text)71 # text_list.append(text[len(text_list) * text_length:])72 text_list = text_byte_num_cut(text, 998)73 # print('分段数:',len(text_list))74 try:75 folder_path = os.path.join(r"E:\python\python-post-tencent\讯飞AI\audio", os.path.splitext(os.path.basename(txt_file_path))[0])76 os.makedirs(folder_path)77 except:78 pass79 for i, every_text in enumerate(text_list):80 r =, headers=getHeader(), data=getBody(every_text))81 contentType = r.headers['Content-Type']82 if contentType == "audio/mpeg":83 sid = r.headers['sid']84 if AUE == "raw":85 # 合成音频格式为pcm、wav并保存在audio目录下86 writeFile(os.path.join(folder_path, '{}.wav'.format(i)), r.content)87 # writeFile( + str(i) + ".wav", r.content)88 else:89 # 合成音频格式为mp3并保存在audio目录下90 writeFile("audio/" + "xiaoyan" + ".mp3", r.content)91 print(i,"success, sid = " + sid)92 else:93 # 错误码链接: (code返回错误码时必看)94 for i in json.loads(r.content).items():95 print(' => '.join(i))96if __name__ == "__main__":...

Full Screen

Full Screen Github


Full Screen

...14 data = json.load(json_file)15 test_data = data["tests"].pop()16 expected_logfile = path.join(test_data["logdir"], "debug.log")17 self.assertEqual(expected_logfile, test_data["logfile"])18 def test_fail_reason(self):19 cmd_line = (20 f"{AVOCADO} run examples/tests/ "21 f"--job-results-dir {} --disable-sysinfo"22 )23, ignore_status=True)24 json_path = path.join(, "latest", "results.json")25 with open(json_path, "r", encoding="utf-8") as json_file:26 data = json.load(json_file)27 test_data = data["tests"].pop()28 self.assertEqual("This test is supposed to fail", test_data["fail_reason"])29 def test_tags_in_result(self):30 cmd_line = (31 f"{AVOCADO} run examples/tests/ "32 f"--job-results-dir {} --disable-sysinfo"...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?