浏览代码

Ensure that a file is closed in the tests

Alex Gaynor 11 年之前
父节点
当前提交
92dbf34286
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      tests/fixtures/tests.py

+ 2 - 1
tests/fixtures/tests.py

@@ -52,7 +52,8 @@ class DumpDataAssertMixin(object):
                                                       'exclude': exclude_list,
                                                       'primary_keys': primary_keys})
         if filename:
-            command_output = open(filename, "r").read()
+            with open(filename, "r") as f:
+                command_output = f.read()
             os.remove(filename)
         else:
             command_output = new_io.getvalue().strip()