mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Merged revisions 81432 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81432 | benjamin.peterson | 2010-05-21 16:31:24 -0500 (Fri, 21 May 2010) | 1 line ensure the last line has a trailing newline #8782 ........
This commit is contained in:
parent
f28ae81741
commit
a3401654e1
3 changed files with 19 additions and 0 deletions
|
|
@ -31,6 +31,11 @@ a = f()
|
|||
|
||||
'''
|
||||
|
||||
SOURCE_3 = '''
|
||||
def f():
|
||||
return 3''' # No ending newline
|
||||
|
||||
|
||||
class LineCacheTests(unittest.TestCase):
|
||||
|
||||
def test_getline(self):
|
||||
|
|
@ -63,6 +68,15 @@ class LineCacheTests(unittest.TestCase):
|
|||
empty = linecache.getlines('a/b/c/__init__.py')
|
||||
self.assertEquals(empty, [])
|
||||
|
||||
def test_no_ending_newline(self):
|
||||
try:
|
||||
with open(support.TESTFN, "w") as fp:
|
||||
fp.write(SOURCE_3)
|
||||
lines = linecache.getlines(support.TESTFN)
|
||||
self.assertEqual(lines, ["\n", "def f():\n", " return 3\n"])
|
||||
finally:
|
||||
support.unlink(support.TESTFN)
|
||||
|
||||
def test_clearcache(self):
|
||||
cached = []
|
||||
for entry in TESTS:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue