[Python-checkins] r63601 - in python/trunk/Lib: bsddb/test/test_all.py test/test_bsddb3.py

gregory.p.smith python-checkins at python.org
Sun May 25 09:14:10 CEST 2008


Author: gregory.p.smith
Date: Sun May 25 09:14:09 2008
New Revision: 63601

Log:
* Give the test_bsddb3 tests a unique temporary directory to run their
  stuff in and clean it up afterwards regardless of the result.
* Get rid of duplicate list of test modules to run, they're maintained
  within test_all now.
* Print the BerkeleyDB version to stderr when running test_bsddb3 to
  help buildbot problem diagnosis.


Modified:
   python/trunk/Lib/bsddb/test/test_all.py
   python/trunk/Lib/test/test_bsddb3.py

Modified: python/trunk/Lib/bsddb/test/test_all.py
==============================================================================
--- python/trunk/Lib/bsddb/test/test_all.py	(original)
+++ python/trunk/Lib/bsddb/test/test_all.py	Sun May 25 09:14:09 2008
@@ -67,6 +67,8 @@
     return path
 
 
+# NOTE: This path is overridden by a unique one and cleaned up
+# afterwards when run under regrtest via Lib/test/test_bsddb3.py.
 get_new_path.prefix="/tmp/z-Berkeley_DB"
 get_new_path.num=0
 
@@ -97,7 +99,7 @@
 test_all.verbose = verbose
 
 
-def suite():
+def suite(module_prefix='', timing_check=None):
     try:
         # this is special, it used to segfault the interpreter
         import test_1413192
@@ -107,14 +109,14 @@
     test_modules = [
         'test_associate',
         'test_basics',
-        'test_compat',
         'test_compare',
+        'test_compat',
+        'test_cursor_pget_bug',
         'test_dbobj',
         'test_dbshelve',
         'test_dbtables',
-        'test_early_close',
         'test_distributed_transactions',
-        'test_replication',
+        'test_early_close',
         'test_get_none',
         'test_join',
         'test_lock',
@@ -122,15 +124,21 @@
         'test_pickle',
         'test_queue',
         'test_recno',
-        'test_thread',
+        'test_replication',
         'test_sequence',
-        'test_cursor_pget_bug',
+        'test_thread',
         ]
 
     alltests = unittest.TestSuite()
     for name in test_modules:
-        module = __import__(name)
+        #module = __import__(name)
+        # Do it this way so that suite may be called externally via
+        # python's Lib/test/test_bsddb3.
+        module = __import__(module_prefix+name, globals(), locals(), name)
+
         alltests.addTest(module.test_suite())
+        if timing_check:
+            alltests.addTest(unittest.makeSuite(timing_check))
     return alltests
 
 

Modified: python/trunk/Lib/test/test_bsddb3.py
==============================================================================
--- python/trunk/Lib/test/test_bsddb3.py	(original)
+++ python/trunk/Lib/test/test_bsddb3.py	Sun May 25 09:14:09 2008
@@ -48,61 +48,29 @@
             sys.__stdout__.flush()
 
 
-def suite():
-    test_modules = [
-        'test_associate',
-        'test_basics',
-        'test_compare',
-        'test_compat',
-        'test_cursor_pget_bug',
-        'test_dbobj',
-        'test_dbshelve',
-        'test_dbtables',
-        'test_distributed_transactions',
-        'test_early_close',
-        'test_get_none',
-        'test_join',
-        'test_lock',
-        'test_misc',
-        'test_pickle',
-        'test_queue',
-        'test_recno',
-        'test_replication',
-        'test_sequence',
-        'test_thread',
-        ]
-
-    alltests = unittest.TestSuite()
-    for name in test_modules:
-        module = __import__("bsddb.test."+name, globals(), locals(), name)
-        #print module,name
-        alltests.addTest(module.test_suite())
-        alltests.addTest(unittest.makeSuite(TimingCheck))
-    return alltests
-
-
 # For invocation through regrtest
 def test_main():
-    run_unittest(suite())
-    db_home = os.path.join(tempfile.gettempdir(), 'db_home')
-    # The only reason to remove db_home is in case if there is an old
-    # one lying around.  This might be by a different user, so just
-    # ignore errors.  We should always make a unique name now.
+    from bsddb import db
+    from bsddb.test import test_all
+    test_all.get_new_path.prefix = os.path.join(tempfile.gettempdir(),
+                                                'z-test_bsddb3-%s' %
+                                                 os.getpid())
+    # Please leave this print in, having this show up in the buildbots
+    # makes diagnosing problems a lot easier.
+    print >>sys.stderr, db.DB_VERSION_STRING
+    print >>sys.stderr, 'Test path prefix:  ', test_all.get_new_path.prefix
     try:
-        rmtree(db_home)
-    except:
-        pass
-    rmtree('db_home%d' % os.getpid())
+        run_unittest(test_all.suite(module_prefix='bsddb.test.',
+                                    timing_check=TimingCheck))
+    finally:
+        # The only reason to remove db_home is in case if there is an old
+        # one lying around.  This might be by a different user, so just
+        # ignore errors.  We should always make a unique name now.
+        try:
+            rmtree(test_all.get_new_path.prefix)
+        except:
+            pass
 
-# For invocation as a script
-if __name__ == '__main__':
-    from bsddb import db
-    print '-=' * 38
-    print db.DB_VERSION_STRING
-    print 'bsddb.db.version():   %s' % (db.version(),)
-    print 'bsddb.db.__version__: %s' % db.__version__
-    print 'bsddb.db.cvsid:       %s' % db.cvsid
-    print 'python version:        %s' % sys.version
-    print '-=' * 38
 
+if __name__ == '__main__':
     test_main()


More information about the Python-checkins mailing list