test(cli): prime monkeypatch undo so palace env doesn't leak
monkeypatch.delenv(name, raising=False) on a missing key registers no undo entry, so the env var cmd_init writes leaked into test_config_from_file on Python 3.13 / Windows / macOS. Prime the slot with setenv before delenv so teardown rolls back the write.
This commit is contained in:
+9
-3
@@ -187,9 +187,15 @@ def test_cmd_init_honors_palace_flag(tmp_path, monkeypatch):
|
|||||||
palace = tmp_path / "custom_palace"
|
palace = tmp_path / "custom_palace"
|
||||||
|
|
||||||
# Make sure no leftover env var from another test leaks in — we want to
|
# Make sure no leftover env var from another test leaks in — we want to
|
||||||
# verify that --palace ALONE drives the resolution.
|
# verify that --palace ALONE drives the resolution. Prime monkeypatch's
|
||||||
monkeypatch.delenv("MEMPALACE_PALACE_PATH", raising=False)
|
# undo list with setenv first so that the env var ``cmd_init`` writes
|
||||||
monkeypatch.delenv("MEMPAL_PALACE_PATH", raising=False)
|
# below is rolled back at teardown (``delenv(raising=False)`` on a
|
||||||
|
# missing key registers no undo entry, which would leak into the next
|
||||||
|
# test).
|
||||||
|
monkeypatch.setenv("MEMPALACE_PALACE_PATH", "")
|
||||||
|
monkeypatch.setenv("MEMPAL_PALACE_PATH", "")
|
||||||
|
monkeypatch.delenv("MEMPALACE_PALACE_PATH")
|
||||||
|
monkeypatch.delenv("MEMPAL_PALACE_PATH")
|
||||||
|
|
||||||
args = argparse.Namespace(
|
args = argparse.Namespace(
|
||||||
dir=str(project),
|
dir=str(project),
|
||||||
|
|||||||
Reference in New Issue
Block a user