[Checkins] SVN: zope.component/tseaver-test_cleanup/ Split out tests for z.c.hookable, z.c.peristentregistry.

Tres Seaver cvs-admin at zope.org
Mon Jun 18 19:20:37 UTC 2012


Log message for revision 126965:
  Split out tests for z.c.hookable, z.c.peristentregistry.
  
  Remove cruft.

Changed:
  _U  zope.component/tseaver-test_cleanup/
  U   zope.component/tseaver-test_cleanup/src/zope/component/tests/test_doctests.py
  A   zope.component/tseaver-test_cleanup/src/zope/component/tests/test_hookable.py
  A   zope.component/tseaver-test_cleanup/src/zope/component/tests/test_persistentregistry.py

-=-
Modified: zope.component/tseaver-test_cleanup/src/zope/component/tests/test_doctests.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/tests/test_doctests.py	2012-06-18 18:50:45 UTC (rev 126964)
+++ zope.component/tseaver-test_cleanup/src/zope/component/tests/test_doctests.py	2012-06-18 19:20:34 UTC (rev 126965)
@@ -15,27 +15,16 @@
 """
 import unittest
 
-from zope.configuration.xmlconfig import XMLConfig, xmlconfig
-from zope.configuration.exceptions import ConfigurationError
 from zope.interface import Interface
-from zope.interface import implements
+from zope.interface import implementer
 from zope.interface.interfaces import IInterface
-from zope.security.checker import ProxyFactory
-from zope.testrunner.layer import UnitTests
 
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interfaces import IComponentLookup
-from zope.component.testfiles.adapter import A1
-from zope.component.testfiles.adapter import A2
-from zope.component.testfiles.adapter import A3
-from zope.component.testfiles.components import Content
-from zope.component.testfiles.components import IContent
-from zope.component.testfiles.views import Request
 from zope.component.testfiles.views import IC
 from zope.component.testfiles.views import IV
 from zope.component.testfiles.views import V1
 from zope.component.testfiles.views import R1
 from zope.component.testfiles.views import IR
+
 from zope.component.testing import setUp
 from zope.component.testing import tearDown
 from zope.component.testing import PlacelessSetup
@@ -46,8 +35,10 @@
 
 class I1(Interface):
     pass
+
 class I2(Interface):
     pass
+
 class I3(Interface):
     pass
 
@@ -57,28 +48,32 @@
 def noop(*args):
     pass
 
+ at implementer(I1)
 class Ob(object):
-    implements(I1)
     def __repr__(self):
         return '<instance Ob>'
 
 
 ob = Ob()
 
+ at implementer(I2)
 class Ob2(object):
-    implements(I2)
     def __repr__(self):
         return '<instance Ob2>'
 
+ at implementer(IC)
+class Ob3(object):
+    pass
+
+ at implementer(I2)
 class Comp(object):
-    implements(I2)
     def __init__(self, context):
         self.context = context
 
 comp = Comp(1)
 
+ at implementer(I3)
 class Comp2(object):
-    implements(I3)
     def __init__(self, context):
         self.context = context
 
@@ -92,6 +87,7 @@
 
     def __conform__(self, interface):
         """This method is specified by the adapter PEP to do the adaptation."""
+        from zope.component.interfaces import IComponentLookup
         if interface is IComponentLookup:
             return self.sitemanager
 
@@ -145,7 +141,6 @@
         import subprocess
         import sys
         import os
-        import tempfile
         import pickle
 
         executable = os.path.abspath(sys.executable)
@@ -181,118 +176,6 @@
         if not success:
             self.fail(''.join(lines))
 
-class HookableTests(unittest.TestCase):
-
-    def test_ctor_no_func(self):
-        from zope.component.hookable import hookable
-        self.assertRaises(TypeError, hookable)
-
-    def test_ctor_simple(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        hooked = hookable(foo)
-        self.failUnless(hooked.original is foo)
-        self.failUnless(hooked.implementation is foo)
-
-    def test_ctor_extra_arg(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        self.assertRaises(TypeError, hookable, foo, foo)
-
-    def test_ctor_extra_arg(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        self.assertRaises(TypeError, hookable, foo, nonesuch=foo)
-
-    def test_sethook(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        def bar():
-            pass
-        hooked = hookable(foo)
-        hooked.sethook(bar)
-        self.failUnless(hooked.original is foo)
-        self.failUnless(hooked.implementation is bar)
-
-    def test_reset(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        def bar():
-            pass
-        hooked = hookable(foo)
-        hooked.sethook(bar)
-        hooked.reset()
-        self.failUnless(hooked.original is foo)
-        self.failUnless(hooked.implementation is foo)
-
-    def test_cant_assign_original(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        def bar():
-            pass
-        hooked = hookable(foo)
-        try:
-            hooked.original = bar
-        except TypeError:
-            pass
-        except AttributeError:
-            pass
-        else:
-            self.fail('Assigned original')
-
-    def test_cant_delete_original(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        hooked = hookable(foo)
-        try:
-            del hooked.original
-        except TypeError:
-            pass
-        except AttributeError:
-            pass
-        else:
-            self.fail('Deleted original')
-
-    def test_cant_assign_original(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        def bar():
-            pass
-        hooked = hookable(foo)
-        try:
-            hooked.implementation = bar
-        except TypeError:
-            pass
-        except AttributeError:
-            pass
-        else:
-            self.fail('Assigned implementation')
-
-    def test_readonly_original(self):
-        from zope.component.hookable import hookable
-        def foo():
-            pass
-        hooked = hookable(foo)
-        try:
-            del hooked.implementation
-        except TypeError:
-            pass
-        except AttributeError:
-            pass
-        else:
-            self.fail('Deleted implementation')
-
-class Ob3(object):
-    implements(IC)
-
 template = """<configure
    xmlns='http://namespaces.zope.org/zope'
    i18n_domain='zope'>
@@ -303,15 +186,18 @@
 class ResourceViewTests(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
+        from zope.configuration.xmlconfig import XMLConfig
         super(ResourceViewTests, self).setUp()
         XMLConfig('meta.zcml', zope.component)()
         XMLConfig('meta.zcml', zope.security)()
 
     def _config(self, zcml, testing=0):
         from cStringIO import StringIO
+        from zope.configuration.xmlconfig import xmlconfig
         xmlconfig(StringIO(template % zcml), testing=testing)
 
     def testView(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         request = Request(IV)
         self.assertEqual(
@@ -332,6 +218,10 @@
 
 
     def testMultiView(self):
+        from zope.component.testfiles.adapter import A1
+        from zope.component.testfiles.adapter import A2
+        from zope.component.testfiles.adapter import A3
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -354,6 +244,7 @@
 
 
     def testMultiView_fails_w_multiple_factories(self):
+        from zope.configuration.exceptions import ConfigurationError
         self.assertRaises(ConfigurationError,
             self._config,
             '''
@@ -367,6 +258,10 @@
             ''')
 
     def testView_w_multiple_factories(self):
+        from zope.component.testfiles.adapter import A1
+        from zope.component.testfiles.adapter import A2
+        from zope.component.testfiles.adapter import A3
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -393,6 +288,7 @@
         self.assertEqual(a1.context[0], ob)
 
     def testView_fails_w_no_factories(self):
+        from zope.configuration.exceptions import ConfigurationError
         self.assertRaises(ConfigurationError,
             self._config,
             '''
@@ -404,6 +300,7 @@
 
 
     def testViewThatProvidesAnInterface(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         self.assertEqual(
             zope.component.queryMultiAdapter((ob, Request(IR)), IV, u'test'),
@@ -437,6 +334,7 @@
 
 
     def testUnnamedViewThatProvidesAnInterface(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         self.assertEqual(
             zope.component.queryMultiAdapter((ob, Request(IR)), IV), None)
@@ -465,6 +363,11 @@
         self.assertEqual(v.__class__, V1)
 
     def testViewHavingARequiredClass(self):
+        from zope.component.interfaces import ComponentLookupError
+        from zope.component.testfiles.adapter import A1
+        from zope.component.testfiles.components import Content
+        from zope.component.testfiles.components import IContent
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view
@@ -478,13 +381,16 @@
         a1 = zope.component.getMultiAdapter((content, Request(IR)))
         self.assert_(isinstance(a1, A1))
 
+        @implementer(IContent)
         class MyContent:
-            implements(IContent)
+            pass
 
         self.assertRaises(ComponentLookupError, zope.component.getMultiAdapter,
                           (MyContent(), Request(IR)))
 
     def testInterfaceProtectedView(self):
+        from zope.security.checker import ProxyFactory
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -502,6 +408,8 @@
         self.assertRaises(Exception, getattr, v, 'action')
 
     def testAttributeProtectedView(self):
+        from zope.security.checker import ProxyFactory
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -519,6 +427,7 @@
         self.assertRaises(Exception, getattr, v, 'index')
 
     def testInterfaceAndAttributeProtectedView(self):
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -536,6 +445,7 @@
         self.assertEqual(v.action(), 'done')
 
     def testDuplicatedInterfaceAndAttributeProtectedView(self):
+        from zope.component.testfiles.views import Request
         self._config(
             '''
             <view name="test"
@@ -553,6 +463,7 @@
         self.assertEqual(v.action(), 'done')
 
     def testIncompleteProtectedViewNoPermission(self):
+        from zope.configuration.exceptions import ConfigurationError
         self.assertRaises(
             ConfigurationError,
             self._config,
@@ -582,6 +493,7 @@
             testing=1)
 
     def testResource(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         self.assertEqual(
             zope.component.queryAdapter(Request(IV), name=u'test'), None)
@@ -597,6 +509,7 @@
             R1)
 
     def testResourceThatProvidesAnInterface(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         self.assertEqual(zope.component.queryAdapter(Request(IR), IV, u'test'),
                          None)
@@ -627,6 +540,7 @@
         self.assertEqual(v.__class__, R1)
 
     def testUnnamedResourceThatProvidesAnInterface(self):
+        from zope.component.testfiles.views import Request
         ob = Ob3()
         self.assertEqual(zope.component.queryAdapter(Request(IR), IV), None)
 
@@ -664,40 +578,8 @@
             ''',
             testing=1)
 
-
-class ConditionalSecurityLayer(UnitTests):
-
-    __name__ = 'ConditionalSecurity'
-    __bases__ = ()
-
-    def setUp(self):
-        import sys
-        import zope.component.zcml
-        setUp()
-        self.modules = {}
-        for m in ('zope.security', 'zope.proxy'):
-            self.modules[m] = sys.modules[m]
-            sys.modules[m] = None
-        reload(zope.component.zcml)
-
-    def tearDown(self):
-        import sys
-        import zope.component.zcml
-        tearDown()
-        for m in ('zope.security', 'zope.proxy'):
-            sys.modules[m] = self.modules[m]
-        reload(zope.component.zcml)
-
-
-def setUpRegistryTests(tests):
-    setUp()
-
-def tearDownRegistryTests(tests):
-    tearDown()
-    import zope.event
-    zope.event.subscribers.pop()
-
 def clearZCML(test=None):
+    from zope.configuration.xmlconfig import XMLConfig
     import zope.component
     tearDown()
     setUp()
@@ -707,7 +589,6 @@
     import doctest
     return unittest.TestSuite((
         doctest.DocTestSuite(setUp=setUp, tearDown=tearDown),
-        unittest.makeSuite(HookableTests),
         doctest.DocTestSuite('zope.component.interface',
                              setUp=setUp, tearDown=tearDown),
         doctest.DocTestSuite('zope.component.nexttesting'),

Added: zope.component/tseaver-test_cleanup/src/zope/component/tests/test_hookable.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/tests/test_hookable.py	                        (rev 0)
+++ zope.component/tseaver-test_cleanup/src/zope/component/tests/test_hookable.py	2012-06-18 19:20:34 UTC (rev 126965)
@@ -0,0 +1,132 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Pure-Python hookable tests
+"""
+import unittest
+
+
+class HookableTests(unittest.TestCase):
+
+    def test_ctor_no_func(self):
+        from zope.component.hookable import hookable
+        self.assertRaises(TypeError, hookable)
+
+    def test_ctor_simple(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        hooked = hookable(foo)
+        self.failUnless(hooked.original is foo)
+        self.failUnless(hooked.implementation is foo)
+
+    def test_ctor_extra_arg(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        self.assertRaises(TypeError, hookable, foo, foo)
+
+    def test_ctor_extra_arg_miss(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        self.assertRaises(TypeError, hookable, foo, nonesuch=foo)
+
+    def test_sethook(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        def bar():
+            pass
+        hooked = hookable(foo)
+        hooked.sethook(bar)
+        self.failUnless(hooked.original is foo)
+        self.failUnless(hooked.implementation is bar)
+
+    def test_reset(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        def bar():
+            pass
+        hooked = hookable(foo)
+        hooked.sethook(bar)
+        hooked.reset()
+        self.failUnless(hooked.original is foo)
+        self.failUnless(hooked.implementation is foo)
+
+    def test_cant_assign_original(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        def bar():
+            pass
+        hooked = hookable(foo)
+        try:
+            hooked.original = bar
+        except TypeError:
+            pass
+        except AttributeError:
+            pass
+        else:
+            self.fail('Assigned original')
+
+    def test_cant_delete_original(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        hooked = hookable(foo)
+        try:
+            del hooked.original
+        except TypeError:
+            pass
+        except AttributeError:
+            pass
+        else:
+            self.fail('Deleted original')
+
+    def test_cant_assign_implementation(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        def bar():
+            pass
+        hooked = hookable(foo)
+        try:
+            hooked.implementation = bar
+        except TypeError:
+            pass
+        except AttributeError:
+            pass
+        else:
+            self.fail('Assigned implementation')
+
+    def test_cant_delete_implementation(self):
+        from zope.component.hookable import hookable
+        def foo():
+            pass
+        hooked = hookable(foo)
+        try:
+            del hooked.implementation
+        except TypeError:
+            pass
+        except AttributeError:
+            pass
+        else:
+            self.fail('Deleted implementation')
+
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(HookableTests),
+    ))

Added: zope.component/tseaver-test_cleanup/src/zope/component/tests/test_persistentregistry.py
===================================================================
--- zope.component/tseaver-test_cleanup/src/zope/component/tests/test_persistentregistry.py	                        (rev 0)
+++ zope.component/tseaver-test_cleanup/src/zope/component/tests/test_persistentregistry.py	2012-06-18 19:20:34 UTC (rev 126965)
@@ -0,0 +1,294 @@
+##############################################################################
+#
+# Copyright (c) 2001 - 2012 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Persistent component registry tests
+"""
+import unittest
+
+from zope.interface import Interface
+from zope.interface import implements
+from zope.component import adapter
+from zope.component.testing import setUp
+from zope.component.testing import tearDown
+
+
+class I1(Interface):
+    pass
+
+class I2(Interface):
+    pass
+
+class U(object):
+
+    def __init__(self, name):
+        self.__name__ = name
+
+    def __repr__(self):
+        return "%s(%s)" % (self.__class__.__name__, self.__name__)
+
+class U1(U):
+    implements(I1)
+
+class U12(U):
+    implements(I1, I2)
+
+ at adapter(I1)
+def handle1(x):
+    print 'handle1', x
+
+def handle(*objects):
+    print 'handle', objects
+
+ at adapter(I1)
+def handle3(x):
+    print 'handle3', x
+
+ at adapter(I1)
+def handle4(x):
+    print 'handle4', x
+
+def test_persistent_component_managers():
+    """
+Here, we'll demonstrate that changes work even when data are stored in
+a database and when accessed from multiple connections.
+
+Start by setting up a database and creating two transaction
+managers and database connections to work with.
+
+    >>> from zope.component.testing import setUp, tearDown
+    >>> setUp()
+    >>> import ZODB.tests.util
+    >>> db = ZODB.tests.util.DB()
+    >>> import transaction
+    >>> t1 = transaction.TransactionManager()
+    >>> c1 = db.open(transaction_manager=t1)
+    >>> r1 = c1.root()
+    >>> t2 = transaction.TransactionManager()
+    >>> c2 = db.open(transaction_manager=t2)
+    >>> r2 = c2.root()
+
+Create a set of components registries in the database, alternating
+connections.
+
+    >>> from zope.component.persistentregistry import PersistentComponents
+
+    >>> _ = t1.begin()
+    >>> r1[1] = PersistentComponents('1')
+    >>> t1.commit()
+
+    >>> _ = t2.begin()
+    >>> r2[2] = PersistentComponents('2', (r2[1], ))
+    >>> t2.commit()
+
+    >>> _ = t1.begin()
+    >>> r1[3] = PersistentComponents('3', (r1[1], ))
+    >>> t1.commit()
+
+    >>> _ = t2.begin()
+    >>> r2[4] = PersistentComponents('4', (r2[2], r2[3]))
+    >>> t2.commit()
+
+    >>> _ = t1.begin()
+    >>> r1[1].__bases__
+    ()
+    >>> r1[2].__bases__ == (r1[1], )
+    True
+
+    >>> r1[1].registerUtility(U1(1))
+    >>> r1[1].queryUtility(I1)
+    U1(1)
+    >>> r1[2].queryUtility(I1)
+    U1(1)
+    >>> t1.commit()
+
+    >>> _ = t2.begin()
+    >>> r2[1].registerUtility(U1(2))
+    >>> r2[2].queryUtility(I1)
+    U1(2)
+
+    >>> r2[4].queryUtility(I1)
+    U1(2)
+    >>> t2.commit()
+
+
+    >>> _ = t1.begin()
+    >>> r1[1].registerUtility(U12(1), I2)
+    >>> r1[4].queryUtility(I2)
+    U12(1)
+    >>> t1.commit()
+
+
+    >>> _ = t2.begin()
+    >>> r2[3].registerUtility(U12(3), I2)
+    >>> r2[4].queryUtility(I2)
+    U12(3)
+    >>> t2.commit()
+
+    >>> _ = t1.begin()
+
+    >>> r1[1].registerHandler(handle1, info="First handler")
+    >>> r1[2].registerHandler(handle, required=[U])
+
+    >>> r1[3].registerHandler(handle3)
+
+    >>> r1[4].registerHandler(handle4)
+
+    >>> r1[4].handle(U1(1))
+    handle1 U1(1)
+    handle3 U1(1)
+    handle (U1(1),)
+    handle4 U1(1)
+
+    >>> t1.commit()
+
+    >>> _ = t2.begin()
+    >>> r2[4].handle(U1(1))
+    handle1 U1(1)
+    handle3 U1(1)
+    handle (U1(1),)
+    handle4 U1(1)
+    >>> t2.abort()
+
+    >>> db.close()
+    >>> tearDown()
+    """
+
+def persistent_registry_doesnt_scew_up_subsribers():
+    """
+    >>> from zope.component.testing import setUp, tearDown
+    >>> setUp()
+    >>> import ZODB.tests.util
+    >>> db = ZODB.tests.util.DB()
+    >>> import transaction
+    >>> t1 = transaction.TransactionManager()
+    >>> c1 = db.open(transaction_manager=t1)
+    >>> r1 = c1.root()
+    >>> t2 = transaction.TransactionManager()
+    >>> c2 = db.open(transaction_manager=t2)
+    >>> r2 = c2.root()
+
+    >>> from zope.component.persistentregistry import PersistentComponents
+
+    >>> _ = t1.begin()
+    >>> r1[1] = PersistentComponents('1')
+    >>> r1[1].registerHandler(handle1)
+    >>> r1[1].registerSubscriptionAdapter(handle1, provided=I2)
+    >>> _ = r1[1].unregisterHandler(handle1)
+    >>> _ = r1[1].unregisterSubscriptionAdapter(handle1, provided=I2)
+    >>> t1.commit()
+    >>> _ = t1.begin()
+    >>> r1[1].registerHandler(handle1)
+    >>> r1[1].registerSubscriptionAdapter(handle1, provided=I2)
+    >>> t1.commit()
+
+    >>> _ = t2.begin()
+    >>> len(list(r2[1].registeredHandlers()))
+    1
+    >>> len(list(r2[1].registeredSubscriptionAdapters()))
+    1
+    >>> t2.abort()
+    >>> tearDown()
+    """
+
+
+
+class GlobalRegistry:
+    pass
+
+from zope.component.globalregistry import GlobalAdapterRegistry
+base = GlobalAdapterRegistry(GlobalRegistry, 'adapters')
+GlobalRegistry.adapters = base
+def clear_base():
+    base.__init__(GlobalRegistry, 'adapters')
+
+def test_deghostification_of_persistent_adapter_registries():
+    """
+
+We want to make sure that we see updates corrextly.
+
+    >>> import persistent
+    >>> import transaction
+    >>> from zope.interface import Interface
+    >>> from zope.interface import implements
+    >>> class IFoo(Interface):
+    ...     pass
+    >>> class Foo(persistent.Persistent):
+    ...     implements(IFoo)
+    ...     name = ''
+    ...     def __init__(self, name=''):
+    ...         self.name = name
+    ...     def __repr__(self):
+    ...         return 'Foo(%r)' % self.name
+
+    >>> from zope.component.testing import setUp, tearDown
+    >>> setUp()
+    >>> len(base._v_subregistries)
+    0
+
+    >>> import ZODB.tests.util
+    >>> db = ZODB.tests.util.DB()
+    >>> tm1 = transaction.TransactionManager()
+    >>> c1 = db.open(transaction_manager=tm1)
+    >>> from zope.component.persistentregistry import PersistentAdapterRegistry
+    >>> r1 = PersistentAdapterRegistry((base,))
+    >>> r2 = PersistentAdapterRegistry((r1,))
+    >>> c1.root()[1] = r1
+    >>> c1.root()[2] = r2
+    >>> tm1.commit()
+    >>> r1._p_deactivate()
+
+    >>> len(base._v_subregistries)
+    0
+
+    >>> tm2 = transaction.TransactionManager()
+    >>> c2 = db.open(transaction_manager=tm2)
+    >>> r1 = c2.root()[1]
+    >>> r2 = c2.root()[2]
+
+    >>> r1.lookup((), IFoo, '')
+
+    >>> base.register((), IFoo, '', Foo(''))
+    >>> r1.lookup((), IFoo, '')
+    Foo('')
+
+    >>> r2.lookup((), IFoo, '1')
+
+    >>> r1.register((), IFoo, '1', Foo('1'))
+
+    >>> r2.lookup((), IFoo, '1')
+    Foo('1')
+
+    >>> r1.lookup((), IFoo, '2')
+    >>> r2.lookup((), IFoo, '2')
+
+    >>> base.register((), IFoo, '2', Foo('2'))
+
+    >>> r1.lookup((), IFoo, '2')
+    Foo('2')
+
+    >>> r2.lookup((), IFoo, '2')
+    Foo('2')
+
+Cleanup:
+
+    >>> db.close()
+    >>> clear_base()
+    >>> tearDown()
+    """
+
+
+def test_suite():
+    import doctest
+    return unittest.TestSuite((
+        doctest.DocTestSuite(setUp=setUp, tearDown=tearDown),
+        ))



More information about the checkins mailing list