浏览代码

Close file in test.

Jelmer Vernooij 10 年之前
父节点
当前提交
4e80105f66
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      dulwich/tests/test_repository.py

+ 3 - 2
dulwich/tests/test_repository.py

@@ -64,8 +64,9 @@ class CreateRepositoryTests(TestCase):
         self.assertFileContentsEqual(b'', repo, os.path.join('info', 'exclude'))
         self.assertFileContentsEqual(None, repo, 'nonexistent file')
         barestr = b'bare = ' + str(expect_bare).lower().encode('ascii')
-        config_text = repo.get_named_file('config').read()
-        self.assertTrue(barestr in config_text, "%r" % config_text)
+        with repo.get_named_file('config') as f:
+            config_text = f.read()
+            self.assertTrue(barestr in config_text, "%r" % config_text)
 
     def test_create_disk_bare(self):
         tmp_dir = tempfile.mkdtemp()