更新验证器提价
This commit is contained in:
51
scripts/run_tests.py
Normal file
51
scripts/run_tests.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
运行测试脚本 - 执行所有测试并生成报告
|
||||
"""
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run_tests(coverage: bool = False) -> int:
|
||||
"""运行测试"""
|
||||
project_root = Path(__file__).parent.parent
|
||||
|
||||
cmd = [sys.executable, "-m", "pytest", "tests/", "-v"]
|
||||
|
||||
if coverage:
|
||||
cmd.extend([
|
||||
"--cov=.",
|
||||
"--cov-report=html",
|
||||
"--cov-report=term-missing"
|
||||
])
|
||||
|
||||
print(f"运行命令: {' '.join(cmd)}")
|
||||
print("-" * 60)
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, cwd=project_root)
|
||||
return result.returncode
|
||||
except Exception as e:
|
||||
print(f"运行测试失败: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="运行测试")
|
||||
parser.add_argument(
|
||||
"--coverage", "-c",
|
||||
action="store_true",
|
||||
help="生成覆盖率报告"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
return run_tests(coverage=args.coverage)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user