-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodule_test.py
More file actions
103 lines (80 loc) · 2.77 KB
/
Copy pathmodule_test.py
File metadata and controls
103 lines (80 loc) · 2.77 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
模块测试脚本
检查各个模块是否能正常导入和运行
"""
import sys
import os
# 添加项目根目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def test_imports():
"""测试模块导入"""
print("开始测试模块导入...")
try:
from core.router import Router
print("✓ Router模块导入成功")
except Exception as e:
print(f"✗ Router模块导入失败: {e}")
return False
try:
from core.aggregator import Aggregator
print("✓ Aggregator模块导入成功")
except Exception as e:
print(f"✗ Aggregator模块导入失败: {e}")
return False
try:
from memory.memory_manager import MemoryManager
print("✓ MemoryManager模块导入成功")
except Exception as e:
print(f"✗ MemoryManager模块导入失败: {e}")
return False
try:
from memory.memory_optimizer_enhanced import MemoryOptimizerEnhanced
print("✓ MemoryOptimizerEnhanced模块导入成功")
except Exception as e:
print(f"✗ MemoryOptimizerEnhanced模块导入失败: {e}")
return False
print("所有模块导入测试通过!")
return True
def test_basic_functionality():
"""测试基本功能"""
print("\n开始测试基本功能...")
try:
# 测试Router
from core.router import Router
router = Router()
print("✓ Router实例化成功")
# 测试Aggregator
from core.aggregator import Aggregator
aggregator = Aggregator()
print("✓ Aggregator实例化成功")
# 测试MemoryManager
from memory.memory_manager import MemoryManager
memory_manager = MemoryManager()
print("✓ MemoryManager实例化成功")
# 测试MemoryOptimizerEnhanced
from memory.memory_optimizer_enhanced import MemoryOptimizerEnhanced
memory_optimizer = MemoryOptimizerEnhanced()
print("✓ MemoryOptimizerEnhanced实例化成功")
print("所有基本功能测试通过!")
return True
except Exception as e:
print(f"✗ 基本功能测试失败: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""主函数"""
print("模块和功能测试")
print("=" * 30)
import_success = test_imports()
if not import_success:
return False
functionality_success = test_basic_functionality()
return functionality_success
if __name__ == "__main__":
success = main()
if success:
print("\n所有测试通过!")
else:
print("\n测试失败!")
sys.exit(0 if success else 1)