[Zope3-checkins] CVS: Zope3/src/zope/documenttemplate/tests - dtmltestbase.py:1.3 testdt_if.py:1.5 testdt_in.py:1.4 testdt_try.py:1.5 testdt_var.py:1.5 testdt_with.py:1.4

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Mar 18 23:26:25 EST 2004


Update of /cvs-repository/Zope3/src/zope/documenttemplate/tests
In directory cvs.zope.org:/tmp/cvs-serv14372/src/zope/documenttemplate/tests

Modified Files:
	dtmltestbase.py testdt_if.py testdt_in.py testdt_try.py 
	testdt_var.py testdt_with.py 
Log Message:


Adjusted testing code to provide and expect unicode.




=== Zope3/src/zope/documenttemplate/tests/dtmltestbase.py 1.2 => 1.3 ===
--- Zope3/src/zope/documenttemplate/tests/dtmltestbase.py:1.2	Wed Dec 25 09:13:37 2002
+++ Zope3/src/zope/documenttemplate/tests/dtmltestbase.py	Thu Mar 18 23:26:25 2004
@@ -14,7 +14,6 @@
 
 $Id$
 """
-
 import os
 import unittest
 from zope.documenttemplate.dt_html import HTML


=== Zope3/src/zope/documenttemplate/tests/testdt_if.py 1.4 => 1.5 ===
--- Zope3/src/zope/documenttemplate/tests/testdt_if.py:1.4	Thu May  1 15:35:41 2003
+++ Zope3/src/zope/documenttemplate/tests/testdt_if.py	Thu Mar 18 23:26:25 2004
@@ -14,7 +14,6 @@
 
 $Id$
 """
-
 import unittest
 from zope.documenttemplate.tests.dtmltestbase import DTMLTestBase
 
@@ -24,14 +23,14 @@
     def testBasic(self):
 
         html = self.doc_class(
-            """\
+            u"""\
              <dtml-if value>
                The arguments were: <dtml-var value>
              </dtml-if>
             """)
 
-        result1 = "The arguments were: foo"
-        result2 = ""
+        result1 = u"The arguments were: foo"
+        result2 = u""
 
         self.assertEqual(html(value='foo').strip(), result1.strip())
         self.assertEqual(html().strip(), result2.strip())
@@ -40,7 +39,7 @@
     def testElse(self):
 
         html = self.doc_class(
-            """\
+            u"""\
              <dtml-if value>
                The arguments were: <dtml-var value>
              <dtml-else>
@@ -48,8 +47,8 @@
              </dtml-if>
             """)
 
-        result1 = "The arguments were: foo"
-        result2 = "No arguments were given."
+        result1 = u"The arguments were: foo"
+        result2 = u"No arguments were given."
 
         self.assertEqual(html(value='foo').strip(), result1.strip())
         self.assertEqual(html().strip(), result2.strip())
@@ -57,7 +56,7 @@
     def testElIf(self):
 
         html = self.doc_class(
-            """\
+            u"""\
              <dtml-if value>
                The arguments were: <dtml-var value>
              <dtml-elif attribute>
@@ -65,8 +64,8 @@
              </dtml-if>
             """)
 
-        result1 = "The arguments were: foo"
-        result2 = "The attributes were: bar"
+        result1 = u"The arguments were: foo"
+        result2 = u"The attributes were: bar"
 
         self.assertEqual(html(value='foo', attribute='').strip(),
                          result1.strip())


=== Zope3/src/zope/documenttemplate/tests/testdt_in.py 1.3 => 1.4 ===
--- Zope3/src/zope/documenttemplate/tests/testdt_in.py:1.3	Thu Mar 13 13:49:13 2003
+++ Zope3/src/zope/documenttemplate/tests/testdt_in.py	Thu Mar 18 23:26:25 2004
@@ -24,19 +24,19 @@
 
     def testMapping(self):
         data = (
-            dict(name='jim', age=39),
-            dict(name='kak', age=29),
-            dict(name='will', age=8),
-            dict(name='andrew', age=5),
-            dict(name='chessie',age=2),
+            dict(name=u'jim', age=39),
+            dict(name=u'kak', age=29),
+            dict(name=u'will', age=8),
+            dict(name=u'andrew', age=5),
+            dict(name=u'chessie',age=2),
             )
 
-        html="""
+        html=u"""
 <dtml-in data mapping>
    <dtml-var name>, <dtml-var age>
 </dtml-in>
 """
-        expected = """
+        expected = u"""
    jim, 39
    kak, 29
    will, 8
@@ -49,7 +49,7 @@
 
     def testObjectSequence(self):
         seq = (ObjectStub(name=1), ObjectStub(name=2), ObjectStub(name=3))
-        html = """
+        html = u"""
 <dtml-in seq>
    <dtml-var name>
 </dtml-in>
@@ -65,7 +65,7 @@
 
     def testSequenceNamespace(self):
         ns = {'prop_ids': ('name', 'id'), 'name': 'good', 'id': 'times'}
-        html = """:<dtml-in prop_ids><dtml-var sequence-item>=<dtml-var
+        html = u""":<dtml-in prop_ids><dtml-var sequence-item>=<dtml-var
         expr="_[_['sequence-item']]">:</dtml-in>"""
 
         result = self.doc_class(html)(None, ns)
@@ -75,8 +75,8 @@
 
 
     def testElse(self):
-        seq=(ObjectStub(name=1), ObjectStub(name=2), ObjectStub(name=3))
-        html="""
+        seq = (ObjectStub(name=1), ObjectStub(name=2), ObjectStub(name=3))
+        html = u"""
 <dtml-in data mapping>
 <dtml-var name>, <dtml-var age>
 <dtml-else>
@@ -85,7 +85,7 @@
 </dtml-in>
 </dtml-in>
 """
-        expected = """
+        expected = u"""
 1
 2
 3
@@ -95,19 +95,19 @@
 
 
     def testStringSyntax(self):
-        data=(
-            dict(name='jim', age=39),
-            dict(name='kak', age=29),
-            dict(name='will', age=8),
-            dict(name='andrew', age=5),
-            dict(name='chessie',age=2),
+        data = (
+            dict(name=u'jim', age=39),
+            dict(name=u'kak', age=29),
+            dict(name=u'will', age=8),
+            dict(name=u'andrew', age=5),
+            dict(name=u'chessie',age=2),
             )
-        s="""
+        s = u"""
 %(in data mapping)[
    %(name)s, %(age)s
 %(in)]
 """
-        expected = """
+        expected = u"""
    jim, 39
    kak, 29
    will, 8


=== Zope3/src/zope/documenttemplate/tests/testdt_try.py 1.4 => 1.5 ===
--- Zope3/src/zope/documenttemplate/tests/testdt_try.py:1.4	Thu May  1 15:35:41 2003
+++ Zope3/src/zope/documenttemplate/tests/testdt_try.py	Thu Mar 18 23:26:25 2004
@@ -23,7 +23,7 @@
     def testBasic(self):
 
         html = self.doc_class(
-            """
+            u"""
             <dtml-try>
               foo = <dtml-var value>
             <dtml-except>
@@ -31,8 +31,8 @@
             </dtml-try>
             """)
 
-        result1 = "foo = bar"
-        result2 = "There is no bar variable."
+        result1 = u"foo = bar"
+        result2 = u"There is no bar variable."
 
         self.assertEqual(html(value='bar').strip(), result1.strip())
         self.assertEqual(html().strip(), result2.strip())


=== Zope3/src/zope/documenttemplate/tests/testdt_var.py 1.4 => 1.5 ===
--- Zope3/src/zope/documenttemplate/tests/testdt_var.py:1.4	Thu May  1 15:35:41 2003
+++ Zope3/src/zope/documenttemplate/tests/testdt_var.py	Thu Mar 18 23:26:25 2004
@@ -25,15 +25,15 @@
 
     def testFmt(self):
         html = self.doc_class (
-            '''<dtml-var spam fmt="$%.2f bob\'s your uncle"
+            u'''<dtml-var spam fmt="$%.2f bob\'s your uncle"
                               null="spam%eggs!|">''')
 
-        self.assertEqual(html(spam=42), '$42.00 bob\'s your uncle')
-        self.assertEqual(html(spam=None), 'spam%eggs!|')
+        self.assertEqual(html(spam=42), u'$42.00 bob\'s your uncle')
+        self.assertEqual(html(spam=None), u'spam%eggs!|')
 
     def testDefaultFmt(self):
         html = self.doc_class (
-            """
+            u"""
                       <dtml-var spam >
             html:     <dtml-var spam fmt=html-quote>
             url:      <dtml-var spam fmt=url-quote>
@@ -46,7 +46,7 @@
             """)
 
         result1 = (
-            """
+            u"""
                       4200000
             html:     4200000
             url:      4200000
@@ -61,7 +61,7 @@
         # Caution:  Some of these lines have significant trailing whitespace.
         # Necessary trailing blanks are explicitly forced via \x20.
         result2 = (
-            """
+            u"""
                       None
             html:     None
             url:      None
@@ -74,7 +74,7 @@
             """)
 
         result3 = (
-            """
+            u"""
                       <a href="spam">\nfoo bar
             html:     &lt;a href=&quot;spam&quot;&gt;\nfoo bar
             url:      %3Ca%20href%3D%22spam%22%3E%0Afoo%20bar
@@ -88,7 +88,7 @@
 
         self.assertEqual(html(spam=4200000), result1)
         self.assertEqual(html(spam=None), result2)
-        self.assertEqual(html(spam='<a href="spam">\nfoo bar'), result3)
+        self.assertEqual(html(spam=u'<a href="spam">\nfoo bar'), result3)
 
 
     def testRender(self):
@@ -96,20 +96,20 @@
         class C:
             x = 1
             def y(self): return self.x * 2
-            h = self.doc_class("The h method, <dtml-var x> <dtml-var y>")
-            h2 = self.doc_class("The h2 method")
+            h = self.doc_class(u"The h method, <dtml-var x> <dtml-var y>")
+            h2 = self.doc_class(u"The h2 method")
 
-        res1 = self.doc_class("<dtml-var x>, <dtml-var y>, <dtml-var h>")(C())
+        res1 = self.doc_class(u"<dtml-var x>, <dtml-var y>, <dtml-var h>")(C())
         res2 = self.doc_class(
-           """
+           u"""
            <dtml-var expr="_.render(i.x)">,
            <dtml-var expr="_.render(i.y)">,
 
            <dtml-var expr="_.render(i.h2)">""")(i=C())
 
-        expected = '1, 2, The h method, 1 2'
+        expected = u'1, 2, The h method, 1 2'
         expected2 = (
-            """
+            u"""
            1,
            2,
 


=== Zope3/src/zope/documenttemplate/tests/testdt_with.py 1.3 => 1.4 ===
--- Zope3/src/zope/documenttemplate/tests/testdt_with.py:1.3	Thu Mar 13 13:49:13 2003
+++ Zope3/src/zope/documenttemplate/tests/testdt_with.py	Thu Mar 18 23:26:25 2004
@@ -22,15 +22,15 @@
 
     def testBasic(self):
         class person:
-            name='Jim'
+            name=u'Jim'
             height_inches=73
 
-        result = self.doc_class("""<dtml-with person>
+        result = self.doc_class(u'''<dtml-with person>
         Hi, my name is <dtml-var name>
         My height is <dtml-var "height_inches*2.54"> centimeters.
-        </dtml-with>""")(person=person)
+        </dtml-with>''')(person=person)
 
-        expected = """        Hi, my name is Jim
+        expected = u"""        Hi, my name is Jim
         My height is 185.42 centimeters.
         """
 




More information about the Zope3-Checkins mailing list