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
95aaeee5
Kaydet (Commit)
95aaeee5
authored
Ock 03, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a subprocess test of remapping standard file descriptors (issue #1187).
üst
4d419689
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
test_subprocess.py
Lib/test/test_subprocess.py
+48
-0
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
95aaeee5
...
...
@@ -955,6 +955,54 @@ class POSIXProcessTestCase(BaseTestCase):
# all standard fds closed.
self
.
check_close_std_fds
([
0
,
1
,
2
])
def
test_remapping_std_fds
(
self
):
# open up some temporary files
temps
=
[
mkstemp
()
for
i
in
range
(
3
)]
try
:
temp_fds
=
[
fd
for
fd
,
fname
in
temps
]
# unlink the files -- we won't need to reopen them
for
fd
,
fname
in
temps
:
os
.
unlink
(
fname
)
# write some data to what will become stdin, and rewind
os
.
write
(
temp_fds
[
1
],
b
"STDIN"
)
os
.
lseek
(
temp_fds
[
1
],
0
,
0
)
# move the standard file descriptors out of the way
saved_fds
=
[
os
.
dup
(
fd
)
for
fd
in
range
(
3
)]
try
:
# duplicate the file objects over the standard fd's
for
fd
,
temp_fd
in
enumerate
(
temp_fds
):
os
.
dup2
(
temp_fd
,
fd
)
# now use those files in the "wrong" order, so that subprocess
# has to rearrange them in the child
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import sys; got = sys.stdin.read();'
'sys.stdout.write("got
%
s"
%
got); sys.stderr.write("err")'
],
stdin
=
temp_fds
[
1
],
stdout
=
temp_fds
[
2
],
stderr
=
temp_fds
[
0
])
p
.
wait
()
finally
:
# restore the original fd's underneath sys.stdin, etc.
for
std
,
saved
in
enumerate
(
saved_fds
):
os
.
dup2
(
saved
,
std
)
os
.
close
(
saved
)
for
fd
in
temp_fds
:
os
.
lseek
(
fd
,
0
,
0
)
out
=
os
.
read
(
temp_fds
[
2
],
1024
)
err
=
support
.
strip_python_stderr
(
os
.
read
(
temp_fds
[
0
],
1024
))
self
.
assertEqual
(
out
,
b
"got STDIN"
)
self
.
assertEqual
(
err
,
b
"err"
)
finally
:
for
fd
in
temp_fds
:
os
.
close
(
fd
)
def
test_surrogates_error_message
(
self
):
def
prepare
():
raise
ValueError
(
"surrogate:
\uDCff
"
)
...
...
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