[Python-checkins] python/dist/src/Lib/test test_support.py,1.52,1.53
bcannon@users.sourceforge.net
bcannon@users.sourceforge.net
Sun, 04 May 2003 14:15:30 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv3106/Lib/test
Modified Files:
test_support.py
Log Message:
'forget' now also deletes any proper .pyo files.
Added some docstrings.
Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** test_support.py 1 May 2003 17:45:51 -0000 1.52
--- test_support.py 4 May 2003 21:15:27 -0000 1.53
***************
*** 1,3 ****
! """Supporting definitions for the Python regression test."""
if __name__ != 'test.test_support':
--- 1,3 ----
! """Supporting definitions for the Python regression tests."""
if __name__ != 'test.test_support':
***************
*** 51,54 ****
--- 51,56 ----
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
***************
*** 58,66 ****
--- 60,81 ----
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
***************
*** 142,145 ****
--- 157,163 ----
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):