[ZPT] CVS: Zope/lib/python/Products/PageTemplates/tests - __init__.py:1.2 batch.py:1.3 testDTMLTests.py:1.7 testExpressions.py:1.9 testHTMLTests.py:1.13 testTALES.py:1.4 util.py:1.4
Martijn Pieters
mj@zope.com
Wed, 14 Aug 2002 18:17:26 -0400
Update of /cvs-repository/Zope/lib/python/Products/PageTemplates/tests
In directory cvs.zope.org:/tmp/cvs-serv23135/tests
Modified Files:
__init__.py batch.py testDTMLTests.py testExpressions.py
testHTMLTests.py testTALES.py util.py
Log Message:
Clean up indentation and trailing whitespace.
=== Zope/lib/python/Products/PageTemplates/tests/__init__.py 1.1 => 1.2 ===
--- Zope/lib/python/Products/PageTemplates/tests/__init__.py:1.1 Fri Mar 23 12:19:17 2001
+++ Zope/lib/python/Products/PageTemplates/tests/__init__.py Wed Aug 14 18:17:24 2002
@@ -19,7 +19,7 @@
'Harness method name "%s" called, "%s" expected.' %
(name, cs[0][0]) )
return self._method_
-
+
def _method_(self, *args, **kwargs):
name, aargs, akwargs = self.__callstack.pop(0)
assert aargs == args, "Harness method arguments"
@@ -34,4 +34,3 @@
assert aargs == args, "Harness method arguments"
assert akwargs == kwargs, "Harness method keyword args"
return result
-
=== Zope/lib/python/Products/PageTemplates/tests/batch.py 1.2 => 1.3 ===
--- Zope/lib/python/Products/PageTemplates/tests/batch.py:1.2 Wed Nov 28 10:51:01 2001
+++ Zope/lib/python/Products/PageTemplates/tests/batch.py Wed Aug 14 18:17:24 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
######################################################################
@@ -32,7 +32,7 @@
self._last=end-1
self._first=start-1
-
+
self._sequence=sequence
self._size=size
self._start=start
=== Zope/lib/python/Products/PageTemplates/tests/testDTMLTests.py 1.6 => 1.7 ===
--- Zope/lib/python/Products/PageTemplates/tests/testDTMLTests.py:1.6 Thu Jan 24 15:38:27 2002
+++ Zope/lib/python/Products/PageTemplates/tests/testDTMLTests.py Wed Aug 14 18:17:24 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import os, sys, unittest
@@ -20,7 +20,7 @@
from AccessControl.SecurityManagement import noSecurityManager
class AqPageTemplate(Implicit, PageTemplate):
- pass
+ pass
class UnitTestSecurityPolicy:
"""
@@ -39,105 +39,104 @@
, *args
, **kw):
return 1
-
+
def checkPermission( self, permission, object, context) :
return 1
class DTMLTests(unittest.TestCase):
- def setUp(self):
- self.t=(AqPageTemplate())
- self.policy = UnitTestSecurityPolicy()
- self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
- noSecurityManager() # Use the new policy.
-
- def tearDown(self):
- SecurityManager.setSecurityPolicy( self.oldPolicy )
- noSecurityManager() # Reset to old policy.
-
- def check1(self):
- """DTML test 1: if, in, and var:
-
- %(comment)[ blah %(comment)]
- <html><head><title>Test of documentation templates</title></head>
- <body>
- %(if args)[
- <dl><dt>The arguments to this test program were:<p>
- <dd>
- <ul>
- %(in args)[
- <li>Argument number %(num)d was %(arg)s
- %(in args)]
- </ul></dl><p>
- %(if args)]
- %(else args)[
- No arguments were given.<p>
- %(else args)]
- And thats da trooth.
- </body></html>
- """
-
- tal = util.read_input('DTML1.html')
- self.t.write(tal)
-
- aa=util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
- o=self.t.__of__(aa)()
- expect = util.read_output('DTML1a.html')
-
- util.check_xml(expect, o)
-
- aa=util.argv(())
- o=self.t.__of__(aa)()
- expect = util.read_output('DTML1b.html')
- util.check_xml(expect, o)
+ def setUp(self):
+ self.t=(AqPageTemplate())
+ self.policy = UnitTestSecurityPolicy()
+ self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
+ noSecurityManager() # Use the new policy.
+
+ def tearDown(self):
+ SecurityManager.setSecurityPolicy( self.oldPolicy )
+ noSecurityManager() # Reset to old policy.
- def check3(self):
- """DTML test 3: batches and formatting:
+ def check1(self):
+ """DTML test 1: if, in, and var:
+ %(comment)[ blah %(comment)]
<html><head><title>Test of documentation templates</title></head>
<body>
- <!--#if args-->
- The arguments were:
- <!--#in args size=size end=end-->
- <!--#if previous-sequence-->
- (<!--#var previous-sequence-start-arg-->-
- <!--#var previous-sequence-end-arg-->)
- <!--#/if previous-sequence-->
- <!--#if sequence-start-->
- <dl>
- <!--#/if sequence-start-->
- <dt><!--#var sequence-arg-->.</dt>
- <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
- <!--#if next-sequence-->
- (<!--#var next-sequence-start-arg-->-
- <!--#var next-sequence-end-arg-->)
- <!--#/if next-sequence-->
- <!--#/in args-->
- </dl>
- <!--#else args-->
- No arguments were given.<p>
- <!--#/if args-->
- And I\'m 100% sure!
+ %(if args)[
+ <dl><dt>The arguments to this test program were:<p>
+ <dd>
+ <ul>
+ %(in args)[
+ <li>Argument number %(num)d was %(arg)s
+ %(in args)]
+ </ul></dl><p>
+ %(if args)]
+ %(else args)[
+ No arguments were given.<p>
+ %(else args)]
+ And thats da trooth.
</body></html>
- """
+ """
- tal = util.read_input('DTML3.html')
- self.t.write(tal)
+ tal = util.read_input('DTML1.html')
+ self.t.write(tal)
- aa=util.argv(('one', 'two', 'three', 'four', 'five',
- 'six', 'seven', 'eight', 'nine', 'ten',
- 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
- 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty',
- ))
- from Products.PageTemplates.tests import batch
- o=self.t.__of__(aa)(batch=batch.batch(aa.args, 5))
+ aa=util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
+ o=self.t.__of__(aa)()
+ expect = util.read_output('DTML1a.html')
+
+ util.check_xml(expect, o)
+
+ aa=util.argv(())
+ o=self.t.__of__(aa)()
+ expect = util.read_output('DTML1b.html')
+ util.check_xml(expect, o)
+
+ def check3(self):
+ """DTML test 3: batches and formatting:
+
+ <html><head><title>Test of documentation templates</title></head>
+ <body>
+ <!--#if args-->
+ The arguments were:
+ <!--#in args size=size end=end-->
+ <!--#if previous-sequence-->
+ (<!--#var previous-sequence-start-arg-->-
+ <!--#var previous-sequence-end-arg-->)
+ <!--#/if previous-sequence-->
+ <!--#if sequence-start-->
+ <dl>
+ <!--#/if sequence-start-->
+ <dt><!--#var sequence-arg-->.</dt>
+ <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
+ <!--#if next-sequence-->
+ (<!--#var next-sequence-start-arg-->-
+ <!--#var next-sequence-end-arg-->)
+ <!--#/if next-sequence-->
+ <!--#/in args-->
+ </dl>
+ <!--#else args-->
+ No arguments were given.<p>
+ <!--#/if args-->
+ And I\'m 100% sure!
+ </body></html>
+ """
+
+ tal = util.read_input('DTML3.html')
+ self.t.write(tal)
+
+ aa=util.argv(('one', 'two', 'three', 'four', 'five',
+ 'six', 'seven', 'eight', 'nine', 'ten',
+ 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
+ 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty',
+ ))
+ from Products.PageTemplates.tests import batch
+ o=self.t.__of__(aa)(batch=batch.batch(aa.args, 5))
- expect = util.read_output('DTML3.html')
- util.check_xml(expect, o)
+ expect = util.read_output('DTML3.html')
+ util.check_xml(expect, o)
def test_suite():
- return unittest.makeSuite(DTMLTests, 'check')
+ return unittest.makeSuite(DTMLTests, 'check')
if __name__=='__main__':
- main()
-
+ main()
=== Zope/lib/python/Products/PageTemplates/tests/testExpressions.py 1.8 => 1.9 ===
--- Zope/lib/python/Products/PageTemplates/tests/testExpressions.py:1.8 Wed Oct 17 16:00:33 2001
+++ Zope/lib/python/Products/PageTemplates/tests/testExpressions.py Wed Aug 14 18:17:24 2002
@@ -15,7 +15,7 @@
e.compile('string:a ${x/y} b ${y/z} c')
e.compile('python: 2 + 2')
e.compile('python: 2 \n+\n 2\n')
-
+
def test_suite():
return unittest.makeSuite(ExpressionTests)
=== Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py 1.12 => 1.13 ===
--- Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py:1.12 Fri Jan 11 15:52:48 2002
+++ Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py Wed Aug 14 18:17:24 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
import os, sys, unittest
@@ -20,10 +20,10 @@
from Acquisition import Implicit
class AqPageTemplate(Implicit, PageTemplate):
- pass
+ pass
class Folder(util.Base):
- pass
+ pass
class UnitTestSecurityPolicy:
@@ -43,91 +43,90 @@
, *args
, **kw):
return 1
-
+
def checkPermission( self, permission, object, context) :
return 1
class HTMLTests(unittest.TestCase):
- def setUp(self):
- self.folder = f = Folder()
- f.laf = AqPageTemplate()
- f.t = AqPageTemplate()
- self.policy = UnitTestSecurityPolicy()
- self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
- noSecurityManager() # Use the new policy.
-
- def tearDown(self):
- SecurityManager.setSecurityPolicy( self.oldPolicy )
- noSecurityManager() # Reset to old policy.
-
- def assert_expected(self, t, fname, *args, **kwargs):
- t.write(util.read_input(fname))
- assert not t._v_errors, 'Template errors: %s' % t._v_errors
- expect = util.read_output(fname)
- out = apply(t, args, kwargs)
- util.check_html(expect, out)
-
- def getProducts(self):
- return [
- {'description': 'This is the tee for those who LOVE Zope. '
- 'Show your heart on your tee.',
- 'price': 12.99, 'image': 'smlatee.jpg'
- },
- {'description': 'This is the tee for Jim Fulton. '
- 'He\'s the Zope Pope!',
- 'price': 11.99, 'image': 'smpztee.jpg'
- },
- ]
-
- def check1(self):
- self.assert_expected(self.folder.laf, 'TeeShopLAF.html')
-
- def check2(self):
- self.folder.laf.write(util.read_input('TeeShopLAF.html'))
-
- self.assert_expected(self.folder.t, 'TeeShop2.html',
- getProducts=self.getProducts)
-
- def check3(self):
- self.folder.laf.write(util.read_input('TeeShopLAF.html'))
-
- self.assert_expected(self.folder.t, 'TeeShop1.html',
- getProducts=self.getProducts)
-
- def checkSimpleLoop(self):
- self.assert_expected(self.folder.t, 'Loop1.html')
-
- def checkFancyLoop(self):
- self.assert_expected(self.folder.t, 'Loop2.html')
-
- def checkGlobalsShadowLocals(self):
- self.assert_expected(self.folder.t, 'GlobalsShadowLocals.html')
-
- def checkStringExpressions(self):
- self.assert_expected(self.folder.t, 'StringExpression.html')
-
- def checkReplaceWithNothing(self):
- self.assert_expected(self.folder.t, 'CheckNothing.html')
-
- def checkWithXMLHeader(self):
- self.assert_expected(self.folder.t, 'CheckWithXMLHeader.html')
-
- def checkNotExpression(self):
- self.assert_expected(self.folder.t, 'CheckNotExpression.html')
-
- def checkPathNothing(self):
- self.assert_expected(self.folder.t, 'CheckPathNothing.html')
-
- def checkPathAlt(self):
- self.assert_expected(self.folder.t, 'CheckPathAlt.html')
+ def setUp(self):
+ self.folder = f = Folder()
+ f.laf = AqPageTemplate()
+ f.t = AqPageTemplate()
+ self.policy = UnitTestSecurityPolicy()
+ self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
+ noSecurityManager() # Use the new policy.
+
+ def tearDown(self):
+ SecurityManager.setSecurityPolicy( self.oldPolicy )
+ noSecurityManager() # Reset to old policy.
+
+ def assert_expected(self, t, fname, *args, **kwargs):
+ t.write(util.read_input(fname))
+ assert not t._v_errors, 'Template errors: %s' % t._v_errors
+ expect = util.read_output(fname)
+ out = apply(t, args, kwargs)
+ util.check_html(expect, out)
+
+ def getProducts(self):
+ return [
+ {'description': 'This is the tee for those who LOVE Zope. '
+ 'Show your heart on your tee.',
+ 'price': 12.99, 'image': 'smlatee.jpg'
+ },
+ {'description': 'This is the tee for Jim Fulton. '
+ 'He\'s the Zope Pope!',
+ 'price': 11.99, 'image': 'smpztee.jpg'
+ },
+ ]
+
+ def check1(self):
+ self.assert_expected(self.folder.laf, 'TeeShopLAF.html')
+
+ def check2(self):
+ self.folder.laf.write(util.read_input('TeeShopLAF.html'))
+
+ self.assert_expected(self.folder.t, 'TeeShop2.html',
+ getProducts=self.getProducts)
+
+ def check3(self):
+ self.folder.laf.write(util.read_input('TeeShopLAF.html'))
+
+ self.assert_expected(self.folder.t, 'TeeShop1.html',
+ getProducts=self.getProducts)
+
+ def checkSimpleLoop(self):
+ self.assert_expected(self.folder.t, 'Loop1.html')
+
+ def checkFancyLoop(self):
+ self.assert_expected(self.folder.t, 'Loop2.html')
+
+ def checkGlobalsShadowLocals(self):
+ self.assert_expected(self.folder.t, 'GlobalsShadowLocals.html')
+
+ def checkStringExpressions(self):
+ self.assert_expected(self.folder.t, 'StringExpression.html')
+
+ def checkReplaceWithNothing(self):
+ self.assert_expected(self.folder.t, 'CheckNothing.html')
+
+ def checkWithXMLHeader(self):
+ self.assert_expected(self.folder.t, 'CheckWithXMLHeader.html')
+
+ def checkNotExpression(self):
+ self.assert_expected(self.folder.t, 'CheckNotExpression.html')
+
+ def checkPathNothing(self):
+ self.assert_expected(self.folder.t, 'CheckPathNothing.html')
- def checkBatchIteration(self):
- self.assert_expected(self.folder.t, 'CheckBatchIteration.html')
+ def checkPathAlt(self):
+ self.assert_expected(self.folder.t, 'CheckPathAlt.html')
+
+ def checkBatchIteration(self):
+ self.assert_expected(self.folder.t, 'CheckBatchIteration.html')
def test_suite():
- return unittest.makeSuite(HTMLTests, 'check')
+ return unittest.makeSuite(HTMLTests, 'check')
if __name__=='__main__':
- main()
-
+ main()
=== Zope/lib/python/Products/PageTemplates/tests/testTALES.py 1.3 => 1.4 ===
--- Zope/lib/python/Products/PageTemplates/tests/testTALES.py:1.3 Wed Oct 17 16:00:33 2001
+++ Zope/lib/python/Products/PageTemplates/tests/testTALES.py Wed Aug 14 18:17:24 2002
@@ -94,7 +94,7 @@
ctxt.setLocal('v2', 2)
assert c['v1'] == 1, 'Variable "v1"'
-
+
ctxt.beginScope()
ctxt.setLocal('v1', 3)
ctxt.setGlobal('g', 1)
@@ -109,7 +109,7 @@
assert c['g'] == 1, "Global from inner scope"
ctxt.endScope()
-
+
def test_suite():
return unittest.makeSuite(TALESTests)
=== Zope/lib/python/Products/PageTemplates/tests/util.py 1.3 => 1.4 ===
--- Zope/lib/python/Products/PageTemplates/tests/util.py:1.3 Wed Nov 28 10:51:01 2001
+++ Zope/lib/python/Products/PageTemplates/tests/util.py Wed Aug 14 18:17:24 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
######################################################################
@@ -28,15 +28,15 @@
def items(self): return [('bruce',self)]*7
def __len__(self): return 7
def __getitem__(self,index):
- if (type(index) is type(1) and
+ if (type(index) is type(1) and
(index < 0 or index > 6)): raise IndexError, index
return self
isDocTemp=0
def __getattr__(self,name):
if name[:1]=='_': raise AttributeError, name
return self
-
-bruce=Bruce()
+
+bruce=Bruce()
class arg(Base):
__allow_access_to_unprotected_subobjects__=1