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
9bc35682
Kaydet (Commit)
9bc35682
authored
Kas 09, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use script_helper in one more test
üst
e912f5ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
35 deletions
+35
-35
script_helper.py
Lib/test/script_helper.py
+21
-7
test_cmd_line.py
Lib/test/test_cmd_line.py
+14
-28
No files found.
Lib/test/script_helper.py
Dosyayı görüntüle @
9bc35682
...
@@ -15,11 +15,17 @@ from imp import source_from_cache
...
@@ -15,11 +15,17 @@ from imp import source_from_cache
from
test.support
import
make_legacy_pyc
from
test.support
import
make_legacy_pyc
# Executing the interpreter in a subprocess
# Executing the interpreter in a subprocess
def
_assert_python
(
expected_success
,
*
args
):
def
_assert_python
(
expected_success
,
*
args
,
**
env_vars
):
cmd_line
=
[
sys
.
executable
,
'-E'
]
cmd_line
=
[
sys
.
executable
]
if
env_vars
:
env
=
env_vars
else
:
env
=
os
.
environ
cmd_line
.
append
(
'-E'
)
cmd_line
.
extend
(
args
)
cmd_line
.
extend
(
args
)
p
=
subprocess
.
Popen
(
cmd_line
,
stdin
=
subprocess
.
PIPE
,
p
=
subprocess
.
Popen
(
cmd_line
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
env
=
env
)
try
:
try
:
out
,
err
=
p
.
communicate
()
out
,
err
=
p
.
communicate
()
finally
:
finally
:
...
@@ -33,11 +39,19 @@ def _assert_python(expected_success, *args):
...
@@ -33,11 +39,19 @@ def _assert_python(expected_success, *args):
"stderr follows:
\n
%
s"
%
(
rc
,
err
.
decode
(
'ascii'
,
'ignore'
)))
"stderr follows:
\n
%
s"
%
(
rc
,
err
.
decode
(
'ascii'
,
'ignore'
)))
return
rc
,
out
,
err
return
rc
,
out
,
err
def
assert_python_ok
(
*
args
):
def
assert_python_ok
(
*
args
,
**
env_vars
):
return
_assert_python
(
True
,
*
args
)
"""
Assert that running the interpreter with `args` and optional environment
variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
"""
return
_assert_python
(
True
,
*
args
,
**
env_vars
)
def
assert_python_failure
(
*
args
):
def
assert_python_failure
(
*
args
,
**
env_vars
):
return
_assert_python
(
False
,
*
args
)
"""
Assert that running the interpreter with `args` and optional environment
variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
"""
return
_assert_python
(
False
,
*
args
,
**
env_vars
)
def
spawn_python
(
*
args
):
def
spawn_python
(
*
args
):
cmd_line
=
[
sys
.
executable
,
'-E'
]
cmd_line
=
[
sys
.
executable
,
'-E'
]
...
...
Lib/test/test_cmd_line.py
Dosyayı görüntüle @
9bc35682
...
@@ -5,18 +5,8 @@
...
@@ -5,18 +5,8 @@
import
test.support
,
unittest
import
test.support
,
unittest
import
os
import
os
import
sys
import
sys
from
test.script_helper
import
spawn_python
,
kill_python
,
assert_python_ok
,
assert_python_failure
# spawn_python normally enforces use of -E to avoid environmental effects
# but one test checks PYTHONPATH behaviour explicitly
# XXX (ncoghlan): Give script_helper.spawn_python an option to switch
# off the -E flag that is normally inserted automatically
import
subprocess
import
subprocess
def
_spawn_python_with_env
(
*
args
):
from
test.script_helper
import
spawn_python
,
kill_python
,
assert_python_ok
,
assert_python_failure
cmd_line
=
[
sys
.
executable
]
cmd_line
.
extend
(
args
)
return
subprocess
.
Popen
(
cmd_line
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
# XXX (ncoghlan): Move to script_helper and make consistent with run_python
# XXX (ncoghlan): Move to script_helper and make consistent with run_python
...
@@ -217,23 +207,19 @@ class CmdLineTest(unittest.TestCase):
...
@@ -217,23 +207,19 @@ class CmdLineTest(unittest.TestCase):
self
.
assertTrue
(
data
.
startswith
(
b
'x'
),
data
)
self
.
assertTrue
(
data
.
startswith
(
b
'x'
),
data
)
def
test_large_PYTHONPATH
(
self
):
def
test_large_PYTHONPATH
(
self
):
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
path1
=
"ABCDE"
*
100
path1
=
"ABCDE"
*
100
path2
=
"FGHIJ"
*
100
path2
=
"FGHIJ"
*
100
path
=
path1
+
os
.
pathsep
+
path2
env
[
'PYTHONPATH'
]
=
path1
+
os
.
pathsep
+
path2
code
=
"""if 1:
code
=
"""
import sys
import sys
path = ":".join(sys.path)
path = ":".join(sys.path)
path = path.encode("ascii", "backslashreplace")
path = path.encode("ascii", "backslashreplace")
sys.stdout.buffer.write(path)"""
sys.stdout.buffer.write(path)"""
rc
,
out
,
err
=
assert_python_ok
(
'-S'
,
'-c'
,
code
,
code
=
code
.
strip
()
.
splitlines
()
PYTHONPATH
=
path
)
code
=
'; '
.
join
(
code
)
self
.
assertIn
(
path1
.
encode
(
'ascii'
),
out
)
p
=
_spawn_python_with_env
(
'-S'
,
'-c'
,
code
)
self
.
assertIn
(
path2
.
encode
(
'ascii'
),
out
)
stdout
,
_
=
p
.
communicate
()
p
.
stdout
.
close
()
self
.
assertIn
(
path1
.
encode
(
'ascii'
),
stdout
)
self
.
assertIn
(
path2
.
encode
(
'ascii'
),
stdout
)
def
test_main
():
def
test_main
():
...
...
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