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
f047ba83
Kaydet (Commit)
f047ba83
authored
Kas 11, 2012
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor test_preexec_errpipe to not create an uncollectable reference cycle.
üst
99f9b8df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
test_subprocess.py
Lib/test/test_subprocess.py
+22
-22
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
f047ba83
...
@@ -751,28 +751,22 @@ class POSIXProcessTestCase(BaseTestCase):
...
@@ -751,28 +751,22 @@ class POSIXProcessTestCase(BaseTestCase):
self
.
addCleanup
(
p
.
stdout
.
close
)
self
.
addCleanup
(
p
.
stdout
.
close
)
self
.
assertEqual
(
p
.
stdout
.
read
(),
"apple"
)
self
.
assertEqual
(
p
.
stdout
.
read
(),
"apple"
)
@unittest.skipIf
(
not
os
.
path
.
exists
(
"/dev/zero"
),
"/dev/zero required."
)
class
_TestExecuteChildPopen
(
subprocess
.
Popen
):
def
test_preexec_errpipe_does_not_double_close_pipes
(
self
):
"""Used to test behavior at the end of _execute_child."""
"""Issue16140: Don't double close pipes on preexec error."""
def
__init__
(
self
,
testcase
,
*
args
,
**
kwargs
):
class
SafeConstructorPopen
(
subprocess
.
Popen
):
# Do nothing so we can modify the instance for testing.
def
__init__
(
self
):
self
.
_testcase
=
testcase
pass
# Do nothing so we can modify the instance for testing.
subprocess
.
Popen
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
RealPopen
(
self
,
*
args
,
**
kwargs
):
subprocess
.
Popen
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
_execute_child
(
def
raise_it
():
self
,
args
,
executable
,
preexec_fn
,
close_fds
,
cwd
,
env
,
raise
RuntimeError
(
"force the _execute_child() errpipe_data path."
)
p
=
SafeConstructorPopen
()
def
_test_fds_execute_child_wrapper
(
args
,
executable
,
preexec_fn
,
close_fds
,
cwd
,
env
,
universal_newlines
,
startupinfo
,
creationflags
,
shell
,
universal_newlines
,
startupinfo
,
creationflags
,
shell
,
p2cread
,
p2cwrite
,
p2cread
,
p2cwrite
,
c2pread
,
c2pwrite
,
c2pread
,
c2pwrite
,
errread
,
errwrite
):
errread
,
errwrite
):
try
:
try
:
subprocess
.
Popen
.
_execute_child
(
subprocess
.
Popen
.
_execute_child
(
p
,
args
,
executable
,
preexec_fn
,
close_fds
,
self
,
args
,
executable
,
preexec_fn
,
close_fds
,
cwd
,
env
,
universal_newlines
,
cwd
,
env
,
universal_newlines
,
startupinfo
,
creationflags
,
shell
,
startupinfo
,
creationflags
,
shell
,
p2cread
,
p2cwrite
,
p2cread
,
p2cwrite
,
...
@@ -786,17 +780,23 @@ class POSIXProcessTestCase(BaseTestCase):
...
@@ -786,17 +780,23 @@ class POSIXProcessTestCase(BaseTestCase):
for
_
in
range
(
8
)]
for
_
in
range
(
8
)]
try
:
try
:
for
fd
in
devzero_fds
:
for
fd
in
devzero_fds
:
self
.
assertNotIn
(
fd
,
(
p2cwrite
,
c2pread
,
errread
))
self
.
_testcase
.
assertNotIn
(
fd
,
(
p2cwrite
,
c2pread
,
errread
))
finally
:
finally
:
map
(
os
.
close
,
devzero_fds
)
map
(
os
.
close
,
devzero_fds
)
p
.
_execute_child
=
_test_fds_execute_child_wrapper
@unittest.skipIf
(
not
os
.
path
.
exists
(
"/dev/zero"
),
"/dev/zero required."
)
def
test_preexec_errpipe_does_not_double_close_pipes
(
self
):
"""Issue16140: Don't double close pipes on preexec error."""
def
raise_it
():
raise
RuntimeError
(
"force the _execute_child() errpipe_data path."
)
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
):
p
.
RealPopen
([
sys
.
executable
,
"-c"
,
"pass"
],
self
.
_TestExecuteChildPopen
(
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
self
,
[
sys
.
executable
,
"-c"
,
"pass"
],
stderr
=
subprocess
.
PIPE
,
preexec_fn
=
raise_it
)
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
preexec_fn
=
raise_it
)
def
test_args_string
(
self
):
def
test_args_string
(
self
):
# args is a string
# args is a string
...
...
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