<s> import doctest <EOL> import unittest <EOL> import sys <EOL> from genshi . core import Attrs , Stream , QName <EOL> from genshi . input import HTML , XML <EOL> from genshi . output import DocType , XMLSerializer , XHTMLSerializer , HTMLSerializer , EmptyTagFilter <EOL> class XMLSerializerTestCase ( unittest . TestCase ) : <EOL> def test_with_xml_decl ( self ) : <EOL> stream = Stream ( [ ( Stream . XML_DECL , ( '<STR_LIT:1.0>' , None , - <NUM_LIT:1> ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer , doctype = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_doctype_in_stream ( self ) : <EOL> stream = Stream ( [ ( Stream . DOCTYPE , DocType . HTML_STRICT , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_doctype_in_stream_no_sysid ( self ) : <EOL> stream = Stream ( [ ( Stream . DOCTYPE , <EOL> ( '<STR_LIT:html>' , '<STR_LIT>' , None ) , <EOL> ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> output ) <EOL> def test_doctype_in_stream_no_pubid ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . DOCTYPE , <EOL> ( '<STR_LIT:html>' , None , '<STR_LIT>' ) , <EOL> ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_doctype_in_stream_no_pubid_or_sysid ( self ) : <EOL> stream = Stream ( [ ( Stream . DOCTYPE , ( '<STR_LIT:html>' , None , None ) , <EOL> ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_serializer_doctype ( self ) : <EOL> stream = Stream ( [ ] ) <EOL> output = stream . render ( XMLSerializer , doctype = DocType . HTML_STRICT ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_doctype_one_and_only ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . DOCTYPE , ( '<STR_LIT:html>' , None , None ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XMLSerializer , doctype = DocType . HTML_STRICT ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_comment ( self ) : <EOL> stream = Stream ( [ ( Stream . COMMENT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_processing_instruction ( self ) : <EOL> stream = Stream ( [ ( Stream . PI , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_nested_default_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_nested_bound_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_multiple_default_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_multiple_bound_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ] ) <EOL> output = stream . render ( XMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_atom_with_xhtml ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> class XHTMLSerializerTestCase ( unittest . TestCase ) : <EOL> def test_xml_decl_dropped ( self ) : <EOL> stream = Stream ( [ ( Stream . XML_DECL , ( '<STR_LIT:1.0>' , None , - <NUM_LIT:1> ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XHTMLSerializer , doctype = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_xml_decl_included ( self ) : <EOL> stream = Stream ( [ ( Stream . XML_DECL , ( '<STR_LIT:1.0>' , None , - <NUM_LIT:1> ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) ] ) <EOL> output = stream . render ( XHTMLSerializer , doctype = '<STR_LIT>' , <EOL> drop_xml_decl = False ) <EOL> self . assertEqual ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> output ) <EOL> def test_xml_lang ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_xml_lang_nodup ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_textarea_whitespace ( self ) : <EOL> content = '<STR_LIT>' <EOL> stream = XML ( '<STR_LIT>' % content ) <EOL> output = stream . render ( XHTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' % content , output ) <EOL> def test_pre_whitespace ( self ) : <EOL> content = '<STR_LIT>' <EOL> stream = XML ( '<STR_LIT>' % content ) <EOL> output = stream . render ( XHTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' % content , output ) <EOL> def test_xml_space ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_empty_script ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_script_escaping ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_script_escaping_with_namespace ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_style_escaping ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_style_escaping_with_namespace ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_embedded_svg ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_xhtml_namespace_prefix ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( XHTMLSerializer ) <EOL> self . assertEqual ( text , output ) <EOL> def test_nested_default_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT:p>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT:p>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT:p>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT:p>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XHTMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_nested_bound_namespaces ( self ) : <EOL> stream = Stream ( [ <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT:p>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT:p>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START_NS , ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . START , ( QName ( '<STR_LIT:p>' ) , Attrs ( ) ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT:p>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . TEXT , '<STR_LIT>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END , QName ( '<STR_LIT>' ) , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> ( Stream . END_NS , '<STR_LIT:x>' , ( None , - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> ] ) <EOL> output = stream . render ( XHTMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_html5_doctype ( self ) : <EOL> stream = HTML ( '<STR_LIT>' ) <EOL> output = stream . render ( XHTMLSerializer , doctype = DocType . HTML5 ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> class HTMLSerializerTestCase ( unittest . TestCase ) : <EOL> def test_xml_lang ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_xml_lang_nodup ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_textarea_whitespace ( self ) : <EOL> content = '<STR_LIT>' <EOL> stream = XML ( '<STR_LIT>' % content ) <EOL> output = stream . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' % content , output ) <EOL> def test_pre_whitespace ( self ) : <EOL> content = '<STR_LIT>' <EOL> stream = XML ( '<STR_LIT>' % content ) <EOL> output = stream . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' % content , output ) <EOL> def test_xml_space ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_empty_script ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> def test_script_escaping ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> output ) <EOL> def test_script_escaping_with_namespace ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_style_escaping ( self ) : <EOL> text = '<STR_LIT>' <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> output ) <EOL> def test_style_escaping_with_namespace ( self ) : <EOL> text = """<STR_LIT>""" <EOL> output = XML ( text ) . render ( HTMLSerializer ) <EOL> self . assertEqual ( """<STR_LIT>""" , output ) <EOL> def test_html5_doctype ( self ) : <EOL> stream = HTML ( '<STR_LIT>' ) <EOL> output = stream . render ( HTMLSerializer , doctype = DocType . HTML5 ) <EOL> self . assertEqual ( '<STR_LIT>' , output ) <EOL> class EmptyTagFilterTestCase ( unittest . TestCase ) : <EOL> def test_empty ( self ) : <EOL> stream = XML ( '<STR_LIT>' ) | EmptyTagFilter ( ) <EOL> self . assertEqual ( [ EmptyTagFilter . EMPTY ] , [ ev [ <NUM_LIT:0> ] for ev in stream ] ) <EOL> def test_text_content ( self ) : <EOL> stream = XML ( '<STR_LIT>' ) | EmptyTagFilter ( ) <EOL> self . assertEqual ( [ Stream . START , Stream . TEXT , Stream . END ] , <EOL> [ ev [ <NUM_LIT:0> ] for ev in stream ] ) <EOL> def test_elem_content ( self ) : <EOL> stream = XML ( '<STR_LIT>' ) | EmptyTagFilter ( ) <EOL> self . assertEqual ( [ Stream . START , EmptyTagFilter . EMPTY , <EOL> EmptyTagFilter . EMPTY , Stream . END ] , <EOL> [ ev [ <NUM_LIT:0> ] for ev in stream ] ) <EOL> def suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( unittest . makeSuite ( XMLSerializerTestCase , '<STR_LIT:test>' ) ) <EOL> suite . addTest ( unittest . makeSuite ( XHTMLSerializerTestCase , '<STR_LIT:test>' ) ) <EOL> suite . addTest ( unittest . makeSuite ( HTMLSerializerTestCase , '<STR_LIT:test>' ) ) <EOL> suite . addTest ( unittest . makeSuite ( EmptyTagFilterTestCase , '<STR_LIT:test>' ) ) <EOL> suite . addTest ( doctest . DocTestSuite ( XMLSerializer . __module__ ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
