From a1b49013f477e83bd1652f651f35c2e4eea54b67 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 31 Mar 2009 23:11:32 +0000 Subject: fix TextIOWrapper.read() when the buffer is not readable #5628 --- Lib/test/test_io.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/test/test_io.py') diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index d5be405ef51..53017f352a8 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1754,6 +1754,13 @@ class TextIOWrapperTest(unittest.TestCase): self.assertEquals(f.read(), data * 2) self.assertEquals(buf.getvalue(), (data * 2).encode(encoding)) + def test_unreadable(self): + class UnReadable(self.BytesIO): + def readable(self): + return False + txt = self.TextIOWrapper(UnReadable()) + self.assertRaises(IOError, txt.read) + def test_read_one_by_one(self): txt = self.TextIOWrapper(self.BytesIO(b"AA\r\nBB")) reads = "" -- cgit v1.2.3