]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix ResourceWarnings in test_sax
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 13 May 2013 20:34:21 +0000 (22:34 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 13 May 2013 20:34:21 +0000 (22:34 +0200)
Lib/test/test_sax.py

index 502c962d8e0d427884b7a9ea7fd8659b45bc9b30..78a1c697c5076a99a752f9ea1bf7ec47556e5cf7 100644 (file)
@@ -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