From: Antoine Pitrou Date: Mon, 13 May 2013 20:34:21 +0000 (+0200) Subject: Fix ResourceWarnings in test_sax X-Git-Tag: v3.4.0a1~731^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2adb6fe246c0e07b30a70cd5c08e4aebc5b2923d;p=thirdparty%2FPython%2Fcpython.git Fix ResourceWarnings in test_sax --- diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 502c962d8e0d..78a1c697c507 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -574,7 +574,10 @@ class StreamReaderWriterXmlgenTest(XmlgenTest, unittest.TestCase): def ioclass(self): writer = codecs.open(self.fname, 'w', encoding='ascii', errors='xmlcharrefreplace', buffering=0) - self.addCleanup(support.unlink, self.fname) + def cleanup(): + writer.close() + support.unlink(self.fname) + self.addCleanup(cleanup) writer.getvalue = self.getvalue return writer