""" 运行所有测试的主脚本 """ import sys from pathlib import Path # 添加项目路径 project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) from test_consistency import main as test_consistency from example_usage import ( example_single_prediction, example_batch_prediction, example_smiles_list_prediction ) def run_all_tests(): """运行所有测试""" print("🧪 开始运行广谱抗菌预测API测试套件") print("=" * 60) # 1. 一致性测试 print("\n📊 运行一致性测试...") try: consistency_passed = test_consistency() except Exception as e: print(f"一致性测试失败: {e}") consistency_passed = False # 2. 功能测试 print("\n🔧 运行功能测试...") try: print("测试单分子预测...") example_single_prediction() print("\n测试批量预测...") example_batch_prediction() print("\n测试SMILES列表预测...") example_smiles_list_prediction() functional_passed = True print("✅ 功能测试通过") except Exception as e: print(f"❌ 功能测试失败: {e}") import traceback traceback.print_exc() functional_passed = False # 总结 print("\n" + "=" * 60) print("📋 测试总结:") print(f" 一致性测试: {'✅ 通过' if consistency_passed else '❌ 失败'}") print(f" 功能测试: {'✅ 通过' if functional_passed else '❌ 失败'}") if consistency_passed and functional_passed: print("\n🎉 所有测试通过!API可以正常使用。") return True else: print("\n⚠️ 部分测试失败,请检查问题。") return False if __name__ == "__main__": success = run_all_tests() sys.exit(0 if success else 1)