]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Close a stream properly in test.test_pulldom.
authorBrett Cannon <brett@python.org>
Tue, 15 Mar 2011 21:22:52 +0000 (17:22 -0400)
committerBrett Cannon <brett@python.org>
Tue, 15 Mar 2011 21:22:52 +0000 (17:22 -0400)
Closes issue #11550. Thanks to Ben Hayden for some inspiration on the
solution.

Lib/test/test_pulldom.py

index 417152670c54d923536ab3117cccbed74cfd5328..b81a595f69da03d9459cf907ca35a71766b62b30 100644 (file)
@@ -32,7 +32,9 @@ class PullDOMTestCase(unittest.TestCase):
         # fragment.
 
         # Test with a filename:
-        list(pulldom.parse(tstfile))
+        handler = pulldom.parse(tstfile)
+        self.addCleanup(handler.stream.close)
+        list(handler)
 
         # Test with a file object:
         with open(tstfile, "rb") as fin: