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
9b4ee12e
Kaydet (Commit)
9b4ee12e
authored
Nis 03, 2010
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cross platform unittest.TestResult newline handling when buffering stdout / stderr.
üst
1c7c11ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
result.py
Lib/unittest/result.py
+10
-11
test_result.py
Lib/unittest/test/test_result.py
+5
-4
No files found.
Lib/unittest/result.py
Dosyayı görüntüle @
9b4ee12e
...
...
@@ -19,9 +19,8 @@ def failfast(method):
return
method
(
self
,
*
args
,
**
kw
)
return
inner
NEWLINE
=
os
.
linesep
STDOUT_LINE
=
'
%
sStdout:
%
s
%%
s'
%
(
NEWLINE
,
NEWLINE
)
STDERR_LINE
=
'
%
sStderr:
%
s
%%
s'
%
(
NEWLINE
,
NEWLINE
)
STDOUT_LINE
=
'
\n
Stdout:
\n
%
s'
STDERR_LINE
=
'
\n
Stderr:
\n
%
s'
class
TestResult
(
object
):
...
...
@@ -77,12 +76,12 @@ class TestResult(object):
output
=
sys
.
stdout
.
getvalue
()
error
=
sys
.
stderr
.
getvalue
()
if
output
:
if
not
output
.
endswith
(
NEWLINE
):
output
+=
NEWLINE
if
not
output
.
endswith
(
'
\n
'
):
output
+=
'
\n
'
self
.
_original_stdout
.
write
(
STDOUT_LINE
%
output
)
if
error
:
if
not
error
.
endswith
(
NEWLINE
):
error
+=
NEWLINE
if
not
error
.
endswith
(
'
\n
'
):
error
+=
'
\n
'
self
.
_original_stderr
.
write
(
STDERR_LINE
%
error
)
sys
.
stdout
=
self
.
_original_stdout
...
...
@@ -158,12 +157,12 @@ class TestResult(object):
output
=
sys
.
stdout
.
getvalue
()
error
=
sys
.
stderr
.
getvalue
()
if
output
:
if
not
output
.
endswith
(
NEWLINE
):
output
+=
NEWLINE
if
not
output
.
endswith
(
'
\n
'
):
output
+=
'
\n
'
msgLines
.
append
(
STDOUT_LINE
%
output
)
if
error
:
if
not
error
.
endswith
(
NEWLINE
):
error
+=
NEWLINE
if
not
error
.
endswith
(
'
\n
'
):
error
+=
'
\n
'
msgLines
.
append
(
STDERR_LINE
%
error
)
return
''
.
join
(
msgLines
)
...
...
Lib/unittest/test/test_result.py
Dosyayı görüntüle @
9b4ee12e
import
os
import
sys
import
textwrap
from
cStringIO
import
StringIO
,
OutputType
...
...
@@ -413,8 +414,8 @@ class TestOutputBuffering(unittest.TestCase):
print
'foo'
print
>>
sys
.
stderr
,
'bar'
self
.
assertEqual
(
out_stream
.
getvalue
(),
'foo
\n
'
)
self
.
assertEqual
(
err_stream
.
getvalue
(),
'bar
\n
'
)
self
.
assertEqual
(
out_stream
.
getvalue
(),
'foo
%
s'
%
os
.
linesep
)
self
.
assertEqual
(
err_stream
.
getvalue
(),
'bar
%
s'
%
os
.
linesep
)
self
.
assertEqual
(
result
.
_original_stdout
.
getvalue
(),
''
)
self
.
assertEqual
(
result
.
_original_stderr
.
getvalue
(),
''
)
...
...
@@ -467,13 +468,13 @@ class TestOutputBuffering(unittest.TestCase):
expectedOutMessage
=
textwrap
.
dedent
(
"""
Stdout:
foo
"""
)
"""
)
.
replace
(
'
\n
'
,
os
.
linesep
)
expectedErrMessage
=
''
if
include_error
:
expectedErrMessage
=
textwrap
.
dedent
(
"""
Stderr:
bar
"""
)
"""
)
.
replace
(
'
\n
'
,
os
.
linesep
)
expectedFullMessage
=
'None
\n
%
s
%
s'
%
(
expectedOutMessage
,
expectedErrMessage
)
self
.
assertIs
(
test
,
self
)
...
...
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