(self)
| 4163 | del t._CHUNK_SIZE |
| 4164 | |
| 4165 | def test_internal_buffer_size(self): |
| 4166 | # bpo-43260: TextIOWrapper's internal buffer should not store |
| 4167 | # data larger than chunk size. |
| 4168 | chunk_size = 8192 # default chunk size, updated later |
| 4169 | |
| 4170 | class MockIO(self.MockRawIO): |
| 4171 | def write(self, data): |
| 4172 | if len(data) > chunk_size: |
| 4173 | raise RuntimeError |
| 4174 | return super().write(data) |
| 4175 | |
| 4176 | buf = MockIO() |
| 4177 | t = self.TextIOWrapper(buf, encoding="ascii") |
| 4178 | chunk_size = t._CHUNK_SIZE |
| 4179 | t.write("abc") |
| 4180 | t.write("def") |
| 4181 | # default chunk size is 8192 bytes so t don't write data to buf. |
| 4182 | self.assertEqual([], buf._write_stack) |
| 4183 | |
| 4184 | with self.assertRaises(RuntimeError): |
| 4185 | t.write("x"*(chunk_size+1)) |
| 4186 | |
| 4187 | self.assertEqual([b"abcdef"], buf._write_stack) |
| 4188 | t.write("ghi") |
| 4189 | t.write("x"*chunk_size) |
| 4190 | self.assertEqual([b"abcdef", b"ghi", b"x"*chunk_size], buf._write_stack) |
| 4191 | |
| 4192 | def test_issue119506(self): |
| 4193 | chunk_size = 8192 |
nothing calls this directly
no test coverage detected