Skip to content

Commit e0f4770

Browse files
author
patched.codes[bot]
committed
Patched test_line_endings.py
1 parent b778445 commit e0f4770

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test_line_endings.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
def create_test_files():
4+
# Create a file with CRLF endings
5+
with open('test_crlf.txt', 'wb') as f:
6+
f.write(b'line1\r\nline2\r\nline3\r\n')
7+
8+
# Read and write using current implementation
9+
from patchwork.common.utils.utils import open_with_chardet
10+
11+
# Read the file
12+
with open_with_chardet('test_crlf.txt', 'r') as f:
13+
content = f.read()
14+
15+
# Write back to a new file
16+
with open('test_output.txt', 'w') as f:
17+
f.write(content)
18+
19+
# Compare the files
20+
with open('test_crlf.txt', 'rb') as f1, open('test_output.txt', 'rb') as f2:
21+
original = f1.read()
22+
modified = f2.read()
23+
24+
print(f"Original file bytes: {original}")
25+
print(f"Modified file bytes: {modified}")
26+
print(f"Files are identical: {original == modified}")
27+
28+
create_test_files()

0 commit comments

Comments
 (0)