Files
Auto-Trader/tools
Haozhe Wu 0b05671be1 fix(tests): confine os patches to the module under test
`some_module.os` is the shared os module, so patching an attribute through
it installs the replacement for every importer in the process. That is held
together only by teardown ordering, which a test does not control: any
pytest_runtest_ hook touching the filesystem runs before fixture finalizers,
meets the replacement, and -- when the replacement raises, as most of these
do -- takes the teardown chain with it, after which the undo never happens.
One such test produced ~3000 cascading errors from ~40% of a run onward.

All 14 sites now go through patch_module_os, which swaps the module's
reference rather than the module's contents, and a grep gate keeps the
pattern from coming back.

Closes #1123
2026-08-18 15:20:42 +08:00
..