mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
use addCleanup
This commit is contained in:
parent
233eb54051
commit
6722ac2f00
1 changed files with 26 additions and 29 deletions
|
|
@ -81,9 +81,9 @@ class LineCacheTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_checkcache(self):
|
def test_checkcache(self):
|
||||||
getline = linecache.getline
|
getline = linecache.getline
|
||||||
try:
|
|
||||||
# Create a source file and cache its contents
|
# Create a source file and cache its contents
|
||||||
source_name = support.TESTFN + '.py'
|
source_name = support.TESTFN + '.py'
|
||||||
|
self.addCleanup(test_support.unlink, source_name)
|
||||||
with open(source_name, 'w') as source:
|
with open(source_name, 'w') as source:
|
||||||
source.write(SOURCE_1)
|
source.write(SOURCE_1)
|
||||||
getline(source_name, 1)
|
getline(source_name, 1)
|
||||||
|
|
@ -112,9 +112,6 @@ class LineCacheTests(unittest.TestCase):
|
||||||
self.assertEquals(line, getline(source_name, index + 1))
|
self.assertEquals(line, getline(source_name, index + 1))
|
||||||
source_list.append(line)
|
source_list.append(line)
|
||||||
|
|
||||||
finally:
|
|
||||||
support.unlink(source_name)
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
support.run_unittest(LineCacheTests)
|
support.run_unittest(LineCacheTests)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue