summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sax.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-05-18 17:11:30 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-05-18 17:11:30 (GMT)
commit90a24270f8a76fffbce0a09fb0e879d9ac60cabe (patch)
treeabf5c04c0ca2c3fa52b494d77407015e0ac1cc49 /Lib/test/test_sax.py
parent636f93c63ba286249c1207e3a903f8429efb2041 (diff)
downloadcpython-90a24270f8a76fffbce0a09fb0e879d9ac60cabe.zip
cpython-90a24270f8a76fffbce0a09fb0e879d9ac60cabe.tar.gz
cpython-90a24270f8a76fffbce0a09fb0e879d9ac60cabe.tar.bz2
Close file before reopening to keep Windows happy in test_sax.
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r--Lib/test/test_sax.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 78a1c69..cfa18f7 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -578,13 +578,14 @@ class StreamReaderWriterXmlgenTest(XmlgenTest, unittest.TestCase):
writer.close()
support.unlink(self.fname)
self.addCleanup(cleanup)
- writer.getvalue = self.getvalue
+ def getvalue():
+ # Windows will not let use reopen without first closing
+ writer.close()
+ with open(writer.name, 'rb') as f:
+ return f.read()
+ writer.getvalue = getvalue
return writer
- def getvalue(self):
- with open(self.fname, 'rb') as f:
- return f.read()
-
def xml(self, doc, encoding='iso-8859-1'):
return ('<?xml version="1.0" encoding="%s"?>\n%s' %
(encoding, doc)).encode('ascii', 'xmlcharrefreplace')