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
1812bd44
Commit
1812bd44
authored
Feb 05, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20498: Fixed io.StringIO tests for newline='\n'. Added new tests.
parent
d33491ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
Lib/test/test_memoryio.py
Lib/test/test_memoryio.py
+36
-1
No files found.
Lib/test/test_memoryio.py
View file @
1812bd44
...
...
@@ -536,6 +536,17 @@ class TextIOTestMixin:
self
.
assertIsNone
(
memio
.
errors
)
self
.
assertFalse
(
memio
.
line_buffering
)
def
test_newline_default
(
self
):
memio
=
self
.
ioclass
(
"a
\
n
b
\
r
\
n
c
\
r
d"
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
n
"
,
"b
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
()
self
.
assertEqual
(
memio
.
write
(
"a
\
n
b
\
r
\
n
c
\
r
d"
),
8
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
n
"
,
"b
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
def
test_newline_none
(
self
):
# newline=None
memio
=
self
.
ioclass
(
"a
\
n
b
\
r
\
n
c
\
r
d"
,
newline
=
None
)
...
...
@@ -545,6 +556,8 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(
2
),
"
\
n
b"
)
self
.
assertEqual
(
memio
.
read
(
2
),
"
\
n
c"
)
self
.
assertEqual
(
memio
.
read
(
1
),
"
\
n
"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
n
c
\
n
d"
)
memio
=
self
.
ioclass
(
newline
=
None
)
self
.
assertEqual
(
2
,
memio
.
write
(
"a
\
n
"
))
self
.
assertEqual
(
3
,
memio
.
write
(
"b
\
r
\
n
"
))
...
...
@@ -552,6 +565,7 @@ class TextIOTestMixin:
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
read
(),
"a
\
n
b
\
n
c
\
n
d"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
n
c
\
n
d"
)
memio
=
self
.
ioclass
(
"a
\
r
\
n
b"
,
newline
=
None
)
self
.
assertEqual
(
memio
.
read
(
3
),
"a
\
n
b"
)
...
...
@@ -564,6 +578,7 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(
2
),
"
\
n
c"
)
self
.
assertEqual
(
memio
.
read
(
1
),
"
\
r
"
)
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
(
newline
=
""
)
self
.
assertEqual
(
2
,
memio
.
write
(
"a
\
n
"
))
self
.
assertEqual
(
2
,
memio
.
write
(
"b
\
r
"
))
...
...
@@ -571,11 +586,19 @@ class TextIOTestMixin:
self
.
assertEqual
(
2
,
memio
.
write
(
"
\
r
d"
))
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
n
"
,
"b
\
r
\
n
"
,
"c
\
r
"
,
"d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
def
test_newline_lf
(
self
):
# newline="\n"
memio
=
self
.
ioclass
(
"a
\
n
b
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
(
"a
\
n
b
\
r
\
n
c
\
r
d"
,
newline
=
"
\
n
"
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
n
"
,
"b
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
(
newline
=
"
\
n
"
)
self
.
assertEqual
(
memio
.
write
(
"a
\
n
b
\
r
\
n
c
\
r
d"
),
8
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
n
"
,
"b
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
n
b
\
r
\
n
c
\
r
d"
)
def
test_newline_cr
(
self
):
# newline="\r"
...
...
@@ -583,6 +606,12 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
read
(),
"a
\
r
b
\
r
\
r
c
\
r
d"
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
r
"
,
"b
\
r
"
,
"
\
r
"
,
"c
\
r
"
,
"d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
b
\
r
\
r
c
\
r
d"
)
memio
=
self
.
ioclass
(
newline
=
"
\
r
"
)
self
.
assertEqual
(
memio
.
write
(
"a
\
n
b
\
r
\
n
c
\
r
d"
),
8
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
r
"
,
"b
\
r
"
,
"
\
r
"
,
"c
\
r
"
,
"d"
])
memio
.
seek
(
0
)
self
.
assertEqual
(
memio
.
readlines
(),
[
"a
\
r
"
,
"b
\
r
"
,
"
\
r
"
,
"c
\
r
"
,
"d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
b
\
r
\
r
c
\
r
d"
)
...
...
@@ -597,6 +626,12 @@ class TextIOTestMixin:
self
.
assertEqual
(
memio
.
readlines
(),
[
"a
\
r
\
n
"
,
"b
\
r
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
\
n
b
\
r
\
r
\
n
c
\
r
d"
)
memio
=
self
.
ioclass
(
newline
=
"
\
r
\
n
"
)
self
.
assertEqual
(
memio
.
write
(
"a
\
n
b
\
r
\
n
c
\
r
d"
),
8
)
memio
.
seek
(
0
)
self
.
assertEqual
(
list
(
memio
),
[
"a
\
r
\
n
"
,
"b
\
r
\
r
\
n
"
,
"c
\
r
d"
])
self
.
assertEqual
(
memio
.
getvalue
(),
"a
\
r
\
n
b
\
r
\
r
\
n
c
\
r
d"
)
def
test_issue5265
(
self
):
# StringIO can duplicate newlines in universal newlines mode
memio
=
self
.
ioclass
(
"a
\
r
\
n
b
\
r
\
n
"
,
newline
=
None
)
...
...
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