test(memory): restore the parent package attribute after the writers reimport

The deprecation test re-imports headroom.memory.writers. Also remove and restore
headroom.memory.writers on the parent package, so later tests see one package object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra
2026-10-09 18:41:39 -07:00
co-authored by Claude Opus 5.5
parent c1d2b6b9df
commit 58e5702d66
+6 -1
View File
@@ -26,7 +26,12 @@ from headroom.memory.writers.generic_writer import GenericMemoryWriter
def test_importing_the_writers_package_warns_deprecated(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.delitem(sys.modules, "headroom.memory.writers")
# Restore both the sys.modules entry and the parent attribute afterwards, so
# later tests see the original package object whatever the import form.
import headroom.memory
monkeypatch.delitem(sys.modules, "headroom.memory.writers", raising=False)
monkeypatch.delattr(headroom.memory, "writers", raising=False)
with pytest.warns(DeprecationWarning, match="headroom.memory.writers is deprecated"):
importlib.import_module("headroom.memory.writers")