[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/interface/ merge r72239 from branches/3.3

Ross Patterson me at rpatterson.net
Sat Jan 27 18:09:40 EST 2007


Log message for revision 72240:
  merge r72239 from branches/3.3
  
  Add a test and a fix for a problem creating the persistent versions of
  declarations pointed out by Jim.
  
  Fix up a docstring format per feedback from Jim.
  

Changed:
  U   Zope3/trunk/src/zope/app/interface/__init__.py
  U   Zope3/trunk/src/zope/app/interface/tests/test_interface.py

-=-
Modified: Zope3/trunk/src/zope/app/interface/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/interface/__init__.py	2007-01-27 23:01:51 UTC (rev 72239)
+++ Zope3/trunk/src/zope/app/interface/__init__.py	2007-01-27 23:09:39 UTC (rev 72240)
@@ -81,7 +81,7 @@
         ProvidesClass.__init__(self, *args, **kw)
         self.dependents = DependentsDict()
 def persistentProvides(obj):
-    return PersistentProvidesClass(*obj.__reduce__()[1:])
+    return PersistentProvidesClass(*obj.__reduce__()[1])
 persistentFactories[Provides] = persistentProvides
 
 from zope.interface.declarations import Implements

Modified: Zope3/trunk/src/zope/app/interface/tests/test_interface.py
===================================================================
--- Zope3/trunk/src/zope/app/interface/tests/test_interface.py	2007-01-27 23:01:51 UTC (rev 72239)
+++ Zope3/trunk/src/zope/app/interface/tests/test_interface.py	2007-01-27 23:09:39 UTC (rev 72240)
@@ -111,9 +111,11 @@
         self.assertTrue(barmodule.IBar.providedBy(bar))
 
     def test_weakref(self):
-        """Weak references to persistent objects don't remain after
-        ZODB pack and garbage collection."""
+        """Verify interacton of declaration weak refs with ZODB
 
+        Weak references to persistent objects don't remain after ZODB
+        pack and garbage collection."""
+
         bar = self.root['bar'] = Bar()
         baz = self.root['baz'] = Baz()
 
@@ -142,6 +144,32 @@
         barmodule = root['registry'].findModule("barmodule")
 
         self.assertEqual(barmodule.IBar.dependents.keys(), [])
+
+    def test_persistentDeclarations(self):
+        """Verify equivalency of persistent declarations
+
+        Make sure that the persistent declaration instance are
+        equivalent to the non-persistent instances they originate
+        from."""
+
+        self.registry.newModule("barmodule", bar_code)
+        barmodule = self.registry.findModule("barmodule")
+
+        class Baz(object):
+            implements(barmodule.IBar)
+
+        bar = Bar()
+        directlyProvides(bar, barmodule.IBar)
+
+        self.assertEqual(
+            bar.__provides__._Provides__args,
+            barmodule.IBar.dependents.keys()[0]._Provides__args
+            )
+
+        self.assertEqual(
+            Baz.__implemented__.__bases__,
+            barmodule.IBar.dependents.keys()[1].__bases__
+            )
         
 def test_suite():
     return unittest.makeSuite(PersistentInterfaceTest)



More information about the Zope3-Checkins mailing list