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
d48214f2
Kaydet (Commit)
d48214f2
authored
May 14, 2017
tarafından
Zachary Ware
Kaydeden (comit)
GitHub
May 14, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-29763: Clean up _pth tests (GH-954)
üst
99776296
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
46 deletions
+31
-46
test_site.py
Lib/test/test_site.py
+31
-46
No files found.
Lib/test/test_site.py
Dosyayı görüntüle @
d48214f2
...
@@ -17,6 +17,7 @@ import urllib.error
...
@@ -17,6 +17,7 @@ import urllib.error
import
shutil
import
shutil
import
subprocess
import
subprocess
import
sysconfig
import
sysconfig
import
tempfile
from
copy
import
copy
from
copy
import
copy
# These tests are not particularly useful if Python was invoked with -S.
# These tests are not particularly useful if Python was invoked with -S.
...
@@ -502,29 +503,21 @@ class StartupImportTests(unittest.TestCase):
...
@@ -502,29 +503,21 @@ class StartupImportTests(unittest.TestCase):
'import site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))'
])
.
wait
()
'import site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))'
])
.
wait
()
self
.
assertTrue
(
r
,
"'__interactivehook__' not added by enablerlcompleter()"
)
self
.
assertTrue
(
r
,
"'__interactivehook__' not added by enablerlcompleter()"
)
@classmethod
@unittest.skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
class
_pthFileTests
(
unittest
.
TestCase
):
def
_create_underpth_exe
(
self
,
lines
):
def
_create_underpth_exe
(
self
,
lines
):
exe_file
=
os
.
path
.
join
(
os
.
getenv
(
'TEMP'
),
os
.
path
.
split
(
sys
.
executable
)[
1
])
temp_dir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
test
.
support
.
rmtree
,
temp_dir
)
exe_file
=
os
.
path
.
join
(
temp_dir
,
os
.
path
.
split
(
sys
.
executable
)[
1
])
shutil
.
copy
(
sys
.
executable
,
exe_file
)
shutil
.
copy
(
sys
.
executable
,
exe_file
)
_pth_file
=
os
.
path
.
splitext
(
exe_file
)[
0
]
+
'._pth'
_pth_file
=
os
.
path
.
splitext
(
exe_file
)[
0
]
+
'._pth'
try
:
with
open
(
_pth_file
,
'w'
)
as
f
:
with
open
(
_pth_file
,
'w'
)
as
f
:
for
line
in
lines
:
for
line
in
lines
:
print
(
line
,
file
=
f
)
print
(
line
,
file
=
f
)
return
exe_file
return
exe_file
except
:
test
.
support
.
unlink
(
_pth_file
)
test
.
support
.
unlink
(
exe_file
)
raise
@classmethod
def
_cleanup_underpth_exe
(
self
,
exe_file
):
_pth_file
=
os
.
path
.
splitext
(
exe_file
)[
0
]
+
'._pth'
test
.
support
.
unlink
(
_pth_file
)
test
.
support
.
unlink
(
exe_file
)
@classmethod
def
_calc_sys_path_for_underpth_nosite
(
self
,
sys_prefix
,
lines
):
def
_calc_sys_path_for_underpth_nosite
(
self
,
sys_prefix
,
lines
):
sys_path
=
[]
sys_path
=
[]
for
line
in
lines
:
for
line
in
lines
:
...
@@ -534,7 +527,6 @@ class StartupImportTests(unittest.TestCase):
...
@@ -534,7 +527,6 @@ class StartupImportTests(unittest.TestCase):
sys_path
.
append
(
abs_path
)
sys_path
.
append
(
abs_path
)
return
sys_path
return
sys_path
@unittest.skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_nosite_file
(
self
):
def
test_underpth_nosite_file
(
self
):
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
...
@@ -549,20 +541,16 @@ class StartupImportTests(unittest.TestCase):
...
@@ -549,20 +541,16 @@ class StartupImportTests(unittest.TestCase):
os
.
path
.
dirname
(
exe_file
),
os
.
path
.
dirname
(
exe_file
),
pth_lines
)
pth_lines
)
try
:
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
rc
=
subprocess
.
call
([
exe_file
,
'-c'
,
rc
=
subprocess
.
call
([
exe_file
,
'-c'
,
'import sys; sys.exit(sys.flags.no_site and '
'import sys; sys.exit(sys.flags.no_site and '
'len(sys.path) > 200 and '
'len(sys.path) > 200 and '
'sys.path ==
%
r)'
%
sys_path
,
'sys.path ==
%
r)'
%
sys_path
,
],
env
=
env
)
],
env
=
env
)
finally
:
self
.
_cleanup_underpth_exe
(
exe_file
)
self
.
assertTrue
(
rc
,
"sys.path is incorrect"
)
self
.
assertTrue
(
rc
,
"sys.path is incorrect"
)
@unittest.skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_file
(
self
):
def
test_underpth_file
(
self
):
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
...
@@ -574,20 +562,17 @@ class StartupImportTests(unittest.TestCase):
...
@@ -574,20 +562,17 @@ class StartupImportTests(unittest.TestCase):
'import site'
'import site'
])
])
sys_prefix
=
os
.
path
.
dirname
(
exe_file
)
sys_prefix
=
os
.
path
.
dirname
(
exe_file
)
try
:
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
rc
=
subprocess
.
call
([
exe_file
,
'-c'
,
rc
=
subprocess
.
call
([
exe_file
,
'-c'
,
'import sys; sys.exit(not sys.flags.no_site and '
'import sys; sys.exit(not sys.flags.no_site and '
'
%
r in sys.path and
%
r in sys.path and
%
r not in sys.path and '
'
%
r in sys.path and
%
r in sys.path and
%
r not in sys.path and '
'all("
\\
r" not in p and "
\\
n" not in p for p in sys.path))'
%
(
'all("
\\
r" not in p and "
\\
n" not in p for p in sys.path))'
%
(
os
.
path
.
join
(
sys_prefix
,
'fake-path-name'
),
os
.
path
.
join
(
sys_prefix
,
'fake-path-name'
),
libpath
,
libpath
,
os
.
path
.
join
(
sys_prefix
,
'from-env'
),
os
.
path
.
join
(
sys_prefix
,
'from-env'
),
)],
env
=
env
)
)],
env
=
env
)
finally
:
self
.
_cleanup_underpth_exe
(
exe_file
)
self
.
assertTrue
(
rc
,
"sys.path is incorrect"
)
self
.
assertTrue
(
rc
,
"sys.path is incorrect"
)
...
...
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