""" HOW解构V9测试脚本 测试集:从三个账号各选2个帖子,共6个测试用例 """ import asyncio import sys import os # 添加当前目录到path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from how_decode_v9_point_dependency import main # 测试数据集:每个账号选2个帖子 TEST_CASES = [ # 阿里多多酱(宠物类账号) { "account": "阿里多多酱", "files": [ "examples_new/阿里多多酱/output/685b593800000000120141d3_20251104_111017.json", "examples_new/阿里多多酱/output/6865e3ac00000000100251b6_20251104_111021.json", ] }, # 白流苏(美甲类账号) { "account": "白流苏", "files": [ "examples_new/白流苏/output/682c53fd000000000303c64f_20251104_112822.json", "examples_new/白流苏/output/6839827d0000000003039f7e_20251104_112821.json", ] }, # 摸鱼阿希 { "account": "摸鱼阿希", "files": [ "examples_new/摸鱼阿希/output/61bdc28b0000000001024896_20251104_132959.json", "examples_new/摸鱼阿希/output/66619827000000000600486f_20251104_133004.json", ] } ] async def run_test_case(file_path: str, case_num: int, total: int): """运行单个测试用例""" print("\n" + "="*100) print(f"测试用例 {case_num}/{total}: {file_path}") print("="*100) # 临时修改sys.argv来模拟命令行参数 original_argv = sys.argv.copy() sys.argv = ["test_script", file_path] try: from lib.my_trace import set_trace current_time, log_url = set_trace() from agents import trace with trace(f"test case {case_num}"): await main(current_time, log_url) print(f"\n✅ 测试用例 {case_num} 完成") except Exception as e: print(f"\n❌ 测试用例 {case_num} 失败: {e}") import traceback traceback.print_exc() finally: # 恢复原始参数 sys.argv = original_argv async def run_all_tests(): """运行所有测试用例""" all_files = [] # 收集所有测试文件 for account_data in TEST_CASES: account = account_data["account"] for file_path in account_data["files"]: all_files.append((account, file_path)) total = len(all_files) print(f"\n{'='*100}") print(f"HOW解构V9测试 - 共 {total} 个测试用例") print(f"{'='*100}") for idx, (account, file_path) in enumerate(all_files, 1): print(f"\n账号: {account}") await run_test_case(file_path, idx, total) # 添加延迟避免API限流 if idx < total: print(f"\n⏸ 等待2秒后继续下一个测试用例...") await asyncio.sleep(2) print("\n" + "="*100) print(f"✅ 所有 {total} 个测试用例完成!") print("="*100) if __name__ == "__main__": asyncio.run(run_all_tests())