summaryrefslogtreecommitdiff
path: root/test/test_execfile.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-02-22 20:35:45 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-02-22 20:35:45 -0500
commit9eafa7dbc952c0249903d48ee5e511ce747f639a (patch)
treeb5d635c77b21c4ce44a050f32a97510070521cac /test/test_execfile.py
parent24db18eeb864fb85862adbd71cdadaa532dadd2c (diff)
downloadpython-coveragepy-git-9eafa7dbc952c0249903d48ee5e511ce747f639a.tar.gz
Python source files that don't end with a newline can now be executed, fixing #47.
Diffstat (limited to 'test/test_execfile.py')
-rw-r--r--test/test_execfile.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_execfile.py b/test/test_execfile.py
index 8c5e9a11..2f28a069 100644
--- a/test/test_execfile.py
+++ b/test/test_execfile.py
@@ -60,5 +60,17 @@ class RunTest(CoverageTest):
run_python_file('nl.py', ['nl.py'])
self.assertEqual(self.stdout(), "Hello, world!\n"*3)
+ def test_missing_final_newline(self):
+ # Make sure we can deal with a Python file with no final newline.
+ self.make_file("abrupt.py", """\
+ if 1:
+ a = 1
+ print("a is %r" % a)
+ #""")
+ abrupt = open("abrupt.py").read()
+ self.assertEqual(abrupt[-1], '#')
+ run_python_file("abrupt.py", ["abrupt.py"])
+ self.assertEqual(self.stdout(), "a is 1\n")
+
def test_no_such_file(self):
self.assertRaises(NoSource, run_python_file, "xyzzy.py", [])