You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/06/23 11:54:30 UTC

svn commit: r1138805 - /libcloud/trunk/test/file_fixtures.py

Author: tomaz
Date: Thu Jun 23 09:54:29 2011
New Revision: 1138805

URL: http://svn.apache.org/viewvc?rev=1138805&view=rev
Log:
Close the file at the end and don't leak file handlers.

Modified:
    libcloud/trunk/test/file_fixtures.py

Modified: libcloud/trunk/test/file_fixtures.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/file_fixtures.py?rev=1138805&r1=1138804&r2=1138805&view=diff
==============================================================================
--- libcloud/trunk/test/file_fixtures.py (original)
+++ libcloud/trunk/test/file_fixtures.py Thu Jun 23 09:54:29 2011
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 # Helper class for loading large fixture data
+from __future__ import with_statement
 
 import os
 
@@ -32,7 +33,9 @@ class FileFixtures(object):
     def load(self, file):
         path = os.path.join(self.root, file)
         if os.path.exists(path):
-            return open(path, 'r').read()
+            with open(path, 'r') as fh:
+                content = fh.read()
+            return content
         else:
             raise IOError(path)