summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-12-21 21:20:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-12-21 21:20:59 (GMT)
commit7f8f41808b82b5e4812bc2e2d484a6fc8f02295c (patch)
treed04b34c9a8897cfdc8fce780f002b15b97502e12 /Lib/test/test_io.py
parentcfee0e83ebd8826dbdc89035d15e1ea90a577fa2 (diff)
downloadcpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.zip
cpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.tar.gz
cpython-7f8f41808b82b5e4812bc2e2d484a6fc8f02295c.tar.bz2
Issue #10750: The `raw` attribute of buffered IO objects is now read-only.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index a17fcee..ee4e42f 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -730,6 +730,13 @@ class CommonBufferedTests:
self.assertRaises(self.UnsupportedOperation, bufio.tell)
self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+ def test_readonly_attributes(self):
+ raw = self.MockRawIO()
+ buf = self.tp(raw)
+ x = self.MockRawIO()
+ with self.assertRaises(AttributeError):
+ buf.raw = x
+
class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
read_mode = "rb"
@@ -2245,6 +2252,12 @@ class TextIOWrapperTest(unittest.TestCase):
self.assertRaises(self.UnsupportedOperation, txt.tell)
self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
+ def test_readonly_attributes(self):
+ txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
+ buf = self.BytesIO(self.testdata)
+ with self.assertRaises(AttributeError):
+ txt.buffer = buf
+
class CTextIOWrapperTest(TextIOWrapperTest):
def test_initialization(self):