You've already forked HeurAMS-legacy
format
This commit is contained in:
@@ -44,7 +44,9 @@ class TestDashboardScreenUnit(unittest.TestCase):
|
||||
|
||||
# 创建目录
|
||||
for dir_key in ["nucleon_dir", "electron_dir", "orbital_dir", "cache_dir"]:
|
||||
pathlib.Path(config_data["paths"][dir_key]).mkdir(parents=True, exist_ok=True)
|
||||
pathlib.Path(config_data["paths"][dir_key]).mkdir(
|
||||
parents=True, exist_ok=True
|
||||
)
|
||||
|
||||
# 使用 ConfigContext 设置配置
|
||||
self.config_ctx = ConfigContext(self.config)
|
||||
@@ -60,16 +62,19 @@ class TestDashboardScreenUnit(unittest.TestCase):
|
||||
screen = DashboardScreen()
|
||||
# 手动调用 compose 并收集部件
|
||||
from textual.app import ComposeResult
|
||||
|
||||
result = screen.compose()
|
||||
widgets = list(result)
|
||||
# 检查是否包含 Header 和 Footer
|
||||
from textual.widgets import Header, Footer
|
||||
|
||||
header_present = any(isinstance(w, Header) for w in widgets)
|
||||
footer_present = any(isinstance(w, Footer) for w in widgets)
|
||||
self.assertTrue(header_present)
|
||||
self.assertTrue(footer_present)
|
||||
# 检查是否有 ScrollableContainer
|
||||
from textual.containers import ScrollableContainer
|
||||
|
||||
container_present = any(isinstance(w, ScrollableContainer) for w in widgets)
|
||||
self.assertTrue(container_present)
|
||||
# 使用 query_one 查找 union-list,即使屏幕未挂载也可能有效
|
||||
@@ -117,7 +122,9 @@ class TestDashboardScreenPilot(unittest.TestCase):
|
||||
config_data["timestamp_override"] = -1
|
||||
|
||||
for dir_key in ["nucleon_dir", "electron_dir", "orbital_dir", "cache_dir"]:
|
||||
pathlib.Path(config_data["paths"][dir_key]).mkdir(parents=True, exist_ok=True)
|
||||
pathlib.Path(config_data["paths"][dir_key]).mkdir(
|
||||
parents=True, exist_ok=True
|
||||
)
|
||||
|
||||
self.config_ctx = ConfigContext(self.config)
|
||||
self.config_ctx.__enter__()
|
||||
@@ -128,7 +135,7 @@ class TestDashboardScreenPilot(unittest.TestCase):
|
||||
|
||||
def test_dashboard_loads_with_pilot(self):
|
||||
"""使用 Pilot 测试 DashboardScreen 加载。"""
|
||||
with patch('heurams.interface.__main__.environment_check'):
|
||||
with patch("heurams.interface.__main__.environment_check"):
|
||||
app = HeurAMSApp()
|
||||
# 注意:Pilot 在 Textual 6.9.0 中的用法可能不同
|
||||
# 以下为示例代码,可能需要调整
|
||||
@@ -142,4 +149,4 @@ class TestDashboardScreenPilot(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user