Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions tests/comfy_cli/test_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,12 @@ def test_atomic_write_text_preserves_existing_mode(tmp_path):


@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file-mode semantics")
def test_atomic_write_text_new_file_uses_umask_default(tmp_path):
def test_atomic_write_text_new_file_uses_umask_default(tmp_path, monkeypatch):
# A new destination gets the umask-derived default, not mkstemp's hardcoded 0600.
old_umask = os.umask(0o022)
try:
target = tmp_path / "fresh.json"
atomic_write_text(target, "data")
assert stat.S_IMODE(os.stat(target).st_mode) == (0o666 & ~0o022)
finally:
os.umask(old_umask)
monkeypatch.setattr(file_utils, "_UMASK", 0o022)
target = tmp_path / "fresh.json"
atomic_write_text(target, "data")
assert stat.S_IMODE(os.stat(target).st_mode) == (0o666 & ~0o022)


def test_atomic_write_text_cleans_up_tmp_on_failure(tmp_path, monkeypatch):
Expand Down Expand Up @@ -303,16 +300,13 @@ def boom(src, dst):


@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file-mode semantics")
def test_atomic_write_bytes_new_file_uses_umask_default(tmp_path):
def test_atomic_write_bytes_new_file_uses_umask_default(tmp_path, monkeypatch):
# The templates gallery cache relies on this: the old inline mkstemp left it
# at 0600, and the switch to the umask-derived default is intended.
old_umask = os.umask(0o022)
try:
target = tmp_path / "fresh.bin"
atomic_write_bytes(target, b"data")
assert stat.S_IMODE(os.stat(target).st_mode) == (0o666 & ~0o022)
finally:
os.umask(old_umask)
monkeypatch.setattr(file_utils, "_UMASK", 0o022)
target = tmp_path / "fresh.bin"
atomic_write_bytes(target, b"data")
assert stat.S_IMODE(os.stat(target).st_mode) == (0o666 & ~0o022)


# ---------------------------------------------------------------------------
Expand Down
Loading