Commit 313b747
committed
feat(testing): add detect_module_runtime_mode to detect stitched/zipapp builds
Add new detect_module_runtime_mode() function that reliably detects whether a
module is from a stitched build, zipapp, or regular package. Prioritizes marker-
based detection (__STITCHED__, __STANDALONE__) but falls back to path heuristics.
This fixes patch_everywhere() which was corrupting stitched module test isolation
by patching shared __globals__ dicts. Now patch_everywhere() uses the new detector
to skip __globals__ patching for stitched and zipapp modules, which use module-
level setattr instead.
Changes:
- Add detect_module_runtime_mode(mod, *, stitch_hints=None) function
- Make stitch_hints keyword-only parameter
- Pass stitch_hints to detector in both patch_everywhere call sites
- Remove duplicate fallback logic from patch_everywhere (now in detector)
- Export detect_module_runtime_mode in __init__.py
- Add tests for detector and patch_everywhere isolation behavior
- Update API documentation with detect_module_runtime_mode1 parent b0cc90d commit 313b747
File tree
6 files changed
+434
-106
lines changed- docs
- src/apathetic_utils
- tests/30_independant
6 files changed
+434
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1180 | 1228 | | |
1181 | 1229 | | |
1182 | 1230 | | |
| |||
0 commit comments