summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryio.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2009-07-22 03:07:33 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2009-07-22 03:07:33 (GMT)
commitd2bb18b28165ccc6e4678e8046abe6ea7c9677b3 (patch)
treeedacc105f2321cdabb57bced5730c7e9d2610dfe /Lib/test/test_memoryio.py
parente671fd206b1fe31fdad7a9ec570fffe390ec56ee (diff)
downloadcpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.zip
cpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.tar.gz
cpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.tar.bz2
Issue #6241: Better type checking for the arguments of io.StringIO.
Diffstat (limited to 'Lib/test/test_memoryio.py')
-rw-r--r--Lib/test/test_memoryio.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index 0b25283..670dab9 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -140,6 +140,7 @@ class MemoryTestMixin:
self.assertEqual(memio.getvalue(), buf * 2)
memio.__init__(buf)
self.assertEqual(memio.getvalue(), buf)
+ self.assertRaises(TypeError, memio.__init__, [])
def test_read(self):
buf = self.buftype("1234567890")
@@ -530,6 +531,13 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
memio = self.ioclass("a\r\nb\r\n", newline=None)
self.assertEqual(memio.read(5), "a\nb\n")
+ def test_newline_argument(self):
+ self.assertRaises(TypeError, self.ioclass, newline=b"\n")
+ self.assertRaises(ValueError, self.ioclass, newline="error")
+ # These should not raise an error
+ for newline in (None, "", "\n", "\r", "\r\n"):
+ self.ioclass(newline=newline)
+
class CBytesIOTest(PyBytesIOTest):
ioclass = io.BytesIO