diff options
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 042879dce7..1daad449f4 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -701,6 +701,13 @@ class CommonBufferedTests: b.close() self.assertRaises(ValueError, b.flush) + def test_readonly_attributes(self): + raw = self.MockRawIO() + buf = self.tp(raw) + x = self.MockRawIO() + with self.assertRaises((AttributeError, TypeError)): + buf.raw = x + class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): read_mode = "rb" @@ -2211,6 +2218,12 @@ class TextIOWrapperTest(unittest.TestCase): txt.close() self.assertRaises(ValueError, txt.flush) + def test_readonly_attributes(self): + txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii") + buf = self.BytesIO(self.testdata) + with self.assertRaises((AttributeError, TypeError)): + txt.buffer = buf + class CTextIOWrapperTest(TextIOWrapperTest): def test_initialization(self): |