From f2bc23df84907a361e7d9fa20bf1bc8f7a916037 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 20 Oct 2026 12:34:04 +0200 Subject: Keep column widths, splitters and window size across runs QSettings in state.conf next to config.toml, saved on close: every table header (widths, sort column) and splitter of the tabs, and the window geometry. Tests point it at a temp file, never the user's own. Co-Authored-By: Claude Opus 5.5 --- tests/test_gui.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_gui.py b/tests/test_gui.py index d5a1128..bd08e7f 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -21,6 +21,7 @@ os.environ["QT_QPA_PLATFORM"] = "offscreen" # never the real display, even if t import importlib.machinery # noqa: E402 import importlib.util # noqa: E402 +import shutil # noqa: E402 import sys # noqa: E402 import tempfile # noqa: E402 import time # noqa: E402 @@ -305,7 +306,11 @@ class SmokeTest(unittest.TestCase): "truncated": True, "mtime": 0, "resource": "peak memory 3308M\n"}, None), **answers}) - w = MainWindow(config.load("/nonexistent")[0], remote, FakeNotifier()) + if not hasattr(self, "state"): + tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, tmp) + self.state = os.path.join(tmp, "state.conf") # never the user's own + w = MainWindow(config.load("/nonexistent")[0], remote, FakeNotifier(), self.state) self.addCleanup(w.deleteLater) self.addCleanup(lambda: w.jobs_tab and w.jobs_tab.stop()) return w, remote @@ -663,6 +668,16 @@ class SmokeTest(unittest.TestCase): self.assertIn(("job-start", "hint-new", "curl", "nuclei"), remote.calls) self.assertIs(w.tabs.currentWidget(), w.hints_tab) # starting a job stays put + def test_view_state_kept_across_runs(self): + w, _ = self.window() + w.packages_tab.table.setColumnWidth(1, 333) + w.close() # saves + w2, _ = self.window() # same state file + self.assertEqual(w2.packages_tab.table.columnWidth(1), 333) + # the size itself can't be checked here: restoreGeometry clamps to offscreen's 800x600 screen + self.assertTrue(w2.state.value("geometry")) + self.assertEqual(w2.hints_tab.table.columnWidth(1), 220) # untouched: code default + def test_tab_shortcuts_wrap(self): w, _ = self.window() w.poll_jobs() -- cgit v1.2.3