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
7a9ddd1d
Kaydet (Commit)
7a9ddd1d
authored
Haz 05, 2016
tarafından
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge from 3.5. (moves the issue26372 tests to the proper class)
üst
f39571ed
2daf8e7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
46 deletions
+46
-46
test_subprocess.py
Lib/test/test_subprocess.py
+46
-46
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
7a9ddd1d
...
@@ -1238,52 +1238,6 @@ class ProcessTestCase(BaseTestCase):
...
@@ -1238,52 +1238,6 @@ class ProcessTestCase(BaseTestCase):
fds_after_exception
=
os
.
listdir
(
fd_directory
)
fds_after_exception
=
os
.
listdir
(
fd_directory
)
self
.
assertEqual
(
fds_before_popen
,
fds_after_exception
)
self
.
assertEqual
(
fds_before_popen
,
fds_after_exception
)
def
test_communicate_BrokenPipeError_stdin_close
(
self
):
# By not setting stdout or stderr or a timeout we force the fast path
# that just calls _stdin_write() internally due to our mock.
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-c'
,
'pass'
])
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
close
.
side_effect
=
BrokenPipeError
proc
.
communicate
()
# Should swallow BrokenPipeError from close.
mock_proc_stdin
.
close
.
assert_called_with
()
def
test_communicate_BrokenPipeError_stdin_write
(
self
):
# By not setting stdout or stderr or a timeout we force the fast path
# that just calls _stdin_write() internally due to our mock.
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-c'
,
'pass'
])
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
write
.
side_effect
=
BrokenPipeError
proc
.
communicate
(
b
'stuff'
)
# Should swallow the BrokenPipeError.
mock_proc_stdin
.
write
.
assert_called_once_with
(
b
'stuff'
)
mock_proc_stdin
.
close
.
assert_called_once_with
()
def
test_communicate_BrokenPipeError_stdin_flush
(
self
):
# Setting stdin and stdout forces the ._communicate() code path.
# python -h exits faster than python -c pass (but spams stdout).
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-h'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
,
\
open
(
os
.
devnull
,
'wb'
)
as
dev_null
:
mock_proc_stdin
.
flush
.
side_effect
=
BrokenPipeError
# because _communicate registers a selector using proc.stdin...
mock_proc_stdin
.
fileno
.
return_value
=
dev_null
.
fileno
()
# _communicate() should swallow BrokenPipeError from flush.
proc
.
communicate
(
b
'stuff'
)
mock_proc_stdin
.
flush
.
assert_called_once_with
()
def
test_communicate_BrokenPipeError_stdin_close_with_timeout
(
self
):
# Setting stdin and stdout forces the ._communicate() code path.
# python -h exits faster than python -c pass (but spams stdout).
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-h'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
close
.
side_effect
=
BrokenPipeError
# _communicate() should swallow BrokenPipeError from close.
proc
.
communicate
(
timeout
=
999
)
mock_proc_stdin
.
close
.
assert_called_once_with
()
class
RunFuncTestCase
(
BaseTestCase
):
class
RunFuncTestCase
(
BaseTestCase
):
def
run_python
(
self
,
code
,
**
kwargs
):
def
run_python
(
self
,
code
,
**
kwargs
):
...
@@ -2470,6 +2424,52 @@ class POSIXProcessTestCase(BaseTestCase):
...
@@ -2470,6 +2424,52 @@ class POSIXProcessTestCase(BaseTestCase):
if
not
gc_enabled
:
if
not
gc_enabled
:
gc
.
disable
()
gc
.
disable
()
def
test_communicate_BrokenPipeError_stdin_close
(
self
):
# By not setting stdout or stderr or a timeout we force the fast path
# that just calls _stdin_write() internally due to our mock.
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-c'
,
'pass'
])
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
close
.
side_effect
=
BrokenPipeError
proc
.
communicate
()
# Should swallow BrokenPipeError from close.
mock_proc_stdin
.
close
.
assert_called_with
()
def
test_communicate_BrokenPipeError_stdin_write
(
self
):
# By not setting stdout or stderr or a timeout we force the fast path
# that just calls _stdin_write() internally due to our mock.
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-c'
,
'pass'
])
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
write
.
side_effect
=
BrokenPipeError
proc
.
communicate
(
b
'stuff'
)
# Should swallow the BrokenPipeError.
mock_proc_stdin
.
write
.
assert_called_once_with
(
b
'stuff'
)
mock_proc_stdin
.
close
.
assert_called_once_with
()
def
test_communicate_BrokenPipeError_stdin_flush
(
self
):
# Setting stdin and stdout forces the ._communicate() code path.
# python -h exits faster than python -c pass (but spams stdout).
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-h'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
,
\
open
(
os
.
devnull
,
'wb'
)
as
dev_null
:
mock_proc_stdin
.
flush
.
side_effect
=
BrokenPipeError
# because _communicate registers a selector using proc.stdin...
mock_proc_stdin
.
fileno
.
return_value
=
dev_null
.
fileno
()
# _communicate() should swallow BrokenPipeError from flush.
proc
.
communicate
(
b
'stuff'
)
mock_proc_stdin
.
flush
.
assert_called_once_with
()
def
test_communicate_BrokenPipeError_stdin_close_with_timeout
(
self
):
# Setting stdin and stdout forces the ._communicate() code path.
# python -h exits faster than python -c pass (but spams stdout).
proc
=
subprocess
.
Popen
([
sys
.
executable
,
'-h'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
with
proc
,
mock
.
patch
.
object
(
proc
,
'stdin'
)
as
mock_proc_stdin
:
mock_proc_stdin
.
close
.
side_effect
=
BrokenPipeError
# _communicate() should swallow BrokenPipeError from close.
proc
.
communicate
(
timeout
=
999
)
mock_proc_stdin
.
close
.
assert_called_once_with
()
@unittest.skipUnless
(
mswindows
,
"Windows specific tests"
)
@unittest.skipUnless
(
mswindows
,
"Windows specific tests"
)
class
Win32ProcessTestCase
(
BaseTestCase
):
class
Win32ProcessTestCase
(
BaseTestCase
):
...
...
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