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
4ae37775
Kaydet (Commit)
4ae37775
authored
May 08, 2010
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Adds a unittest for the internal os._execvpe function.
üst
73162197
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
test_os.py
Lib/test/test_os.py
+49
-0
No files found.
Lib/test/test_os.py
Dosyayı görüntüle @
4ae37775
...
@@ -633,6 +633,55 @@ class ExecTests(unittest.TestCase):
...
@@ -633,6 +633,55 @@ class ExecTests(unittest.TestCase):
def
test_execvpe_with_bad_arglist
(
self
):
def
test_execvpe_with_bad_arglist
(
self
):
self
.
assertRaises
(
ValueError
,
os
.
execvpe
,
'notepad'
,
[],
None
)
self
.
assertRaises
(
ValueError
,
os
.
execvpe
,
'notepad'
,
[],
None
)
class
_stub_out_for_execvpe_test
(
object
):
"""
Stubs out execv, execve and get_exec_path functions when
used as context manager. Records exec calls. The mock execv
and execve functions always raise an exception as they would
normally never return.
"""
def
__init__
(
self
):
# A list of tuples containing (function name, first arg, args)
# of calls to execv or execve that have been made.
self
.
calls
=
[]
def
_mock_execv
(
self
,
name
,
*
args
):
self
.
calls
.
append
((
'execv'
,
name
,
args
))
raise
RuntimeError
(
"execv called"
)
def
_mock_execve
(
self
,
name
,
*
args
):
self
.
calls
.
append
((
'execve'
,
name
,
args
))
raise
OSError
(
errno
.
ENOTDIR
,
"execve called"
)
def
_mock_get_exec_path
(
self
,
env
=
None
):
return
[
'/p'
,
'/pp'
]
def
__enter__
(
self
):
self
.
orig_execv
=
os
.
execv
self
.
orig_execve
=
os
.
execve
self
.
orig_get_exec_path
=
os
.
get_exec_path
os
.
execv
=
self
.
_mock_execv
os
.
execve
=
self
.
_mock_execve
os
.
get_exec_path
=
self
.
_mock_get_exec_path
def
__exit__
(
self
,
type
,
value
,
tb
):
os
.
execv
=
self
.
orig_execv
os
.
execve
=
self
.
orig_execve
os
.
get_exec_path
=
self
.
orig_get_exec_path
@unittest.skipUnless
(
hasattr
(
os
,
'_execvpe'
),
"No internal os._execvpe function to test."
)
def
test_internal_execvpe
(
self
):
exec_stubbed
=
self
.
_stub_out_for_execvpe_test
()
with
exec_stubbed
:
self
.
assertRaises
(
RuntimeError
,
os
.
_execvpe
,
'/f'
,
[
'-a'
])
self
.
assertEqual
([(
'execv'
,
'/f'
,
([
'-a'
],))],
exec_stubbed
.
calls
)
exec_stubbed
.
calls
=
[]
self
.
assertRaises
(
OSError
,
os
.
_execvpe
,
'f'
,
[
'-a'
],
env
=
{
'spam'
:
'beans'
})
self
.
assertEqual
([(
'execve'
,
'/p/f'
,
([
'-a'
],
{
'spam'
:
'beans'
})),
(
'execve'
,
'/pp/f'
,
([
'-a'
],
{
'spam'
:
'beans'
}))],
exec_stubbed
.
calls
)
class
Win32ErrorTests
(
unittest
.
TestCase
):
class
Win32ErrorTests
(
unittest
.
TestCase
):
def
test_rename
(
self
):
def
test_rename
(
self
):
self
.
assertRaises
(
WindowsError
,
os
.
rename
,
support
.
TESTFN
,
support
.
TESTFN
+
".bak"
)
self
.
assertRaises
(
WindowsError
,
os
.
rename
,
support
.
TESTFN
,
support
.
TESTFN
+
".bak"
)
...
...
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