Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
780145da
Kaydet (Commit)
780145da
authored
Şub 05, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #20498: Fixed io.StringIO tests for newline='\n'. Added new tests.
üst
54c1391b
1812bd44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
test_memoryio.py
Lib/test/test_memoryio.py
+36
-1
No files found.
Lib/test/test_memoryio.py
Dosyayı görüntüle @
780145da
...
...
@@ -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