Ejemplo n.º 1
0
 def test_must_not_double_escape(self):
     tag = ('tag', 
         ('tag2', {'a':'<&>"\'\n\r\t'})
     )
     self.assertEqual(_encode_tag(tag),
                      '<tag>\n'
                      '  <tag2 a="&lt;&amp;&gt;&quot;\'&#10;&#13;&#9;"/>\n'
                      '</tag>')
Ejemplo n.º 2
0
 def test_encode_tag_with_multiple_children(self):
     tag = ('tag', 
         ('tag2', ),
         ('tag3', 'text'),
     )
     self.assertEqual(_encode_tag(tag), '<tag>\n'
                                       '  <tag2/>\n'
                                       '  <tag3>text</tag3>\n'
                                       '</tag>')
Ejemplo n.º 3
0
 def test_encode_tag_with_two_nested(self):
     tag = ('tag', 
         ('tag2', 
             ('tag3', ),
         ),
     )
     self.assertEqual(_encode_tag(tag), '<tag>\n'
                                       '  <tag2>\n'
                                       '    <tag3/>\n'
                                       '  </tag2>\n'
                                       '</tag>')
Ejemplo n.º 4
0
 def test_encode_tag_with_one_nested(self):
     tag = ('tag', ('tag2', ))
     self.assertEqual(_encode_tag(tag), '<tag>\n'
                                       '  <tag2/>\n'
                                       '</tag>')
Ejemplo n.º 5
0
 def test_cdata_escaping_in_tag_body(self):
     self.assertEqual(_encode_tag(('tag', '<&>"\'\n\t\r')),
                      '<tag>&lt;&amp;&gt;"\'\n\t\r</tag>')
Ejemplo n.º 6
0
 def test_cdata_escaping_in_tag_attr(self):
     self.assertEqual(_encode_tag(('tag', {'a':'<&>"\'\n\r\t'})),
                      '<tag a="&lt;&amp;&gt;&quot;\'&#10;&#13;&#9;"/>')
Ejemplo n.º 7
0
 def test_encode_a_tag_with_str_data_and_attrs(self):
     self.assertEqual(_encode_tag(('tag', {'a':1}, 'text')),
                      '<tag a="1">text</tag>')
Ejemplo n.º 8
0
 def test_encode_a_tag_with_unicode_data(self):
     self.assertEqual(_encode_tag(('tag', u'текст')),
                     u'<tag>текст</tag>'.encode('utf-8'))
Ejemplo n.º 9
0
 def test_encode_a_tag_with_str_data(self):
     self.assertEqual(_encode_tag(('tag', 'text')), '<tag>text</tag>')
Ejemplo n.º 10
0
 def test_encode_a_tag_with_attrs(self):
     self.assertEqual(_encode_tag(('tag', {'a':1, 'b':2})),
                      '<tag a="1" b="2"/>')
Ejemplo n.º 11
0
 def test_encode_a_tag(self):
     self.assertEqual(_encode_tag(('tag',)), '<tag/>')