Skip to content

Commit d0b3402

Browse files
committed
[TMP] Preserving newlines in isolate_tests.py
1 parent 0870d13 commit d0b3402

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/isolate_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from os.path import join, isfile, split
1414

1515
def extract_test_cases(path):
16-
lines = open(path, encoding="utf8", errors='ignore', mode='r').read().splitlines()
16+
lines = open(path, encoding="utf8", errors='ignore', mode='r', newline='').read().splitlines()
1717

1818
inside = False
1919
delimiter = ''
@@ -43,7 +43,7 @@ def extract_docs_cases(path):
4343
tests = []
4444

4545
# Collect all snippets of indented blocks
46-
for l in open(path, mode='r', errors='ignore', encoding='utf8').read().splitlines():
46+
for l in open(path, mode='r', errors='ignore', encoding='utf8', newline='').read().splitlines():
4747
if l != '':
4848
if not inside and l.startswith(' '):
4949
# start new test
@@ -72,14 +72,14 @@ def write_cases(f, tests):
7272
# so before checking remove 4 spaces from each line.
7373
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
7474
sol_filename = 'test_%s_%s.sol' % (hashlib.sha256(test.encode("utf-8")).hexdigest(), cleaned_filename)
75-
open(sol_filename, mode='w', encoding='utf8').write(remainder)
75+
open(sol_filename, mode='w', encoding='utf8', newline='').write(remainder)
7676

7777
def extract_and_write(f, path):
7878
if docs:
7979
cases = extract_docs_cases(path)
8080
else:
8181
if f.endswith('.sol'):
82-
cases = [open(path, mode='r', encoding='utf8').read()]
82+
cases = [open(path, mode='r', encoding='utf8', newline='').read()]
8383
else:
8484
cases = extract_test_cases(path)
8585
write_cases(f, cases)

0 commit comments

Comments
 (0)