Files
AstrBot/run_tests.py
united_pooh f865b2b7e9 chore(runtime): 使用 ruff format 并为 peer 补充中文文档
- 运行 ruff format 统一代码格式
- 说明 Peer 在协议层中的命名含义
- 为 Peer 类及其所有方法补充中文注释型文档
2026-03-13 01:39:22 +08:00

57 lines
1.3 KiB
Python

#!/usr/bin/env python
"""
Test runner script for astrbot-sdk.
Usage:
python run_tests.py # Run all tests
python run_tests.py -v # Verbose output
python run_tests.py -k "test_peer" # Run tests matching pattern
python run_tests.py --cov # Run with coverage
python run_tests.py -m "not slow" # Skip slow tests
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
def main() -> int:
"""Run tests with pytest."""
project_root = Path(__file__).parent
tests_dir = project_root / "tests_v4"
# Build pytest command
cmd = [sys.executable, "-m", "pytest", str(tests_dir)]
# Parse arguments
args = sys.argv[1:]
# Handle --cov flag
if "--cov" in args:
args.remove("--cov")
cmd.extend(
[
"--cov=src-new/astrbot_sdk",
"--cov-report=term-missing",
"--cov-report=html:.htmlcov",
]
)
# Default flags if no specific args
if not args:
cmd.extend(["-v", "--tb=short"])
cmd.extend(args)
print(f"Running: {' '.join(cmd)}")
print("-" * 60)
result = subprocess.run(cmd, cwd=project_root)
return result.returncode
if __name__ == "__main__":
sys.exit(main())