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
fed67790
Commit
fed67790
authored
May 04, 2003
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'forget' now also deletes any proper .pyo files.
Added some docstrings.
parent
b010f547
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
Lib/test/test_support.py
Lib/test/test_support.py
+19
-1
No files found.
Lib/test/test_support.py
View file @
fed67790
"""Supporting definitions for the Python regression test."""
"""Supporting definitions for the Python regression test
s
."""
if
__name__
!=
'test.test_support'
:
raise
ImportError
,
'test_support must be imported from the test package'
...
...
@@ -50,6 +50,8 @@ def unload(name):
pass
def
forget
(
modname
):
'''"Forget" a module was ever imported by removing it from sys.modules and
deleting any .pyc and .pyo files.'''
unload
(
modname
)
import
os
for
dirname
in
sys
.
path
:
...
...
@@ -57,11 +59,24 @@ def forget(modname):
os
.
unlink
(
os
.
path
.
join
(
dirname
,
modname
+
'.pyc'
))
except
os
.
error
:
pass
# Deleting the .pyo file cannot be within the 'try' for the .pyc since
# the chance exists that there is no .pyc (and thus the 'try' statement
# is exited) but there is a .pyo file.
try
:
os
.
unlink
(
os
.
path
.
join
(
dirname
,
modname
+
'.pyo'
))
except
os
.
error
:
pass
def
is_resource_enabled
(
resource
):
"""Test whether a resource is enabled. Known resources are set by
regrtest.py."""
return
use_resources
is
not
None
and
resource
in
use_resources
def
requires
(
resource
,
msg
=
None
):
"""Raise ResourceDenied if the specified resource is not available.
If the caller's module is __main__ then automatically return True. The
possibility of False being returned occurs when regrtest.py is executing."""
# see if the caller's module is __main__ - if so, treat as if
# the resource was set
if
sys
.
_getframe
().
f_back
.
f_globals
.
get
(
"__name__"
)
==
"__main__"
:
...
...
@@ -141,6 +156,9 @@ del os, fp
from
os
import
unlink
def
findfile
(
file
,
here
=
__file__
):
"""Try to find a file on sys.path and the working directory. If it is not
found the argument passed to the function is returned (this does not
necessarily signal failure; could still be the legitimate path)."""
import
os
if
os
.
path
.
isabs
(
file
):
return
file
...
...
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