summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_linecache.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-29 23:55:51 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-29 23:55:51 (GMT)
commit0174368449b01720ea117898fc6d4c9341689011 (patch)
tree1218b30c11659064919a245a18d8a4b4bb8173b6 /Lib/test/test_linecache.py
parentdff69853af38b01a808a078ec889205733086a12 (diff)
downloadcpython-0174368449b01720ea117898fc6d4c9341689011.zip
cpython-0174368449b01720ea117898fc6d4c9341689011.tar.gz
cpython-0174368449b01720ea117898fc6d4c9341689011.tar.bz2
Move test_linecache over to file context managers.
Diffstat (limited to 'Lib/test/test_linecache.py')
-rw-r--r--Lib/test/test_linecache.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py
index 06b6ad9..83901e7 100644
--- a/Lib/test/test_linecache.py
+++ b/Lib/test/test_linecache.py
@@ -55,14 +55,16 @@ 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)):
- self.assertEquals(line, getline(filename, index + 1))
+ 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)):
- self.assertEquals(line, getline(filename, index + 1))
+ 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)
empty = linecache.getlines('a/b/c/__init__.py')