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
c0417357
Kaydet (Commit)
c0417357
authored
Mar 11, 2013
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#11963: merge with 3.3.
üst
b65e5799
3300878d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
test_subprocess.py
Lib/test/test_subprocess.py
+36
-12
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
c0417357
...
@@ -184,16 +184,27 @@ class ProcessTestCase(BaseTestCase):
...
@@ -184,16 +184,27 @@ class ProcessTestCase(BaseTestCase):
self
.
assertEqual
(
p
.
stdin
,
None
)
self
.
assertEqual
(
p
.
stdin
,
None
)
def
test_stdout_none
(
self
):
def
test_stdout_none
(
self
):
# .stdout is None when not redirected
# .stdout is None when not redirected, and the child's stdout will
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
# be inherited from the parent. In order to test this we run a
'print(" this bit of output is from a '
# subprocess in a subprocess:
'test of stdout in a different '
# this_test
'process ...")'
],
# \-- subprocess created by this test (parent)
stdin
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
# \-- subprocess created by the parent subprocess (child)
self
.
addCleanup
(
p
.
stdin
.
close
)
# The parent doesn't specify stdout, so the child will use the
# parent's stdout. This test checks that the message printed by the
# child goes to the parent stdout. The parent also checks that the
# child's stdout is None. See #11963.
code
=
(
'import sys; from subprocess import Popen, PIPE;'
'p = Popen([sys.executable, "-c", "print(
\'
test_stdout_none
\'
)"],'
' stdin=PIPE, stderr=PIPE);'
'p.wait(); assert p.stdout is None;'
)
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
code
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
self
.
addCleanup
(
p
.
stdout
.
close
)
self
.
addCleanup
(
p
.
stderr
.
close
)
self
.
addCleanup
(
p
.
stderr
.
close
)
p
.
wait
()
out
,
err
=
p
.
communicate
()
self
.
assertEqual
(
p
.
stdout
,
None
)
self
.
assertEqual
(
p
.
returncode
,
0
,
err
)
self
.
assertEqual
(
out
.
rstrip
(),
b
'test_stdout_none'
)
def
test_stderr_none
(
self
):
def
test_stderr_none
(
self
):
# .stderr is None when not redirected
# .stderr is None when not redirected
...
@@ -471,9 +482,22 @@ class ProcessTestCase(BaseTestCase):
...
@@ -471,9 +482,22 @@ class ProcessTestCase(BaseTestCase):
def
test_stdout_filedes_of_stdout
(
self
):
def
test_stdout_filedes_of_stdout
(
self
):
# stdout is set to 1 (#1531862).
# stdout is set to 1 (#1531862).
cmd
=
r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), b'.\n'))"
# To avoid printing the text on stdout, we do something similar to
rc
=
subprocess
.
call
([
sys
.
executable
,
"-c"
,
cmd
],
stdout
=
1
)
# test_stdout_none (see above). The parent subprocess calls the child
self
.
assertEqual
(
rc
,
2
)
# subprocess passing stdout=1, and this test uses stdout=PIPE in
# order to capture and check the output of the parent. See #11963.
code
=
(
'import sys, subprocess; '
'rc = subprocess.call([sys.executable, "-c", '
' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), '
'b
\'
test with stdout=1
\'
))"], stdout=1); '
'assert rc == 18'
)
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
code
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
self
.
addCleanup
(
p
.
stdout
.
close
)
self
.
addCleanup
(
p
.
stderr
.
close
)
out
,
err
=
p
.
communicate
()
self
.
assertEqual
(
p
.
returncode
,
0
,
err
)
self
.
assertEqual
(
out
.
rstrip
(),
b
'test with stdout=1'
)
def
test_stdout_devnull
(
self
):
def
test_stdout_devnull
(
self
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
...
...
Misc/NEWS
Dosyayı görüntüle @
c0417357
...
@@ -905,6 +905,8 @@ Extension Modules
...
@@ -905,6 +905,8 @@ Extension Modules
Tests
Tests
-----
-----
-
Issue
#
11963
:
remove
human
verification
from
test_parser
and
test_subprocess
.
-
Issue
#
11732
:
add
a
new
suppress_crash_popup
()
context
manager
to
test
.
support
-
Issue
#
11732
:
add
a
new
suppress_crash_popup
()
context
manager
to
test
.
support
that
disables
crash
popups
on
Windows
and
use
it
in
test_faulthandler
and
that
disables
crash
popups
on
Windows
and
use
it
in
test_faulthandler
and
test_capi
.
test_capi
.
...
...
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