[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/tests/util.py Need at atexit handler to clean out layer directories, since the test

Jim Fulton jim at zope.com
Sat Nov 15 17:15:47 EST 2008


Log message for revision 92990:
  Need at atexit handler to clean out layer directories, since the test
  runner doesn't call layer teardown when a layer is run as a
  subprocess.  This seems insane, ...
  

Changed:
  U   ZODB/trunk/src/ZODB/tests/util.py

-=-
Modified: ZODB/trunk/src/ZODB/tests/util.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/util.py	2008-11-15 20:59:56 UTC (rev 92989)
+++ ZODB/trunk/src/ZODB/tests/util.py	2008-11-15 22:15:46 UTC (rev 92990)
@@ -18,6 +18,7 @@
 
 from ZODB.MappingStorage import DB
 
+import atexit
 import os
 import tempfile
 import time
@@ -74,12 +75,19 @@
         self.tmp = tempfile.mkdtemp(self.__name__, dir=os.getcwd())
         os.chdir(self.tmp)
 
+        # sigh. tearDown isn't called when a layer is run in a sub-process.
+        atexit.register(clean, self.tmp)
+
     def tearDown(self):
         os.chdir(self.here)
         zope.testing.setupstack.rmtree(self.tmp)
 
     testSetUp = testTearDown = lambda self: None
 
+def clean(tmp):
+    if os.path.isdir(tmp):
+        zope.testing.setupstack.rmtree(tmp)
+
 class AAAA_Test_Runner_Hack(unittest.TestCase):
     """Hack to work around a bug in the test runner.
 



More information about the Zodb-checkins mailing list