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
4659ccff
Kaydet (Commit)
4659ccff
authored
Eyl 14, 2016
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28114: Add unit tests on os.spawn*()
üst
8cee1038
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
test_os.py
Lib/test/test_os.py
+86
-0
No files found.
Lib/test/test_os.py
Dosyayı görüntüle @
4659ccff
...
...
@@ -1413,6 +1413,7 @@ def _execvpe_mockup(defpath=None):
os
.
execve
=
orig_execve
os
.
defpath
=
orig_defpath
class
ExecTests
(
unittest
.
TestCase
):
@unittest.skipIf
(
USING_LINUXTHREADS
,
"avoid triggering a linuxthreads bug: see issue #4970"
)
...
...
@@ -2163,6 +2164,91 @@ class PidTests(unittest.TestCase):
self
.
assertEqual
(
status
,
(
pid
,
0
))
class
SpawnTests
(
unittest
.
TestCase
):
def
create_args
(
self
,
with_env
=
False
):
self
.
exitcode
=
17
filename
=
support
.
TESTFN
self
.
addCleanup
(
support
.
unlink
,
filename
)
if
not
with_env
:
code
=
'import sys; sys.exit(
%
s)'
%
self
.
exitcode
else
:
self
.
env
=
dict
(
os
.
environ
)
# create an unique key
self
.
key
=
str
(
uuid
.
uuid4
())
self
.
env
[
self
.
key
]
=
self
.
key
# read the variable from os.environ to check that it exists
code
=
(
'import sys, os; magic = os.environ[
%
r]; sys.exit(
%
s)'
%
(
self
.
key
,
self
.
exitcode
))
with
open
(
filename
,
"w"
)
as
fp
:
fp
.
write
(
code
)
return
[
sys
.
executable
,
filename
]
@unittest.skipUnless
(
hasattr
(
os
,
'spawnl'
),
'need os.spawnl'
)
def
test_spawnl
(
self
):
args
=
self
.
create_args
()
exitcode
=
os
.
spawnl
(
os
.
P_WAIT
,
args
[
0
],
*
args
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnle'
),
'need os.spawnle'
)
def
test_spawnle
(
self
):
args
=
self
.
create_args
(
True
)
exitcode
=
os
.
spawnle
(
os
.
P_WAIT
,
args
[
0
],
*
args
,
self
.
env
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnlp'
),
'need os.spawnlp'
)
def
test_spawnlp
(
self
):
args
=
self
.
create_args
()
exitcode
=
os
.
spawnlp
(
os
.
P_WAIT
,
args
[
0
],
*
args
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnlpe'
),
'need os.spawnlpe'
)
def
test_spawnlpe
(
self
):
args
=
self
.
create_args
(
True
)
exitcode
=
os
.
spawnlpe
(
os
.
P_WAIT
,
args
[
0
],
*
args
,
self
.
env
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnv'
),
'need os.spawnv'
)
def
test_spawnv
(
self
):
args
=
self
.
create_args
()
exitcode
=
os
.
spawnv
(
os
.
P_WAIT
,
args
[
0
],
args
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnve'
),
'need os.spawnve'
)
def
test_spawnve
(
self
):
args
=
self
.
create_args
(
True
)
exitcode
=
os
.
spawnve
(
os
.
P_WAIT
,
args
[
0
],
args
,
self
.
env
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnvp'
),
'need os.spawnvp'
)
def
test_spawnvp
(
self
):
args
=
self
.
create_args
()
exitcode
=
os
.
spawnvp
(
os
.
P_WAIT
,
args
[
0
],
args
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnvpe'
),
'need os.spawnvpe'
)
def
test_spawnvpe
(
self
):
args
=
self
.
create_args
(
True
)
exitcode
=
os
.
spawnvpe
(
os
.
P_WAIT
,
args
[
0
],
args
,
self
.
env
)
self
.
assertEqual
(
exitcode
,
self
.
exitcode
)
@unittest.skipUnless
(
hasattr
(
os
,
'spawnv'
),
'need os.spawnv'
)
def
test_nowait
(
self
):
args
=
self
.
create_args
()
pid
=
os
.
spawnv
(
os
.
P_NOWAIT
,
args
[
0
],
args
)
result
=
os
.
waitpid
(
pid
,
0
)
self
.
assertEqual
(
result
[
0
],
pid
)
status
=
result
[
1
]
if
hasattr
(
os
,
'WIFEXITED'
):
self
.
assertTrue
(
os
.
WIFEXITED
(
status
))
self
.
assertEqual
(
os
.
WEXITSTATUS
(
status
),
self
.
exitcode
)
else
:
self
.
assertEqual
(
status
,
self
.
exitcode
<<
8
)
# The introduction of this TestCase caused at least two different errors on
# *nix buildbots. Temporarily skip this to let the buildbots move along.
@unittest.skip
(
"Skip due to platform/environment differences on *NIX buildbots"
)
...
...
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