From d5df36d378054b0c9bcd5ac0f26e2c3786ffd30c Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 31 Oct 2010 18:23:23 +0000 Subject: fix resource warnings in test_sax #10269 --- Lib/test/test_sax.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 6a20513..dff2131 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -463,7 +463,8 @@ class XMLFilterBaseTest(unittest.TestCase): # # =========================================================================== -xml_test_out = open(TEST_XMLFILE_OUT).read() +with open(TEST_XMLFILE_OUT) as f: + xml_test_out = f.read() class ExpatReaderTest(XmlTestBase): @@ -475,7 +476,8 @@ class ExpatReaderTest(XmlTestBase): xmlgen = XMLGenerator(result) parser.setContentHandler(xmlgen) - parser.parse(open(TEST_XMLFILE)) + with open(TEST_XMLFILE) as f: + parser.parse(f) self.assertEquals(result.getvalue(), xml_test_out) @@ -625,8 +627,9 @@ class ExpatReaderTest(XmlTestBase): parser.setContentHandler(xmlgen) inpsrc = InputSource() - inpsrc.setByteStream(open(TEST_XMLFILE)) - parser.parse(inpsrc) + with open(TEST_XMLFILE) as f: + inpsrc.setByteStream(f) + parser.parse(inpsrc) self.assertEquals(result.getvalue(), xml_test_out) -- cgit v0.12