Skip to content

Commit 751c78f

Browse files
committed
Ensure that SpooledTemporaryFile rolls over in writelines
1 parent 0dc71e2 commit 751c78f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_tempfile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,18 @@ def test_writelines(self):
12881288
buf = f.read()
12891289
self.assertEqual(buf, b'xyz')
12901290

1291+
def test_writelines_rollover(self):
1292+
# Verify writelines rolls over before exhausting the iterator
1293+
f = self.do_create(max_size=2)
1294+
1295+
def it():
1296+
yield b'xy'
1297+
self.assertFalse(f._rolled)
1298+
yield b'z'
1299+
self.assertTrue(f._rolled)
1300+
1301+
f.writelines(it())
1302+
12911303
def test_writelines_sequential(self):
12921304
# A SpooledTemporaryFile should hold exactly max_size bytes, and roll
12931305
# over afterward

0 commit comments

Comments
 (0)