Isolate HOME for the unit suite (hermetic audit/queue/state) #307
Reference in New Issue
Block a user
Delete Branch "hermetic-audit-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #302.
Summary
The unit suite could write to and
flockthe real~/.bot-bottle— state, queue, and audit dirs all derive fromsupervise.bot_bottle_root()→Path.home(). A test taking aflockon the real audit log blocks indefinitely when a live bottle's supervise sidecar holds that lock (observed this session: acoverage runhung at 0% CPU); unisolated tests otherwise pollute the developer's home dir.Rather than patch each call site,
tests/unit/__init__.pynow pointsHOMEat a throwaway temp dir for the whole unit package (restored +rmtree'd at exit). This is the robust fix:bot_bottle_root()resolves under the temp dir during the suite (verified).HOME(the manifest tests) now restore to the isolated dir, never the real one.supervise.bot_bottle_rootdirectly are unaffected.Note:
TestAuditLog/test_supervise_edgewere already hermetic; the leak was a test touching the real root for queue/state paths without isolation — the package-level fix closes the whole class. Full unit suite (1476) passes; pyright clean; pylint 10.00.