[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/tests - testSplitter.py:1.4.16.1 testTextIndex.py:1.3.16.1 framework.py:NONE

Tres Seaver tseaver@zope.com
Sat, 13 Oct 2001 16:23:51 -0400


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv23103/TextIndex/tests

Modified Files:
      Tag: tseaver-pxtestcleanup-branch
	testSplitter.py testTextIndex.py 
Removed Files:
      Tag: tseaver-pxtestcleanup-branch
	framework.py 
Log Message:


 - Refactored tests into subdirectories under their respective packages.

 - Removed dependency of tests on 'execfile( "framework.py" )'

 - TextIndex/TextIndex.py: replaced corrected use of 'insintance', rather
   than using 'type'.

 - Ensured that tests which need to catch logged errors don't leave
   the logger in a hosed state.


=== Zope/lib/python/Products/PluginIndexes/TextIndex/tests/testSplitter.py 1.4 => 1.4.16.1 ===
 
 import os,sys
-execfile(os.path.join(sys.path[0],'framework.py'))
 
 import unittest,locale
 from Products.PluginIndexes.TextIndex import Splitter


=== Zope/lib/python/Products/PluginIndexes/TextIndex/tests/testTextIndex.py 1.3 => 1.3.16.1 ===
 ##############################################################################
 
-import sys, os
-execfile(os.path.join(sys.path[0],'framework.py'))
+import sys, os, unittest
 import zLOG
 
 def log_write(subsystem, severity, summary, detail, error):
     if severity >= zLOG.PROBLEM:
         assert 0, "%s(%s): %s" % (subsystem, severity, summary)
 
-zLOG.log_write=log_write
 
 import ZODB, ZODB.DemoStorage, ZODB.FileStorage
-import TextIndex
-import GlobbingLexicon
+from Products.PluginIndexes.TextIndex import TextIndex
+from Products.PluginIndexes.TextIndex import GlobbingLexicon
+
+class Dummy:
+
+    def __init__( self, text ):
+        self._text = text
+
+    def text( self ):
+        return self._text
+    
+    def __str__( self ):
+        return '<Dummy: %s>' % self._text
+    
+    __repr__ = __str__
 
 class Tests(unittest.TestCase):
 
    def setUp(self):
        self.index=TextIndex.TextIndex('text')
        self.doc=Dummy(text='this is the time, when all good zopes')
+       self.old_log_write = zLOG.log_write
+       zLOG.log_write=log_write
+
 
    def dbopen(self):
        n = 'fs_tmp__%s' % os.getpid()
@@ -124,6 +138,7 @@
        if hasattr(self, 'jar'):
            self.dbclose()
            os.system('rm -f fs_tmp__*')
+       zLOG.log_write=self.old_log_write
 
    def checkSimpleAddDelete(self):
        "Check that we can add and delete an object without error"

=== Removed File Zope/lib/python/Products/PluginIndexes/TextIndex/tests/framework.py ===