From 939bb036d13fd60a532efbb24a6915457e2f2127 Mon Sep 17 00:00:00 2001 From: Alexander Gubin Date: Tue, 29 Apr 2025 14:32:43 +0200 Subject: [PATCH] fix(commit): use os.unlink to remove temp file NamedTemporaryFile doesn't have a unlink function when delete=False is used Fix https://github.com/commitizen-tools/commitizen/issues/1352 --- commitizen/commands/commit.py | 2 +- tests/commands/test_commit_command.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index abecb3b3c..93f048082 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -89,7 +89,7 @@ def manual_edit(self, message: str) -> str: subprocess.call(argv) with open(file_path) as temp_file: message = temp_file.read().strip() - file.unlink() + os.unlink(file.name) return message def __call__(self): diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 55751f690..3a92f5af4 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -511,8 +511,6 @@ def test_manual_edit(editor, config, mocker: MockFixture, tmp_path): assert edited_message == test_message.strip() - temp_file.unlink() - @skip_below_py_3_13 def test_commit_command_shows_description_when_use_help_option(