加快门禁:删除测试窗口、释放桩线程并并行运行三个阶段
关闭后未删除的测试窗口让每次主题切换重排全部残留控件,ui_check 每次关窗还要等桩线程 5 秒。Linux 上结论不变,test_ui_smoke 75→64 s、ui_check 52→16 s;Windows 门禁结果见 .scratch/gate-speed/。
This commit is contained in:
@@ -97,6 +97,8 @@ def make_window(qt_app, tmp_path, monkeypatch):
|
||||
|
||||
yield _make
|
||||
|
||||
from PySide6.QtCore import QCoreApplication, QEvent
|
||||
|
||||
for window in created:
|
||||
try:
|
||||
window.close()
|
||||
@@ -104,6 +106,14 @@ def make_window(qt_app, tmp_path, monkeypatch):
|
||||
# Reported rather than swallowed: a window that cannot close is a Qt lifetime
|
||||
# problem worth seeing, but it must not turn a green test red.
|
||||
logging.getLogger(__name__).debug("could not close a test window", exc_info=True)
|
||||
# ``close()`` only hides a window: something in the window keeps it referenced,
|
||||
# so it stayed alive for the rest of the session. Every leaked window's ~600
|
||||
# widgets are then re-polished by each later ``app.setStyleSheet`` — measured on
|
||||
# Linux, one theme switch takes 0.07 s with one window and 0.85 s after ten closed
|
||||
# ones, and three theme tests took 76 s of a 231 s Windows suite. Delete it.
|
||||
window.deleteLater()
|
||||
created.clear()
|
||||
QCoreApplication.sendPostedEvents(None, QEvent.Type.DeferredDelete)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user