diff options
Diffstat (limited to 'Lib/lib2to3/tests/test_refactor.py')
| -rw-r--r-- | Lib/lib2to3/tests/test_refactor.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py index 73122d8..b6d5b57 100644 --- a/Lib/lib2to3/tests/test_refactor.py +++ b/Lib/lib2to3/tests/test_refactor.py @@ -231,6 +231,23 @@ from __future__ import print_function""" os.path.join("a_dir", "stuff.py")] check(tree, tree) + def test_preserve_file_newlines(self): + rt = self.rt(fixers=_2TO3_FIXERS) + for nl in ("\r\n", "\n"): + data = "print y%s%syes%sok%s" % ((nl,) * 4) + handle, tmp = tempfile.mkstemp() + os.close(handle) + try: + with open(tmp, "w") as fp: + fp.write(data) + rt.refactor_file(tmp) + with open(tmp, "r") as fp: + contents = fp.read() + finally: + os.unlink(tmp) + for line in contents.splitlines(True): + self.assertTrue(line.endswith(nl)) + def test_file_encoding(self): fn = os.path.join(TEST_DATA_DIR, "different_encoding.py") self.check_file_refactoring(fn) |
