从失败信息里抠线索

👁️ 2 人浏览 💬 0 人评论 ❤️ 添加收藏

一段失败输出。抠出测试名、期望值、实际值:

msg = """FAIL: test_store_report (TestStoreReport)
AssertionError: '合计 109.5 约 15.64 外币' != '合计 98.55 约 14.08 外币'"""
name = msg.split("FAIL: ")[1].split(" ")[0]
parts = msg.split("AssertionError: ")[1].split(" != ")
got = parts[0].strip("'")
want = parts[1].strip("'")
print(name + "/" + got.split()[1] + "/" + want.split()[1] + "/" + str(round(float(got.split()[1]) * 0.9, 2) == float(want.split()[1])))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论