Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3ed2cb55
Commit
3ed2cb55
authored
Oct 16, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also add tests for TextIOWrapper.writelines() (issue #15744).
parent
131a4899
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
Lib/test/test_io.py
Lib/test/test_io.py
+22
-0
No files found.
Lib/test/test_io.py
View file @
3ed2cb55
...
...
@@ -2287,6 +2287,28 @@ class TextIOWrapperTest(unittest.TestCase):
reads
+=
c
self
.
assertEqual
(
reads
,
"A"
*
127
+
"
\
n
B"
)
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
):
txt
=
self
.
TextIOWrapper
(
self
.
BytesIO
(
self
.
testdata
),
encoding
=
"ascii"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment