From ff5e2c8c92f5a8cf376b5a2011fe9a9dc908ca5a Mon Sep 17 00:00:00 2001 From: John Fraser Date: Tue, 7 Apr 2026 12:57:03 +1000 Subject: [PATCH] fix(test): replace brittle substring assertions in test_linux_uses_dot_config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assertion `assert "AppData" not in str(paths.config_dir)` failed on Windows-hosted CI because pytest's tmp_path is located under AppData\Local\Temp\..., so "AppData" appears in the full absolute path even when the Linux config-path logic is correct. Replace the three vague substring checks with a single exact pathlib comparison: assert paths.config_dir == tmp_path / ".config" / "agileforecasting" This is stricter (exact match, not substring), platform-agnostic (does not depend on where tmp_path is rooted), and makes the intent explicit: on Linux the config directory must be exactly /.config/agileforecasting. The production code in secure_store._config_base() is unchanged — it was correct before and after this fix. Co-Authored-By: Claude Sonnet 4.6 --- tests/test_windows_compat.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_windows_compat.py b/tests/test_windows_compat.py index 0d086af..9e6e71c 100644 --- a/tests/test_windows_compat.py +++ b/tests/test_windows_compat.py @@ -50,16 +50,21 @@ def test_windows_appdata_fallback_when_env_missing(self, monkeypatch, tmp_path): assert paths.config_dir == fake_home / "AppData" / "Roaming" / "agileforecasting" def test_linux_uses_dot_config(self, monkeypatch, tmp_path): - """On Linux, default_paths() should use ~/.config/agileforecasting.""" + """On Linux, default_paths() should use ~/.config/agileforecasting. + + The assertion compares against the exact expected path rather than + checking substrings of the full absolute path. Substring checks are + brittle on Windows-hosted CI where pytest's tmp_path is located under + AppData\\Local\\Temp, causing an "AppData not in path" assertion to + fail even when the Linux path logic is correct. + """ monkeypatch.delenv("APPDATA", raising=False) with patch.object(sys, "platform", "linux"): with patch("os.path.expanduser", return_value=str(tmp_path)): from agile_mc.secure_store import default_paths paths = default_paths() - assert ".config" in str(paths.config_dir) - assert "agileforecasting" in str(paths.config_dir) - assert "AppData" not in str(paths.config_dir) + assert paths.config_dir == tmp_path / ".config" / "agileforecasting" def test_enc_file_is_inside_config_dir(self, monkeypatch, tmp_path): """enc_file should always sit directly inside config_dir."""