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
5424ad8a
Commit
5424ad8a
authored
Mar 15, 2006
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make test_runpy close all references to test modules before trying to delete the underlying files
parent
21d3a7cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
Lib/test/test_runpy.py
Lib/test/test_runpy.py
+11
-8
No files found.
Lib/test/test_runpy.py
View file @
5424ad8a
...
@@ -113,13 +113,6 @@ class RunModuleTest(unittest.TestCase):
...
@@ -113,13 +113,6 @@ class RunModuleTest(unittest.TestCase):
return
pkg_dir
,
mod_fname
,
mod_name
return
pkg_dir
,
mod_fname
,
mod_name
def
_del_pkg
(
self
,
top
,
depth
,
mod_name
):
def
_del_pkg
(
self
,
top
,
depth
,
mod_name
):
for
root
,
dirs
,
files
in
os
.
walk
(
top
,
topdown
=
False
):
for
name
in
files
:
os
.
remove
(
os
.
path
.
join
(
root
,
name
))
for
name
in
dirs
:
os
.
rmdir
(
os
.
path
.
join
(
root
,
name
))
os
.
rmdir
(
top
)
if
verbose
:
print
" Removed package tree"
for
i
in
range
(
depth
+
1
):
# Don't forget the module itself
for
i
in
range
(
depth
+
1
):
# Don't forget the module itself
parts
=
mod_name
.
rsplit
(
"."
,
i
)
parts
=
mod_name
.
rsplit
(
"."
,
i
)
entry
=
parts
[
0
]
entry
=
parts
[
0
]
...
@@ -127,6 +120,13 @@ class RunModuleTest(unittest.TestCase):
...
@@ -127,6 +120,13 @@ class RunModuleTest(unittest.TestCase):
if
verbose
:
print
" Removed sys.modules entries"
if
verbose
:
print
" Removed sys.modules entries"
del
sys
.
path
[
0
]
del
sys
.
path
[
0
]
if
verbose
:
print
" Removed sys.path entry"
if
verbose
:
print
" Removed sys.path entry"
for
root
,
dirs
,
files
in
os
.
walk
(
top
,
topdown
=
False
):
for
name
in
files
:
os
.
remove
(
os
.
path
.
join
(
root
,
name
))
for
name
in
dirs
:
os
.
rmdir
(
os
.
path
.
join
(
root
,
name
))
os
.
rmdir
(
top
)
if
verbose
:
print
" Removed package tree"
def
_check_module
(
self
,
depth
):
def
_check_module
(
self
,
depth
):
pkg_dir
,
mod_fname
,
mod_name
=
(
pkg_dir
,
mod_fname
,
mod_name
=
(
...
@@ -134,13 +134,16 @@ class RunModuleTest(unittest.TestCase):
...
@@ -134,13 +134,16 @@ class RunModuleTest(unittest.TestCase):
try
:
try
:
if
verbose
:
print
"Running from source:"
,
mod_name
if
verbose
:
print
"Running from source:"
,
mod_name
d1
=
run_module
(
mod_name
)
# Read from source
d1
=
run_module
(
mod_name
)
# Read from source
self
.
failUnless
(
d1
[
"x"
]
==
1
)
del
d1
# Ensure __loader__ entry doesn't keep file open
__import__
(
mod_name
)
__import__
(
mod_name
)
os
.
remove
(
mod_fname
)
os
.
remove
(
mod_fname
)
if
verbose
:
print
"Running from compiled:"
,
mod_name
if
verbose
:
print
"Running from compiled:"
,
mod_name
d2
=
run_module
(
mod_name
)
# Read from bytecode
d2
=
run_module
(
mod_name
)
# Read from bytecode
self
.
failUnless
(
d2
[
"x"
]
==
1
)
del
d2
# Ensure __loader__ entry doesn't keep file open
finally
:
finally
:
self
.
_del_pkg
(
pkg_dir
,
depth
,
mod_name
)
self
.
_del_pkg
(
pkg_dir
,
depth
,
mod_name
)
self
.
failUnless
(
d1
[
"x"
]
==
d2
[
"x"
]
==
1
)
if
verbose
:
print
"Module executed successfully"
if
verbose
:
print
"Module executed successfully"
def
test_run_module
(
self
):
def
test_run_module
(
self
):
...
...
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