[Checkins] SVN: zope.component/tseaver-test_cleanup/ Cover where the context passed to 'getSitemanager' has adapter to IComponentLookup.

Tres Seaver cvs-admin at zope.org
Tue Jun 26 23:00:41 UTC 2012


Log message for revision 127109:
  Cover where the context passed to 'getSitemanager' has adapter to IComponentLookup.

Changed:
  _U  zope.component/tseaver-test_cleanup/
  U   zope.component/tseaver-test_cleanup/src/zope/component/tests/test__api.py

-=-
Modified: zope.component/tseaver-test_cleanup/src/zope/component/tests/test__api.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/tests/test__api.py	2012-06-26 23:00:33 UTC (rev 127108)
+++ zope.component/tseaver-test_cleanup/src/zope/component/tests/test__api.py	2012-06-26 23:00:37 UTC (rev 127109)
@@ -44,11 +44,22 @@
         context = ConformsToIComponentLookup(sitemanager)
         self.assertTrue(self._callFUT(context) is sitemanager)
 
-    def test_getSiteManager_w_invalid_context(self):
+    def test_getSiteManager_w_invalid_context_no_adapter(self):
         from zope.component.interfaces import ComponentLookupError
         self.assertRaises(ComponentLookupError, self._callFUT, object())
 
+    def test_getSiteManager_w_invalid_context_w_adapter(self):
+        from zope.interface import Interface
+        from zope.component.globalregistry import getGlobalSiteManager
+        from zope.component.interfaces import IComponentLookup
+        gsm = getGlobalSiteManager()
+        sm = object()
+        def _adapt(x):
+            return sm
+        gsm.registerAdapter(_adapt, (Interface,), IComponentLookup, '')
+        self.assertTrue(self._callFUT(object()) is sm)
 
+
 class Test_getAdapterInContext(unittest.TestCase):
 
     from zope.component.testing import setUp, tearDown



More information about the checkins mailing list