[Zope-Checkins] CVS: Zope/lib/python/AccessControl/tests - testSecurity.py:1.11.14.1

Tres Seaver tseaver at zope.com
Mon Jan 12 18:58:41 EST 2004


Update of /cvs-repository/Zope/lib/python/AccessControl/tests
In directory cvs.zope.org:/tmp/cvs-serv32086/lib/python/AccessControl/tests

Modified Files:
      Tag: Zope-2_7-branch
	testSecurity.py 
Log Message:
 - Ensure that min, max, and sum are in DTML namespace (Collector #1169)


=== Zope/lib/python/AccessControl/tests/testSecurity.py 1.11 => 1.11.14.1 ===
--- Zope/lib/python/AccessControl/tests/testSecurity.py:1.11	Mon Jan 27 17:55:27 2003
+++ Zope/lib/python/AccessControl/tests/testSecurity.py	Mon Jan 12 18:58:40 2004
@@ -78,6 +78,38 @@
         res = html(c=c)
         assert res == '10', res
 
+    def testNewDTMLBuiltins(self):
+
+        #
+        #   N.B.:  we *don't* test for the 2.2 / 2.3-only builtins
+        #          (sum, iter, enumerate) because they *shouldn't* be
+        #          available in Zope 2.6, which must be restricted to
+        #          Python 2.1 idioms.
+        #
+        NEW_BUILTINS_TEMPLATE = """
+        <dtml-var expr="_.min([1,2])">
+        <dtml-var expr="_.max([2,3])">
+        <dtml-var expr="_.sum([1,2,3,4])">
+        """
+
+        EXPECTED = ['1', '3', '10']
+
+        #
+        #   XXX:    these expressions seem like they should work, with
+        #           the following ExPECTED, but they raise Unauthorized
+        #           on the 'next' name.
+        #
+        #<dtml-var expr="_.iter([1,2,3]).next()">
+        #<dtml-var expr="_.enumerate([1,2,3]).next()">
+        #
+        #EXPECTED = ['1', '3', '10', '1', '(0, 1)']
+
+        template = self.doc_class(NEW_BUILTINS_TEMPLATE)
+        res = template()
+        lines = filter(None, [x.strip() for x in res.split('\n')])
+
+        self.assertEqual(lines, EXPECTED)
+
     # Note: we need more tests!
 
 def test_suite():




More information about the Zope-Checkins mailing list