From 80bed76c8a0692dbb176ed0cd1f390d7400392d2 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 14 Oct 2026 07:10:16 +0200 Subject: [PATCH] tools/test_setup_mac: the --source test no longer runs setup.data_folder() for real The real data_folder() moves the model files of this checkout and of the data folder named in the user's settings.json into --data-dir and saves that folder as the new data folder. With a TemporaryDirectory the models are deleted on exit and settings.json is left pointing at a deleted directory (found on the M4 and on the PC: the test wrote %APPDATA%/Strata/settings.json and ~/.config/strata/settings.json). The test is about --source, so data_folder is mocked. --- tools/test_setup_mac.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/test_setup_mac.py b/tools/test_setup_mac.py index 5a1e6c15..900180a4 100644 --- a/tools/test_setup_mac.py +++ b/tools/test_setup_mac.py @@ -261,7 +261,11 @@ class Source(unittest.TestCase): self.addCleanup(env.stop) os.environ.pop("STRATA_SOURCE", None) warnings = [] + # setup.data_folder() is mocked: the real one moves the model files of this checkout and of the data folder in + # the user's settings.json into --data-dir, and saves that dir as the new data folder; with a temp dir that + # deletes the models on exit and leaves settings.json pointing at a deleted directory with tempfile.TemporaryDirectory() as tmp, \ + mock.patch.object(setup, "data_folder", lambda requested: (Path(tmp), [])), \ mock.patch("subprocess.run", fake_run(M5)), \ mock.patch.object(setup, "warn", lambda *a, **k: warnings.append(" ".join(str(x) for x in a))), \ mock.patch.object(setup, "say", lambda *a, **k: None), \