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

Modified Files:
      Tag: tseaver-hasattr_geddon-branch
        PackableStorage.py StorageTestBase.py testPersistentMapping.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/ZODB/tests/PackableStorage.py 1.20.6.3 => 1.20.6.3.26.1 ===
--- Packages/ZODB/tests/PackableStorage.py:1.20.6.3     Fri Jan 16 14:17:51 2004
+++ Packages/ZODB/tests/PackableStorage.py      Sat May 28 20:41:37 2005
@@ -35,6 +35,7 @@
 from ZODB.tests.StorageTestBase import snooze
 from ZODB.POSException import ConflictError, StorageError
 from ZODB.PersistentMapping import PersistentMapping
+from ZODB.utils import safe_hasattr
 
 ZERO = '\0'*8
 
@@ -77,7 +78,7 @@
 # Fun, huh?
 def dumps(obj):
     def getpersid(obj):
-        if hasattr(obj, 'getoid'):
+        if safe_hasattr(obj, 'getoid'):
             return obj.getoid()
         return None
     s = StringIO()


=== Packages/ZODB/tests/StorageTestBase.py 1.27.6.1 => 1.27.6.1.36.1 ===
--- Packages/ZODB/tests/StorageTestBase.py:1.27.6.1     Mon Sep 15 17:26:57 2003
+++ Packages/ZODB/tests/StorageTestBase.py      Sat May 28 20:41:37 2005
@@ -32,6 +32,7 @@
 
 from ZODB.Transaction import Transaction
 from ZODB.utils import u64
+from ZODB.utils import safe_hasattr
 
 from ZODB.tests.MinPO import MinPO
 
@@ -52,7 +53,8 @@
     p = Pickler(f, 1)
     p.persistent_id = lambda obj: getattr(obj, '_p_oid', None)
     klass = obj.__class__
-    assert not hasattr(obj, '__getinitargs__'), "not ready for constructors"
+    assert not safe_hasattr(obj,
+                            '__getinitargs__'), "not ready for constructors"
     args = None
 
     mod = getattr(klass, '__module__', None)


=== Packages/ZODB/tests/testPersistentMapping.py 1.5.34.1 => 1.5.34.1.36.1 ===
--- Packages/ZODB/tests/testPersistentMapping.py:1.5.34.1       Mon Sep 15 
17:26:57 2003
+++ Packages/ZODB/tests/testPersistentMapping.py        Sat May 28 20:41:37 2005
@@ -25,6 +25,7 @@
 import ZODB
 from ZODB.MappingStorage import MappingStorage
 from ZODB.Transaction import Transaction
+from ZODB.utils import safe_hasattr
 import cPickle
 import cStringIO
 import sys
@@ -49,8 +50,8 @@
         # If the root can be loaded successfully, we should be okay.
         r = db.open().root()
         # But make sure it looks like a new mapping
-        self.assert_(hasattr(r, 'data'))
-        self.assert_(not hasattr(r, '_container'))
+        self.assert_(safe_hasattr(r, 'data'))
+        self.assert_(not safe_hasattr(r, '_container'))
 
     def checkNewPicklesAreSafe(self):
         s = MappingStorage()
@@ -71,8 +72,8 @@
         state = u.load()
         inst.__setstate__(state)
 
-        self.assert_(hasattr(inst, '_container'))
-        self.assert_(not hasattr(inst, 'data'))
+        self.assert_(safe_hasattr(inst, '_container'))
+        self.assert_(not safe_hasattr(inst, 'data'))
 
 def find_global(modulename, classname):
     """Helper for this test suite to get special PersistentMapping"""

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to