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

evan@serenade.digicool.com evan@serenade.digicool.com
Sat, 16 Jun 2001 11:50:13 -0400


Update of /cvs-repository/Packages/TAL/tests
In directory serenade:/home/evan/Zope/pt/lib/python/TAL/tests

Modified Files:
      Tag: tal-1_3_0
	test_htmltalparser.py 
Log Message:
Merge trunk changes for release 1.3.2



--- Updated File test_htmltalparser.py in package Packages/TAL --
--- test_htmltalparser.py	2001/05/18 01:24:05	1.18
+++ test_htmltalparser.py	2001/06/16 15:49:42	1.18.2.1
@@ -7,6 +7,8 @@
 import utils
 import unittest
 
+from string import rfind
+
 from TAL import HTMLTALParser
 from TAL.TALDefs import TAL_VERSION, TALError, METALError
 
@@ -19,10 +21,14 @@
     final_program = []
 
     def _merge(self, p1, p2):
-        if p1 and p2 and p1[-1][0] == 'rawtext' and p2[0][0] == 'rawtext':
-            return p1[:-1] + [('rawtext', p1[-1][1] + p2[0][1])] + p2[1:]
-        else:
-            return p1+p2
+        if p1 and p2:
+            op1, args1 = p1[-1]
+            op2, args2 = p2[0]
+            if op1[:7] == 'rawtext' and op2[:7] == 'rawtext':
+                return (p1[:-1]
+                        + [rawtext(args1[0] + args2[0])]
+                        + p2[1:])
+        return p1+p2
 
     def _run_check(self, source, program, macros={}):
         parser = HTMLTALParser.HTMLTALParser()
@@ -30,8 +36,12 @@
         got_program, got_macros = parser.getCode()
         program = self._merge(self.initial_program, program)
         program = self._merge(program, self.final_program)
-        self.assert_(got_program == program, got_program)
-        self.assert_(got_macros == macros, got_macros)
+        self.assert_(got_program == program,
+                     "Program:\n" + pprint.pformat(got_program)
+                     + "\nExpected:\n" + pprint.pformat(program))
+        self.assert_(got_macros == macros,
+                     "Macros:\n" + pprint.pformat(got_macros)
+                     + "\nExpected:\n" + pprint.pformat(macros))
 
     def _get_check(self, source, program=[], macros={}):
         parser = HTMLTALParser.HTMLTALParser()
@@ -47,34 +57,42 @@
         self.assertRaises(exc, parse)
 
 
+def rawtext(s):
+    """Compile raw text to the appropriate instruction."""
+    if "\n" in s:
+        return ("rawtextColumn", (s, len(s) - (rfind(s, "\n") + 1)))
+    else:
+        return ("rawtextOffset", (s, len(s)))
+
+
 class HTMLTALParserTestCases(TestCaseBase):
 
     def check_code_simple_identity(self):
         self._run_check("""<html a='b' b="c" c=d><title>My Title</html>""", [
-            ('rawtext', '<html a="b" b="c" c="d">'
-                        '<title>My Title</title></html>'),
+            rawtext('<html a="b" b="c" c="d">'
+                    '<title>My Title</title></html>'),
             ])
 
     def check_code_implied_list_closings(self):
         self._run_check("""<ul><li><p><p><li></ul>""", [
-            ('rawtext', '<ul><li><p></p><p></p></li><li></li></ul>'),
+            rawtext('<ul><li><p></p><p></p></li><li></li></ul>'),
             ])
         self._run_check("""<dl><dt><dt><dd><dd><ol><li><li></ol></dl>""", [
-            ('rawtext', '<dl><dt></dt><dt></dt><dd></dd>'
-                        '<dd><ol><li></li><li></li></ol></dd></dl>'),
+            rawtext('<dl><dt></dt><dt></dt><dd></dd>'
+                    '<dd><ol><li></li><li></li></ol></dd></dl>'),
             ])
 
     def check_code_implied_table_closings(self):
         self._run_check("""<p>text <table><tr><th>head\t<tr><td>cell\t"""
                         """<table><tr><td>cell \n \t \n<tr>""", [
-            ('rawtext', '<p>text</p> <table><tr><th>head</th>'
-                        '</tr>\t<tr><td>cell\t<table><tr><td>cell</td>'
-                        '</tr> \n \t \n<tr></tr></table></td></tr></table>'),
+            rawtext('<p>text</p> <table><tr><th>head</th>'
+                    '</tr>\t<tr><td>cell\t<table><tr><td>cell</td>'
+                    '</tr> \n \t \n<tr></tr></table></td></tr></table>'),
             ])
         self._run_check("""<table><tr><td>cell """
                         """<table><tr><td>cell </table></table>""", [
-            ('rawtext', '<table><tr><td>cell <table><tr><td>cell</td></tr>'
-                        ' </table></td></tr></table>'),
+            rawtext('<table><tr><td>cell <table><tr><td>cell</td></tr>'
+                    ' </table></td></tr></table>'),
             ])
 
     def check_code_bad_nesting(self):
@@ -84,7 +102,7 @@
 
     def check_code_attr_syntax(self):
         output = [
-            ('rawtext', '<a b="v" c="v" d="v" e></a>'),
+            rawtext('<a b="v" c="v" d="v" 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)
@@ -94,40 +112,39 @@
     def check_code_attr_values(self):
         self._run_check(
             """<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [
-            ('rawtext',
-             '<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')])
+            rawtext('<a b="xxx\n\txxx" c="yyy\t\nyyy" d="\txyz\n"></a>')])
         self._run_check("""<a b='' c="">""", [
-            ('rawtext', '<a b="" c=""></a>'),
+            rawtext('<a b="" c=""></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;'>""", [
-            ('rawtext', '<a b="&amp;&gt;&lt;&quot;\'"></a>'),
+            rawtext('<a b="&amp;&gt;&lt;&quot;\'"></a>'),
             ])
         self._run_check("""<a b='\"'>""", [
-            ('rawtext', '<a b="&quot;"></a>'),
+            rawtext('<a b="&quot;"></a>'),
             ])
         self._run_check("""<a b='&'>""", [
-            ('rawtext', '<a b="&amp;"></a>'),
+            rawtext('<a b="&amp;"></a>'),
             ])
         self._run_check("""<a b='<'>""", [
-            ('rawtext', '<a b="&lt;"></a>'),
+            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>""", [
-            ('rawtext', '<a a.b="v" c:d="v" e-f="v"></a>'),
+            rawtext('<a a.b="v" c:d="v" e-f="v"></a>'),
             ])
 
     def check_code_pcdata_entityref(self):
         self._run_check("""&nbsp;""", [
-            ('rawtext', '&nbsp;'),
+            rawtext('&nbsp;'),
             ])
 
     def check_code_short_endtags(self):
         self._run_check("""<html><img/></html>""", [
-            ('rawtext', '<html><img /></html>'),
+            rawtext('<html><img /></html>'),
             ])
 
 
@@ -138,11 +155,12 @@
 
     def check_define_macro(self):
         macro = self.initial_program + [
-            ('startTag', 'p', [('metal:define-macro', 'M', 'metal')]),
-            ('rawtext', 'booh</p>')]
+            ('startTag', ('p', [('metal:define-macro', 'M', 2)])),
+            rawtext('booh</p>'),
+            ]
         program = [
             ('setPosition', (1, 0)),
-            ('defineMacro', 'M', macro),
+            ('defineMacro', ('M', macro)),
             ]
         macros = {'M': macro}
         self._run_check('<p metal:define-macro="M">booh</p>', program, macros)
@@ -151,23 +169,23 @@
         self._run_check('<p metal:use-macro="M">booh</p>', [
             ('setPosition', (1, 0)),
             ('useMacro',
-             'M', '$M$', {},
-             [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
-              ('rawtext', 'booh</p>')]),
+             ('M', '$M$', {},
+              [('startTag', ('p', [('metal:use-macro', 'M', 2)])),
+               rawtext('booh</p>')])),
             ])
 
     def check_define_slot(self):
         macro = self.initial_program + [
-            ('startTag', 'p', [('metal:define-macro', 'M', 'metal')]),
-            ('rawtext', 'foo'),
+            ('startTag', ('p', [('metal:define-macro', 'M', 2)])),
+            rawtext('foo'),
             ('setPosition', (1, 29)),
-            ('defineSlot', 'S',
-             [('startTag', 'span', [('metal:define-slot', 'S', 'metal')]),
-              ('rawtext', 'spam</span>')]),
-            ('rawtext', 'bar</p>'),
+            ('defineSlot', ('S',
+             [('startTag', ('span', [('metal:define-slot', 'S', 2)])),
+              rawtext('spam</span>')])),
+            rawtext('bar</p>'),
             ]
         program = [('setPosition', (1, 0)),
-                   ('defineMacro', 'M', macro)]
+                   ('defineMacro', ('M', macro))]
         macros = {'M': macro}
         self._run_check('<p metal:define-macro="M">foo'
                         '<span metal:define-slot="S">spam</span>bar</p>',
@@ -178,16 +196,17 @@
                         '<span metal:fill-slot="S">spam</span>bar</p>', [
             ('setPosition', (1, 0)),
             ('useMacro',
-             'M', '$M$',
-             {'S': [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
-                    ('rawtext', 'spam</span>')]},
-             [('startTag', 'p', [('metal:use-macro', 'M', 'metal')]),
-              ('rawtext', 'foo'),
+             ('M', '$M$',
+              {'S': [('startTag', ('span',
+                                   [('metal:fill-slot', 'S', 2)])),
+                     rawtext('spam</span>')]},
+             [('startTag', ('p', [('metal:use-macro', 'M', 2)])),
+              rawtext('foo'),
               ('setPosition', (1, 26)),
-              ('fillSlot', 'S',
-               [('startTag', 'span', [('metal:fill-slot', 'S', 'metal')]),
-                ('rawtext', 'spam</span>')]),
-              ('rawtext', 'bar</p>')]),
+              ('fillSlot', ('S',
+               [('startTag', ('span', [('metal:fill-slot', 'S', 2)])),
+                rawtext('spam</span>')])),
+              rawtext('bar</p>')])),
             ])
 
 
@@ -199,177 +218,165 @@
     def check_define_1(self):
         self._run_check("<p tal:define='xyzzy string:spam'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:define': 'xyzzy string:spam'}),
-            ('setLocal', 'xyzzy', '$string:spam$'),
-            ('startTag', 'p', [('tal:define', 'xyzzy string:spam', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('beginScope', {'tal:define': 'xyzzy string:spam'}),
+            ('setLocal', ('xyzzy', '$string:spam$')),
+            ('startTag', ('p', [('tal:define', 'xyzzy string:spam', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_define_2(self):
         self._run_check("<p tal:define='local xyzzy string:spam'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:define': 'local xyzzy string:spam'}),
-            ('setLocal', 'xyzzy', '$string:spam$'),
-            ('startTag', 'p',
-             [('tal:define', 'local xyzzy string:spam', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('beginScope', {'tal:define': 'local xyzzy string:spam'}),
+            ('setLocal', ('xyzzy', '$string:spam$')),
+            ('startTag', ('p',
+             [('tal:define', 'local xyzzy string:spam', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_define_3(self):
         self._run_check("<p tal:define='global xyzzy string:spam'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:define': 'global xyzzy string:spam'}),
-            ('setGlobal', 'xyzzy', '$string:spam$'),
-            ('startTag', 'p',
-             [('tal:define', 'global xyzzy string:spam', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('beginScope', {'tal:define': 'global xyzzy string:spam'}),
+            ('setGlobal', ('xyzzy', '$string:spam$')),
+            ('startTag', ('p',
+             [('tal:define', 'global xyzzy string:spam', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_define_4(self):
         self._run_check("<p tal:define='x string:spam; y x'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:define': 'x string:spam; y x'}),
-            ('setLocal', 'x', '$string:spam$'),
-            ('setLocal', 'y', '$x$'),
-            ('startTag', 'p', [('tal:define', 'x string:spam; y x', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('beginScope', {'tal:define': 'x string:spam; y x'}),
+            ('setLocal', ('x', '$string:spam$')),
+            ('setLocal', ('y', '$x$')),
+            ('startTag', ('p', [('tal:define', 'x string:spam; y x', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_define_5(self):
         self._run_check("<p tal:define='x string:;;;;; y x'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:define': 'x string:;;;;; y x'}),
-            ('setLocal', 'x', '$string:;;$'),
-            ('setLocal', 'y', '$x$'),
-            ('startTag', 'p', [('tal:define', 'x string:;;;;; y x', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('beginScope', {'tal:define': 'x string:;;;;; y x'}),
+            ('setLocal', ('x', '$string:;;$')),
+            ('setLocal', ('y', '$x$')),
+            ('startTag', ('p', [('tal:define', 'x string:;;;;; y x', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_define_6(self):
         self._run_check(
             "<p tal:define='x string:spam; global y x; local z y'></p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs',
+            ('beginScope',
              {'tal:define': 'x string:spam; global y x; local z y'}),
-            ('setLocal', 'x', '$string:spam$'),
-            ('setGlobal', 'y', '$x$'),
-            ('setLocal', 'z', '$y$'),
-            ('startTag', 'p',
-             [('tal:define', 'x string:spam; global y x; local z y', 'tal')]),
-            ('rawtext', '</p>'),
-            ('endScope',),
+            ('setLocal', ('x', '$string:spam$')),
+            ('setGlobal', ('y', '$x$')),
+            ('setLocal', ('z', '$y$')),
+            ('startTag', ('p',
+             [('tal:define', 'x string:spam; global y x; local z y', 3)])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_condition(self):
         self._run_check(
             "<p><span tal:condition='python:1'><b>foo</b></span></p>", [
-            ('rawtext', '<p>'),
+            rawtext('<p>'),
             ('setPosition', (1, 3)),
-            ('beginScope',),
-            ('rawAttrs', {'tal:condition': 'python:1'}),
-            ('condition', '$python:1$',
-             [('startTag', 'span', [('tal:condition', 'python:1', 'tal')]),
-              ('rawtext', '<b>foo</b></span>')]),
-            ('endScope',),
-            ('rawtext', '</p>'),
+            ('beginScope', {'tal:condition': 'python:1'}),
+            ('condition', ('$python:1$',
+             [('startTag', ('span', [('tal:condition', 'python:1', 3)])),
+              rawtext('<b>foo</b></span>')])),
+            ('endScope', ()),
+            rawtext('</p>'),
             ])
 
     def check_content_1(self):
         self._run_check("<p tal:content='string:foo'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:content': 'string:foo'}), 
-             ('startTag', 'p', [('tal:content', 'string:foo', 'tal')]),
-             ('insertText', '$string:foo$', [('rawtext', 'bar')]),
-             ('rawtext', '</p>'),
-             ('endScope',),
+             ('beginScope', {'tal:content': 'string:foo'}), 
+             ('startTag', ('p', [('tal:content', 'string:foo', 3)])),
+             ('insertText', ('$string:foo$', [rawtext('bar')])),
+             ('endScope', ()),
+             rawtext('</p>'),
              ])
 
     def check_content_2(self):
         self._run_check("<p tal:content='text string:foo'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:content': 'text string:foo'}),
-             ('startTag', 'p', [('tal:content', 'text string:foo', 'tal')]),
-             ('insertText', '$string:foo$', [('rawtext', 'bar')]),
-             ('rawtext', '</p>'),
-             ('endScope',),
+             ('beginScope', {'tal:content': 'text string:foo'}),
+             ('startTag', ('p', [('tal:content', 'text string:foo', 3)])),
+             ('insertText', ('$string:foo$', [rawtext('bar')])),
+             ('endScope', ()),
+             rawtext('</p>'),
              ])
 
     def check_content_3(self):
         self._run_check("<p tal:content='structure string:<br>'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:content': 'structure string:<br>'}),
-             ('startTag', 'p',
-              [('tal:content', 'structure string:<br>', 'tal')]),
-             ('insertStructure', '$string:<br>$', {}, [('rawtext', 'bar')]),
-             ('rawtext', '</p>'),
-             ('endScope',),
+             ('beginScope', {'tal:content': 'structure string:<br>'}),
+             ('startTag', ('p',
+              [('tal:content', 'structure string:<br>', 3)])),
+             ('insertStructure',
+              ('$string:<br>$', {}, [rawtext('bar')])),
+             ('endScope', ()),
+             rawtext('</p>'),
              ])
 
     def check_replace_1(self):
         self._run_check("<p tal:replace='string:foo'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:replace': 'string:foo'}),
-             ('insertText', '$string:foo$',
-              [('startTag', 'p', [('tal:replace', 'string:foo', 'tal')]),
-               ('rawtext', 'bar</p>')]),
-             ('endScope',),
+             ('beginScope', {'tal:replace': 'string:foo'}),
+             ('insertText', ('$string:foo$',
+              [('startTag', ('p', [('tal:replace', 'string:foo', 3)])),
+               rawtext('bar</p>')])),
+             ('endScope', ()),
              ])
 
     def check_replace_2(self):
         self._run_check("<p tal:replace='text string:foo'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:replace': 'text string:foo'}),
-             ('insertText', '$string:foo$',
-              [('startTag', 'p', [('tal:replace', 'text string:foo', 'tal')]),
-               ('rawtext', 'bar</p>')]),
-             ('endScope',),
+             ('beginScope', {'tal:replace': 'text string:foo'}),
+             ('insertText', ('$string:foo$',
+              [('startTag', ('p',
+                             [('tal:replace', 'text string:foo', 3)])),
+               rawtext('bar</p>')])),
+             ('endScope', ()),
              ])
 
     def check_replace_3(self):
         self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:replace': 'structure string:<br>'}),
-             ('insertStructure', '$string:<br>$', {},
-              [('startTag', 'p',
-                [('tal:replace', 'structure string:<br>', 'tal')]),
-               ('rawtext', 'bar</p>')]),
-             ('endScope',),
+             ('beginScope', {'tal:replace': 'structure string:<br>'}),
+             ('insertStructure', ('$string:<br>$', {},
+              [('startTag', ('p',
+                [('tal:replace', 'structure string:<br>', 3)])),
+               rawtext('bar</p>')])),
+             ('endScope', ()),
              ])
 
     def check_repeat(self):
         self._run_check("<p tal:repeat='x python:(1,2,3)'>"
                         "<span tal:replace='x'>dummy</span></p>", [
              ('setPosition', (1, 0)),
-             ('beginScope',),
-             ('rawAttrs', {'tal:repeat': 'x python:(1,2,3)'}),
-             ('loop', 'x', '$python:(1,2,3)$',
-              [('startTag', 'p', [('tal:repeat', 'x python:(1,2,3)', 'tal')]),
+             ('beginScope', {'tal:repeat': 'x python:(1,2,3)'}),
+             ('loop', ('x', '$python:(1,2,3)$',
+              [('startTag', ('p',
+                             [('tal:repeat', 'x python:(1,2,3)', 3)])),
                ('setPosition', (1, 33)),
-               ('beginScope',),
-               ('rawAttrs', {'tal:replace': 'x'}),
-               ('insertText', '$x$',
-                [('startTag', 'span', [('tal:replace', 'x', 'tal')]),
-                 ('rawtext', 'dummy</span>')]),
-               ('endScope',),
-               ('rawtext', '</p>')]),
-             ('endScope',),
+               ('beginScope', {'tal:replace': 'x'}),
+               ('insertText', ('$x$',
+                [('startTag', ('span', [('tal:replace', 'x', 3)])),
+                 rawtext('dummy</span>')])),
+               ('endScope', ()),
+               rawtext('</p>')])),
+             ('endScope', ()),
              ])
 
     def check_attributes_1(self):
@@ -377,77 +384,73 @@
                         "'href string:http://www.zope.org; x string:y'>"
                         "link</a>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs',
+            ('beginScope',
              {'tal:attributes': 'href string:http://www.zope.org; x string:y',
               'name': 'bar', 'href': 'foo'}),
-            ('startTag', 'a',
-             [('href', 'foo', 'replace', '$string:http://www.zope.org$'),
-              ('name', 'bar'),
+            ('startTag', ('a',
+             [('href', 'foo', 0, '$string:http://www.zope.org$'),
+              ('name', 'name="bar"'),
               ('tal:attributes',
-               'href string:http://www.zope.org; x string:y', 'tal'),
-              ('x', None, 'insert', '$string:y$')]),
-            ('rawtext', 'link</a>'),
-            ('endScope',),
+               'href string:http://www.zope.org; x string:y', 3),
+              ('x', None, 1, '$string:y$')])),
+            ('endScope', ()),
+            rawtext('link</a>'),
             ])
 
     def check_attributes_2(self):
         self._run_check("<p tal:replace='structure string:<img>' "
                         "tal:attributes='src string:foo.png'>duh</p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs',
+            ('beginScope',
              {'tal:attributes': 'src string:foo.png',
               'tal:replace': 'structure string:<img>'}),
-            ('insertStructure', '$string:<img>$',
+            ('insertStructure', ('$string:<img>$',
              {'src': '$string:foo.png$'},
-             [('startTag', 'p',
-               [('tal:replace', 'structure string:<img>', 'tal'),
-                ('tal:attributes', 'src string:foo.png', 'tal')]),
-              ('rawtext', 'duh</p>')]),
-            ('endScope',),
+             [('startTag', ('p',
+               [('tal:replace', 'structure string:<img>', 3),
+                ('tal:attributes', 'src string:foo.png', 3)])),
+              rawtext('duh</p>')])),
+            ('endScope', ()),
             ])
 
     def check_on_error_1(self):
         self._run_check("<p tal:on-error='string:error' "
                         "tal:content='notHere'>okay</p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs',
+            ('beginScope',
              {'tal:content': 'notHere', 'tal:on-error': 'string:error'}),
             ('onError',
-             [('startTag', 'p',
-               [('tal:on-error', 'string:error', 'tal'),
-                ('tal:content', 'notHere', 'tal')]),
-              ('insertText', '$notHere$', [('rawtext', 'okay')]),
-              ('rawtext', '</p>')],
-             [('startTag', 'p',
-               [('tal:on-error', 'string:error', 'tal'),
-                ('tal:content', 'notHere', 'tal')]),
-              ('insertText', '$string:error$', []),
-              ('rawtext', '</p>')]),
-            ('endScope',),
+             ([('startTag', ('p',
+                [('tal:on-error', 'string:error', 3),
+                 ('tal:content', 'notHere', 3)])),
+               ('insertText', ('$notHere$', [rawtext('okay')])),
+               rawtext('</p>')],
+              [('startTag', ('p',
+                [('tal:on-error', 'string:error', 3),
+                 ('tal:content', 'notHere', 3)])),
+               ('insertText', ('$string:error$', [])),
+               rawtext('</p>')])),
+            ('endScope', ()),
             ])
 
     def check_on_error_2(self):
         self._run_check("<p tal:on-error='string:error' "
                         "tal:replace='notHere'>okay</p>", [
             ('setPosition', (1, 0)),
-            ('beginScope',),
-            ('rawAttrs',
+            ('beginScope',
              {'tal:replace': 'notHere', 'tal:on-error': 'string:error'}),
             ('onError',
-             [('insertText', '$notHere$',
-               [('startTag', 'p',
-                 [('tal:on-error', 'string:error', 'tal'),
-                  ('tal:replace', 'notHere', 'tal')]),
-                ('rawtext', 'okay</p>')])],
-             [('startTag', 'p',
-               [('tal:on-error', 'string:error', 'tal'),
-                ('tal:replace', 'notHere', 'tal')]),
-              ('insertText', '$string:error$', []),
-              ('rawtext', '</p>')]),
-            ('endScope',),
+             ([('insertText', ('$notHere$',
+                [('startTag', ('p',
+                  [('tal:on-error', 'string:error', 3),
+                   ('tal:replace', 'notHere', 3)])),
+                 rawtext('okay</p>')]))],
+              [('startTag', ('p',
+                [('tal:on-error', 'string:error', 3),
+                 ('tal:replace', 'notHere', 3)])),
+               ('insertText', ('$string:error$', [])),
+               rawtext('</p>')])),
+            ('endScope', ()),
             ])
 
     def check_dup_attr(self):