|
|
10 månader sedan | |
|---|---|---|
| .. | ||
| README.md | 10 månader sedan | |
| __init__.py | 10 månader sedan | |
| test_runner.py | 10 månader sedan | |
这是神机项目的统一测试框架,将所有测试功能整合到一个脚本中,避免项目中散落多个测试文件。
tests/
├── __init__.py # 测试模块初始化
├── test_runner.py # 统一测试运行器
└── README.md # 本说明文件
# 查看帮助
python tests/test_runner.py --help
# 列出所有可用测试
python tests/test_runner.py --list
# 运行所有测试
python tests/test_runner.py --test all
# 测试身份解决方案
python tests/test_runner.py --test identity
# 测试数据加载器
python tests/test_runner.py --test data_loader
# 测试模型下载功能
python tests/test_runner.py --test download
# 测试Git下载功能
python tests/test_runner.py --test git_download
# 测试模型推理功能
python tests/test_runner.py --test inference
要添加新的测试功能,请按以下步骤操作:
在 TestRunner 类中添加新的测试方法:
def test_new_feature(self):
"""测试新功能"""
print("=== 新功能测试 ===")
try:
# 测试逻辑
print("✅ 新功能测试通过")
return True
except Exception as e:
print(f"❌ 新功能测试失败: {e}")
return False
在 __init__ 方法中注册新测试:
self.tests: Dict[str, Callable] = {
# ... 现有测试
'new_feature': self.test_new_feature,
# ...
}
更新 run_all_tests 方法中的测试列表:
test_methods = [
# ... 现有测试
('新功能', self.test_new_feature),
# ...
]
测试脚本使用统一的输出格式:
模块导入失败
模型文件不存在
权限错误
如果测试失败,可以查看详细的错误信息和堆栈跟踪。测试脚本会自动显示异常详情。