Move test_linecache over to file context managers.

This commit is contained in:
Brett Cannon 2010-10-29 23:55:51 +00:00
parent dff69853af
commit 0174368449
1 changed files with 6 additions and 4 deletions

View File

@ -55,13 +55,15 @@ class LineCacheTests(unittest.TestCase):
# Check whether lines correspond to those from file iteration
for entry in TESTS:
filename = os.path.join(TEST_PATH, entry) + '.py'
for index, line in enumerate(open(filename)):
with open(filename) as file:
for index, line in enumerate(file):
self.assertEquals(line, getline(filename, index + 1))
# Check module loading
for entry in MODULES:
filename = os.path.join(MODULE_PATH, entry) + '.py'
for index, line in enumerate(open(filename)):
with open(filename) as file:
for index, line in enumerate(file):
self.assertEquals(line, getline(filename, index + 1))
# Check that bogus data isn't returned (issue #1309567)