[Zope-Checkins] CVS: Packages/SearchIndex/tests - testUnKeywordIndex.py:1.9.130.1 testUnTextIndex.py:1.13.68.1.34.1 test_UnIndex.py:1.8.130.1

Tres Seaver tseaver at palladion.com
Sat May 28 20:42:16 EDT 2005


Update of /cvs-repository/Packages/SearchIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/SearchIndex/tests

Modified Files:
      Tag: tseaver-hasattr_geddon-branch
	testUnKeywordIndex.py testUnTextIndex.py test_UnIndex.py 
Log Message:

  - Removed all uses of the 'hasattr' builtin from the core, where
    the object being tested derives (or might) from Persistent.
    XXX:  currently, this branch imports a 'safe_hasattr' from ZODB.utils,
    which adds a dependency on ZODB for some packages;  we probably
    need a better location, and perhas a C implementation?


=== Packages/SearchIndex/tests/testUnKeywordIndex.py 1.9 => 1.9.130.1 ===
--- Packages/SearchIndex/tests/testUnKeywordIndex.py:1.9	Wed Aug 14 17:46:24 2002
+++ Packages/SearchIndex/tests/testUnKeywordIndex.py	Sat May 28 20:41:35 2005
@@ -13,6 +13,7 @@
 import unittest
 
 import ZODB
+from ZODB.utils import safe_hasattr
 from SearchIndex.UnKeywordIndex import UnKeywordIndex
 
 class Dummy:
@@ -69,7 +70,8 @@
           '%s | %s' % ( map( None, result ),
                         map(lambda x: x[0], expectedValues ))
 
-        if hasattr(result, 'keys'): result=result.keys()
+        if safe_hasattr(result, 'keys'):
+            result=result.keys()
         for k, v in expectedValues:
             assert k in result
 


=== Packages/SearchIndex/tests/testUnTextIndex.py 1.13.68.1 => 1.13.68.1.34.1 ===
--- Packages/SearchIndex/tests/testUnTextIndex.py:1.13.68.1	Thu Jul 24 15:31:20 2003
+++ Packages/SearchIndex/tests/testUnTextIndex.py	Sat May 28 20:41:35 2005
@@ -17,6 +17,7 @@
 
 import SearchIndex.UnTextIndex
 import SearchIndex.GlobbingLexicon
+from ZODB.utils import safe_hasattr
 
 class Dummy:
 
@@ -45,7 +46,7 @@
 
     def tearDown(self):
         get_transaction().abort()
-        if hasattr(self, 'jar'):
+        if safe_hasattr(self, 'jar'):
             self.dbclose()
             cleanDB()
         self.__dict__.clear()


=== Packages/SearchIndex/tests/test_UnIndex.py 1.8 => 1.8.130.1 ===
--- Packages/SearchIndex/tests/test_UnIndex.py:1.8	Wed Aug 14 17:46:24 2002
+++ Packages/SearchIndex/tests/test_UnIndex.py	Sat May 28 20:41:35 2005
@@ -14,6 +14,7 @@
 import unittest
 
 import ZODB
+from ZODB.utils import safe_hasattr
 from SearchIndex.UnIndex import UnIndex
 
 class Dummy:
@@ -80,7 +81,7 @@
 
     def _checkApply( self, req, expectedValues ):
         result, used = self._index._apply_index( req )
-        if hasattr(result, 'keys'):
+        if safe_hasattr(result, 'keys'):
             result = result.keys()
         assert used == ( 'foo', )
         assert len( result ) == len( expectedValues ), \



More information about the Zope-Checkins mailing list