mirror of https://github.com/python/cpython.git
Also add tests for TextIOWrapper.writelines() (issue #15744).
This commit is contained in:
parent
78e761eafe
commit
eadca1defa
|
@ -2233,6 +2233,28 @@ def test_read_by_chunk(self):
|
||||||
reads += c
|
reads += c
|
||||||
self.assertEqual(reads, "A"*127+"\nB")
|
self.assertEqual(reads, "A"*127+"\nB")
|
||||||
|
|
||||||
|
def test_writelines(self):
|
||||||
|
l = ['ab', 'cd', 'ef']
|
||||||
|
buf = self.BytesIO()
|
||||||
|
txt = self.TextIOWrapper(buf)
|
||||||
|
txt.writelines(l)
|
||||||
|
txt.flush()
|
||||||
|
self.assertEqual(buf.getvalue(), b'abcdef')
|
||||||
|
|
||||||
|
def test_writelines_userlist(self):
|
||||||
|
l = UserList(['ab', 'cd', 'ef'])
|
||||||
|
buf = self.BytesIO()
|
||||||
|
txt = self.TextIOWrapper(buf)
|
||||||
|
txt.writelines(l)
|
||||||
|
txt.flush()
|
||||||
|
self.assertEqual(buf.getvalue(), b'abcdef')
|
||||||
|
|
||||||
|
def test_writelines_error(self):
|
||||||
|
txt = self.TextIOWrapper(self.BytesIO())
|
||||||
|
self.assertRaises(TypeError, txt.writelines, [1, 2, 3])
|
||||||
|
self.assertRaises(TypeError, txt.writelines, None)
|
||||||
|
self.assertRaises(TypeError, txt.writelines, b'abc')
|
||||||
|
|
||||||
def test_issue1395_1(self):
|
def test_issue1395_1(self):
|
||||||
txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
|
txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue