Skip to content

Commit 05da95c

Browse files
committed
save to the same file name
1 parent b09d71a commit 05da95c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sdk/ai/azure-ai-projects/tests/test_base.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ def patched_open_crlf_to_lf(*args, **kwargs):
105105

106106
# Only create temp file if conversion was needed
107107
if converted_content != content:
108-
# Create a temporary file with the converted content
109-
temp_fd, temp_path = tempfile.mkstemp(suffix=ext)
110-
os.write(temp_fd, converted_content)
111-
os.close(temp_fd)
108+
# Create a sub temp folder and save file with same filename
109+
temp_dir = tempfile.mkdtemp()
110+
original_filename = os.path.basename(file_path)
111+
temp_path = os.path.join(temp_dir, original_filename)
112+
113+
# Write the converted content to the temp file
114+
with _BUILTIN_OPEN(temp_path, "wb") as temp_file:
115+
temp_file.write(converted_content)
116+
112117
# Replace file path with temp path
113118
if args:
114119
# File path was passed as positional arg

0 commit comments

Comments
 (0)