summaryrefslogtreecommitdiff
path: root/test/test_execfile.py
diff options
context:
space:
mode:
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", [])