Back to index

python3.2  3.2.2
Public Member Functions
test.test_memoryio.BytesIOMixin Class Reference
Inheritance diagram for test.test_memoryio.BytesIOMixin:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_getbuffer

Detailed Description

Definition at line 387 of file test_memoryio.py.


Member Function Documentation

Definition at line 389 of file test_memoryio.py.

00389 
00390     def test_getbuffer(self):
00391         memio = self.ioclass(b"1234567890")
00392         buf = memio.getbuffer()
00393         self.assertEqual(bytes(buf), b"1234567890")
00394         memio.seek(5)
00395         buf = memio.getbuffer()
00396         self.assertEqual(bytes(buf), b"1234567890")
00397         # Trying to change the size of the BytesIO while a buffer is exported
00398         # raises a BufferError.
00399         self.assertRaises(BufferError, memio.write, b'x' * 100)
00400         self.assertRaises(BufferError, memio.truncate)
00401         # Mutating the buffer updates the BytesIO
00402         buf[3:6] = b"abc"
00403         self.assertEqual(bytes(buf), b"123abc7890")
00404         self.assertEqual(memio.getvalue(), b"123abc7890")
00405         # After the buffer gets released, we can resize the BytesIO again
00406         del buf
00407         support.gc_collect()
00408         memio.truncate()
00409 

Here is the call graph for this function:


The documentation for this class was generated from the following file: