summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
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):