-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_simple_startup.py
More file actions
141 lines (106 loc) · 3.4 KB
/
test_simple_startup.py
File metadata and controls
141 lines (106 loc) · 3.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test script đơn giản để kiểm tra khởi động MainWindow
"""
import sys
import os
import traceback
# Thêm path cho QuangTPS
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
def test_basic_imports():
"""Test các import cơ bản"""
print("Testing basic imports...")
try:
from PyQt5.QtWidgets import QApplication
print("✓ PyQt5.QtWidgets imported successfully")
except ImportError as e:
print(f"✗ PyQt5.QtWidgets import failed: {e}")
return False
try:
from PyQt5.QtCore import Qt
print("✓ PyQt5.QtCore imported successfully")
except ImportError as e:
print(f"✗ PyQt5.QtCore import failed: {e}")
return False
return True
def test_mainwindow_import():
"""Test import MainWindow"""
print("\nTesting MainWindow import...")
try:
from quangtps.ui.main_window import MainWindow
print("✓ MainWindow imported successfully")
return True
except ImportError as e:
print(f"✗ MainWindow import failed: {e}")
traceback.print_exc()
return False
except Exception as e:
print(f"✗ MainWindow import error: {e}")
traceback.print_exc()
return False
def test_mainwindow_creation():
"""Test tạo MainWindow instance"""
print("\nTesting MainWindow creation...")
try:
from PyQt5.QtWidgets import QApplication
from quangtps.ui.main_window import MainWindow
# Tạo QApplication nếu chưa có
app = QApplication.instance()
if app is None:
app = QApplication(sys.argv)
# Tạo MainWindow
window = MainWindow()
print("✓ MainWindow created successfully")
# Test hiển thị
window.show()
print("✓ MainWindow shown successfully")
return True
except Exception as e:
print(f"✗ MainWindow creation failed: {e}")
traceback.print_exc()
return False
def test_launch_application():
"""Test launch_application function"""
print("\nTesting launch_application function...")
try:
from quangtps.ui.main_window import launch_application
print("✓ launch_application imported successfully")
return True
except ImportError as e:
print(f"✗ launch_application import failed: {e}")
return False
except Exception as e:
print(f"✗ launch_application error: {e}")
traceback.print_exc()
return False
def main():
"""Chạy tất cả tests"""
print("QuangTPS Simple Startup Test")
print("=" * 40)
tests = [
test_basic_imports,
test_mainwindow_import,
test_launch_application,
test_mainwindow_creation,
]
passed = 0
total = len(tests)
for test in tests:
try:
if test():
passed += 1
except Exception as e:
print(f"✗ Test {test.__name__} crashed: {e}")
traceback.print_exc()
print(f"\nResults: {passed}/{total} tests passed")
if passed == total:
print("✓ All tests passed! MainWindow should start successfully.")
return 0
else:
print("✗ Some tests failed. Check errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())