Skip to content

Commit 939bb03

Browse files
committed
fix(commit): use os.unlink to remove temp file
NamedTemporaryFile doesn't have a unlink function when delete=False is used Fix commitizen-tools#1352
1 parent af28565 commit 939bb03

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

commitizen/commands/commit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def manual_edit(self, message: str) -> str:
8989
subprocess.call(argv)
9090
with open(file_path) as temp_file:
9191
message = temp_file.read().strip()
92-
file.unlink()
92+
os.unlink(file.name)
9393
return message
9494

9595
def __call__(self):

tests/commands/test_commit_command.py

-2
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,6 @@ def test_manual_edit(editor, config, mocker: MockFixture, tmp_path):
511511

512512
assert edited_message == test_message.strip()
513513

514-
temp_file.unlink()
515-
516514

517515
@skip_below_py_3_13
518516
def test_commit_command_shows_description_when_use_help_option(

0 commit comments

Comments
 (0)