From 9eafa7dbc952c0249903d48ee5e511ce747f639a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 22 Feb 2010 20:35:45 -0500 Subject: Python source files that don't end with a newline can now be executed, fixing #47. --- test/test_execfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/test_execfile.py') 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", []) -- cgit v1.2.1