]> granicus.if.org Git - python/commitdiff
Properly close a file in test_minidom.
authorBrett Cannon <bcannon@gmail.com>
Sat, 30 Oct 2010 00:14:59 +0000 (00:14 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sat, 30 Oct 2010 00:14:59 +0000 (00:14 +0000)
Lib/test/test_minidom.py

index 97668d343cbcef90bb446fb821bc0f5034112882..7b845ef19df659bee834ccacfaf9aa579f3cf85d 100644 (file)
@@ -73,9 +73,10 @@ class MinidomTest(unittest.TestCase):
         self.confirm(t == s, "looking for %s, found %s" % (repr(s), repr(t)))
 
     def testParseFromFile(self):
-        dom = parse(open(tstfile))
-        dom.unlink()
-        self.confirm(isinstance(dom, Document))
+        with open(tstfile) as file:
+            dom = parse(file)
+            dom.unlink()
+            self.confirm(isinstance(dom, Document))
 
     def testGetElementsByTagName(self):
         dom = parse(tstfile)