[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope-cvs
Subject:    [Zope-Checkins] CVS: Packages/ZODB/tests - testCache.py:1.13.10.8
From:       Tim Peters <tim.one () comcast ! net>
Date:       2005-02-24 19:59:04
Message-ID: 20050224195904.BA943203357 () mail ! zope ! org
[Download RAW message or body]

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

Modified Files:
      Tag: Zope-2_7-branch
	testCache.py 
Log Message:
Change the exception raised when an attempt is made to add two objects to
the cache with the same oid.  The former messsage didn't make sense.

Add a test to verify that this exception does get raised, and that the
message given is the intended one.

This is the first of a series of checkins, to fix critical bugs where
ZODB can in fact raise this exception in rare, but normal, use cases.


=== Packages/ZODB/tests/testCache.py 1.13.10.7 => 1.13.10.8 ===
--- Packages/ZODB/tests/testCache.py:1.13.10.7	Mon Jun  7 18:46:47 2004
+++ Packages/ZODB/tests/testCache.py	Thu Feb 24 14:59:04 2005
@@ -369,6 +369,28 @@
         else:
             self.fail("expect that you can't delete jar of cached object")
 
+    def checkTwoObjsSameOid(self):
+        # Try to add two distinct objects with the same oid to the cache.
+        # This has always been an error, but the error message prior to
+        # ZODB 3.2.6 didn't make sense.  This test verifies that (a) an
+        # exception is raised; and, (b) the error message is the intended
+        # one.
+        obj1 = StubObject()
+        key = obj1._p_oid = p64(1)
+        obj1._p_jar = self.jar
+        self.cache[key] = obj1
+
+        obj2 = StubObject()
+        obj2._p_oid = key
+        obj2._p_jar = self.jar
+        try:
+            self.cache[key] = obj2
+        except ValueError, detail:
+            self.assertEqual(str(detail),
+                             "A different object already has the same oid")
+        else:
+            self.fail("two objects with the same oid should have failed")
+
 def test_suite():
     s = unittest.makeSuite(DBMethods, 'check')
     s.addTest(unittest.makeSuite(LRUCacheTests, 'check'))

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic