diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-22 20:35:45 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-22 20:35:45 -0500 |
commit | 9eafa7dbc952c0249903d48ee5e511ce747f639a (patch) | |
tree | b5d635c77b21c4ce44a050f32a97510070521cac /test/test_execfile.py | |
parent | 24db18eeb864fb85862adbd71cdadaa532dadd2c (diff) | |
download | python-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.py | 12 |
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", []) |