|
13 | 13 | from os.path import join, isfile, split |
14 | 14 |
|
15 | 15 | 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() |
17 | 17 |
|
18 | 18 | inside = False |
19 | 19 | delimiter = '' |
@@ -43,7 +43,7 @@ def extract_docs_cases(path): |
43 | 43 | tests = [] |
44 | 44 |
|
45 | 45 | # 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(): |
47 | 47 | if l != '': |
48 | 48 | if not inside and l.startswith(' '): |
49 | 49 | # start new test |
@@ -72,14 +72,14 @@ def write_cases(f, tests): |
72 | 72 | # so before checking remove 4 spaces from each line. |
73 | 73 | remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE) |
74 | 74 | 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) |
76 | 76 |
|
77 | 77 | def extract_and_write(f, path): |
78 | 78 | if docs: |
79 | 79 | cases = extract_docs_cases(path) |
80 | 80 | else: |
81 | 81 | if f.endswith('.sol'): |
82 | | - cases = [open(path, mode='r', encoding='utf8').read()] |
| 82 | + cases = [open(path, mode='r', encoding='utf8', newline='').read()] |
83 | 83 | else: |
84 | 84 | cases = extract_test_cases(path) |
85 | 85 | write_cases(f, cases) |
|
0 commit comments