[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/tests/util.py Added doctest setup helper functions.

Jim Fulton jim at zope.com
Mon Mar 26 18:04:45 EDT 2007


Log message for revision 73653:
  Added doctest setup helper functions.
  

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

-=-
Modified: ZODB/trunk/src/ZODB/tests/util.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/util.py	2007-03-26 19:32:22 UTC (rev 73652)
+++ ZODB/trunk/src/ZODB/tests/util.py	2007-03-26 22:04:44 UTC (rev 73653)
@@ -16,7 +16,11 @@
 $Id$
 """
 
+import os
+import shutil
+import tempfile
 import time
+
 import persistent
 import transaction
 from ZODB.MappingStorage import MappingStorage
@@ -38,3 +42,18 @@
 
     def __repr__(self):
         return 'P(%s)' % self.name
+
+def setUp(test):
+    test.globs['__teardown_stack__'] = []
+    tmp = tempfile.mkdtemp('test')
+    registerTearDown(test, lambda : shutil.rmtree(tmp))
+    here = os.getcwd()
+    registerTearDown(test, lambda : os.chdir(here))
+    os.chdir(tmp)
+    
+def registerTearDown(test, func):
+    test.globs['__teardown_stack__'].append(func)    
+    
+def tearDown(test):
+    for f in test.globs['__teardown_stack__']:
+        f()



More information about the Zodb-checkins mailing list