summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-07-29 17:04:57 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-07-29 17:04:57 (GMT)
commita264384fe6de357680ca0cf02cd6024bbba0ba45 (patch)
treeea2c7c77a9c36cda0843e1628a4e0262d13c4c4f /Lib/test
parent2b16844326f9a88f7c5daf16abfb04cee70f02bc (diff)
parent10f0c50a0bc9237d640cb7beb216d63f9ec2b3eb (diff)
downloadcpython-a264384fe6de357680ca0cf02cd6024bbba0ba45.zip
cpython-a264384fe6de357680ca0cf02cd6024bbba0ba45.tar.gz
cpython-a264384fe6de357680ca0cf02cd6024bbba0ba45.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.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index ed8564c..5735350 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -802,6 +802,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"
@@ -999,7 +1013,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):
@@ -1260,7 +1274,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):
@@ -1650,7 +1664,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):