diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-10-29 23:55:51 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-10-29 23:55:51 (GMT) |
commit | 0174368449b01720ea117898fc6d4c9341689011 (patch) | |
tree | 1218b30c11659064919a245a18d8a4b4bb8173b6 /Lib/test/test_linecache.py | |
parent | dff69853af38b01a808a078ec889205733086a12 (diff) | |
download | cpython-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.py | 10 |
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') |