diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-10-31 18:23:23 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-10-31 18:23:23 (GMT) |
commit | d5df36d378054b0c9bcd5ac0f26e2c3786ffd30c (patch) | |
tree | 4ce3e4902fe5d1a3b4b3c1c99a8f97aabc6f38ed /Lib/test/test_sax.py | |
parent | a807137c3916ecd098cedc5a3d725310d43a88d9 (diff) | |
download | cpython-d5df36d378054b0c9bcd5ac0f26e2c3786ffd30c.zip cpython-d5df36d378054b0c9bcd5ac0f26e2c3786ffd30c.tar.gz cpython-d5df36d378054b0c9bcd5ac0f26e2c3786ffd30c.tar.bz2 |
fix resource warnings in test_sax #10269
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r-- | Lib/test/test_sax.py | 11 |
1 files 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) |