Commit 13f5652
committed
fix: make app-folder resolution and its tests cross-platform
Fixes the four Windows CI failures (all pre-existing: this PR had only
touched base.py and tests/test_base.py) and one real Windows bug found
while investigating.
Code fix -- Windows 'cache' collided with 'data'/'state':
APP_FOLDER_STANDARDS described the Windows cache root as
FolderSpec("LOCALAPPDATA", join(%LOCALAPPDATA%, "Temp")). Since the
fallback is only used when the env var is *absent*, and LOCALAPPDATA is
always set on Windows, the "Temp" default was dead code: cache resolved
to %LOCALAPPDATA%, exactly the data/state root. Clearing an app's cache
would have deleted the user's data. FolderSpec gains a `subpath` field
that expresses "a kind that lives inside another kind's root", so cache
is now the documented %LOCALAPPDATA%\Temp.
The table also snapshotted os.getenv() into its own fallbacks at import
time, which made those fallbacks untestable and unreachable. They are now
declarative literals (~\AppData\Roaming etc.), so a missing env var yields
a real absolute root instead of "" -- an empty root would have degraded
os.path.join(root, app_name) into a *relative* path.
The single os.name branch is now app_folder_standards(os_name), so either
platform's table can be resolved from any platform, and
system_default_for_app_data_folder takes it via an optional keyword. That
makes Windows behaviour testable on Linux/macOS -- see the new
tests/test_platform_standards.py, which loops over both platforms.
Test fixes -- assertions that were POSIX-shaped, not wrong behaviour:
- test_app_data.py steered app folders with XDG_CONFIG_HOME/XDG_DATA_HOME.
XDG is a POSIX standard and is correctly ignored on Windows, so the
redirection silently did nothing there: two tests failed on the location
assertion and five others passed while writing into the runner's real
user profile. They now use config2py's own CONFIG2PY_<KIND>_DIR override,
which is honoured on every platform, and compare resolved Path objects
rather than strings. Location is now asserted in 5 tests, up from 2.
- test_sync_store.py::test_store_repr asserted a separator literal
(`temp_file in repr(store)`); pathlib's repr always spells paths with
forward slashes, so the native Windows form never appears. It now
asserts the store's filepath identity plus the separator-free filename.
Doctest fix:
get_app_folder's doctest expected '.../.config/config2py'. Rather than
skipping it, it now asserts the properties that hold on every platform:
the result is absolute, is named after the app, and sits directly inside
the 'config' root. That is strictly more coverage than the ELLIPSIS form.
Also corrected get_app_rootdir's docstring, which advertised the override
variables under wrong names (CONFIG2PY_*_FOLDER instead of CONFIG2PY_*_DIR)
and implied XDG works everywhere.
pytest config: testpaths named "tests", which does not exist (tests live in
config2py/tests/), so pytest warned and fell back to recursive discovery from
the CWD. Set to ["config2py"]. doctest_optionflags now match what the wads
run-tests-uv action passes on the command line (ELLIPSIS,
IGNORE_EXCEPTION_DETAIL) -- it overrides the file, so NORMALIZE_WHITESPACE
here meant local runs and CI applied different rules.
Collected tests: 106 -> 127 (+20 platform tests, +1 doctest), no warnings.
Dependents gate (29 suites) unchanged before/after: 25 pass, 2 pre-existing
failures (smart-cv, yp), 1 no-tests, 1 tests-disabled.
Claude-Session: https://claude.ai/code/session_01Kug7UUbVeCQgruvNXUq63c1 parent c7bd1a6 commit 13f5652
5 files changed
Lines changed: 256 additions & 41 deletions
File tree
- config2py
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
11 | 33 | | |
12 | 34 | | |
13 | 35 | | |
14 | 36 | | |
15 | 37 | | |
16 | 38 | | |
| 39 | + | |
17 | 40 | | |
18 | 41 | | |
19 | 42 | | |
20 | 43 | | |
21 | 44 | | |
| 45 | + | |
22 | 46 | | |
23 | 47 | | |
24 | 48 | | |
| |||
36 | 60 | | |
37 | 61 | | |
38 | 62 | | |
| 63 | + | |
39 | 64 | | |
40 | 65 | | |
41 | 66 | | |
| |||
110 | 135 | | |
111 | 136 | | |
112 | 137 | | |
| 138 | + | |
113 | 139 | | |
114 | 140 | | |
115 | 141 | | |
| |||
121 | 147 | | |
122 | 148 | | |
123 | 149 | | |
124 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
125 | 154 | | |
126 | 155 | | |
127 | 156 | | |
| |||
145 | 174 | | |
146 | 175 | | |
147 | 176 | | |
148 | | - | |
| 177 | + | |
149 | 178 | | |
150 | 179 | | |
151 | 180 | | |
152 | 181 | | |
| 182 | + | |
153 | 183 | | |
154 | 184 | | |
155 | | - | |
| 185 | + | |
156 | 186 | | |
157 | 187 | | |
158 | 188 | | |
159 | | - | |
| 189 | + | |
160 | 190 | | |
161 | 191 | | |
162 | | - | |
| 192 | + | |
163 | 193 | | |
164 | 194 | | |
165 | 195 | | |
| |||
168 | 198 | | |
169 | 199 | | |
170 | 200 | | |
171 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
172 | 204 | | |
173 | 205 | | |
174 | | - | |
| 206 | + | |
175 | 207 | | |
176 | 208 | | |
177 | 209 | | |
| |||
184 | 216 | | |
185 | 217 | | |
186 | 218 | | |
187 | | - | |
| 219 | + | |
188 | 220 | | |
189 | 221 | | |
190 | 222 | | |
| |||
194 | 226 | | |
195 | 227 | | |
196 | 228 | | |
| 229 | + | |
197 | 230 | | |
198 | 231 | | |
199 | | - | |
| 232 | + | |
200 | 233 | | |
201 | 234 | | |
202 | 235 | | |
203 | | - | |
| 236 | + | |
204 | 237 | | |
205 | 238 | | |
206 | | - | |
| 239 | + | |
207 | 240 | | |
208 | 241 | | |
209 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
274 | 281 | | |
275 | 282 | | |
276 | 283 | | |
| |||
0 commit comments