HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/supervisor/tests/__pycache__/test_templating.cpython-36.opt-1.pyc
3

�k�`���@s�ddlZddlZddlZdZdZdZdZdZdZdZ	d	Z
Gd
d�dej�ZGdd
�d
ej�Z
Gdd�dej�ZGdd�dej�ZGdd�dej�Zdd�Zdd�Zdd�Zdd�Zedkr�e�dS)�Na<?xml version="1.0"?>
<root xmlns:meld="https://github.com/Supervisor/supervisor">
  <list meld:id="list">
    <item meld:id="item">
       <name meld:id="name">Name</name>
       <description meld:id="description">Description</description>
    </item>
  </list>
</root>z�<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:meld="https://github.com/Supervisor/supervisor">
   <body meld:id="body">Hello!</body>
</html>z�<html>
  <body>
    <area/><base/><basefont/><br/><col/><frame/><hr/><img/><input/><isindex/>
    <link/><meta/><param/>
  </body>
</html>a?<html>
  <body>
  <tag selected="true"/>
  <tag checked="true"/>
  <tag compact="true"/>
  <tag declare="true"/>
  <tag defer="true"/>
  <tag disabled="true"/>
  <tag ismap="true"/>
  <tag multiple="true"/>
  <tag nohref="true"/>
  <tag noresize="true"/>
  <tag noshade="true"/>
  <tag nowrap="true"/>
  </body>
</html>z^
<html>
<head></head>
<body>
  <!-- test entity references -->
  <p>&nbsp;</p>
</body>
</html>a:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:meld="https://github.com/Supervisor/supervisor"
      xmlns:bar="http://foo/bar">
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
    <title meld:id="title">This will be escaped in html output: &amp;</title>
    <script>this won't be escaped in html output: &amp;</script>
    <script type="text/javascript">
            //<![CDATA[
              // this won't be escaped in html output
              function match(a,b) {
                 if (a < b && a > 0) then { return 1 }
                }
             //]]>
    </script>
    <style>this won't be escaped in html output: &amp;</style>
  </head>
  <!-- a comment -->
  <body>
    <div bar:baz="slab"/>
    <div meld:id="content_well">
      <form meld:id="form1" action="." method="POST">
      <img src="foo.gif"/>
      <table border="0" meld:id="table1">
        <tbody meld:id="tbody">
          <tr meld:id="tr" class="foo">
            <td meld:id="td1">Name</td>
            <td meld:id="td2">Description</td>
          </tr>
        </tbody>
      </table>
      <input type="submit" name="submit" value=" Next "/>
      </form>
    </div>
  </body>
</html>a<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <title meld:id="title">test doc</title>
</head>
<body>
 <!-- comment! -->
 Oh yeah...<br>
<br>
<table style="text-align: left; width: 100px;" border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td>Yup</td>
      <td>More </td>
      <td>Stuff</td>
      <td>Oh Yeah</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>
<br>
<a href=".">And an image...</a><br>
<br>
<img style="width: 2048px; height: 1536px;" alt="dumb" src="IMG_0102.jpg">
</body>
</html>aO
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title>Emergency Contacts</title>
</head>
<body>
   <div class="header">Emergency Contacts</div>

   <form action="." method="POST">
    <table>

      <tbody meld:id="tbody">

	<tr>
	  <th>Title</th>
	  <td>
	    <input type="text" name="honorific" size="6" value=""
		   meld:id="honorific"/>
	  </td>
	</tr>

	<tr>
	  <th>First Name</th>
	  <td>
	    <input type="text" name="firstname" size="20" value=""
		   meld:id="firstname"/>
	  </td>
	</tr>

	<tr>
	  <th>Middle Name</th>
	  <td>
	    <input type="text" name="middlename" size="15" value=""
		   meld:id="middlename"/>
	  </td>
	</tr>

	<tr>
	  <th>Last Name</th>
	  <td>
	    <input type="text" name="lastname" size="20" value=""
		   meld:id="lastname"/>
	  </td>
	</tr>

	<tr>

	  <th>Suffix</th>
	  <td style="width: 554px;">
          <select name="suffix" meld:id="suffix">
	      <option value="Jr.">Jr.</option>
	      <option value="Sr.">Sr.</option>
	      <option value="III">III</option>
	    </select>
          </td>

        </tr>

	<tr>
	  <th>Address 1</th>
	  <td>
	    <input type="text" name="address1" size="30" value=""
		   meld:id="address1"/>
	  </td>
	</tr>

	<tr>
	  <th>Address 2</th>
	  <td>
	    <input type="text" name="address2" size="30" value=""
		   meld:id="address2"/>
	  </td>
	</tr>

	<tr>
	  <th>City</th>
	  <td>
	    <input type="text" name="city" size="20" value=""
		   meld:id="city"/>
	  </td>
	</tr>

	<tr>
	  <th>State</th>
	  <td>
	    <input type="text" name="state" size="5" value=""
		   meld:id="state"/>
	  </td>
	</tr>

	<tr>
	  <th>ZIP</th>
	  <td>
	    <input type="text" name="zip" size="8" value=""
		   meld:id="zip"/>
	  </td>
	</tr>

	<tr>
	  <th>Home Phone</th>
	  <td>
	    <input type="text" name="homephone" size="12" value=""
		   meld:id="homephone"/>
	  </td>
	</tr>

	<tr>
	  <th>Cell/Mobile Phone</th>
	  <td>
	    <input type="text" name="cellphone" size="12" value=""
		   meld:id="cellphone"/>
	  </td>
	</tr>

	<tr>
	  <th>Email Address</th>
	  <td>
	    <input type="text" name="email" size="20" value=""
		   meld:id="email"/>
	  </td>
	</tr>

	<tr>
	  <th>Over 18? (Checkbox Boolean)</th>
	  <td>
            <input type="checkbox" name="over18" meld:id="over18"
                   value="true" checked="true"/>
	  </td>
	</tr>

	<tr>

	  <th>Mail OK? (Checkbox Ternary)</th>
          <td style="width: 554px;" meld:id="mailok:inputgroup">
            <input type="hidden" name="mailok:default"
                   value="false"/>
            <input type="checkbox" name="mailok"
                   value="true" checked/>
            <input type="checkbox" name="mailok"
                   value="false"/>
          </td>

        </tr>

	<tr>

	  <th>Favorite Color (Radio)</th>
          <td style="width: 554px;" meld:id="favorite_color:inputgroup">
            Red   <input type="radio" name="favorite_color"
                         value="Red"/>
            Green <input type="radio" name="favorite_color"
                         value="Green"/>
            Blue  <input type="radio" name="favorite_color"
                         value="Blue"/>
          </td>

        </tr>

	<tr>
	  <th></th>
	  <td>
	    <input type="submit" value=" Update " name="edit:method" />
	  </td>
	</tr>

      </tbody>
    </table>
    </form>

<p><a href="..">Return to list</a></p>
</body>
</html>
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �MeldAPITestscCsddlm}||�S)Nr)�parse_xmlstring)�supervisor.templatingr)�self�stringr�r�%/usr/lib/python3.6/test_templating.py�_makeElement8szMeldAPITests._makeElementcCsddlm}||�S)Nr)�parse_htmlstring)rr
)rrr
rrr�_makeElementFromHTML<sz!MeldAPITests._makeElementFromHTMLcCs>|jt�}|jd�}|j|jd�|jd�}|j|jd�dS)N�item�name�Name)r	�_SIMPLE_XML�findmeld�assertEqual�tag�text)r�rootrr
rrr�
test_findmeld@s



zMeldAPITests.test_findmeldcCsP|jt�}|jd�}|j|jd�|jdd�}|j|d�|j|jd�d�dS)Nr�unknown�foo)r	rrrr)rrrrrrr�test_findmeld_defaultGs

z"MeldAPITests.test_findmeld_defaultcCs�|jt�}|jd�}|j|jd�ddd�ddd�g}x6|j|�D](\}}|d|jd�_|d|jd�_qBW|j|d	jd�|j|d
jd�dS)NrzJeff Buckley�ethereal)r
�description�Slipknot�heavyr
rr�)r	rrrr�repeatr)rrr�data�element�drrr�test_repeat_nochildOs

z MeldAPITests.test_repeat_nochildcCs�|jt�}|jd�}|j|jd�ddd�ddd�g}x8|j|d�D](\}}|d|jd�_|d	|jd	�_qDW|j|d
d
jd�|j|d
djd�|j|dd
jd�|j|ddjd�dS)N�listzJeff Buckleyr)r
rrrrr
rrr)r	rrrrrr)rrr#rr r!rrr�test_repeat_child[s

zMeldAPITests.test_repeat_childcCsL|jt�}|ddd�|jd�}|j|jd�|jd�}|j|jd�dS)Nr�bar)rr
r
r)r	rrrr)rrr
�descrrr�test_modis


zMeldAPITests.test_modcCsF|jt�}|jfddd��}|jd�}|j|jd�|j|dg�dS)Nr�a)r�jammyjamrr))r	rZ	fillmeldsrrr)rr�unfilledr&rrr�test_fillmeldsqs


zMeldAPITests.test_fillmeldsc	CsVddddddddd	d
ddd
dddd�dddddddddddddddd d�dddddddddddd!ddd"d#d$�g}|jt�}|j�}|jf|d%�}|j|g�|j|jd&�jd'd�|j|jd(�jd'd�|jd)�}|j|jd'd�|jd*�}|j|d#jd+d+�|j|jd,�jd-d-�|jd.�}|j|d#jd-d-�|jd/�}|j|d#jd-d-�|j�}|jf|d#�}|j|d/g�|j|jd,�jjd-�d�|jd.�}|j|d0jd-d-�|j|d#jjd-�d�|j�}|jf|d0�}|jt|�d1d*g�|j|jd&�j	d�|jd/�}|j|d0jd-d-�|j|d#jjd-�d�dS)2NzMr.ZChrisZPhillipsZ	McDonoughz802 Caroline St.zApt. 2BZFredericksburgZVAZ22401z555-1212z555-1313z[email protected]Sr.T�trueZGreen)�	honorific�	firstname�
middlename�lastname�address1�address2�city�state�zip�	homephone�	cellphone�email�suffix�over18zmailok:inputgroupzfavorite_color:inputgroupZFred�ZRogersz1 Imaginary LanezApt. 3AzNever Never LandZLAZ00001z555-1111z555-4444z[email protected]Jr.FZfalseZYellowZIVZBluer)r.r/r0r1r2r3r4r5r6r7r8r9r:zmailok:inputgroupzfavorite_color:inputgroup�notthererr-�valuer.r/r9Zselectedr:Zcheckedzmailok:inputgroupzfavorite_color:inputgroup�r<)
r�_FILLMELDFORM_HTML�cloneZfillmeldhtmlformrr�attrib�get�sortedr)	rrrr@r*r/r9ZmailokZ
favoritecolorrrr�test_fillmeldhtmlformxs`







z"MeldAPITests.test_fillmeldhtmlformcCsXddlm}|jt�}|jd�}|jd�|d}|j|j|�|jt|j	��d�dS)Nr)�Replacer#zthis is a textual replacementr)
rrEr	rr�replacerr�len�getchildren)rrEr�L�Rrrr�!test_replace_removes_all_elements�s


z.MeldAPITests.test_replace_removes_all_elementscCsddlm}|jt�}|jd�}|jd�|jt|j��d�|d}|j|j	d�|jt|j��d�|d}|j|j	d�|jt|j��d�|d}|j|j	d	�|jt|j��d�|d}|j|j	|�|j|j
d�|jt|j��d�|j|jd
�dS)Nr)rErzthis is a textual replacementrr#rr>r
F)rrEr	rrrFrrGrHrr�	structure)rrEr�DrI�I�Nrrr�'test_replace_replaces_the_right_element�s&


z4MeldAPITests.test_replace_replaces_the_right_elementcCs*ddlm}|jt�}|jd�}|jd�|jt|j��d�|d}|j|j	d�|jt|j��d�|d}|j|j	d�|jt|j��d�|d}|j|j	d	�|jt|j��d�|d}|j|j	d�|j|j
d�|jt|j��d�|d}|j|j	|�|j|j
d�|j|jd
�dS)Nr)rErzthis is a textual replacementrr#rr>r
F)rrEr	rr�contentrrGrHrrrL)rrErrMrIrNrO�Trrr�test_content�s,


zMeldAPITests.test_contentcCs\ddlm}|jt�}|jd�}|jddddd�|j|jd	dd
ddddd
dd|di�dS)Nr)�_MELD_ID�form1r%�1�2�#)r�baz�g�actionrrYrZ�method�POSTr[)rrTr	�_COMPLEX_XHTMLr�
attributesrrA)rrTrrMrrr�test_attributes�s

zMeldAPITests.test_attributescCs|ddlm}ddlm}|jt�}|jd�}|j|ddd�|ddd�d	�|j|j	d
|ddd�ddd
|ddd�|di�dS)Nr)rT)�	as_stringrUr%�latin1)�encodingrX)rr[rr\r]r[)
rrT�supervisor.compatrar	r^rr_rrA)rrTrarrMrrr�test_attributes_unicode�s

z$MeldAPITests.test_attributes_unicodecCs |jd�}|jt|jdd�dS)Nz
<root></root>r)r)r	�assertRaises�
ValueErrorr_)rrrrr�$test_attributes_nonstringtype_raises�s
z1MeldAPITests.test_attributes_nonstringtype_raisesN)�__name__�
__module__�__qualname__r	rrrr"r$r'r+rDrKrPrSr`rerhrrrrr7s7	
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=S)>�MeldElementInterfaceTestscCsddlm}|S)Nr)�_MeldElementInterface)rrm)rrmrrr�_getTargetClasssz)MeldElementInterfaceTests._getTargetClasscOs|j�}|||�S)N)rn)r�arg�kw�klassrrr�_makeOnesz"MeldElementInterfaceTests._makeOnecCs�|jdi�}ddlm}|jd|di�}|jd|di�}|jd|di�}|jd|di�}|j|�|j|�|j|�|j|�dd	d
�ddd
�g}x6|j|�D](\}}	|	d|jd�_|	d|jd�_q�W|jt|�d
�|d}
|jt|
�d�|
d}|jt|�d
�|d}|d}
|j|jd�|j|
jd	�|d}|jt|�d�|d}|jt|�d
�|d}|d}|j|jd�|j|jd�dS)Nrr)rTr�recordr
rzJeff Buckleyr)r
rrrr>r)	rrrrT�appendrrrrrG)rrrTrrsr
rrr r!Zitem1Zrecord1Zname1Zdesc1Zitem2Zrecord2Zname2Zdesc2rrr�test_repeats@



z%MeldElementInterfaceTests.test_repeatcCs~|jdddi�}|jd�|jt|j�d�|jd}|j|j|�|j|jd�|j|jd�ddlm	}|j|j
|�dS)	N�div�id�thediv�hellorrF)rE)rrrQrrG�	_children�parentrrLrrEr)r�el�replacenoderErrr�test_content_simple_nostructure/s

z9MeldElementInterfaceTests.test_content_simple_nostructurecCs�|jdddi�}|jddd�|jt|j�d�|jd}|j|j|�|j|jd�|j|jd�dd	lm	}|j|j
|�dS)
NrvrwrxryT)rLrr)rE)rrrQrrGrzr{rrLrrEr)rr|r}rErrr�test_content_simple_structure:s
z7MeldElementInterfaceTests.test_content_simple_structurecCs2ddlm}|jd|di�}|j|jd�|�dS)Nr)rTrvrx)rrTrrrr)rrTr|rrr�test_findmeld_simpleEsz.MeldElementInterfaceTests.test_findmeld_simplecCsLddlm}|jd|di�}|jd|di�}|j|�|j|jd�|�dS)Nr)rTrvrx�span�thespan)rrTrrrtrr)rrTr|r�rrr�!test_findmeld_simple_oneleveldownJs

z;MeldElementInterfaceTests.test_findmeld_simple_oneleveldowncCsfddlm}|jd|di�}|jd|di�}|jd|di�}|j|�|j|�|j|jd�|�dS)	Nr)rTrvrxr�r�r(Zthea)rrTrrrtrr)rrTr|r�r(rrr�"test_findmeld_simple_twolevelsdownQs

z<MeldElementInterfaceTests.test_findmeld_simple_twolevelsdowncCsB|jdddi�}|j|jd�|j|jd�|j|jddi�dS)Nrvrwrx)rrrr{rrA)rZifacerrr�	test_ctorZsz#MeldElementInterfaceTests.test_ctorcCs<|jdddi�}|j�}|jt|�d�|j|d|�dS)Nrvrwrxrr)rr�getiteratorrrG)rrv�iteratorrrr�test_getiterator_simple`sz1MeldElementInterfaceTests.test_getiterator_simplecCs�|jdddi�}|jdi�}|jdddi�}|jdddi�}d|_d	|_|j|�|j|�|j|�|j�}|jt|�d
�|j|d|�|j|d|�|j|d
|�|j|d|�dS)Nrvrwrxr�rW�span3�3�abcz  �rrr>�)rrr�tailrtr�rrG)rrvr��span2r��itrrr�test_getiteratorfs


z*MeldElementInterfaceTests.test_getiteratorcCs�|jdddi�}|jdi�}|jdddi�}|jdddi�}d|_d	|_|j|�|j|�|j|�|jdd
�}|jt|�d�|j|d|�|j|d
|�|j|d|�|j|d|�dS)Nrvrwrxr�rWr�r�r�z  )rr�rrr>r�)rrrr�rtr�rrG)rrvr�r�r�r�rrr�test_getiterator_tag_ignoredxs


z6MeldElementInterfaceTests.test_getiterator_tag_ignoredcCsJ|jdddi�}|jdi�}|j|�|j|djd�|j|j|�dS)Nrvrwrxr�r)rrrtrrr{)rrvr�rrr�test_append�s

z%MeldElementInterfaceTests.test_appendcCs||jdddi�}|jdi�}|jdddi�}|j|�||d<|j|djd�|j|djddi�|j|dj|�dS)Nrvrwrxr�rWr)rrrtrrrAr{)rrvr�r�rrr�test__setitem__�s
z)MeldElementInterfaceTests.test__setitem__cCs�|jdddi�}|jdi�}|jdddi�}|j|�|jd|�|j|djd�|j|djddi�|j|dj|�|j|djd�|j|dji�|j|dj|�dS)Nrvrwrxr�rWrr)rrrt�insertrrrAr{)rrvr�r�rrr�test_insert�s
z%MeldElementInterfaceTests.test_insertcCs>|jdddi�}d|_d|_|jdi�}|j|�|j�dS)Nrvrwrxr�z   r�)rrrr�rtr@)rrvr�rrr�test_clone_simple�s
z+MeldElementInterfaceTests.test_clone_simplecCs"|jdddi�}|jdi�}|jdddi�}|jdddi�}d|_d	|_|j|�|j|�|j|�|j�}|j|j|j�|j|j|j�|j|d
j|d
j�|j|d
j|d
j�|j|d
d
j|d
d
j�|j|d
d
j|d
d
j�|j|d
d
d
j|d
d
d
j�|j|d
d
d
j|d
d
d
j�|j|d
d
d
j|d
d
d
j�|j|d
d
d
j|d
d
d
j�|jt	|�t	|��|jt	|d
�t	|d
��|jt	|d
d
�t	|d
d
��|jt	|d
d
d
�t	|d
d
d
��dS)Nrvrwrxr�rWr�r�r�z  r)
rrrr�rtr@rrrAZassertNotEqualrw)rrvr�r�r��div2rrr�
test_clone�s0


  (((($z$MeldElementInterfaceTests.test_clonecCs4|jdi�}|j|jd�|j�|j|jd�dS)Nrv)rrrr{�deparent)rrvrrr�test_deparent_noparent�sz0MeldElementInterfaceTests.test_deparent_noparentcCs�|jdi�}|j|jd�|jdi�}|j|�|j|jd�|j|j|�|j|d|�|j�|j|jd�|jt|jd�dS)Nr{�childr)rrrr{rtr�rf�
IndexError�__getitem__)rr{r�rrr�test_deparent_withparent�s
z2MeldElementInterfaceTests.test_deparent_withparentcCs�|jdi�}|jdi�}|jdi�}|jdi�}|||f}||dd�<|j|j|�|j|j|�|j|j|�|j|jt|��dS)Nr{�child1�child2�child3rr>)rrrr{rzr#)rr{r�r�r��childrenrrr�
test_setslice�s
z'MeldElementInterfaceTests.test_setslicecCs�|jdi�}|jdi�}|jdi�}|jdi�}|||f}||dd�<|dd�=|j|jd�|j|jd�|j|j|�|jt|j�d�dS)Nr{r�r�r�rr>r)rrrr{rGrz)rr{r�r�r�r�rrr�
test_delslice�s

z'MeldElementInterfaceTests.test_delslicecCsP|jdi�}|jdi�}|j|�|j|�|j|jd�|jt|j�d�dS)Nr{r�r)rrrt�removerr{rGrz)rr{r�rrr�test_remove�s

z%MeldElementInterfaceTests.test_removec
Cs�ddlm}|jd|di�}|jd|di�}|jd|di�}|jd|di�}|jd|d	i�}|jd|d
i�}|jd|di�}|jdi�}	|jd|di�}
|j|�|j|�|j|�|j|	�|	j|�|j|�|j|�|j|
�d
d�}|j||j��dg�|j||j��ddg�|j||j��dddg�|j||j��ddddg�|j||	j��dddddg�|j||j��d	dddddg�|j||j��d
d	dddddg�|j||j��dd
d	dddddg�|j||
j��ddg�dS)Nr)rTrv�div1r��span1r�r��span4�span5�span6r�cSsdd�|D�S)NcSsg|]}|j��qSr)�meldid)�.0�xrrr�
<listcomp>szGMeldElementInterfaceTests.test_lineage.<locals>.ids.<locals>.<listcomp>r)rIrrr�idssz3MeldElementInterfaceTests.test_lineage.<locals>.ids)rrTrrrtrZlineage)rrTr�r�r�r�r�r�r�rr�r�rrr�test_lineage�sJ










z&MeldElementInterfaceTests.test_lineagecCs�ddlm}|jdddi�}|jdi�}|jdddi�}|jdddi�}|j|�|j|�|j|�|j�}|j||d	d
d��dS)Nr)�as_bytesrvrwr�r�rWr�zM<div id="div1"><span><span id="2"></span></span><div2 id="div2"></div2></div>rb)rc)rdr�rrrt�	shortreprr)rr�rvr�r�r��rrrr�test_shortrepr)s


z(MeldElementInterfaceTests.test_shortreprcCs@ddlm}ddlm}|t�}|j�}|j||ddd��dS)Nr)r)r�z�<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
     [...]
</head>
  <!--  a comment  -->
   [...]
</html>rb)rc)rrrdr�r^r�r)rrr�rr�rrr�test_shortrepr27sz)MeldElementInterfaceTests.test_shortrepr2cs�ddlm}ddlm�|t�}|j�}|jd�di�}|j|�|jd�}|j�|jd�}|j�|j|�|j	|�}|d}�fd	d
�|dD�}	�fdd
�|d
D�}
�fdd
�|dD�}|	j
�|
j
�|j
�|j|	dg�|j|
dddg�|j|dg�|d}�fdd
�|dD�}	�fdd
�|d
D�}
�fdd
�|dD�}|	j
�|
j
�|j
�|j|	dg�|j|
dg�|j|dg�dS)Nr)r)rTrvZnewdiv�tr�title�	unreducedcsg|]}|j��qSr)rA)r�r�)rTrrr�Vsz<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>�addedcsg|]}|j��qSr)rA)r�r�)rTrrr�Ws�removedcsg|]}|j��qSr)rA)r�r�)rTrrr�Xs�moved�td1�td2�reducedcsg|]}|j��qSr)rA)r�r�)rTrrr�bscsg|]}|j��qSr)rA)r�r�)rTrrr�cscsg|]}|j��qSr)rA)r�r�)rTrrr�ds)rrrTr^r@rrrtrr��diffmeld�sortr)rrrr@rvr�r�Zdiff�changesZ	addedtagsZremovedtagsZ	movedtagsr)rTr�test_diffmeld1Fs@




z(MeldElementInterfaceTests.test_diffmeld1c	Csd}d}ddlm}||�}||�}|j|�}dd�|ddD�}d	g}|j||�d
d�|ddD�}g}|j||�dd�|dd
D�}g}|j||�dd�|ddD�}d	g}|j||�dd�|ddD�}g}|j||�dd�|dd
D�}g}|j||�dS)Nzi
        <root>
          <a meld:id="a">
             <b meld:id="b"></b>
          </a>
        </root>zd
        <root>
          <a meld:id="a"></a>
          <b meld:id="b"></b>
        </root>
        r)r
cSsg|]}|j��qSr)r�)r�r�rrrr�sz<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>r�r��bcSsg|]}|j��qSr)r�)r�r�rrrr��sr�cSsg|]}|j��qSr)r�)r�r�rrrr��sr�cSsg|]}|j��qSr)r�)r�r�rrrr��sr�cSsg|]}|j��qSr)r�)r�r�rrrr��scSsg|]}|j��qSr)r�)r�r�rrrr��s)rr
r�r)	r�source�targetr
�source_root�target_rootr��actual�expectedrrr�test_diffmeld2ls0
z(MeldElementInterfaceTests.test_diffmeld2c	Cs(d}d}ddlm}||�}||�}|j|�}dd�|ddD�}d	d
g}|j||�dd�|ddD�}d
dg}|j||�dd�|ddD�}ddg}|j||�dd�|ddD�}d	g}|j||�dd�|ddD�}d
g}|j||�dd�|ddD�}dg}|j||�dS)Nz�
        <root>
          <a meld:id="a">
             <b meld:id="b">
               <c meld:id="c"></c>
             </b>
          </a>
          <z meld:id="z">
            <y meld:id="y"></y>
          </z>
        </root>
        z�
        <root>
          <b meld:id="b">
            <c meld:id="c"></c>
          </b>
          <a meld:id="a"></a>
          <d meld:id="d">
             <e meld:id="e"></e>
          </d>
        </root>
        r)r
cSsg|]}|j��qSr)r�)r�r�rrrr��sz<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>r�r�r��ccSsg|]}|j��qSr)r�)r�r�rrrr��sr�r!�ecSsg|]}|j��qSr)r�)r�r�rrrr��sr��z�ycSsg|]}|j��qSr)r�)r�r�rrrr��sr�cSsg|]}|j��qSr)r�)r�r�rrrr��scSsg|]}|j��qSr)r�)r�r�rrrr��s)rr
r�r)	rr�r�r
r�r�r�r�r�rrr�test_diffmeld3�s0
z(MeldElementInterfaceTests.test_diffmeld3c	Cs.d}d}ddlm}||�}||�}|j|�}dd�|ddD�}d	d
g}|j||�dd�|ddD�}d
dg}|j||�dd�|ddD�}ddddg}|j||�dd�|ddD�}d	g}|j||�dd�|ddD�}d
g}|j||�dd�|ddD�}ddg}|j||�dS)Na!
        <root>
          <a meld:id="a">
             <b meld:id="b">
               <c meld:id="c">
                 <d meld:id="d"></d>
               </c>
             </b>
          </a>
          <z meld:id="z">
            <y meld:id="y"></y>
          </z>
        </root>
        a
        <root>
          <p>
            <a meld:id="a">
               <b meld:id="b"></b>
            </a>
          </p>
          <p>
            <m meld:id="m">
              <n meld:id="n"></n>
            </m>
          </p>
        </root>
        r)r
cSsg|]}|j��qSr)r�)r�r�rrrr��sz<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>r�r�r(r�cSsg|]}|j��qSr)r�)r�r�rrrr��sr��m�ncSsg|]}|j��qSr)r�)r�r�rrrr��sr�r�r!r�r�cSsg|]}|j��qSr)r�)r�r�rrrr�sr�cSsg|]}|j��qSr)r�)r�r�rrrr�scSsg|]}|j��qSr)r�)r�r�rrrr�s)rr
r�r)	rr�r�r
r�r�r�r�r�rrr�test_diffmeld4�s0
z(MeldElementInterfaceTests.test_diffmeld4c	Cs"d}d}ddlm}||�}||�}|j|�}dd�|ddD�}d	d
ddg}|j||�d
d�|ddD�}g}|j||�dd�|ddD�}g}|j||�dd�|ddD�}d	dg}|j||�dd�|ddD�}g}|j||�dd�|ddD�}g}|j||�dS)Na!
        <root>
          <a meld:id="a">
             <b meld:id="b">
               <c meld:id="c">
                 <d meld:id="d"></d>
               </c>
             </b>
          </a>
          <z meld:id="z">
            <y meld:id="y"></y>
          </z>
        </root>
        a}
        <root>
          <p>
            <a meld:id="a">
               <b meld:id="b">
                 <p>
                   <c meld:id="c">
                     <d meld:id="d"></d>
                   </c>
                 </p>
               </b>
            </a>
          </p>
          <z meld:id="z">
            <y meld:id="y"></y>
          </z>
        </root>
        r)r
cSsg|]}|j��qSr)r�)r�r�rrrr�3sz<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>r�r�r(r�r�r!cSsg|]}|j��qSr)r�)r�r�rrrr�7sr�cSsg|]}|j��qSr)r�)r�r�rrrr�;sr�cSsg|]}|j��qSr)r�)r�r�rrrr�@sr�cSsg|]}|j��qSr)r�)r�r�rrrr�DscSsg|]}|j��qSr)r�)r�r�rrrr�Hs)rr
r�r)	rr�r�r
r�r�r�r�r�rrr�test_diffmeld5s0
z(MeldElementInterfaceTests.test_diffmeld5N)!rirjrkrnrrrur~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrl�s<'	


*&-7<rlc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�ParserTestscGsddlm}||�}|S)Nr)r)rr)r�argsrrrrr�_parseOszParserTests._parsecGsddlm}||�}|S)Nr)r
)rr
)rr�r
rrrr�_parse_htmlTszParserTests._parse_htmlcCsddlm}|jt�}|j|jd�|j|jd�|d}|j|jd�|j|j|�|j|j|d�|d}|j|jd�|j|j|�|j|j|d�|d}|d}|j|jd�|j|j|�|j|j|d�|j|jd�|j|j|�|j|j|d�dS)	Nr)rTrr#rrr
r)rrTr�rrrr{rA)rrTrZl1strr
rrrr�test_parse_simple_xmlYs(
z!ParserTests.test_parse_simple_xmlcCs�d}ddlm}|jt�}|j|j|d�|j|ji�|j|jd�|d}|j|j|d�|j|j|d�|j|j|�dS)Nz {http://www.w3.org/1999/xhtml}%sr)rT�html�body)rrTr��
_SIMPLE_XHTMLrrrAr{)r�xhtml_nsrTrr�rrr�test_parse_simple_xhtmlos
z#ParserTests.test_parse_simple_xhtmlcCsld}ddlm}|jt�}|j|j|d�|j|ji�|j|jd�|d}|j|j|d�|j|ji�|j|j|�|d}|j|j|d�|j|jdd�|j|j|�|d	}|j|j|d
�|j|j|d
�|j|j|�|d}|j|j|d�|j|ji�|j|j|�|d}|j|j|d
�|j|jddi�|j|j|�|d	}	|j|	j|d
�|j|	j|d�|j|	j|�|	d}
|j|
j|d�|j|
j|d�|j|
jdd�|j|
jdd�|j|
j|	�|
d}|j|j|d�|j|j|
�|
d	}|j|j|d�|j|j|d�|j|jdd�|j|j|
�|d}
|j|
j|d�|j|
j|d�|j|
j|�|
d}|j|j|d�|j|j|d�|j|jdd�|j|j|
�|d}|j|j|d �|j|j|d!�|j|j|�|d	}|j|j|d �|j|j|d"�|j|j|�dS)#Nz {http://www.w3.org/1999/xhtml}%sr)rTr��head�metarQztext/html; charset=ISO-8859-1rr�r>r�rvz{http://foo/bar}bazZslabZcontent_well�formrUr[�.r\r]�img�tableZtable1�border�0�tbodyr��classrZtdr�r�)rrTr�r^rrrAr{)rr�rTrr�r�r�r�r�r�r�r�r�r�r�r�r�rrr�test_parse_complex_xhtml|s|
z$ParserTests.test_parse_complex_xhtmlcCs�ddlm}ddlm}|jt�}|j|jd�|j|ji�|j|jd�|d}|j|jd�|j|ji�|j|j|�|d}|j|jd�|j|jdd�|d	}|j|jd
�|j|j|d
�|j|j|�|d	}|j|jd�|j|ji�|j|j|�|d}|j|j|�|d}	|j|	jd
�|j|	jddddd��|j|	j|�|d}
|j|
jd�|d}|j|jd�dS)Nr)rT)�Commentr�r�r�rQztext/html; charset=ISO-8859-1rr�r�r�r�ztext-align: left; width: 100px;rVrW)Zstyler�ZcellpaddingZcellspacing�r(�r�)	rrTr�r��	_NVU_HTMLrrrAr{)rrTr�rr�r�r�r�Zcommentr�Zhrefr�rrr�
test_nvu_html�sH

zParserTests.test_nvu_htmlcCs d}d|}|jt|j|�dS)Nz(https://github.com/Supervisor/supervisorzF<html xmlns:meld="%s" meld:id="repeat"><body meld:id="repeat"/></html>)rfrgr�)r�meld_ns�repeatedrrr�!test_dupe_meldids_fails_parse_xml�sz-ParserTests.test_dupe_meldids_fails_parse_xmlcCs d}d|}|jt|j|�dS)Nz(https://github.com/Supervisor/supervisorzF<html xmlns:meld="%s" meld:id="repeat"><body meld:id="repeat"/></html>)rfrgr�)rr�r�rrr�"test_dupe_meldids_fails_parse_html�sz.ParserTests.test_dupe_meldids_fails_parse_htmlN)rirjrkr�r�r�r�r�r�r�r�rrrrr�Ns
J*r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�	UtilTestscCs,ddlm}d}||�}d}|j||�dS)Nr)�insert_doctypez
<root></root>z�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root></root>)rr�r)rr��origr�r�rrr�test_insert_xhtml_doctype�s
z#UtilTests.test_insert_xhtml_doctypecCs,ddlm}d}||�}d}|j||�dS)Nr)r�z5<?xml version="1.0" encoding="latin-1"?><root></root>z�<?xml version="1.0" encoding="latin-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root></root>)rr�r)rr�r�r�r�rrr�!test_insert_doctype_after_xmldecls
z+UtilTests.test_insert_doctype_after_xmldeclcCs,ddlm}d}||�}d}|j||�dS)Nr)�insert_meld_ns_declz5<?xml version="1.0" encoding="latin-1"?><root></root>zk<?xml version="1.0" encoding="latin-1"?><root xmlns:meld="https://github.com/Supervisor/supervisor"></root>)rr�r)rr�r�r�r�rrr�test_insert_meld_ns_decls
z"UtilTests.test_insert_meld_ns_declcCs,ddlm}d}||�}d}|j||�dS)Nr)�prefeedzD<?xml version="1.0" encoding="latin-1"?><root xmlns:meld="#"></root>z�<?xml version="1.0" encoding="latin-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root xmlns:meld="#"></root>)rr�r)rr�r�r�r�rrr�'test_prefeed_preserves_existing_meld_nss
z1UtilTests.test_prefeed_preserves_existing_meld_nscCs(ddlm}d}||�}|j||�dS)Nr)r�z�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><root xmlns:meld="https://github.com/Supervisor/supervisor"></root>)rr�r)rr�r�r�rrr�'test_prefeed_preserves_existing_doctypesz1UtilTests.test_prefeed_preserves_existing_doctypeN)rirjrkr�r�r�r�r�rrrrr��s
r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOS)P�WriterTestscCsddlm}||�}|S)Nr)r)rr)r�xmlrrrrrr�!szWriterTests._parsecCsddlm}||�}|S)Nr)r
)rr
)rr�r
rrrrr�&szWriterTests._parse_htmlc	KsRyddlm}Wnddlm}YnX|�}||f|�|jd�|j�}|S)Nr)�BytesIO)�StringIO)�iorr�seek�read)r�fnrpr�outr�rrr�_write+s
zWriterTests._writecKs|j|jf|�S)N)rZ	write_xml)r�noderprrr�
_write_xml6szWriterTests._write_xmlcKs|j|jf|�S)N)rZ
write_html)rrrprrr�_write_html9szWriterTests._write_htmlcKs|j|jf|�S)N)rZwrite_xhtml)rrrprrr�_write_xhtml<szWriterTests._write_xhtmlcCs<ddlm}t||dd��}t||dd��}|j||�dS)Nr)rarb)rc)rdra�
normalize_xmlr)rr(r�rarrr�assertNormalizedXMLEqual?sz$WriterTests.assertNormalizedXMLEqualcCs<ddlm}t||dd��}t||dd��}|j||�dS)Nr)rarb)rc)rdrarr)rr(r�rarrr�assertNormalizedHTMLEqualEsz%WriterTests.assertNormalizedHTMLEqualcCs�|jt�}|j|�}d}|j||�xD|jd�jd
�D]0\}}t|d�|jd�_t|d�|jd�_q6W|j|�}d}|j||�dS)Nz�<?xml version="1.0"?><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>rrr>rr
rz�<?xml version="1.0"?><root>
  <list>
    <item>
       <name>1</name>
       <description>2</description>
    </item>
  </list>
</root>�rr>)r)r�rr	r
rr�strr)rrr�r�r|rrrr�test_write_simple_xmlKs


z!WriterTests.test_write_simple_xmlcCs(|jt�}|j|�}d}|j||�dS)Nz�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body>Hello!</body></html>)r�r�rr
)rrr�r�rrr�test_write_simple_xhtmlfs

z#WriterTests.test_write_simple_xhtmlcCs(|jt�}|j|�}d}|j||�dS)Nz�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <body>Hello!</body>
</html>)r�r�r
r)rrr�r�rrr�test_write_simple_xhtml_as_htmlls

z+WriterTests.test_write_simple_xhtml_as_htmlcCs(|jt�}|j|�}d}|j||�dS)Na<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    <title>This will be escaped in html output: &amp;</title>
    <script>this won't be escaped in html output: &</script>
    <script type="text/javascript">
            //
              // this won't be escaped in html output
              function match(a,b) {
                 if (a < b && a > 0) then { return 1 }
                }
             //
    </script>
    <style>this won't be escaped in html output: &</style>
  </head>
  <!-- a comment -->
  <body>
    <div></div>
    <div>
      <form action="." method="POST">
      <img src="foo.gif">
      <table border="0">
        <tbody>
          <tr class="foo">
            <td>Name</td>
            <td>Description</td>
          </tr>
        </tbody>
      </table>
      <input name="submit" type="submit" value=" Next ">
      </form>
    </div>
  </body>
</html>)r�r^r
r)rrr�r�rrr� test_write_complex_xhtml_as_htmlus

#z,WriterTests.test_write_complex_xhtml_as_htmlcCs(|jt�}|j|�}d}|j||�dS)NaV<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
    <title>This will be escaped in html output: &amp;</title>
    <script>this won't be escaped in html output: &amp;</script>
    <script type="text/javascript">
            //
              // this won't be escaped in html output
              function match(a,b) {
                 if (a &lt; b &amp;&amp; a > 0) then { return 1 }
                }
             //
    </script>
    <style>this won't be escaped in html output: &amp;</style>
  </head>
  <!--  a comment  -->
  <body>
    <div ns0:baz="slab" xmlns:ns0="http://foo/bar" />
    <div>
      <form action="." method="POST">
      <img src="foo.gif" />
      <table border="0">
        <tbody>
          <tr class="foo">
            <td>Name</td>
            <td>Description</td>
          </tr>
        </tbody>
      </table>
      <input name="submit" type="submit" value=" Next " />
      </form>
    </div>
  </body>
</html>)r�r^rr
)rrr�r�rrr�!test_write_complex_xhtml_as_xhtml�s

#z-WriterTests.test_write_complex_xhtml_as_xhtmlcCs<ddlm}|jt�}|j|�}d}|j||dd�|�dS)Nr)raz�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <body>
    <area><base><basefont><br><col><frame><hr><img><input><isindex>
    <link><meta><param>
  </body>
</html>rb)rc)rdrar��_EMPTYTAGS_HTMLr
r)rrarr�r�rrr�test_write_emptytags_html�s


z%WriterTests.test_write_emptytags_htmlcCs(|jt�}|j|�}d}|j||�dS)Na�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <body>
  <tag selected></tag>
  <tag checked></tag>
  <tag compact></tag>
  <tag declare></tag>
  <tag defer></tag>
  <tag disabled></tag>
  <tag ismap></tag>
  <tag multiple></tag>
  <tag nohref></tag>
  <tag noresize></tag>
  <tag noshade></tag>
  <tag nowrap></tag>
  </body>
</html>)r��_BOOLEANATTRS_XHTMLr
r)rrr�r�rrr�%test_write_booleanattrs_xhtml_as_html�s

z1WriterTests.test_write_booleanattrs_xhtml_as_htmlcCs,|jt�}|j|dd�}d}|j||�dS)NT)�pipelinez�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body ns0:id="body" xmlns:ns0="https://github.com/Supervisor/supervisor">Hello!</body></html>)r�r�rr
)rrr�r�rrr� test_write_simple_xhtml_pipeline�s
z,WriterTests.test_write_simple_xhtml_pipelinecCs,|jt�}|j|dd�}d}|j||�dS)NT)ra<?xml version="1.0"?><root>
  <list ns0:id="list" xmlns:ns0="https://github.com/Supervisor/supervisor">
    <item ns0:id="item">
       <name ns0:id="name">Name</name>
       <description ns0:id="description">Description</description>
    </item>
  </list>
</root>)r�rr	r
)rrr�r�rrr�test_write_simple_xml_pipeline�s
z*WriterTests.test_write_simple_xml_pipelinecCs,|jt�}|j|dd�}d}|j||�dS)Nzlatin-1)rcz�<?xml version="1.0" encoding="latin-1"?><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>)r�rr	r
)rrr�r�rrr�'test_write_simple_xml_override_encodings
z3WriterTests.test_write_simple_xml_override_encodingcCs,|jt�}|j|dd�}d}|j||�dS)NT)�fragmentz<root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>)r�rr	r
)rrr�r�rrr�!test_write_simple_xml_as_fragments
z-WriterTests.test_write_simple_xml_as_fragmentcCs:|jt�}ddlm}|j||jd�}d}|j||�dS)Nr)�doctypea<?xml version="1.0"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>)r�rrr r	�xhtmlr
)rrr r�r�rrr�"test_write_simple_xml_with_doctypes

	z.WriterTests.test_write_simple_xml_with_doctypecCs<|jt�}ddlm}|j|d|jd�}d}|j||�dS)Nr)r F)�declarationr z�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>)r�rrr r	r!r
)rrr r�r�rrr�+test_write_simple_xml_doctype_nodeclaration-s

z7WriterTests.test_write_simple_xml_doctype_nodeclarationcCs>|jt�}ddlm}|j|d|jdd�}d}|j||�dS)Nr)r T)r#r rz<root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>)r�rrr r	r!r
)rrr r�r�rrr�<test_write_simple_xml_fragment_kills_doctype_and_declaration<s
zHWriterTests.test_write_simple_xml_fragment_kills_doctype_and_declarationcCs.|jt�}|j|ddd�}d}|j||�dS)Nzlatin-1T)rcr#z�<?xml version="1.0" encoding="latin-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body>Hello!</body></html>)r�r�rr
)rrr�r�rrr�)test_write_simple_xhtml_override_encodingKs
z5WriterTests.test_write_simple_xhtml_override_encodingcCs,|jt�}|j|dd�}d}|j||�dS)NT)rz <html><body>Hello!</body></html>)r�r�rr
)rrr�r�rrr�#test_write_simple_xhtml_as_fragmentQs
z/WriterTests.test_write_simple_xhtml_as_fragmentcCs:|jt�}ddlm}|j||jd�}d}|j||�dS)Nr)r z�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body>Hello!</body></html>)r�r�rr rr!r
)rrr r�r�rrr�$test_write_simple_xhtml_with_doctypeWs

z0WriterTests.test_write_simple_xhtml_with_doctypecCs<|jt�}ddlm}|j|d|jd�}d}|j||�dS)Nr)r F)r#r z�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body>Hello!</body></html>)r�r�rr rr!r
)rrr r�r�rrr�-test_write_simple_xhtml_doctype_nodeclaration^s

z9WriterTests.test_write_simple_xhtml_doctype_nodeclarationcCs>|jt�}ddlm}|j|d|jdd�}d}|j||�dS)Nr)r T)r#r rz <html><body>Hello!</body></html>)r�r�rr rr!r
)rrr r�r�rrr�>test_write_simple_xhtml_fragment_kills_doctype_and_declarationfs
zJWriterTests.test_write_simple_xhtml_fragment_kills_doctype_and_declarationcCs,|jt�}|j|dd�}d}|j||�dS)NT)rz <html><body>Hello!</body></html>)r�r�r
r
)rrr�r�rrr�(test_write_simple_xhtml_as_html_fragmentns
z4WriterTests.test_write_simple_xhtml_as_html_fragmentcCs(|jt�}|j|�}d}|j||�dS)Nz�
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><body>Hello!</body></html>)r�r�r
r
)rrr�r�rrr�,test_write_simple_xhtml_with_doctype_as_htmlts

z8WriterTests.test_write_simple_xhtml_with_doctype_as_htmlcCs:|jt�}ddlm}|j||jd�}d}|j||�dS)Nr)r z|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><body>Hello!</body></html>)r�r�rr r
Zhtml_strictr
)rrr r�r�rrr�+test_write_simple_xhtml_as_html_new_doctype|s

z7WriterTests.test_write_simple_xhtml_as_html_new_doctypecCs&ddlm}|j|jtf|jd�dS)Nr)�expatz.<html><head></head><body>&fleeb;</body></html>)Zxml.parsersr.rf�error�SyntaxErrorr�)rr.rrr�test_unknown_entity�szWriterTests.test_unknown_entitycCs@|jt�}|jd�}|jddd�|j|�}d}|j||�dS)Nrzdescription &<foo>&amp;<bar>F)rLz�<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          <description>description &amp;&lt;foo>&amp;&lt;bar></description>
        </item>
        </list>
        </root>)r�rrrQr	r
)rrrMr�r�rrr�test_content_nostructure�s


	z$WriterTests.test_content_nostructurecCs@|jt�}|jd�}|jddd�|j|�}d}|j||�dS)Nrzdescription &<foo> <bar>T)rLz�<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          <description>description &<foo> <bar></description>
        </item>
        </list>
        </root>)r�rrrQr	r
)rrrMr�r�rrr�test_content_structure�s


	z"WriterTests.test_content_structurecCs@|jt�}|jd�}|jddd�|j|�}d}|j||�dS)Nrzdescription &<foo>&amp;<bar>F)rLz�<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          description &amp;&lt;foo>&amp;&lt;bar>
        </item>
        </list>
        </root>)r�rrrFr	r
)rrrMr�r�rrr�test_replace_nostructure�s


	z$WriterTests.test_replace_nostructurecCs@|jt�}|jd�}|jddd�|j|�}d}|j||�dS)Nrzdescription &<foo> <bar>T)rLz�<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          description &<foo> <bar>
        </item>
        </list>
        </root>)r�rrrFr	r
)rrrMr�r�rrr�test_replace_structure�s


	z"WriterTests.test_replace_structurecCs8ddlm}ddlm}d}|j|ddd�||��dS)Nr)r�)�
_escape_cdatazO< > &lt;&amp; &&apos; && &foo "" http://www.example.com?foo=bar&bang=baz &#123;zf&lt; > &lt;&amp; &amp;&apos; &amp;&amp; &amp;foo "" http://www.example.com?foo=bar&amp;bang=baz &#123;rb)rc)rdr�rr6r)rr�r6r(rrr�test_escape_cdata�szWriterTests.test_escape_cdatacCsVddlm}ddlm}ddlm}||ddd�dd�}|j|ddd�||d	��dS)
Nr)r6)r�)ra�€rb)rcz&#128;�ascii)rr6rdr�rar)rr6r�rar(rrr�test_escape_cdata_unicodeerror�sz*WriterTests.test_escape_cdata_unicodeerrorcCs:ddlm}ddlm}d}|j|ddd�||d��dS)Nr)�_escape_attrib)r�zO< > &lt;&amp; &&apos; && &foo "" http://www.example.com?foo=bar&bang=baz &#123;zp&lt; > &lt;&amp; &amp;&apos; &amp;&amp; &amp;foo &quot;&quot; http://www.example.com?foo=bar&amp;bang=baz &#123;rb)rc)rr;rdr�r)rr;r�r(rrr�test_escape_attrib�szWriterTests.test_escape_attribcCsVddlm}ddlm}ddlm}||ddd�dd�}|j|ddd�||d	��dS)
Nr)r;)r�)rar8rb)rcz&#128;r9)rr;rdr�rar)rr;r�rar(rrr�test_escape_attrib_unicodeerror�sz+WriterTests.test_escape_attrib_unicodeerrorN)*rirjrkr�r�rr	r
rr
rrrrrrrrrrrrr"r$r%r&r'r(r)r*r+r,r-r1r2r3r4r5r7r:r<r=rrrrr� sN	)/


	r�cCs tjdd|�}tjdd|�}|S)Nz[ \t]+� z/>�>)�re�sub)�srrr�normalize_html�srCcCs.tjdd|�}tjdd|�}tjdd|�}|S)Nz\s+r>z(?s)\s+<�<z(?s)>\s+r?)r@rA)rBrrrr�srcCstjtjt�S)N)�unittestZ
findTestCases�sys�modulesrirrrr�
test_suite�srHcCstjdd�dS)NrH)ZdefaultTest)rE�mainrrrrrIsrI�__main__)rEr@rFrr�rrZ_ENTITIES_XHTMLr^r�r?ZTestCaserrlr�r�r�rCrrHrIrirrrr�<module>s>
	&'0IS/$U