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
595c8d34
Kaydet (Commit)
595c8d34
authored
Agu 12, 2010
tarafından
Tim Golden
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#2304: fix incorporating Eric Smith's .format suggestion and tested on Ubuntu as well as Windows
üst
d748c3d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
5 deletions
+51
-5
subprocess.py
Lib/subprocess.py
+1
-1
test_subprocess.py
Lib/test/test_subprocess.py
+50
-4
No files found.
Lib/subprocess.py
Dosyayı görüntüle @
595c8d34
...
@@ -829,7 +829,7 @@ class Popen(object):
...
@@ -829,7 +829,7 @@ class Popen(object):
startupinfo
.
dwFlags
|=
_subprocess
.
STARTF_USESHOWWINDOW
startupinfo
.
dwFlags
|=
_subprocess
.
STARTF_USESHOWWINDOW
startupinfo
.
wShowWindow
=
_subprocess
.
SW_HIDE
startupinfo
.
wShowWindow
=
_subprocess
.
SW_HIDE
comspec
=
os
.
environ
.
get
(
"COMSPEC"
,
"cmd.exe"
)
comspec
=
os
.
environ
.
get
(
"COMSPEC"
,
"cmd.exe"
)
args
=
comspec
+
" /c "
+
args
args
=
'{} /c "{}"'
.
format
(
comspec
,
args
)
if
(
_subprocess
.
GetVersion
()
>=
0x80000000
or
if
(
_subprocess
.
GetVersion
()
>=
0x80000000
or
os
.
path
.
basename
(
comspec
)
.
lower
()
==
"command.com"
):
os
.
path
.
basename
(
comspec
)
.
lower
()
==
"command.com"
):
# Win9x, or using command.com on NT. We need to
# Win9x, or using command.com on NT. We need to
...
...
Lib/test/test_subprocess.py
Dosyayı görüntüle @
595c8d34
...
@@ -28,7 +28,7 @@ def remove_stderr_debug_decorations(stderr):
...
@@ -28,7 +28,7 @@ def remove_stderr_debug_decorations(stderr):
return
re
.
sub
(
"
\
[
\
d+ refs
\
]
\r
?
\n
?$"
,
""
,
stderr
.
decode
())
.
encode
()
return
re
.
sub
(
"
\
[
\
d+ refs
\
]
\r
?
\n
?$"
,
""
,
stderr
.
decode
())
.
encode
()
#return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
#return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
class
Process
TestCase
(
unittest
.
TestCase
):
class
Base
TestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
# Try to minimize the number of children we have so this test
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
# doesn't crash on some buildbots (Alphas in particular).
...
@@ -41,14 +41,15 @@ class ProcessTestCase(unittest.TestCase):
...
@@ -41,14 +41,15 @@ class ProcessTestCase(unittest.TestCase):
if
hasattr
(
support
,
"reap_children"
):
if
hasattr
(
support
,
"reap_children"
):
support
.
reap_children
()
support
.
reap_children
()
def
mkstemp
(
self
):
def
mkstemp
(
self
,
*
args
,
**
kwargs
):
"""wrapper for mkstemp, calling mktemp if mkstemp is not available"""
"""wrapper for mkstemp, calling mktemp if mkstemp is not available"""
if
hasattr
(
tempfile
,
"mkstemp"
):
if
hasattr
(
tempfile
,
"mkstemp"
):
return
tempfile
.
mkstemp
()
return
tempfile
.
mkstemp
(
*
args
,
**
kwargs
)
else
:
else
:
fname
=
tempfile
.
mktemp
()
fname
=
tempfile
.
mktemp
(
*
args
,
**
kwargs
)
return
os
.
open
(
fname
,
os
.
O_RDWR
|
os
.
O_CREAT
),
fname
return
os
.
open
(
fname
,
os
.
O_RDWR
|
os
.
O_CREAT
),
fname
class
ProcessTestCase
(
BaseTestCase
):
#
#
# Generic tests
# Generic tests
#
#
...
@@ -863,6 +864,7 @@ class ProcessTestCase(unittest.TestCase):
...
@@ -863,6 +864,7 @@ class ProcessTestCase(unittest.TestCase):
p
.
terminate
()
p
.
terminate
()
self
.
assertNotEqual
(
p
.
wait
(),
0
)
self
.
assertNotEqual
(
p
.
wait
(),
0
)
class
CommandTests
(
unittest
.
TestCase
):
class
CommandTests
(
unittest
.
TestCase
):
# The module says:
# The module says:
# "NB This only works (and is only relevant) for UNIX."
# "NB This only works (and is only relevant) for UNIX."
...
@@ -893,6 +895,50 @@ class CommandTests(unittest.TestCase):
...
@@ -893,6 +895,50 @@ class CommandTests(unittest.TestCase):
unit_tests
=
[
ProcessTestCase
,
CommandTests
]
unit_tests
=
[
ProcessTestCase
,
CommandTests
]
if
mswindows
:
class
CommandsWithSpaces
(
BaseTestCase
):
def
setUp
(
self
):
super
()
.
setUp
()
f
,
fname
=
self
.
mkstemp
(
".py"
,
"te st"
)
self
.
fname
=
fname
.
lower
()
os
.
write
(
f
,
b
"import sys;"
b
"sys.stdout.write('
%
d
%
s'
%
(len(sys.argv), [a.lower () for a in sys.argv]))"
)
os
.
close
(
f
)
def
tearDown
(
self
):
os
.
remove
(
self
.
fname
)
super
()
.
tearDown
()
def
with_spaces
(
self
,
*
args
,
**
kwargs
):
kwargs
[
'stdout'
]
=
subprocess
.
PIPE
p
=
subprocess
.
Popen
(
*
args
,
**
kwargs
)
self
.
assertEqual
(
p
.
stdout
.
read
()
.
decode
(
"mbcs"
),
"2 [
%
r, 'ab cd']"
%
self
.
fname
)
def
test_shell_string_with_spaces
(
self
):
# call() function with string argument with spaces on Windows
self
.
with_spaces
(
'"
%
s" "
%
s"'
%
(
self
.
fname
,
"ab cd"
),
shell
=
1
)
def
test_shell_sequence_with_spaces
(
self
):
# call() function with sequence argument with spaces on Windows
self
.
with_spaces
([
self
.
fname
,
"ab cd"
],
shell
=
1
)
def
test_noshell_string_with_spaces
(
self
):
# call() function with string argument with spaces on Windows
self
.
with_spaces
(
'"
%
s" "
%
s" "
%
s"'
%
(
sys
.
executable
,
self
.
fname
,
"ab cd"
))
def
test_noshell_sequence_with_spaces
(
self
):
# call() function with sequence argument with spaces on Windows
self
.
with_spaces
([
sys
.
executable
,
self
.
fname
,
"ab cd"
])
unit_tests
.
append
(
CommandsWithSpaces
)
if
getattr
(
subprocess
,
'_has_poll'
,
False
):
if
getattr
(
subprocess
,
'_has_poll'
,
False
):
class
ProcessTestCaseNoPoll
(
ProcessTestCase
):
class
ProcessTestCaseNoPoll
(
ProcessTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
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