[Python-checkins] r85958 - python/branches/py3k/Lib/test/test_linecache.py

brett.cannon python-checkins at python.org
Sat Oct 30 01:55:51 CEST 2010


Author: brett.cannon
Date: Sat Oct 30 01:55:51 2010
New Revision: 85958

Log:
Move test_linecache over to file context managers.

Modified:
   python/branches/py3k/Lib/test/test_linecache.py

Modified: python/branches/py3k/Lib/test/test_linecache.py
==============================================================================
--- python/branches/py3k/Lib/test/test_linecache.py	(original)
+++ python/branches/py3k/Lib/test/test_linecache.py	Sat Oct 30 01:55:51 2010
@@ -55,14 +55,16 @@
         # 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')


More information about the Python-checkins mailing list