[CMF-checkins] SVN: CMF/trunk/C Fixed test breakage induced by use of Z3 pagetempalates in Zope 2.10+.

Tres Seaver tseaver at palladion.com
Fri Oct 20 09:03:59 EDT 2006


Log message for revision 70843:
  Fixed test breakage induced by use of Z3 pagetempalates in Zope 2.10+.
  
  

Changed:
  U   CMF/trunk/CHANGES.txt
  U   CMF/trunk/CMFCore/tests/base/utils.py
  U   CMF/trunk/CMFCore/tests/test_FSReSTMethod.py
  U   CMF/trunk/CMFCore/tests/test_FSSTXMethod.py

-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt	2006-10-20 12:57:48 UTC (rev 70842)
+++ CMF/trunk/CHANGES.txt	2006-10-20 13:03:58 UTC (rev 70843)
@@ -18,6 +18,8 @@
 
   Bug Fixes
 
+    - Fixed test breakage induced by use of Z3 pagetempalates in Zope 2.10+.
+
     - CMFDefault skins: Fixed encoding issues in welcome and reminder emails.
       'password_email' and 'registered_email' now encode their return value
       correctly, using 'email_charset' and the new 'makeEmail' function.

Modified: CMF/trunk/CMFCore/tests/base/utils.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/utils.py	2006-10-20 12:57:48 UTC (rev 70842)
+++ CMF/trunk/CMFCore/tests/base/utils.py	2006-10-20 13:03:58 UTC (rev 70843)
@@ -26,3 +26,15 @@
         if catalog.getpath( rid ) == path:
             return 1
     return 0
+
+def _setUpDefaultTraversable():
+    from zope.interface import Interface
+    from zope.component import provideAdapter
+    try:
+        from zope.traversing.interfaces import ITraversable
+        from zope.traversing.adapters import DefaultTraversable
+    except ImportError: # Zope < 2.10
+        from zope.app.traversing.interfaces import ITraversable
+        from zope.app.traversing.adapters import DefaultTraversable
+
+    provideAdapter(DefaultTraversable, (Interface,), ITraversable)

Modified: CMF/trunk/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSReSTMethod.py	2006-10-20 12:57:48 UTC (rev 70842)
+++ CMF/trunk/CMFCore/tests/test_FSReSTMethod.py	2006-10-20 13:03:58 UTC (rev 70843)
@@ -18,10 +18,14 @@
 import os
 import re
 
+from zope.component.testing import PlacelessSetup
+
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
 
+
 class FSReSTMaker(FSDVTest):
 
     def setUp(self):
@@ -68,22 +72,25 @@
 WS = re.compile(r'\s+')
 
 def _normalize_whitespace(text):
-    return ' '.join(WS.split(text))
+    return ' '.join(WS.split(text.rstrip()))
 
 
-class FSReSTMethodTests(RequestTest, FSReSTMaker):
+class FSReSTMethodTests(RequestTest, FSReSTMaker, PlacelessSetup):
 
     def setUp(self):
         RequestTest.setUp(self)
         FSReSTMaker.setUp(self)
+        PlacelessSetup.setUp(self)
 
     def tearDown(self):
+        PlacelessSetup.tearDown(self)
         FSReSTMaker.tearDown(self)
         RequestTest.tearDown(self)
 
     def test___call__( self ):
         script = self._makeOne( 'testReST', 'testReST.rst' )
         script = script.__of__(self.app)
+        _setUpDefaultTraversable()
         self.assertEqual(_normalize_whitespace(script(self.REQUEST)),
                          _normalize_whitespace(_EXPECTED_HTML))
 
@@ -94,6 +101,7 @@
         original_len = len( self.RESPONSE.headers )
         script = self._makeOne('testReST', 'testReST.rst')
         script = script.__of__(self.root)
+        _setUpDefaultTraversable()
         script(self.REQUEST, self.RESPONSE)
         self.failUnless( len( self.RESPONSE.headers ) >= original_len + 2 )
         self.failUnless( 'foo' in self.RESPONSE.headers.keys() )
@@ -138,12 +146,16 @@
                  ,
                  )
 
-class FSReSTMethodCustomizationTests( SecurityTest, FSReSTMaker ):
+class FSReSTMethodCustomizationTests(SecurityTest,
+                                     FSReSTMaker,
+                                     PlacelessSetup,
+                                    ):
 
     def setUp( self ):
         from OFS.Folder import Folder
         SecurityTest.setUp( self )
         FSReSTMaker.setUp(self)
+        PlacelessSetup.setUp(self)
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
@@ -160,6 +172,7 @@
         self.fsReST = self.fsdir.testReST
 
     def tearDown( self ):
+        PlacelessSetup.tearDown(self)
         FSReSTMaker.tearDown( self )
         SecurityTest.tearDown( self )
 
@@ -181,7 +194,8 @@
         self.assertEqual(propinfo['type'], 'text')
         self.assertEqual(target.rest, self.fsReST.raw)
 
-        self.assertEqual(target.document_src(), _CUSTOMIZED_TEMPLATE_ZPT)
+        self.assertEqual(_normalize_whitespace(target.document_src()),
+                         _normalize_whitespace(_CUSTOMIZED_TEMPLATE_ZPT))
 
     def test_customize_caching(self):
         # Test to ensure that cache manager associations survive customizing

Modified: CMF/trunk/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSSTXMethod.py	2006-10-20 12:57:48 UTC (rev 70842)
+++ CMF/trunk/CMFCore/tests/test_FSSTXMethod.py	2006-10-20 13:03:58 UTC (rev 70843)
@@ -18,9 +18,12 @@
 import os
 import re
 
+from zope.component.testing import PlacelessSetup
+
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest
 from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
 
 class FSSTXMaker(FSDVTest):
 
@@ -59,7 +62,7 @@
 WS = re.compile(r'\s+')
 
 def _normalize_whitespace(text):
-    return ' '.join(WS.split(text))
+    return ' '.join(WS.split(text.rstrip()))
 
 
 class _TemplateSwitcher:
@@ -87,14 +90,20 @@
             main = ZopePageTemplate('main_template', _TEST_MAIN_TEMPLATE)
             self.root._setOb('main_template', main)
 
-class FSSTXMethodTests(RequestTest, FSSTXMaker, _TemplateSwitcher):
+class FSSTXMethodTests(RequestTest,
+                       FSSTXMaker,
+                       _TemplateSwitcher,
+                       PlacelessSetup,
+                      ):
 
     def setUp(self):
         _TemplateSwitcher.setUp(self)
         FSSTXMaker.setUp(self)
         RequestTest.setUp(self)
+        PlacelessSetup.setUp(self)
 
     def tearDown(self):
+        PlacelessSetup.tearDown(self)
         RequestTest.tearDown(self)
         FSSTXMaker.tearDown(self)
         _TemplateSwitcher.tearDown(self)
@@ -110,6 +119,7 @@
         self._setWhichTemplate('ZPT')
         script = self._makeOne( 'testSTX', 'testSTX.stx' )
         script = script.__of__(self.app)
+        _setUpDefaultTraversable()
         self.assertEqual(_normalize_whitespace(script(self.REQUEST)),
                          _normalize_whitespace(_EXPECTED_HTML))
 
@@ -165,14 +175,18 @@
                  ,
                  )
 
-class FSSTXMethodCustomizationTests( SecurityTest, FSSTXMaker,
-                                     _TemplateSwitcher ):
+class FSSTXMethodCustomizationTests(SecurityTest,
+                                    FSSTXMaker,
+                                    _TemplateSwitcher,
+                                    PlacelessSetup,
+                                   ):
 
     def setUp( self ):
         from OFS.Folder import Folder
         FSSTXMaker.setUp(self)
         SecurityTest.setUp( self )
         _TemplateSwitcher.setUp( self )
+        PlacelessSetup.setUp(self)
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
@@ -189,6 +203,7 @@
         self.fsSTX = self.fsdir.testSTX
 
     def tearDown( self ):
+        PlacelessSetup.tearDown(self)
         _TemplateSwitcher.tearDown( self )
         FSSTXMaker.tearDown( self )
         SecurityTest.tearDown( self )
@@ -232,7 +247,8 @@
         self.assertEqual(propinfo['type'], 'text')
         self.assertEqual(target.stx, self.fsSTX.raw)
 
-        self.assertEqual(target.document_src(), _CUSTOMIZED_TEMPLATE_ZPT)
+        self.assertEqual(_normalize_whitespace(target.document_src()),
+                         _normalize_whitespace(_CUSTOMIZED_TEMPLATE_ZPT))
 
     def test_customize_caching(self):
         # Test to ensure that cache manager associations survive customizing



More information about the CMF-checkins mailing list