[CMF-checkins] SVN: CMF/trunk/CMF - refactored test setup for events (fixes some broken tests on Zope trunk)

Yvo Schubbe y.2006_ at wcm-solutions.de
Tue May 23 08:14:55 EDT 2006


Log message for revision 68254:
  - refactored test setup for events (fixes some broken tests on Zope trunk)

Changed:
  U   CMF/trunk/CMFCore/tests/base/testcase.py
  U   CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
  U   CMF/trunk/CMFCore/tests/test_OpaqueItems.py
  U   CMF/trunk/CMFCore/tests/test_PortalContent.py
  U   CMF/trunk/CMFCore/tests/test_PortalFolder.py
  U   CMF/trunk/CMFDefault/tests/test_Discussions.py
  U   CMF/trunk/CMFDefault/tests/test_Image.py
  U   CMF/trunk/CMFDefault/tests/test_Portal.py
  U   CMF/trunk/CMFTopic/tests/test_Topic.py
  U   CMF/trunk/CMFUid/tests/test_uidannotation.py

-=-
Modified: CMF/trunk/CMFCore/tests/base/testcase.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/testcase.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFCore/tests/base/testcase.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -11,14 +11,12 @@
 from stat import S_IREAD, S_IWRITE
 from tempfile import mktemp
 
-import Products
 import transaction
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from AccessControl.SecurityManager import setSecurityPolicy
 from Products.Five import zcml
 from Testing.makerequest import makerequest
-from zope.app.testing.placelesssetup import PlacelessSetup
 
 from dummy import DummyFolder
 from security import AnonymousUser
@@ -47,7 +45,8 @@
 """
 
 def setUpTraversing():
-    import Products.Five
+    import Products
+
     zcml.load_config('meta.zcml', Products.Five)
     try:
         # BBB: for Zope 2.9
@@ -56,7 +55,18 @@
     except ImportError:
         zcml.load_config('traversing.zcml', Products.Five)
 
+def setUpEvents():
+    import Products
+    import zope.app
 
+    #   First, set up "stock" OFS event propagation
+    zcml.load_config('meta.zcml', Products.Five)
+    zcml.load_config('configure.zcml', zope.app.event)
+    zcml.load_config('event.zcml', Products.Five)
+    #   Now, register the CMF-specific handler
+    zcml.load_config('event.zcml', Products.CMFCore)
+
+
 class LogInterceptor:
 
     logged = None
@@ -180,22 +190,6 @@
 _prefix = abspath(join(_prefix,'..'))
 
 
-class ContentEventAwareTests(PlacelessSetup):
-
-    """ Mix-in for test case classes which need to get object events handled.
-    """
-    # BBB: replace PlacelessSetup by zope.component.eventtesting.setUp
-    #      and zope.testing.cleanup.cleanUp if we no longer support Zope 2.9
-
-    def setUp(self):
-        PlacelessSetup.setUp(self)
-        #   First, set up "stock" OFS event propagation
-        zcml.load_config('meta.zcml', Products.Five)
-        zcml.load_config('event.zcml', Products.Five)
-        #   Now, register the CMF-specific handler
-        zcml.load_config('event.zcml', Products.CMFCore)
-
-
 class FSDVTest( TestCase, WarningInterceptor ):
     # Base class for FSDV test, creates a fake skin
     # copy that can be edited.

Modified: CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -22,6 +22,7 @@
 from OFS.Folder import Folder
 from OFS.SimpleItem import SimpleItem
 from zope.interface import implements
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Products.CMFCore.exceptions import NotFound
@@ -29,8 +30,8 @@
 from Products.CMFCore.tests.test_PortalFolder import _AllowedUser
 from Products.CMFCore.tests.test_PortalFolder import _SensitiveSecurityPolicy
 from Products.CMFCore.tests.base.testcase import LogInterceptor
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 
 CMF_SECURITY_INDEXES = CMFCatalogAware._cmf_security_indexes
 
@@ -214,15 +215,15 @@
     # FIXME: more tests needed
 
 
-class CMFCatalogAware_CopySupport_Tests(SecurityTest, ContentEventAwareTests):
+class CMFCatalogAware_CopySupport_Tests(SecurityTest):
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def _makeSite(self):
         import cStringIO

Modified: CMF/trunk/CMFCore/tests/test_OpaqueItems.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_OpaqueItems.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFCore/tests/test_OpaqueItems.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -18,6 +18,7 @@
 import Testing
 
 from zope.interface import implements
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.interfaces import ICallableOpaqueItem
 from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
@@ -29,8 +30,8 @@
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.tests.base.dummy \
     import DummyContent as OriginalDummyContent
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.TypesTool import TypesTool
 
 
@@ -137,11 +138,11 @@
 # Unit Tests
 # -------------------------------------------
 
-class ManageBeforeAfterTests(SecurityTest, ContentEventAwareTests):
+class ManageBeforeAfterTests(SecurityTest):
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
 
         root = self.root
 
@@ -177,8 +178,8 @@
             pass
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def test_nonCallableItem(self):
         # no exception should be raised

Modified: CMF/trunk/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalContent.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFCore/tests/test_PortalContent.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -20,11 +20,12 @@
 
 from AccessControl.SecurityManagement import newSecurityManager
 from Acquisition import aq_base
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyUserFolder
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 
 
 class PortalContentTests(unittest.TestCase):
@@ -50,22 +51,22 @@
         verifyClass(IDynamicType, PortalContent)
 
 
-class TestContentCopyPaste(SecurityRequestTest, ContentEventAwareTests):
+class TestContentCopyPaste(SecurityRequestTest):
 
     # Tests related to http://www.zope.org/Collectors/CMF/205
     # Copy/pasting a content item must set ownership to pasting user
 
     def setUp(self):
         SecurityRequestTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
 
         self.root._setObject('site', DummySite('site'))
         self.site = self.root.site
         self.acl_users = self.site._setObject('acl_users', DummyUserFolder())
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityRequestTest.tearDown(self)
+        cleanUp()
 
     def _initContent(self, folder, id):
         from Products.CMFCore.PortalContent import PortalContent

Modified: CMF/trunk/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalFolder.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFCore/tests/test_PortalFolder.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -30,6 +30,7 @@
 from OFS.Image import manage_addFile
 from OFS.tests.testCopySupport import makeConnection
 from Testing.makerequest import makerequest
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.CatalogTool import CatalogTool
 from Products.CMFCore.exceptions import BadRequest
@@ -37,10 +38,10 @@
 from Products.CMFCore.tests.base.dummy import DummyFactory
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyUserFolder
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import newSecurityManager
 from Products.CMFCore.tests.base.testcase import noSecurityManager
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
 from Products.CMFCore.tests.base.tidata import FTIDATA_DUMMY
 from Products.CMFCore.tests.base.utils import has_path
@@ -54,12 +55,13 @@
              'permission': 'View'}]
 
 
-class PortalFolderFactoryTests(SecurityTest, ContentEventAwareTests):
+class PortalFolderFactoryTests(SecurityTest):
 
     def setUp(self):
         from Products.CMFCore.PortalFolder import PortalFolder
+
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
 
         self.root._setObject( 'portal_types', TypesTool() )
         types_tool = self.root.portal_types
@@ -76,8 +78,8 @@
         types_tool._setObject( 'Dummy Content', FTI(**fti) )
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def _makeOne( self, id ):
         from Products.CMFCore.PortalFolder import PortalFolder
@@ -117,16 +119,16 @@
                          , type_name='Dummy Content', id='foo' )
 
 
-class PortalFolderTests(SecurityTest, ContentEventAwareTests):
+class PortalFolderTests(SecurityTest):
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         self.site = DummySite('site').__of__(self.root)
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def _getTargetClass(self):
         from Products.CMFCore.PortalFolder import PortalFolder
@@ -442,17 +444,17 @@
         self.failIf(test.checkIdAvailable('foo'))
 
 
-class PortalFolderMoveTests(SecurityTest, ContentEventAwareTests):
+class PortalFolderMoveTests(SecurityTest):
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         self.root._setObject( 'site', DummySite('site') )
         self.site = self.root.site
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def _makeOne(self, id, *args, **kw):
         from Products.CMFCore.PortalFolder import PortalFolder

Modified: CMF/trunk/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Discussions.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFDefault/tests/test_Discussions.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -18,12 +18,14 @@
 import unittest
 import Testing
 
+from zope.testing.cleanup import cleanUp
+
 from Products.CMFCore.CatalogTool import CatalogTool
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyTool
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.tests.base.tidata import FTIDATA_DUMMY
 from Products.CMFCore.tests.base.utils import has_path
 from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
@@ -94,19 +96,19 @@
         verifyClass(IDiscussable, DiscussionItemContainer)
 
 
-class DiscussionTests(SecurityTest, ContentEventAwareTests):
+class DiscussionTests(SecurityTest):
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         self.site = DummySite('site').__of__(self.root)
         self.site._setObject( 'portal_discussion', DiscussionTool() )
         self.site._setObject( 'portal_membership', DummyTool() )
         self.site._setObject( 'portal_types', TypesTool() )
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def _makeDummyContent(self, id, *args, **kw):
         return self.site._setObject( id, DummyContent(id, *args, **kw) )

Modified: CMF/trunk/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Image.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFDefault/tests/test_Image.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -31,8 +31,8 @@
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyTool
 from Products.CMFCore.tests.base.security import OmnipotentUser
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.tests.base.testcase import setUpTraversing
 from Products.CMFDefault import tests
 
@@ -103,14 +103,14 @@
         self.assertEqual(image.content_type, 'image/jpeg')
 
 
-class TestImageCopyPaste(SecurityRequestTest, ContentEventAwareTests):
+class TestImageCopyPaste(SecurityRequestTest):
 
     # Tests related to http://www.zope.org/Collectors/CMF/176
     # Copy/pasting an image (or file) should reset the object's workflow state.
 
     def setUp(self):
         SecurityRequestTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         setUpTraversing()
         zcml.load_config('permissions.zcml', Products.Five)
         zcml.load_config('configure.zcml', Products.GenericSetup)
@@ -135,7 +135,6 @@
 
     def tearDown(self):
         noSecurityManager()
-        ContentEventAwareTests.tearDown(self)
         SecurityRequestTest.tearDown(self)
         cleanUp()
 

Modified: CMF/trunk/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Portal.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFDefault/tests/test_Portal.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -23,12 +23,12 @@
 from Products.Five import zcml
 from zope.testing.cleanup import cleanUp
 
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.tests.base.testcase import setUpTraversing
 
 
-class CMFSiteTests(SecurityRequestTest, ContentEventAwareTests):
+class CMFSiteTests(SecurityRequestTest):
 
     def _makeSite( self, id='testsite' ):
 
@@ -49,7 +49,7 @@
 
     def setUp(self):
         SecurityRequestTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         setUpTraversing()
         zcml.load_config('permissions.zcml', Products.Five)
         zcml.load_config('configure.zcml', Products.GenericSetup)
@@ -57,7 +57,6 @@
         zcml.load_config('configure.zcml', Products.DCWorkflow)
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityRequestTest.tearDown(self)
         cleanUp()
 

Modified: CMF/trunk/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_Topic.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFTopic/tests/test_Topic.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -19,10 +19,11 @@
 import Testing
 
 from Acquisition import Implicit
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.tests.base.dummy import DummySite
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
 from Products.CMFCore.TypesTool import TypesTool
 
@@ -119,19 +120,19 @@
         return self._max_items
 
 
-class TestTopic(SecurityTest, ContentEventAwareTests):
+class TestTopic(SecurityTest):
 
     """ Test all the general Topic cases.
     """
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         self.site = DummySite('site').__of__(self.root)
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
-        SecurityTest.tearDown(self) 
+        SecurityTest.tearDown(self)
+        cleanUp()
 
     def _getTargetClass(self):
         from Products.CMFTopic.Topic import Topic

Modified: CMF/trunk/CMFUid/tests/test_uidannotation.py
===================================================================
--- CMF/trunk/CMFUid/tests/test_uidannotation.py	2006-05-23 09:36:11 UTC (rev 68253)
+++ CMF/trunk/CMFUid/tests/test_uidannotation.py	2006-05-23 12:14:51 UTC (rev 68254)
@@ -21,17 +21,18 @@
 from OFS.event import ObjectClonedEvent
 from zope.app.container.contained import ObjectAddedEvent
 from zope.event import notify
+from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.tests.base.dummy import DummyContent
-from Products.CMFCore.tests.base.testcase import ContentEventAwareTests
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.testcase import setUpEvents
 
 
 UID_ATTRNAME = 'cmf_uid'
 
 
-class UniqueIdAnnotationToolTests(ContentEventAwareTests, SecurityTest):
+class UniqueIdAnnotationToolTests(SecurityTest):
 
     def _getTargetClass(self):
         from Products.CMFUid.UniqueIdAnnotationTool \
@@ -41,13 +42,13 @@
 
     def setUp(self):
         SecurityTest.setUp(self)
-        ContentEventAwareTests.setUp(self)
+        setUpEvents()
         self.root._setObject('portal_uidannotation', self._getTargetClass()())
         self.root._setObject('dummy', DummyContent(id='dummy'))
 
     def tearDown(self):
-        ContentEventAwareTests.tearDown(self)
         SecurityTest.tearDown(self)
+        cleanUp()
 
     def test_z3interfaces(self):
         from zope.interface.verify import verifyClass



More information about the CMF-checkins mailing list