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
66fb5ef3
Kaydet (Commit)
66fb5ef3
authored
Eki 02, 2017
tarafından
Miss Islington (bot)
Kaydeden (comit)
Victor Stinner
Eki 02, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[3.6] bpo-31158: Fix nondeterministic read in test_pty (GH-3808) (GH-3852)
(cherry picked from commit
e6f62f69
)
üst
c0418160
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
test_pty.py
Lib/test/test_pty.py
+19
-2
No files found.
Lib/test/test_pty.py
Dosyayı görüntüle @
66fb5ef3
...
...
@@ -10,6 +10,7 @@ import sys
import
select
import
signal
import
socket
import
io
# readline
import
unittest
TEST_STRING_1
=
b
"I wish to buy a fish license.
\n
"
...
...
@@ -23,6 +24,16 @@ else:
pass
# Note that os.read() is nondeterministic so we need to be very careful
# to make the test suite deterministic. A normal call to os.read() may
# give us less than expected.
#
# Beware, on my Linux system, if I put 'foo\n' into a terminal fd, I get
# back 'foo\r\n' at the other end. The behavior depends on the termios
# setting. The newline translation may be OS-specific. To make the
# test suite deterministic and OS-independent, the functions _readline
# and normalize_output can be used.
def
normalize_output
(
data
):
# Some operating systems do conversions on newline. We could possibly
# fix that by doing the appropriate termios.tcsetattr()s. I couldn't
...
...
@@ -44,6 +55,12 @@ def normalize_output(data):
return
data
def
_readline
(
fd
):
"""Read one line. May block forever if no newline is read."""
reader
=
io
.
FileIO
(
fd
,
mode
=
'rb'
,
closefd
=
False
)
return
reader
.
readline
()
# Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
# because pty code is not too portable.
...
...
@@ -98,14 +115,14 @@ class PtyTest(unittest.TestCase):
debug
(
"Writing to slave_fd"
)
os
.
write
(
slave_fd
,
TEST_STRING_1
)
s1
=
os
.
read
(
master_fd
,
1024
)
s1
=
_readline
(
master_fd
)
self
.
assertEqual
(
b
'I wish to buy a fish license.
\n
'
,
normalize_output
(
s1
))
debug
(
"Writing chunked output"
)
os
.
write
(
slave_fd
,
TEST_STRING_2
[:
5
])
os
.
write
(
slave_fd
,
TEST_STRING_2
[
5
:])
s2
=
os
.
read
(
master_fd
,
1024
)
s2
=
_readline
(
master_fd
)
self
.
assertEqual
(
b
'For my pet fish, Eric.
\n
'
,
normalize_output
(
s2
))
os
.
close
(
slave_fd
)
...
...
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