[CMF-checkins] SVN: CMF/trunk/CMFCore/ - fixed the unit tests that
failed on Zope 2.10
Yvo Schubbe
y.2006_ at wcm-solutions.de
Tue May 30 12:18:51 EDT 2006
Log message for revision 68396:
- fixed the unit tests that failed on Zope 2.10
(There is still one error, but that seems to be caused by a Zope bug.)
Changed:
U CMF/trunk/CMFCore/Expression.py
U CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py
U CMF/trunk/CMFCore/tests/test_Expression.py
U CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
-=-
Modified: CMF/trunk/CMFCore/Expression.py
===================================================================
--- CMF/trunk/CMFCore/Expression.py 2006-05-30 16:10:52 UTC (rev 68395)
+++ CMF/trunk/CMFCore/Expression.py 2006-05-30 16:18:49 UTC (rev 68396)
@@ -25,17 +25,18 @@
from utils import getToolByName
-class Expression (Persistent):
- text = ''
- _v_compiled = None
+class Expression(Persistent):
security = ClassSecurityInfo()
def __init__(self, text):
self.text = text
- self._v_compiled = getEngine().compile(text)
+ if text:
+ self._v_compiled = getEngine().compile(text)
def __call__(self, econtext):
+ if not self.text:
+ return ''
compiled = self._v_compiled
if compiled is None:
compiled = self._v_compiled = getEngine().compile(self.text)
@@ -44,7 +45,6 @@
res = compiled(econtext)
if isinstance(res, Exception):
raise res
- #print 'returning %s from %s' % (`res`, self.text)
return res
InitializeClass(Expression)
Modified: CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2006-05-30 16:10:52 UTC (rev 68395)
+++ CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2006-05-30 16:18:49 UTC (rev 68396)
@@ -57,9 +57,6 @@
class CachingPolicyTests(unittest.TestCase):
- def setUp(self):
- self._epoch = DateTime(0)
-
def _makePolicy( self, policy_id, **kw ):
from Products.CMFCore.CachingPolicyManager import CachingPolicy
@@ -70,6 +67,13 @@
return createCPContext( DummyContent2(self._epoch)
, 'foo_view', kw, self._epoch )
+ def setUp(self):
+ setUpTraversing()
+ self._epoch = DateTime(0)
+
+ def tearDown(self):
+ cleanUp()
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFCore.CachingPolicyManager import CachingPolicy
@@ -396,9 +400,12 @@
return CachingPolicyManager(*args, **kw)
def setUp(self):
-
+ setUpTraversing()
self._epoch = DateTime()
+ def tearDown(self):
+ cleanUp()
+
def assertEqualDelta( self, lhs, rhs, delta ):
self.failUnless( abs( lhs - rhs ) <= delta )
Modified: CMF/trunk/CMFCore/tests/test_Expression.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_Expression.py 2006-05-30 16:10:52 UTC (rev 68395)
+++ CMF/trunk/CMFCore/tests/test_Expression.py 2006-05-30 16:18:49 UTC (rev 68396)
@@ -49,21 +49,34 @@
def test_anonymous_ec(self):
self.portal.portal_membership = DummyMembershipTool()
ec = createExprContext(self.folder, self.portal, self.object)
- member = ec.global_vars['member']
+ if hasattr(ec, 'contexts'):
+ member = ec.contexts['member']
+ else:
+ # BBB: for Zope 2.9
+ member = ec.global_vars['member']
self.failIf(member)
def test_authenticatedUser_ec(self):
self.portal.portal_membership = DummyMembershipTool(anon=0)
ec = createExprContext(self.folder, self.portal, self.object)
- member = ec.global_vars['member']
+ if hasattr(ec, 'contexts'):
+ member = ec.contexts['member']
+ else:
+ # BBB: for Zope 2.9
+ member = ec.global_vars['member']
self.assertEqual(member.getId(), 'dummy')
def test_ec_context(self):
self.portal.portal_membership = DummyMembershipTool()
ec = createExprContext(self.folder, self.portal, self.object)
- object = ec.global_vars['object']
- portal = ec.global_vars['portal']
- folder = ec.global_vars['folder']
+ if hasattr(ec, 'contexts'):
+ contexts = ec.contexts
+ else:
+ # BBB: for Zope 2.9
+ contexts = ec.global_vars
+ object = contexts['object']
+ portal = contexts['portal']
+ folder = contexts['folder']
self.failUnless(object)
self.assertEqual(object.id, 'bar')
self.assertEqual(object.absolute_url(), 'url_bar')
Modified: CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2006-05-30 16:10:52 UTC (rev 68395)
+++ CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2006-05-30 16:18:49 UTC (rev 68396)
@@ -24,6 +24,7 @@
from OFS.Folder import Folder
from Products.PageTemplates.TALES import Undefined
from Products.StandardCacheManagers import RAMCacheManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.FSPageTemplate import FSPageTemplate
from Products.CMFCore.FSMetadata import FSMetadata
@@ -31,6 +32,7 @@
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.testcase import setUpTraversing
class FSPTMaker(FSDVTest):
@@ -47,10 +49,12 @@
def setUp(self):
FSPTMaker.setUp(self)
RequestTest.setUp(self)
+ setUpTraversing()
def tearDown(self):
RequestTest.tearDown(self)
FSPTMaker.tearDown(self)
+ cleanUp()
def test_Call( self ):
More information about the CMF-checkins
mailing list