Initial import of ORISYS arm workstation
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""工位 Qt 运行时回归:无设备、无 ROS,检测导致一分钟崩溃的引用计数错误。
|
||||
|
||||
运行:bash station/run_station.sh --self-test
|
||||
"""
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import PySide6
|
||||
from PySide6.QtWidgets import QApplication, QLabel
|
||||
|
||||
|
||||
class QtRuntimeTest(unittest.TestCase):
|
||||
def test_void_calls_preserve_none(self):
|
||||
# 先检查版本,防止在有缺陷的绑定上运行压力循环导致解释器直接 abort。
|
||||
self.assertEqual(PySide6.__version__, "6.8.3")
|
||||
app = QApplication.instance() or QApplication([])
|
||||
label = QLabel("warmup")
|
||||
|
||||
def refresh():
|
||||
label.setText("updated")
|
||||
label.update()
|
||||
label.setVisible(False)
|
||||
label.style().unpolish(label)
|
||||
label.style().polish(label)
|
||||
|
||||
for _ in range(20):
|
||||
refresh()
|
||||
app.processEvents()
|
||||
before = sys.getrefcount(None)
|
||||
for _ in range(4000):
|
||||
refresh()
|
||||
after = sys.getrefcount(None)
|
||||
self.assertGreater(after - before, -50, "Qt 调用持续递减 None 引用计数")
|
||||
label.deleteLater()
|
||||
app.processEvents()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user