chore(commands): remove dead test-fixture path from reset_layout
This commit is contained in:
+4
-9
@@ -355,21 +355,16 @@ def reset_layout(app: "App") -> None:
|
|||||||
window names that no longer exist (e.g. after a refactor renames
|
window names that no longer exist (e.g. after a refactor renames
|
||||||
windows) and the dock space appears empty / non-recoverable via
|
windows) and the dock space appears empty / non-recoverable via
|
||||||
the Windows menu. Sets every show_windows entry to True and
|
the Windows menu. Sets every show_windows entry to True and
|
||||||
deletes manualslop_layout.ini so hello_imgui regenerates a fresh
|
deletes the cwd's manualslop_layout.ini so hello_imgui regenerates
|
||||||
dock layout on the next frame (and the next process shutdown saves
|
a fresh dock layout on the next process restart. The show_windows
|
||||||
the new layout in place of the stale one). The user will need to
|
toggles take effect immediately.
|
||||||
restart sloppy.py for the dock layout to fully take effect; the
|
|
||||||
show_windows toggles take effect immediately.
|
|
||||||
"""
|
"""
|
||||||
if hasattr(app, "show_windows") and isinstance(app.show_windows, dict):
|
if hasattr(app, "show_windows") and isinstance(app.show_windows, dict):
|
||||||
for name in app.show_windows.keys():
|
for name in app.show_windows.keys():
|
||||||
app.show_windows[name] = True
|
app.show_windows[name] = True
|
||||||
try:
|
try:
|
||||||
import os
|
import os
|
||||||
layout_paths = [
|
layout_paths: list[str] = ["manualslop_layout.ini"]
|
||||||
"manualslop_layout.ini",
|
|
||||||
os.path.join("tests", "artifacts", "live_gui_workspace", "manualslop_layout.ini"),
|
|
||||||
]
|
|
||||||
for p in layout_paths:
|
for p in layout_paths:
|
||||||
if os.path.exists(p):
|
if os.path.exists(p):
|
||||||
os.remove(p)
|
os.remove(p)
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import ast
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
import src.commands as commands
|
||||||
|
|
||||||
|
|
||||||
|
def test_reset_layout_excludes_test_fixture_path() -> None:
|
||||||
|
source: str = inspect.getsource(commands.reset_layout)
|
||||||
|
assert "tests/artifacts/live_gui_workspace" not in source
|
||||||
|
assert "os.path.join" not in source
|
||||||
|
assert "manualslop_layout.ini" in source
|
||||||
|
|
||||||
|
|
||||||
|
def test_reset_layout_runs_on_clean_app() -> None:
|
||||||
|
class _MockApp:
|
||||||
|
pass
|
||||||
|
mock_app: _MockApp = _MockApp()
|
||||||
|
mock_app.show_windows = {}
|
||||||
|
commands.reset_layout(mock_app)
|
||||||
Reference in New Issue
Block a user