summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2006-03-15 13:11:54 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2006-03-15 13:11:54 (GMT)
commit586b83c4bb01faa0b1e23badf94efe7c7ab1185e (patch)
treea26e782a70f56cc7b9f459a94689f8fee2a77c3d /Lib
parenta2173a189a679cd6babf85a0369b1969f173dfb3 (diff)
downloadcpython-586b83c4bb01faa0b1e23badf94efe7c7ab1185e.zip
cpython-586b83c4bb01faa0b1e23badf94efe7c7ab1185e.tar.gz
cpython-586b83c4bb01faa0b1e23badf94efe7c7ab1185e.tar.bz2
Don't let cleanup errors mask real errors in the runpy tests
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_runpy.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index 7f1fa64..5d8607b 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -116,17 +116,30 @@ class RunModuleTest(unittest.TestCase):
for i in range(depth+1): # Don't forget the module itself
parts = mod_name.rsplit(".", i)
entry = parts[0]
- del sys.modules[entry]
+ try:
+ del sys.modules[entry]
+ except KeyError, ex:
+ if verbose: print ex # Persist with cleaning up
if verbose: print " Removed sys.modules entries"
del sys.path[0]
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))
+ try:
+ os.remove(os.path.join(root, name))
+ except OSError, ex:
+ if verbose: print ex # Persist with cleaning up
for name in dirs:
- os.rmdir(os.path.join(root, name))
- os.rmdir(top)
- if verbose: print " Removed package tree"
+ fullname = os.path.join(root, name)
+ try:
+ os.rmdir(fullname)
+ except OSError, ex:
+ if verbose: print ex # Persist with cleaning up
+ try:
+ os.rmdir(top)
+ if verbose: print " Removed package tree"
+ except OSError, ex:
+ if verbose: print ex # Persist with cleaning up
def _check_module(self, depth):
pkg_dir, mod_fname, mod_name = (