Skip to content

Commit b44e184

Browse files
committed
Port #11488 patch from 3.1 (changeset f816841bab03)
1 parent a3ed3f0 commit b44e184

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Lib/test/test_tempfile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,23 @@ def test_write_sequential(self):
689689
f.write('x')
690690
self.assertTrue(f._rolled)
691691

692+
def test_writelines(self):
693+
# Verify writelines with a SpooledTemporaryFile
694+
f = self.do_create()
695+
f.writelines((b'x', b'y', b'z'))
696+
f.seek(0)
697+
buf = f.read()
698+
self.assertEqual(buf, b'xyz')
699+
700+
def test_writelines_sequential(self):
701+
# A SpooledTemporaryFile should hold exactly max_size bytes, and roll
702+
# over afterward
703+
f = self.do_create(max_size=35)
704+
f.writelines((b'x' * 20, b'x' * 10, b'x' * 5))
705+
self.assertFalse(f._rolled)
706+
f.write(b'x')
707+
self.assertTrue(f._rolled)
708+
692709
def test_sparse(self):
693710
# A SpooledTemporaryFile that is written late in the file will extend
694711
# when that occurs

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Brian Curtin
182182
Lisandro Dalcin
183183
Andrew Dalke
184184
Lars Damerow
185+
Evan Dandrea
185186
Eric Daniel
186187
Scott David Daniels
187188
Ben Darnell

0 commit comments

Comments
 (0)