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 | b007d17e5e2da220c57920b84c7f337bc8b378d0 (patch) | |
| tree | 2aeb27234b8ba1c2ae7e25c2f73c370816e29b41 /test/test_execfile.py | |
| parent | bf001ce15db6a5847fa41919474d9d007d2d49d3 (diff) | |
| download | python-coveragepy-b007d17e5e2da220c57920b84c7f337bc8b378d0.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 8c5e9a1..2f28a06 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", []) |
