Skip to content

Commit 33edb99

Browse files
committed
Add a test case for writing data that is over 2GB
1 parent ea65e69 commit 33edb99

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_csv.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,20 @@ def test_ordered_dict_reader(self):
15601560
OrderedDict([('fname', 'John'), ('lname', 'Cleese')]),
15611561
])
15621562

1563+
class HugeDataTest(unittest.TestCase):
1564+
def test_write_huge_data(self):
1565+
bad_size = 2 * 1024 * 1024 * 1024 + 1 # Just over 2GB
1566+
val = 'x' * bad_size
1567+
with TemporaryFile("w", encoding="utf-8", newline='') as fileobj:
1568+
csv_writer = csv.writer(fileobj, delimiter=',',
1569+
quotechar='|',
1570+
quoting=csv.QUOTE_MINIMAL)
1571+
csv_writer.writerow([val])
1572+
fileobj.seek(0)
1573+
reader = csv.reader(fileobj)
1574+
row = next(reader)
1575+
self.assertEqual(len(row), 1)
1576+
15631577

15641578
class MiscTestCase(unittest.TestCase):
15651579
def test__all__(self):

0 commit comments

Comments
 (0)