run_tests.py
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Direct runner for the forum log monitor integration tests."""
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[3]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from tests.integration.forum.test_monitor import TestLogMonitor
def main():
"""Run the forum log monitor tests without requiring pytest."""
print("=" * 60)
print("ForumEngine 日志解析集成测试")
print("=" * 60)
print()
test_instance = TestLogMonitor()
test_methods = [name for name in dir(test_instance) if name.startswith("test_")]
passed = 0
failed = 0
for test_method_name in test_methods:
test_method = getattr(test_instance, test_method_name)
print(f"运行测试: {test_method_name}...", end=" ")
try:
test_instance.setup_method()
try:
test_method()
finally:
test_instance.teardown_method()
print("✓ 通过")
passed += 1
except AssertionError as exc:
print(f"✗ 失败: {exc}")
failed += 1
except Exception as exc:
print(f"✗ 错误: {exc}")
failed += 1
print()
print("=" * 60)
print(f"测试结果: {passed} 通过, {failed} 失败")
print("=" * 60)
raise SystemExit(1 if failed else 0)
if __name__ == "__main__":
main()