]> granicus.if.org Git - python/commitdiff
#11488: Add tests for writelines method of SpooledTemporaryFile.
authorR David Murray <rdmurray@bitdance.com>
Mon, 14 Mar 2011 13:55:46 +0000 (09:55 -0400)
committerR David Murray <rdmurray@bitdance.com>
Mon, 14 Mar 2011 13:55:46 +0000 (09:55 -0400)
Patch by Evan Dandrea.

Lib/test/test_tempfile.py
Misc/ACKS

index f48ab88f97e35e2853ce62d6bb367a525d50c53e..f72b0b19c49d94d5feee3fd0a9c9902892c5cb86 100644 (file)
@@ -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
index 9d4be3fc08640a18f3589611a5be86cf662a9c93..a18dd18efebc5f008643ed742e1a52d438a8f8c9 100644 (file)
--- 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