[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/tests/test_ - fixed tests on Python 2.7
Yvo Schubbe
cvs-admin at zope.org
Mon May 21 09:23:06 UTC 2012
Log message for revision 126413:
- fixed tests on Python 2.7
Changed:
U Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_FSPythonScript.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py 2012-05-20 20:34:32 UTC (rev 126412)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py 2012-05-21 09:23:02 UTC (rev 126413)
@@ -16,6 +16,8 @@
import unittest
import Testing
+import warnings
+
from AccessControl.SecurityManagement import newSecurityManager
from zope.component import getSiteManager
from zope.interface.verify import verifyClass
@@ -31,15 +33,11 @@
from Products.CMFCore.MembershipTool import MembershipTool
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import WarningInterceptor
from Products.CMFCore.URLTool import URLTool
-class ActionsToolTests(unittest.TestCase, WarningInterceptor):
+class ActionsToolTests(unittest.TestCase):
- def tearDown(self):
- self._free_warning_output()
-
def _getTargetClass(self):
from Products.CMFCore.ActionsTool import ActionsTool
@@ -87,16 +85,17 @@
del ActionProviderBase.__warningregistry__
except AttributeError:
pass
- self._trap_warning_output()
tool = self._makeOne()
tool.addAction('an_id', 'name', '', '', '', 'object')
- rval = tool.getActionObject('object/an_id')
- self.assertEqual(rval, tool._actions[0])
- warning = self._our_stderr_stream.getvalue()
- self.assertTrue(
- 'DeprecationWarning: '
- 'Old-style actions are deprecated and will be removed in CMF '
- '2.4. Use Action and Action Category objects instead.' in warning)
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ tool.getActionObject('object/an_id')
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertTrue(
+ 'Old-style actions are deprecated and will be removed in CMF '
+ '2.4. Use Action and Action Category objects instead.'
+ in str(w[-1].message))
def test_getActionObject_skips_newstyle_actions(self):
tool = self._makeOne()
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_FSPythonScript.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_FSPythonScript.py 2012-05-20 20:34:32 UTC (rev 126412)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_FSPythonScript.py 2012-05-21 09:23:02 UTC (rev 126413)
@@ -229,8 +229,8 @@
"""
_DIFF_TEXT = """\
---- original
-+++ modified
+--- original
++++ modified
@@ -7,4 +7,4 @@
##parameters=
##title=
@@ -262,7 +262,8 @@
self.assertEqual(len(list(cps.getDiff())), 0)
cps.write(_REPLACEMENT_TEXT)
- self.assertEqual(list(cps.getDiff()), _DIFF_TEXT.splitlines())
+ self.assertEqual([l.rstrip() for l in cps.getDiff()],
+ _DIFF_TEXT.splitlines())
class WarnMe(SimpleItem):
More information about the checkins
mailing list