summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-14 13:55:46 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-14 13:55:46 (GMT)
commitd89ee79d19e156e874b7a292b705d167b7fe56ab (patch)
tree74ccabaad23f40f3f9abb220a9c63cf22e65b0e9
parent8fea2e6a502b9fb13905e5657a06f14c1afd0c24 (diff)
downloadcpython-d89ee79d19e156e874b7a292b705d167b7fe56ab.zip
cpython-d89ee79d19e156e874b7a292b705d167b7fe56ab.tar.gz
cpython-d89ee79d19e156e874b7a292b705d167b7fe56ab.tar.bz2
#11488: Add tests for writelines method of SpooledTemporaryFile.
Patch by Evan Dandrea.
-rw-r--r--Lib/test/test_tempfile.py17
-rw-r--r--Misc/ACKS1
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index f48ab88..f72b0b1 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -697,6 +697,23 @@ class test_SpooledTemporaryFile(TC):
f.write(b'x')
self.assertTrue(f._rolled)
+ def test_writelines(self):
+ # Verify writelines with a SpooledTemporaryFile
+ f = self.do_create()
+ f.writelines((b'x', b'y', b'z'))
+ f.seek(0)
+ buf = f.read()
+ self.assertEqual(buf, b'xyz')
+
+ def test_writelines_sequential(self):
+ # A SpooledTemporaryFile should hold exactly max_size bytes, and roll
+ # over afterward
+ f = self.do_create(max_size=35)
+ f.writelines((b'x' * 20, b'x' * 10, b'x' * 5))
+ self.assertFalse(f._rolled)
+ f.write(b'x')
+ self.assertTrue(f._rolled)
+
def test_sparse(self):
# A SpooledTemporaryFile that is written late in the file will extend
# when that occurs
diff --git a/Misc/ACKS b/Misc/ACKS
index 9d4be3f..a18dd18 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -176,6 +176,7 @@ Tom Culliton
Lisandro Dalcin
Andrew Dalke
Lars Damerow
+Evan Dandrea
Eric Daniel
Scott David Daniels
Ben Darnell