@@ 89-104 (lines=16) @@ | ||
86 | assert f.newlines == '\r\n' |
|
87 | ||
88 | ||
89 | def test_generate_files_with_windows_newline(tmp_path): |
|
90 | """Verify windows source line end not changed during files generation.""" |
|
91 | generate.generate_files( |
|
92 | context={'cookiecutter': {'food': 'pizzä'}}, |
|
93 | repo_dir='tests/test-generate-files', |
|
94 | output_dir=tmp_path, |
|
95 | ) |
|
96 | ||
97 | newline_file = Path(tmp_path, 'inputpizzä/simple-with-newline-crlf.txt') |
|
98 | assert newline_file.is_file() |
|
99 | assert newline_file.exists() |
|
100 | ||
101 | with open(newline_file, 'r', encoding='utf-8', newline='') as f: |
|
102 | simple_text = f.readline() |
|
103 | assert simple_text == 'newline is CRLF\r\n' |
|
104 | assert f.newlines == '\r\n' |
|
105 | ||
106 | ||
107 | def test_generate_files_with_windows_newline_forced_to_linux_by_context(tmp_path): |
|
@@ 52-67 (lines=16) @@ | ||
49 | assert simple_text == 'I eat pizzä' |
|
50 | ||
51 | ||
52 | def test_generate_files_with_linux_newline(tmp_path): |
|
53 | """Verify new line not removed by templating engine after folder generation.""" |
|
54 | generate.generate_files( |
|
55 | context={'cookiecutter': {'food': 'pizzä'}}, |
|
56 | repo_dir='tests/test-generate-files', |
|
57 | output_dir=tmp_path, |
|
58 | ) |
|
59 | ||
60 | newline_file = Path(tmp_path, 'inputpizzä/simple-with-newline.txt') |
|
61 | assert newline_file.is_file() |
|
62 | assert newline_file.exists() |
|
63 | ||
64 | with open(newline_file, 'r', encoding='utf-8', newline='') as f: |
|
65 | simple_text = f.readline() |
|
66 | assert simple_text == 'newline is LF\n' |
|
67 | assert f.newlines == '\n' |
|
68 | ||
69 | ||
70 | def test_generate_files_with_trailing_newline_forced_to_linux_by_context(tmp_path): |