[Zope-Checkins] CVS: Zope2 - testCatalog.py:1.1.4.6

Andreas Jung andreas@dhcp165.digicool.com
Tue, 13 Mar 2001 09:37:42 -0500


Update of /mnt/cvs-repository/Zope2/lib/python/Products/ZCatalog/tests
In directory yetix:/work/Zope2/Catalog-BTrees-Integration/lib/python/Products/ZCatalog/tests

Modified Files:
      Tag: Catalog-BTrees-Integration
	testCatalog.py 
Log Message:
prelimary version for integration into the Zope testsuites



--- Updated File testCatalog.py in package test --
--- testCatalog.py	2001/03/11 22:33:40	1.1.4.5
+++ testCatalog.py	2001/03/13 14:37:40	1.1.4.6
@@ -7,6 +7,9 @@
     Andreas Jung, andreas@digicool.com
     
     $Log$
+    Revision 1.1.4.6  2001/03/13 14:37:40  andreas
+    prelimary version for integration into the Zope testsuites
+
     Revision 1.1.4.5  2001/03/11 22:33:40  andreas
     commit
 
@@ -68,8 +71,8 @@
 from SearchIndex.UnKeywordIndex import UnKeywordIndex
 from SearchIndex.Lexicon import Lexicon
 
-import getopt,whrandom,thread,time,string,mailbox,rfc822
-from Testing.unittest import TestCase, TestSuite, TextTestRunner,makeSuite
+import getopt,whrandom,time,string,mailbox,rfc822
+from Testing import unittest
 
 
 # maximum number of files to read for the test suite
@@ -86,10 +89,13 @@
 updateIterations = 100
 
 # input mailbox file
-mbox   = "/usr/home/andreas/zope.mbox"
+mbox   = os.environ.get("TESTCATALOG_MBOX","/usr/home/andreas/zope.mbox")
 mbox2  = "/usr/home/andreas/python.mbox"
 
 
+dataDir = ""
+
+
 #
 # Don't change anything below
 #
@@ -121,13 +127,14 @@
 
         
         
-class testCatalog(Persistence.Persistent,TestCase):
+class testCatalog(Persistence.Persistent,unittest.TestCase):
     """ Wrapper around the catalog stuff """
 
-    def __init__(self,mboxname):
+    def __init__(self,mboxname,maxfiles):
         self.msg_ids = []
         self.num_files = 0
         self.keywords = []
+        self.maxfiles = maxfiles
         
         self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary', globbing=1)
         self._catalog    = Catalog.Catalog()
@@ -151,7 +158,7 @@
         i = 0
 
         msg = mb.next()
-        while msg and self.num_files<maxFiles:
+        while msg and self.num_files<self.maxfiles:
             self.catMessage(msg)
             self.msg_ids.append(msg.dict["message-id"])
 
@@ -167,7 +174,6 @@
         
 
     def catMessage(self,m):
-        print m.dict["message-id"]
         self._catalog.catalogObject( testMessage(m) , m.dict["message-id"] )
         
     def uncatMessage(self,uid):
@@ -176,7 +182,7 @@
             
 class testMessage(ExtensionClass.Base):
 
-    def __init__(self,msg):
+    def __init__(self,msg,modify_doc=0):
 
         self.sender  = msg.dict.get("from","")
         self.subject = msg.dict.get("subject","")
@@ -184,6 +190,10 @@
         self.content = str(msg)
         self.keywords= string.split(self.subject , " ")
 
+        if modify_doc !=0:
+            self.keywords = map(self.reverse,self.keywords)
+            
+
         self.file_id = msg.dict.get("message-id","")
    
         self.length  = len(str(msg))
@@ -191,17 +201,24 @@
         try:
             self.date    =  time.mktime(rfc822.parsedate(date)[:9])
         except: pass  
+
+    def reverse(self,s):
+        l = list(s)
+        l.reverse()
+        return string.join(l,"")
         
+
+        
     def __del__(self):
        pass 
 
-class BuildEnv(dispatcher.Dispatcher,TestCase):
+class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
     """ build environment """        
 
-    def __init__(self,func):
+    def __init__(self,func,*args,**kw):
 
-        TestCase.__init__(self,func)
-        dispatcher.Dispatcher.__init__(self)
+        unittest.TestCase.__init__(self,func,args,kw)
+        dispatcher.Dispatcher.__init__(self,func)
 
         self.init_phase = 0
 
@@ -214,12 +231,12 @@
     #############################################################        
 
         
-    def buildTestEnvironment(self,*args):
+    def buildTestEnvironment(self,args,kw):
         self.init_phase = 1
-        self.dispatcher("funcTestEnvironment",("funcTestEnvironment",1,(),{}))
+        self.dispatcher("funcTestEnvironment",("funcTestEnvironment",1,args,kw))
 
 
-    def funcTestEnvironment(self,*args):
+    def funcTestEnvironment(self,dataDir,maxFiles):
 
         env = self.th_setup()
 
@@ -229,7 +246,7 @@
         zodb = testZODB("%s/Data_orig.fs" % dataDir)
             
         print "parsing and reading mailbox file %s....please wait" % mbox
-        tc = testCatalog( mbox )
+        tc = testCatalog( mbox,maxFiles )
             
         print "writing Catalog to ZODB"
         zodb.write("catalog" , tc)
@@ -245,13 +262,13 @@
         self.th_teardown(env)
 
         
-class testSearches(dispatcher.Dispatcher,TestCase):
+class testSearches(dispatcher.Dispatcher,unittest.TestCase):
     """ test searches """
 
     def __init__(self,func,*args,**kw):
 
-        TestCase.__init__(self,func,args,kw) 
-        dispatcher.Dispatcher.__init__(self)
+        unittest.TestCase.__init__(self,func,args,kw) 
+        dispatcher.Dispatcher.__init__(self,func)
 
         self.init_phase = 0
 
@@ -261,12 +278,12 @@
         
 
     def setUp(self):
+
         os.system("rm -fr data/work")
         if not os.path.exists("data/work"): os.makedirs("data/work")
         assert os.system("cp %s/Data_orig.fs data/work/Data.fs" % dataDir)==0, "Error while replicating original data"
         
-        self.zodb 	 	= testZODB("data/work/Data.fs")
-        self.catalog	= self.zodb.read("catalog")
+        self.zodb 	 	= testZODB("data/work/Data.fs",open=0)
         self.threads    = {} 
         self.conflicts  = {}
 
@@ -446,11 +463,14 @@
         msgs = self.setupUpdatesMethod(kw["numUpdates"])
         keys = msgs.keys()
 
+        rdgen = whrandom.whrandom()
+        rdgen.seed(int(time.time()) % 256,int(time.time()) % 256,int(time.time()) % 256)
+
         env = self.th_setup()
 
         for i in range(len(keys)):
 
-            r = whrandom.randint(0,len(msgs)-1)
+            r = rdgen.randint(0,len(msgs)-1)
 
             mid = keys[r]
             obj = msgs[mid]
@@ -458,14 +478,18 @@
 
             try:
                 cat.uncatalogObject(mid)
-                cat.catalogObject(obj,mid)
 
                 if kw.get("commit",1)==1:
                     get_transaction().commit()            
                     time.sleep(0.1)
 
+                cat.catalogObject(obj,mid)
+                if kw.get("commit",1)==1:
+                    get_transaction().commit()            
+                    time.sleep(0.1)
+
             except ZODB.POSException.ConflictError:
-#                print sys.exc_type,sys.exc_value
+                print sys.exc_type,sys.exc_value
                 conflicts = conflicts + 1
 
         try:
@@ -511,8 +535,12 @@
         """ test reindexing of existing data """
         self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000) , {} ))
 
+    def testReindexingAndModify(self,args,kw):
+        """ test reindexing of existing data but with modifications"""
+        self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000,1) , {} ))
+
 
-    def funcReindexing(self,mbox,numfiles=100):
+    def funcReindexing(self,mbox,numfiles=100,modify_doc=0):
         """ test reindexing of existing data """
 
         conflicts = 0
@@ -526,7 +554,7 @@
         msg = mb.next()
         while msg and i<numfiles:
 
-            obj = testMessage(msg)
+            obj = testMessage(msg,modify_doc)
             mid = msg.dict["message-id"]
 
             try:
@@ -557,14 +585,10 @@
         # depended we are running in multithreaded mode we must take
         # care how threads open the ZODB
 
-        if thread.get_ident()==mainThreadID:
-            cat = self.catalog._catalog
-            msg_ids = self.catalog.msg_ids
-        else:
-            connection  = self.zodb.db.open()
-            root        = connection.root()
-            cat	        = root["catalog"]._catalog
-            msg_ids     = root['catalog'].msg_ids
+        connection  = self.zodb.db.open()
+        root        = connection.root()
+        cat	        = root["catalog"]._catalog
+        msg_ids     = root['catalog'].msg_ids
 
         return cat,msg_ids
 
@@ -582,7 +606,7 @@
     def tearDown(self):
         self._vocabulary = self._catalog = None
 
-class TestAddDelColumn(CatalogBase, TestCase):
+class TestAddDelColumn(CatalogBase, unittest.TestCase):
     def checkAdd(self):
         self._catalog.addColumn('id')
         assert self._catalog.schema.has_key('id') == 1, 'add column failed'
@@ -600,7 +624,7 @@
         self._catalog.delColumn('id')
         assert self._catalog.schema.has_key('id') != 1, 'del column failed'
 
-class TestAddDelIndexes(CatalogBase, TestCase):
+class TestAddDelIndexes(CatalogBase, unittest.TestCase):
     def checkAddFieldIndex(self):
         self._catalog.addIndex('id', 'FieldIndex')
         assert type(self._catalog.indexes['id']) is type(UnIndex('id')),\
@@ -632,11 +656,11 @@
         self._catalog.delIndex('id')
         assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
 
-class TestSimultaneousAddAndRead(CatalogBase, TestCase):
+class TestSimultaneousAddAndRead(CatalogBase, unittest.TestCase):
     def checkMultiThread(self):
         pass
 
-class TestZCatalogObject(TestCase):
+class TestZCatalogObject(unittest.TestCase):
     def checkInstantiateWithoutVocab(self):
         v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
         zc = ZCatalog.ZCatalog('acatalog')
@@ -655,7 +679,7 @@
         zc._setObject('vocab', v)
         assert zc.getVocabulary() == v
 
-class TestCatalogObject(TestCase):
+class TestCatalogObject(unittest.TestCase):
     def setUp(self):
         self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary',
                                                  globbing=1)
@@ -750,30 +774,20 @@
         for x in range(0, self.upper):
             self._catalog.uncatalogObject(`x`)
 
-# environment
-
-
-
-
-    
 
-
-
 def usage(program):
     print "Usage: "
     print
     print "initalize the test catalog:   %s -i -f <maximum number files to use> " % program
     print "to run the basic tests:       %s -b -f <maximum number files to use> " % program
     print "to run the advanced tests:    %s -a -f <maximum number files to use> " % program
-
                 
-if __name__ == '__main__':
 
-#    sys.setcheckinterval(-1)
+def main():
 
-    mainThreadID = thread.get_ident()
+    global dataDir
 
-    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:x",['help'])
+    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:xp",['help'])
     opts.sort()
 
     optsLst = map(lambda x: x[0],opts)
@@ -789,12 +803,12 @@
 
     if '-i' in optsLst:
 
-        tests = [ BuildEnv("buildTestEnvironment") ]
+        tests = [ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ]
 
-        testsuite = TestSuite()
+        testsuite = unittest.TestSuite()
         for x in tests: testsuite.addTest(x)
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite)
 
         sys.exit(0)
@@ -803,14 +817,14 @@
     if '-b' in optsLst:
 
         # Chris' tests
-        s1 = makeSuite(TestAddDelIndexes, 'check')
-        s2 = makeSuite(TestCatalogObject, 'check')
-        s3 = makeSuite(TestAddDelColumn, 'check')
-        s4 = makeSuite(TestZCatalogObject, 'check')
+        s1 = unittest.makeSuite(TestAddDelIndexes, 'check')
+        s2 = unittest.makeSuite(TestCatalogObject, 'check')
+        s3 = unittest.makeSuite(TestAddDelColumn, 'check')
+        s4 = unittest.makeSuite(TestZCatalogObject, 'check')
     
-        testsuite = TestSuite((s1,s2,s3,s4,))
+        testsuite = unittest.TestSuite((s1,s2,s3,s4,))
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite)
 
         # andreas' tests
@@ -828,10 +842,10 @@
              testSearches("testKeywordRangeIndex",numThreads=4)
         ]
 
-        testsuite1 = TestSuite()
+        testsuite1 = unittest.TestSuite()
         for x in basic_tests: testsuite1.addTest(x)
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite1)
 
     if '-a' in optsLst:
@@ -852,10 +866,9 @@
     if '-x' in optsLst:
 
         basic_tests = [
-            testSearches("testUpdates",numThreads=1,numUpdates=100),
-            testSearches("testUpdates",numThreads=1,numUpdates=100,commit=0),
-            testSearches("testUpdates",numThreads=2,numUpdates=100),
-            testSearches("testUpdates",numThreads=2,numUpdates=100,commit=0),
+#           testSearches("testReindexing",numThreads=1),
+#           testSearches("testReindexingAndModify",numThreads=1),
+            testSearches("testUpdates",numThreads=10,numUpdates=100),
         ]
 
         testsuite1 = TestSuite()
@@ -863,4 +876,55 @@
 
         runner = TextTestRunner()
         runner.run(testsuite1)
+
+    if '-p' in optsLst:
+        unittest.TextTestRunner().run(test_suite())
+
+def test_suite():
+
+    return get_tests('basic')
+
+
+def get_tests(what):
+
+    maxFiles = 100
+    dataDir = 'data/%d' % maxFiles
+
+    ts_cm= (
+         unittest.makeSuite(TestAddDelIndexes,  'check'),
+         unittest.makeSuite(TestCatalogObject,  'check'),
+         unittest.makeSuite(TestAddDelColumn,   'check'),
+         unittest.makeSuite(TestZCatalogObject, 'check')
+    )
+
+    t_aj = (
+         BuildEnv('buildTestEnvironment',dataDir,maxFiles),
+         testSearches("testFulltextIndex",numThreads=1),
+         testSearches("testFieldIndex",numThreads= 1),
+         testSearches("testFieldRangeIndex",numThreads=1),
+         testSearches("testKeywordIndex",numThreads= 1),
+         testSearches("testKeywordRangeIndex",numThreads= 1)
+    )
+
+    if what=='basic':    
+        ts = unittest.TestSuite(ts_cm)
+        for x in t_aj: ts.addTest(x)
+        return ts
+
+
+
+def pdebug():
+    import pdb
+    test_suite()
+
+def debug():
+   test_suite().debug()
+ 
+def pdebug():
+    import pdb
+    pdb.run('debug()')
+
+
+if __name__ == '__main__':
+       main()
 



--- Updated File testCatalog.py in package Zope2 --
--- testCatalog.py	2001/03/11 22:33:40	1.1.4.5
+++ testCatalog.py	2001/03/13 14:37:40	1.1.4.6
@@ -7,6 +7,9 @@
     Andreas Jung, andreas@digicool.com
     
     $Log$
+    Revision 1.1.4.6  2001/03/13 14:37:40  andreas
+    prelimary version for integration into the Zope testsuites
+
     Revision 1.1.4.5  2001/03/11 22:33:40  andreas
     commit
 
@@ -68,8 +71,8 @@
 from SearchIndex.UnKeywordIndex import UnKeywordIndex
 from SearchIndex.Lexicon import Lexicon
 
-import getopt,whrandom,thread,time,string,mailbox,rfc822
-from Testing.unittest import TestCase, TestSuite, TextTestRunner,makeSuite
+import getopt,whrandom,time,string,mailbox,rfc822
+from Testing import unittest
 
 
 # maximum number of files to read for the test suite
@@ -86,10 +89,13 @@
 updateIterations = 100
 
 # input mailbox file
-mbox   = "/usr/home/andreas/zope.mbox"
+mbox   = os.environ.get("TESTCATALOG_MBOX","/usr/home/andreas/zope.mbox")
 mbox2  = "/usr/home/andreas/python.mbox"
 
 
+dataDir = ""
+
+
 #
 # Don't change anything below
 #
@@ -121,13 +127,14 @@
 
         
         
-class testCatalog(Persistence.Persistent,TestCase):
+class testCatalog(Persistence.Persistent,unittest.TestCase):
     """ Wrapper around the catalog stuff """
 
-    def __init__(self,mboxname):
+    def __init__(self,mboxname,maxfiles):
         self.msg_ids = []
         self.num_files = 0
         self.keywords = []
+        self.maxfiles = maxfiles
         
         self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary', globbing=1)
         self._catalog    = Catalog.Catalog()
@@ -151,7 +158,7 @@
         i = 0
 
         msg = mb.next()
-        while msg and self.num_files<maxFiles:
+        while msg and self.num_files<self.maxfiles:
             self.catMessage(msg)
             self.msg_ids.append(msg.dict["message-id"])
 
@@ -167,7 +174,6 @@
         
 
     def catMessage(self,m):
-        print m.dict["message-id"]
         self._catalog.catalogObject( testMessage(m) , m.dict["message-id"] )
         
     def uncatMessage(self,uid):
@@ -176,7 +182,7 @@
             
 class testMessage(ExtensionClass.Base):
 
-    def __init__(self,msg):
+    def __init__(self,msg,modify_doc=0):
 
         self.sender  = msg.dict.get("from","")
         self.subject = msg.dict.get("subject","")
@@ -184,6 +190,10 @@
         self.content = str(msg)
         self.keywords= string.split(self.subject , " ")
 
+        if modify_doc !=0:
+            self.keywords = map(self.reverse,self.keywords)
+            
+
         self.file_id = msg.dict.get("message-id","")
    
         self.length  = len(str(msg))
@@ -191,17 +201,24 @@
         try:
             self.date    =  time.mktime(rfc822.parsedate(date)[:9])
         except: pass  
+
+    def reverse(self,s):
+        l = list(s)
+        l.reverse()
+        return string.join(l,"")
         
+
+        
     def __del__(self):
        pass 
 
-class BuildEnv(dispatcher.Dispatcher,TestCase):
+class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
     """ build environment """        
 
-    def __init__(self,func):
+    def __init__(self,func,*args,**kw):
 
-        TestCase.__init__(self,func)
-        dispatcher.Dispatcher.__init__(self)
+        unittest.TestCase.__init__(self,func,args,kw)
+        dispatcher.Dispatcher.__init__(self,func)
 
         self.init_phase = 0
 
@@ -214,12 +231,12 @@
     #############################################################        
 
         
-    def buildTestEnvironment(self,*args):
+    def buildTestEnvironment(self,args,kw):
         self.init_phase = 1
-        self.dispatcher("funcTestEnvironment",("funcTestEnvironment",1,(),{}))
+        self.dispatcher("funcTestEnvironment",("funcTestEnvironment",1,args,kw))
 
 
-    def funcTestEnvironment(self,*args):
+    def funcTestEnvironment(self,dataDir,maxFiles):
 
         env = self.th_setup()
 
@@ -229,7 +246,7 @@
         zodb = testZODB("%s/Data_orig.fs" % dataDir)
             
         print "parsing and reading mailbox file %s....please wait" % mbox
-        tc = testCatalog( mbox )
+        tc = testCatalog( mbox,maxFiles )
             
         print "writing Catalog to ZODB"
         zodb.write("catalog" , tc)
@@ -245,13 +262,13 @@
         self.th_teardown(env)
 
         
-class testSearches(dispatcher.Dispatcher,TestCase):
+class testSearches(dispatcher.Dispatcher,unittest.TestCase):
     """ test searches """
 
     def __init__(self,func,*args,**kw):
 
-        TestCase.__init__(self,func,args,kw) 
-        dispatcher.Dispatcher.__init__(self)
+        unittest.TestCase.__init__(self,func,args,kw) 
+        dispatcher.Dispatcher.__init__(self,func)
 
         self.init_phase = 0
 
@@ -261,12 +278,12 @@
         
 
     def setUp(self):
+
         os.system("rm -fr data/work")
         if not os.path.exists("data/work"): os.makedirs("data/work")
         assert os.system("cp %s/Data_orig.fs data/work/Data.fs" % dataDir)==0, "Error while replicating original data"
         
-        self.zodb 	 	= testZODB("data/work/Data.fs")
-        self.catalog	= self.zodb.read("catalog")
+        self.zodb 	 	= testZODB("data/work/Data.fs",open=0)
         self.threads    = {} 
         self.conflicts  = {}
 
@@ -446,11 +463,14 @@
         msgs = self.setupUpdatesMethod(kw["numUpdates"])
         keys = msgs.keys()
 
+        rdgen = whrandom.whrandom()
+        rdgen.seed(int(time.time()) % 256,int(time.time()) % 256,int(time.time()) % 256)
+
         env = self.th_setup()
 
         for i in range(len(keys)):
 
-            r = whrandom.randint(0,len(msgs)-1)
+            r = rdgen.randint(0,len(msgs)-1)
 
             mid = keys[r]
             obj = msgs[mid]
@@ -458,14 +478,18 @@
 
             try:
                 cat.uncatalogObject(mid)
-                cat.catalogObject(obj,mid)
 
                 if kw.get("commit",1)==1:
                     get_transaction().commit()            
                     time.sleep(0.1)
 
+                cat.catalogObject(obj,mid)
+                if kw.get("commit",1)==1:
+                    get_transaction().commit()            
+                    time.sleep(0.1)
+
             except ZODB.POSException.ConflictError:
-#                print sys.exc_type,sys.exc_value
+                print sys.exc_type,sys.exc_value
                 conflicts = conflicts + 1
 
         try:
@@ -511,8 +535,12 @@
         """ test reindexing of existing data """
         self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000) , {} ))
 
+    def testReindexingAndModify(self,args,kw):
+        """ test reindexing of existing data but with modifications"""
+        self.dispatcher("testReindexing" , ("funcReindexing",kw["numThreads"] , (mbox,1000,1) , {} ))
+
 
-    def funcReindexing(self,mbox,numfiles=100):
+    def funcReindexing(self,mbox,numfiles=100,modify_doc=0):
         """ test reindexing of existing data """
 
         conflicts = 0
@@ -526,7 +554,7 @@
         msg = mb.next()
         while msg and i<numfiles:
 
-            obj = testMessage(msg)
+            obj = testMessage(msg,modify_doc)
             mid = msg.dict["message-id"]
 
             try:
@@ -557,14 +585,10 @@
         # depended we are running in multithreaded mode we must take
         # care how threads open the ZODB
 
-        if thread.get_ident()==mainThreadID:
-            cat = self.catalog._catalog
-            msg_ids = self.catalog.msg_ids
-        else:
-            connection  = self.zodb.db.open()
-            root        = connection.root()
-            cat	        = root["catalog"]._catalog
-            msg_ids     = root['catalog'].msg_ids
+        connection  = self.zodb.db.open()
+        root        = connection.root()
+        cat	        = root["catalog"]._catalog
+        msg_ids     = root['catalog'].msg_ids
 
         return cat,msg_ids
 
@@ -582,7 +606,7 @@
     def tearDown(self):
         self._vocabulary = self._catalog = None
 
-class TestAddDelColumn(CatalogBase, TestCase):
+class TestAddDelColumn(CatalogBase, unittest.TestCase):
     def checkAdd(self):
         self._catalog.addColumn('id')
         assert self._catalog.schema.has_key('id') == 1, 'add column failed'
@@ -600,7 +624,7 @@
         self._catalog.delColumn('id')
         assert self._catalog.schema.has_key('id') != 1, 'del column failed'
 
-class TestAddDelIndexes(CatalogBase, TestCase):
+class TestAddDelIndexes(CatalogBase, unittest.TestCase):
     def checkAddFieldIndex(self):
         self._catalog.addIndex('id', 'FieldIndex')
         assert type(self._catalog.indexes['id']) is type(UnIndex('id')),\
@@ -632,11 +656,11 @@
         self._catalog.delIndex('id')
         assert self._catalog.indexes.has_key('id') != 1, 'del index failed'
 
-class TestSimultaneousAddAndRead(CatalogBase, TestCase):
+class TestSimultaneousAddAndRead(CatalogBase, unittest.TestCase):
     def checkMultiThread(self):
         pass
 
-class TestZCatalogObject(TestCase):
+class TestZCatalogObject(unittest.TestCase):
     def checkInstantiateWithoutVocab(self):
         v = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
         zc = ZCatalog.ZCatalog('acatalog')
@@ -655,7 +679,7 @@
         zc._setObject('vocab', v)
         assert zc.getVocabulary() == v
 
-class TestCatalogObject(TestCase):
+class TestCatalogObject(unittest.TestCase):
     def setUp(self):
         self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary',
                                                  globbing=1)
@@ -750,30 +774,20 @@
         for x in range(0, self.upper):
             self._catalog.uncatalogObject(`x`)
 
-# environment
-
-
-
-
-    
 
-
-
 def usage(program):
     print "Usage: "
     print
     print "initalize the test catalog:   %s -i -f <maximum number files to use> " % program
     print "to run the basic tests:       %s -b -f <maximum number files to use> " % program
     print "to run the advanced tests:    %s -a -f <maximum number files to use> " % program
-
                 
-if __name__ == '__main__':
 
-#    sys.setcheckinterval(-1)
+def main():
 
-    mainThreadID = thread.get_ident()
+    global dataDir
 
-    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:x",['help'])
+    opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:xp",['help'])
     opts.sort()
 
     optsLst = map(lambda x: x[0],opts)
@@ -789,12 +803,12 @@
 
     if '-i' in optsLst:
 
-        tests = [ BuildEnv("buildTestEnvironment") ]
+        tests = [ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ]
 
-        testsuite = TestSuite()
+        testsuite = unittest.TestSuite()
         for x in tests: testsuite.addTest(x)
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite)
 
         sys.exit(0)
@@ -803,14 +817,14 @@
     if '-b' in optsLst:
 
         # Chris' tests
-        s1 = makeSuite(TestAddDelIndexes, 'check')
-        s2 = makeSuite(TestCatalogObject, 'check')
-        s3 = makeSuite(TestAddDelColumn, 'check')
-        s4 = makeSuite(TestZCatalogObject, 'check')
+        s1 = unittest.makeSuite(TestAddDelIndexes, 'check')
+        s2 = unittest.makeSuite(TestCatalogObject, 'check')
+        s3 = unittest.makeSuite(TestAddDelColumn, 'check')
+        s4 = unittest.makeSuite(TestZCatalogObject, 'check')
     
-        testsuite = TestSuite((s1,s2,s3,s4,))
+        testsuite = unittest.TestSuite((s1,s2,s3,s4,))
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite)
 
         # andreas' tests
@@ -828,10 +842,10 @@
              testSearches("testKeywordRangeIndex",numThreads=4)
         ]
 
-        testsuite1 = TestSuite()
+        testsuite1 = unittest.TestSuite()
         for x in basic_tests: testsuite1.addTest(x)
 
-        runner = TextTestRunner()
+        runner = unittest.TextTestRunner()
         runner.run(testsuite1)
 
     if '-a' in optsLst:
@@ -852,10 +866,9 @@
     if '-x' in optsLst:
 
         basic_tests = [
-            testSearches("testUpdates",numThreads=1,numUpdates=100),
-            testSearches("testUpdates",numThreads=1,numUpdates=100,commit=0),
-            testSearches("testUpdates",numThreads=2,numUpdates=100),
-            testSearches("testUpdates",numThreads=2,numUpdates=100,commit=0),
+#           testSearches("testReindexing",numThreads=1),
+#           testSearches("testReindexingAndModify",numThreads=1),
+            testSearches("testUpdates",numThreads=10,numUpdates=100),
         ]
 
         testsuite1 = TestSuite()
@@ -863,4 +876,55 @@
 
         runner = TextTestRunner()
         runner.run(testsuite1)
+
+    if '-p' in optsLst:
+        unittest.TextTestRunner().run(test_suite())
+
+def test_suite():
+
+    return get_tests('basic')
+
+
+def get_tests(what):
+
+    maxFiles = 100
+    dataDir = 'data/%d' % maxFiles
+
+    ts_cm= (
+         unittest.makeSuite(TestAddDelIndexes,  'check'),
+         unittest.makeSuite(TestCatalogObject,  'check'),
+         unittest.makeSuite(TestAddDelColumn,   'check'),
+         unittest.makeSuite(TestZCatalogObject, 'check')
+    )
+
+    t_aj = (
+         BuildEnv('buildTestEnvironment',dataDir,maxFiles),
+         testSearches("testFulltextIndex",numThreads=1),
+         testSearches("testFieldIndex",numThreads= 1),
+         testSearches("testFieldRangeIndex",numThreads=1),
+         testSearches("testKeywordIndex",numThreads= 1),
+         testSearches("testKeywordRangeIndex",numThreads= 1)
+    )
+
+    if what=='basic':    
+        ts = unittest.TestSuite(ts_cm)
+        for x in t_aj: ts.addTest(x)
+        return ts
+
+
+
+def pdebug():
+    import pdb
+    test_suite()
+
+def debug():
+   test_suite().debug()
+ 
+def pdebug():
+    import pdb
+    pdb.run('debug()')
+
+
+if __name__ == '__main__':
+       main()