[ZPT] CVS: Packages/TAL - test_htmltalparser.py:1.2

guido@digicool.com guido@digicool.com
Wed, 21 Mar 2001 17:43:46 -0500 (EST)


Update of /cvs-repository/Packages/TAL/test
In directory korak:/tmp/cvs-serv17854

Modified Files:
	test_htmltalparser.py 
Log Message:
Add tests detailing when <foo/> should be generated and when
<foo></foo>.  (This fails until the next checkins.)



--- Updated File test_htmltalparser.py in package Packages/TAL --
--- test_htmltalparser.py	2001/03/20 03:26:38	1.1
+++ test_htmltalparser.py	2001/03/21 22:43:46	1.2
@@ -11,12 +11,13 @@
 
 
 class HTMLTALParserTestCases(unittest.TestCase):
+
     def _run_check(self, source, program, macros={}):
         parser = HTMLTALParser.HTMLTALParser()
         parser.parseString(source)
         got_program, got_macros = parser.getCode()
-        assert got_program == program, got_program
-        assert got_macros == macros, got_macros
+        self.assert_(got_program == program, got_program)
+        self.assert_(got_macros == macros, got_macros)
 
     def _get_check(self, source, xxx=None):
         parser = HTMLTALParser.HTMLTALParser()
@@ -40,34 +41,34 @@
             ('setPosition', (1, 4)),
             ('rawtext', '<li>'),
             ('setPosition', (1, 8)),
-            ('rawtext', '<p/>'),
+            ('rawtext', '<p></p>'),
             ('setPosition', (1, 11)),
-            ('rawtext', '<p/></li>'),
+            ('rawtext', '<p></p></li>'),
             ('setPosition', (1, 14)),
-            ('rawtext', '<li/></ul>'),
+            ('rawtext', '<li></li></ul>'),
             ])
         self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [
             ('setPosition', (1, 0)),
             ('rawtext', '<dl>'),
             ('setPosition', (1, 4)),
-            ('rawtext', '<dt/>'),
+            ('rawtext', '<dt></dt>'),
             ('setPosition', (1, 8)),
-            ('rawtext', '<dt/>'),
+            ('rawtext', '<dt></dt>'),
             ('setPosition', (1, 12)),
-            ('rawtext', '<dd/>'),
+            ('rawtext', '<dd></dd>'),
             ('setPosition', (1, 16)),
             ('rawtext', '<dd>'),
             ('setPosition', (1, 20)),
             ('rawtext', '<ol>'),
             ('setPosition', (1, 24)),
-            ('rawtext', '<li/>'),
+            ('rawtext', '<li></li>'),
             ('setPosition', (1, 28)),
-            ('rawtext', '<li/></ol></dd></dl>'),
+            ('rawtext', '<li></li></ol></dd></dl>'),
             ])
 
     def check_code_implied_table_closings(self):
-        self._run_check("""<p>text <table><tr><th>head <tr><td>cell """
-                        """<table><tr><td>cell <tr>""", [
+        self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t"""
+                        """<table><tr><td>cell \n \t \n<tr>""", [
             ('setPosition', (1, 0)),
             ('rawtext', '<p>text</p> '),
             ('setPosition', (1, 8)),
@@ -75,19 +76,19 @@
             ('setPosition', (1, 15)),
             ('rawtext', '<tr>'),
             ('setPosition', (1, 19)),
-            ('rawtext', '<th>head</th></tr> '),
+            ('rawtext', '<th>head</th></tr>\t'),
             ('setPosition', (1, 28)),
             ('rawtext', '<tr>'),
             ('setPosition', (1, 32)),
-            ('rawtext', '<td>cell '),
+            ('rawtext', '<td>cell\t'),
             ('setPosition', (1, 41)),
             ('rawtext', '<table>'),
             ('setPosition', (1, 48)),
             ('rawtext', '<tr>'),
             ('setPosition', (1, 52)),
-            ('rawtext', '<td>cell</td></tr> '),
-            ('setPosition', (1, 61)),
-            ('rawtext', '<tr/></table></td></tr></table>'),
+            ('rawtext', '<td>cell</td></tr> \n \t \n'),
+            ('setPosition', (3, 0)),
+            ('rawtext', '<tr></tr></table></td></tr></table>'),
             ])
         self._run_check("""<table><tr><td>cell """
                         """<table><tr><td>cell </table></table>""", [
@@ -113,7 +114,7 @@
     def check_code_attr_syntax(self):
         output = [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a b="v" c="v" d="v" e="e"/>'),
+            ('rawtext', '<a b="v" c="v" d="v" e="e"></a>'),
             ]
         self._run_check("""<a b='v' c="v" d=v e>""", output)
         self._run_check("""<a  b = 'v' c = "v" d = v e>""", output)
@@ -125,41 +126,49 @@
             """<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
             [('setPosition', (1, 0)),
              ('rawtext',
-              '<a b="xxx\012\011xxx" c="yyy\011\012yyy" d="\011xyz\012"/>')])
+              '<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')])
         self._run_check("""<a b='' c="" d=>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a b="" c="" d=""/>'),
+            ('rawtext', '<a b="" c="" d=""></a>'),
             ])
 
     def check_code_attr_entity_replacement(self):
         # we expect entities *not* to be replaced by HTLMParser!
         self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"/>'),
+            ('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'),
             ])
         self._run_check("""<a b='\"'>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', "<a b='\"'/>"),
+            ('rawtext', "<a b='\"'></a>"),
             ])
         self._run_check("""<a b='&'>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a b="&amp;"/>'),
+            ('rawtext', '<a b="&amp;"></a>'),
             ])
         self._run_check("""<a b='<'>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a b="&lt;"/>'),
+            ('rawtext', '<a b="&lt;"></a>'),
             ])
 
     def check_code_attr_funky_names(self):
         self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
             ('setPosition', (1, 0)),
-            ('rawtext', '<a a.b="v" c:d="v" e-f="v"/>'),
+            ('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'),
+            ])
+
+    def check_code_pcdata_entityref(self):
+        self._run_check("""&nbsp;""", [
+            ('rawtext', '&nbsp;'),
             ])
 
-##     def check_code_pcdata_entityref(self):
-##         self._get_check("""&nbsp;""", [
-##             ('rawtext', '&nbsp;'),
-##             ])
+    def check_code_short_endtags(self):
+        self._run_check("""<html><img/></html>""", [
+            ('setPosition', (1, 0)),
+            ('rawtext', '<html>'),
+            ('setPosition', (1, 6)),
+            ('rawtext', '<img/></html>'),
+            ])
 
 
 def test_suite():