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
186335bd
Commit
186335bd
authored
Aug 22, 2010
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that no __pycache__ directory is needlessly left behind when testing
imports with an empty string in sys.path.
parent
0723d2c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
Lib/importlib/test/source/test_file_loader.py
Lib/importlib/test/source/test_file_loader.py
+10
-7
No files found.
Lib/importlib/test/source/test_file_loader.py
View file @
186335bd
...
...
@@ -8,6 +8,7 @@ import imp
import
marshal
import
os
import
py_compile
import
shutil
import
stat
import
sys
import
unittest
...
...
@@ -112,18 +113,20 @@ class SimpleTest(unittest.TestCase):
def
test_file_from_empty_string_dir
(
self
):
# Loading a module found from an empty string entry on sys.path should
# not only work, but keep all attributes relative.
with
open
(
'_temp.py'
,
'w'
)
as
file
:
file_path
=
'_temp.py'
with
open
(
file_path
,
'w'
)
as
file
:
file
.
write
(
"# test file for importlib"
)
try
:
with
util
.
uncache
(
'_temp'
):
loader
=
_bootstrap
.
_SourceFileLoader
(
'_temp'
,
'_temp.py'
)
loader
=
_bootstrap
.
_SourceFileLoader
(
'_temp'
,
file_path
)
mod
=
loader
.
load_module
(
'_temp'
)
self
.
assertEqual
(
'_temp.py'
,
mod
.
__file__
)
self
.
assertEqual
(
imp
.
cache_from_source
(
'_temp.py'
),
self
.
assertEqual
(
file_path
,
mod
.
__file__
)
self
.
assertEqual
(
imp
.
cache_from_source
(
file_path
),
mod
.
__cached__
)
finally
:
os
.
unlink
(
'_temp.py'
)
os
.
unlink
(
file_path
)
pycache
=
os
.
path
.
dirname
(
imp
.
cache_from_source
(
file_path
))
shutil
.
rmtree
(
pycache
)
class
BadBytecodeTest
(
unittest
.
TestCase
):
...
...
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