mirror of https://github.com/python/cpython
Move test_linecache over to file context managers.
This commit is contained in:
parent
dff69853af
commit
0174368449
|
@ -55,13 +55,15 @@ class LineCacheTests(unittest.TestCase):
|
||||||
# Check whether lines correspond to those from file iteration
|
# Check whether lines correspond to those from file iteration
|
||||||
for entry in TESTS:
|
for entry in TESTS:
|
||||||
filename = os.path.join(TEST_PATH, entry) + '.py'
|
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))
|
self.assertEquals(line, getline(filename, index + 1))
|
||||||
|
|
||||||
# Check module loading
|
# Check module loading
|
||||||
for entry in MODULES:
|
for entry in MODULES:
|
||||||
filename = os.path.join(MODULE_PATH, entry) + '.py'
|
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))
|
self.assertEquals(line, getline(filename, index + 1))
|
||||||
|
|
||||||
# Check that bogus data isn't returned (issue #1309567)
|
# Check that bogus data isn't returned (issue #1309567)
|
||||||
|
|
Loading…
Reference in New Issue