Commits

anatoly techtonik committed e5aa21a

TestCmd.py: Delay cleanup registration with atexit to avoid exessive
tracebacks when Import fails because of missing pywin32
modules (see http://bugs.python.org/issue16718)

  • Participants
  • Parent commits d78d196

Comments (0)

Files changed (1)

File QMTest/TestCmd.py

 
 re_space = re.compile('\s')
 
-_Cleanup = []
-
-def _clean():
-    global _Cleanup
-    cleanlist = [ c for c in _Cleanup if c ]
-    del _Cleanup[:]
-    cleanlist.reverse()
-    for test in cleanlist:
-        test.cleanup()
-
-atexit.register(_clean)
-
 def _caller(tblist, skip):
     string = ""
     arr = []
             raise Exception(disconnect_message)
         data = memoryview(data)[sent:]
 
+_Cleanup = []
+
+def _clean():
+    global _Cleanup
+    cleanlist = [ c for c in _Cleanup if c ]
+    del _Cleanup[:]
+    cleanlist.reverse()
+    for test in cleanlist:
+        test.cleanup()
+
+atexit.register(_clean)
 
 
 class TestCmd(object):
                 shutil.rmtree(dir, ignore_errors = 1)
             self._dirlist = []
 
-        try:
             global _Cleanup
-            _Cleanup.remove(self)
-        except (AttributeError, ValueError):
-            pass
+            if self in _Cleanup:
+                _Cleanup.remove(self)
 
     def command_args(self, program = None,
                            interpreter = None,
 
         #
         self._dirlist.append(path)
+
         global _Cleanup
-        try:
-            _Cleanup.index(self)
-        except ValueError:
+        if self not in _Cleanup:
             _Cleanup.append(self)
 
         return path