Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
17b1eadb
Commit
17b1eadb
authored
Oct 29, 2016
by
Steve Dower
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes test_underpth* tests more robust by copying the executable.
parent
18178ba8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
25 deletions
+51
-25
Lib/test/test_site.py
Lib/test/test_site.py
+48
-25
PCbuild/rt.bat
PCbuild/rt.bat
+3
-0
No files found.
Lib/test/test_site.py
View file @
17b1eadb
...
@@ -14,6 +14,7 @@ import re
...
@@ -14,6 +14,7 @@ import re
import
encodings
import
encodings
import
urllib.request
import
urllib.request
import
urllib.error
import
urllib.error
import
shutil
import
subprocess
import
subprocess
import
sysconfig
import
sysconfig
from
copy
import
copy
from
copy
import
copy
...
@@ -488,22 +489,44 @@ class StartupImportTests(unittest.TestCase):
...
@@ -488,22 +489,44 @@ 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()"
)
@
unittest
.
skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
@
classmethod
def
test_underpth_nosite_file
(
self
):
def
_create_underpth_exe
(
self
,
lines
):
_pth_file
=
os
.
path
.
splitext
(
sys
.
executable
)[
0
]
+
'._pth'
exe_file
=
os
.
path
.
join
(
os
.
getenv
(
'TEMP'
),
os
.
path
.
split
(
sys
.
executable
)[
1
])
shutil
.
copy
(
sys
.
executable
,
exe_file
)
_pth_file
=
os
.
path
.
splitext
(
exe_file
)[
0
]
+
'._pth'
try
:
try
:
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
with
open
(
_pth_file
,
'w'
)
as
f
:
with
open
(
_pth_file
,
'w'
)
as
f
:
print
(
'fake-path-name'
,
file
=
f
)
for
line
in
lines
:
# Ensure the generated path is very long so that buffer
print
(
line
,
file
=
f
)
# resizing in getpathp.c is exercised
return
exe_file
for
_
in
range
(
200
):
except
:
print
(
libpath
,
file
=
f
)
os
.
unlink
(
_pth_file
)
print
(
'# comment'
,
file
=
f
)
os
.
unlink
(
exe_file
)
raise
@
classmethod
def
_cleanup_underpth_exe
(
self
,
exe_file
):
_pth_file
=
os
.
path
.
splitext
(
exe_file
)[
0
]
+
'._pth'
os
.
unlink
(
_pth_file
)
os
.
unlink
(
exe_file
)
@
unittest
.
skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_nosite_file
(
self
):
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
exe_file
=
self
.
_create_underpth_exe
([
'fake-path-name'
,
*
[
libpath
for
_
in
range
(
200
)],
'# comment'
,
'import site'
])
try
:
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PYTHONPATH'
]
=
'from-env'
rc
=
subprocess
.
call
([
sys
.
executable
,
'-c'
,
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
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 '
'%r in sys.path and %r in sys.path and %r not in sys.path)'
%
(
'%r in sys.path and %r in sys.path and %r not in sys.path)'
%
(
...
@@ -511,34 +534,34 @@ class StartupImportTests(unittest.TestCase):
...
@@ -511,34 +534,34 @@ class StartupImportTests(unittest.TestCase):
libpath
,
libpath
,
os
.
path
.
join
(
sys
.
prefix
,
'from-env'
),
os
.
path
.
join
(
sys
.
prefix
,
'from-env'
),
)],
env
=
env
)
)],
env
=
env
)
self
.
assertEqual
(
rc
,
0
)
finally
:
finally
:
os
.
unlink
(
_pth_file
)
self
.
_cleanup_underpth_exe
(
exe_file
)
self
.
assertEqual
(
rc
,
0
)
@
unittest
.
skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
@
unittest
.
skipUnless
(
sys
.
platform
==
'win32'
,
"only supported on Windows"
)
def
test_underpth_file
(
self
):
def
test_underpth_file
(
self
):
_pth_file
=
os
.
path
.
splitext
(
sys
.
executable
)[
0
]
+
'._pth'
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
exe_prefix
=
os
.
path
.
dirname
(
sys
.
executable
)
exe_file
=
self
.
_create_underpth_exe
([
'fake-path-name'
,
*
[
libpath
for
_
in
range
(
200
)],
'# comment'
,
'import site'
])
try
:
try
:
libpath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
encodings
.
__file__
))
with
open
(
_pth_file
,
'w'
)
as
f
:
print
(
'fake-path-name'
,
file
=
f
)
for
_
in
range
(
200
):
print
(
libpath
,
file
=
f
)
print
(
'# comment'
,
file
=
f
)
print
(
'import site'
,
file
=
f
)
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
env
[
'PYTHONPATH'
]
=
'from-env'
env
[
'PYTHONPATH'
]
=
'from-env'
rc
=
subprocess
.
call
([
sys
.
executable
,
'-c'
,
env
[
'PATH'
]
=
'{};{}'
.
format
(
exe_prefix
,
os
.
getenv
(
'PATH'
))
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)'
%
(
'%r in sys.path and %r in sys.path and %r not 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
)
self
.
assertEqual
(
rc
,
0
)
finally
:
finally
:
os
.
unlink
(
_pth_file
)
self
.
_cleanup_underpth_exe
(
exe_file
)
self
.
assertEqual
(
rc
,
0
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
PCbuild/rt.bat
View file @
17b1eadb
...
@@ -48,6 +48,9 @@ if defined qmode goto Qmode
...
@@ -48,6 +48,9 @@ if defined qmode goto Qmode
echo
Deleting
.pyc/.pyo
files
...
echo
Deleting
.pyc/.pyo
files
...
"
%exe%
"
"
%pcbuild%
rmpyc.py"
"
%exe%
"
"
%pcbuild%
rmpyc.py"
echo
Cleaning
_pth
files
...
if
exist
%prefix%
*
._pth
del
%prefix%
*
._pth
echo
on
echo
on
%cmd%
%cmd%
@echo
off
@echo
off
...
...
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