diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-29 17:02:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-07-29 17:02:46 (GMT) |
commit | 10f0c50a0bc9237d640cb7beb216d63f9ec2b3eb (patch) | |
tree | 397d4d87addaa7af9c5981d8835df62872f20796 /Lib/test | |
parent | 33f799725cb9ae21f0fed87eea4b13d7611ceeee (diff) | |
download | cpython-10f0c50a0bc9237d640cb7beb216d63f9ec2b3eb.zip cpython-10f0c50a0bc9237d640cb7beb216d63f9ec2b3eb.tar.gz cpython-10f0c50a0bc9237d640cb7beb216d63f9ec2b3eb.tar.bz2 |
Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_io.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 95ecd90..0c3e0b8 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -792,6 +792,20 @@ class CommonBufferedTests: buf.raw = x +class SizeofTest: + + @support.cpython_only + def test_sizeof(self): + bufsize1 = 4096 + bufsize2 = 8192 + rawio = self.MockRawIO() + bufio = self.tp(rawio, buffer_size=bufsize1) + size = sys.getsizeof(bufio) - bufsize1 + rawio = self.MockRawIO() + bufio = self.tp(rawio, buffer_size=bufsize2) + self.assertEqual(sys.getsizeof(bufio), size + bufsize2) + + class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): read_mode = "rb" @@ -983,7 +997,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): "failed for {}: {} != 0".format(n, rawio._extraneous_reads)) -class CBufferedReaderTest(BufferedReaderTest): +class CBufferedReaderTest(BufferedReaderTest, SizeofTest): tp = io.BufferedReader def test_constructor(self): @@ -1245,7 +1259,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests): self.tp(self.MockRawIO(), 8, 12) -class CBufferedWriterTest(BufferedWriterTest): +class CBufferedWriterTest(BufferedWriterTest, SizeofTest): tp = io.BufferedWriter def test_constructor(self): @@ -1636,7 +1650,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest): # You can't construct a BufferedRandom over a non-seekable stream. test_unseekable = None -class CBufferedRandomTest(BufferedRandomTest): +class CBufferedRandomTest(BufferedRandomTest, SizeofTest): tp = io.BufferedRandom def test_constructor(self): |