From: Brett Cannon Date: Tue, 15 Mar 2011 21:22:52 +0000 (-0400) Subject: Close a stream properly in test.test_pulldom. X-Git-Tag: v3.3.0a1~2904 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f30645d5521afe5537befd0d9e84a7c539135cdc;p=thirdparty%2FPython%2Fcpython.git Close a stream properly in test.test_pulldom. Closes issue #11550. Thanks to Ben Hayden for some inspiration on the solution. --- diff --git a/Lib/test/test_pulldom.py b/Lib/test/test_pulldom.py index 417152670c54..b81a595f69da 100644 --- a/Lib/test/test_pulldom.py +++ b/Lib/test/test_pulldom.py @@ -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: