Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Jun 1, 2024
1 parent 483975c commit 01327f7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4020,17 +4020,23 @@ def test_issue119506(self):
chunk_size = 8192

class MockIO(self.MockRawIO):
written = False
def write(self, data):
t.write("efg")
if not self.written:
self.written = True
t.write("middle")
return super().write(data)

buf = MockIO()
t = self.TextIOWrapper(buf)
t.write("a" * (chunk_size - 1))
t.write("bcd")
t.write("abc")
t.write("def")
# writing data which size >= chunk_size cause flushing buffer before write.
t.write("g" * chunk_size)
t.flush()

self.assertEqual([b"a" * (chunk_size - 1), b"efgbcd"], buf._write_stack)
self.assertEqual([b"abcdef", b"middle", b"g"*chunk_size],
buf._write_stack)


class PyTextIOWrapperTest(TextIOWrapperTest):
Expand Down

0 comments on commit 01327f7

Please sign in to comment.