From 3fd4a2841a6b66d882d3b974f941faf1b6065ae5 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 24 Feb 2025 10:39:16 -0800 Subject: [PATCH] fix: Use separate temp file for log in editor test script --- tests/basic/test_editor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/basic/test_editor.py b/tests/basic/test_editor.py index 933fee3e8..47b1fac44 100644 --- a/tests/basic/test_editor.py +++ b/tests/basic/test_editor.py @@ -88,8 +88,10 @@ def test_pipe_editor_with_fake_editor(): import sys import tempfile + with tempfile.NamedTemporaryFile(mode="w", suffix=".log", delete=False) as log_f: + log_path = log_f.name + with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: - log_path = f.name + ".log" f.write(f"""import sys with open("{log_path}", "w") as f: f.write(" ".join(sys.argv)) @@ -112,8 +114,7 @@ with open("{log_path}", "w") as f: finally: # Clean up os.unlink(script_path) - if os.path.exists(f"{script_path}.log"): - os.unlink(f"{script_path}.log") + os.unlink(log_path) def test_pipe_editor():