[Checkins] SVN: zope.component/branches/wosc-test-stacking/ Add test that list valued lookups are not affected by stackable

Wolfgang Schnerring wosc at wosc.de
Thu May 19 02:46:02 EDT 2011


Log message for revision 121729:
  Add test that list valued lookups are not affected by stackable
  

Changed:
  U   zope.component/branches/wosc-test-stacking/NOTES.txt
  U   zope.component/branches/wosc-test-stacking/src/zope/component/tests.py

-=-
Modified: zope.component/branches/wosc-test-stacking/NOTES.txt
===================================================================
--- zope.component/branches/wosc-test-stacking/NOTES.txt	2011-05-19 06:39:33 UTC (rev 121728)
+++ zope.component/branches/wosc-test-stacking/NOTES.txt	2011-05-19 06:46:02 UTC (rev 121729)
@@ -6,18 +6,7 @@
   getGlobalSiteManager()
   getSiteManager / setSite
 
-    - Do we need to make cache contents (in AdapterRegistry/Lookup) stackable?
-      aka, do list-like lookup results work or are they broken by push/pop?
-      Example-test:
-      register subscriber
-      A = subscribers
-      push
-      register some more subscribers
-      B = subscribers
-      pop
-      C = subscribers
-      assert C == A
-      assert len(B) > len(C)
+    - stackable.reset() needs to take into account "dying" stackables
 
     - Do we have to make _v_subregistries stackable?
 

Modified: zope.component/branches/wosc-test-stacking/src/zope/component/tests.py
===================================================================
--- zope.component/branches/wosc-test-stacking/src/zope/component/tests.py	2011-05-19 06:39:33 UTC (rev 121728)
+++ zope.component/branches/wosc-test-stacking/src/zope/component/tests.py	2011-05-19 06:46:02 UTC (rev 121729)
@@ -1763,7 +1763,28 @@
         zope.component.stackable.pop()
         self.assertEqual('foo', registry.getUtility(Interface))
 
+    def test_list_valued_lookups_are_not_affected_by_stackable(self):
+        ANY = 'foo'
+        registry = zope.component.registry.Components()
+        registry.registerSubscriptionAdapter(
+            lambda x: ANY, (object,), Interface)
+        registry.registerSubscriptionAdapter(
+            lambda x: ANY, (object,), Interface)
+        original = registry.subscribers((object(),), Interface)
+        self.assertEqual(2, len(original))
 
+        zope.component.stackable.push()
+        registry.registerSubscriptionAdapter(
+            lambda x: ANY, (object,), Interface)
+        after_push = registry.subscribers((object(),), Interface)
+        self.assertEqual(3, len(after_push))
+
+        zope.component.stackable.pop()
+        after_pop = registry.subscribers((object(),), Interface)
+        self.assertEqual(original, after_pop)
+        self.assertEqual(3, len(after_push))
+
+
 def setUpRegistryTests(tests):
     setUp()
 



More information about the checkins mailing list