summaryrefslogtreecommitdiff
path: root/test/test_execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-06-27 17:36:13 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-06-27 17:36:13 -0400
commit0a010564ad1de72dc56e9cb20439deebca453751 (patch)
tree70ac12ae4763c7cea3f49238569d6679d1339857 /test/test_execfile.py
parent35b410d21e280dfeef1b0b23e065bc7f1f1091ab (diff)
downloadpython-coveragepy-git-0a010564ad1de72dc56e9cb20439deebca453751.tar.gz
When executing files, open them in Universal Newline mode, just as Python itself does. Makes it possible to run Python from Windows on Mac, for example.
Diffstat (limited to 'test/test_execfile.py')
-rw-r--r--test/test_execfile.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_execfile.py b/test/test_execfile.py
index eae227a1..6cc7cab8 100644
--- a/test/test_execfile.py
+++ b/test/test_execfile.py
@@ -46,3 +46,14 @@ class RunTest(CoverageTest):
self.assertEqual(os.listdir("."), ["xxx"])
run_python_file("xxx", ["xxx"])
self.assertEqual(os.listdir("."), ["xxx"])
+
+ def test_universal_newlines(self):
+ # Make sure we can read any sort of line ending.
+ pylines = """# try newlines|print 'Hello, world!'|""".split('|')
+ for nl in ('\n', '\r\n', '\r'):
+ fpy = open('nl.py', 'wb')
+ fpy.write(nl.join(pylines))
+ fpy.close()
+ run_python_file('nl.py', ['nl.py'])
+ self.assertEqual(self.stdout(), "Hello, world!\n"*3)
+