
    vg                     8   d dl Z d dlZd dlZdZdZdZdZdZdZdZ	d	Z
 G d
 de j                  Z G d de j                  Z G d de j                  Z G d de j                  Z G d de j                  Zd Zd Zd Zd Zedk    r e             dS dS )    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                   h    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )MeldAPITestsc                 $    ddl m}  ||          S Nr   parse_xmlstringsupervisor.templatingr   )selfstringr   s      ]/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/supervisor/tests/test_templating.py_makeElementzMeldAPITests._makeElement8  s$    999999v&&&    c                 $    ddl m}  ||          S Nr   parse_htmlstringr
   r   )r   r   r   s      r   _makeElementFromHTMLz!MeldAPITests._makeElementFromHTML<  s%    ::::::'''r   c                     |                      t                    }|                    d          }|                     |j        d           |                    d          }|                     |j        d           d S )NitemnameName)r   _SIMPLE_XMLfindmeldassertEqualtagtext)r   rootr   r   s       r   test_findmeldzMeldAPITests.test_findmeld@  sm      --}}V$$6***}}V$$F+++++r   c                 D   |                      t                    }|                    d          }|                     |j        d           |                    dd          }|                     |d           |                     |                    d          d            d S )Nr   unknownfoo)r   r   r   r   r   )r   r   r   r"   s       r   test_findmeld_defaultz"MeldAPITests.test_findmeld_defaultG  s      --}}V$$6***--	511%(((y11488888r   c                    |                      t                    }|                    d          }|                     |j        d           ddddddg}|                    |          D ]E\  }}|d         |                    d          _        |d         |                    d          _        F|                     |d	         j        d           |                     |d
         j        d           d S )Nr   Jeff Buckleyetherealr   descriptionSlipknotheavyr   r)   r      r   r   r   r   r   repeatr   )r   r   r   dataelementds         r   test_repeat_nochildz MeldAPITests.test_repeat_nochildO  s      --}}V$$6***&jAA"'::<++d++ 	D 	DJGQ,-fIGV$$)34]3CG]++00a~666az22222r   c                    |                      t                    }|                    d          }|                     |j        d           ddddddg}|                    |d          D ]E\  }}|d         |                    d          _        |d	         |                    d	          _        F|                     |d
         d
         j        d           |                     |d
         d         j        d           |                     |d         d
         j        d           |                     |d         d         j        d           d S )Nlistr&   r'   r(   r*   r+   r   r   r)   r   r,   r-   )r   r   r4   r/   r0   r1   s         r   test_repeat_childzMeldAPITests.test_repeat_child[  s<     --}}V$$6***&jAA"'::<++dF33 	D 	DJGQ,-fIGV$$)34]3CG]++00a.999a*555a*555a'22222r   c                 
   |                      t                    }|dddz   |                    d          }|                     |j        d           |                    d          }|                     |j        d           d S )Nr#   bar)r)   r   r   r)   )r   r   r   r   r   )r   r   r   descs       r   test_modzMeldAPITests.test_modi  s      --eE2222}}V$$E***}}]++E*****r   c                     |                      t                    } |j        di ddd}|                    d          }|                     |j        d           |                     |dg           d S )Nr#   a)r)   jammyjamr)   r<    )r   r   	fillmeldsr   r   r   )r   r   unfilledr8   s       r   test_fillmeldszMeldAPITests.test_fillmeldsq  s{      --!4>JJ5S$I$IJJ}}]++E***J<00000r   c                    i ddddddddd	d
dddddddddddddddddddddd i dddd!dd"dd#d	d$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/i dd!dd"dd#d	d$dd%dd&dd'dd(dd)dd*dd+dd0dd-dd.dd1d2d3g}|                      t                    }|                                } |j        d9i |d4         }|                     |g            |                     |                    d          j        d5         d           |                     |                    d          j        d5         d           |                    d          }|                     |j        d5         d           |                    d          }|                     |d3         j        d6         d6           |                     |                    d          j        d7         d7           |                    d          }|                     |d3         j        d7         d7           |                    d          }|                     |d3         j        d7         d7           |                                } |j        d9i |d3         }|                     |dg           |                     |                    d          j                            d7          d            |                    d          }|                     |d8         j        d7         d7           |                     |d3         j                            d7          d            |                                } |j        d9i |d8         }|                     t          |          d2dg           |                     |                    d          j	        d            |                    d          }|                     |d8         j        d7         d7           |                     |d3         j                            d7          d            d S ):N	honorificzMr.	firstnameChris
middlenamePhillipslastname	McDonoughaddress1z802 Caroline St.address2zApt. 2BcityFredericksburgstateVAzip22401	homephonez555-1212	cellphonez555-1313emailzuser@example.comsuffixzSr.over18Tzmailok:inputgrouptruezfavorite_color:inputgroupGreenFred Rogersz1 Imaginary LanezApt. 3AzNever Never LandLA00001z555-1111z555-4444zfred@neighborhood.comzJr.FfalseYellowIVBluenottherer,   r   valueselectedchecked   r=   )
r   _FILLMELDFORM_HTMLclonefillmeldhtmlformr   r   attribgetsortedr   )	r   r/   r   rg   r?   rE   rT   mailokfavoritecolors	            r   test_fillmeldhtmlformz"MeldAPITests.test_fillmeldhtmlformx  s   N[ NG N\* NN%/0BN	N#)*:N<CTN 7N (
N 5@
N '	N *2%	N :B$	N
 !N
 *EWNP[ PF PL PP",-?P	P#)*<P>EtP 7P (
P 5@
P ,	P /7u	P ?Gu	P
 !P
 *EXP[ b ",-?	#)*<>Et 7 (
 5@
 ,	 /7t	 >Fe	
 !
 +Ff * (();<<

)5)44DG442&&&44;GDeLLL44;GDgNNN^^L11
*73Z@@@)))*5zBBB118CYOOO 344))4i@@@'BCCq)0;YGGG

)5)44DG44$?#@AAA118<<YGGNNN 344))4i@@@)--i88$???

)5)44DG44))J+ABBB4494@@@'BCCq)0;YGGGq)044Y??FFFFFr   c                 J   ddl m} |                     t                    }|                    d          }|                    d           |d         }|                     |j        |           |                     t          |	                                          d           d S )Nr   Replacer4   this is a textual replacementr,   )
r
   rq   r   r   r   replacer   r   lengetchildren)r   rq   r   LRs        r   !test_replace_removes_all_elementsz.MeldAPITests.test_replace_removes_all_elements  s    111111  --MM&!!			1222G(((T--//00!44444r   c                 0   ddl m} |                     t                    }|                    d          }|                    d           |                     t          |                                          d           |d         }|                     |j	        d           |                     t          |                                          d           |d         }|                     |j	        d           |                     t          |                                          d           |d         }|                     |j	        d	           |                     t          |                                          d           |d         }|                     |j	        |           |                     |j
        d           |                     t          |                                          d           |                     |j        d
           d S Nr   rp   r)   rr   r,   r4   r   re   r   F)r
   rq   r   r   r   rs   r   rt   ru   r   r   	structure)r   rq   r   Drv   INs          r   'test_replace_replaces_the_right_elementz4MeldAPITests.test_replace_replaces_the_right_element  s   111111  --MM-((			1222T--//00!444G'''Q]]__--q111aD'''Q]]__--q111aD'''Q]]__--q111aD(((!@AAAQ]]__--q111e,,,,,r   c                    ddl m} |                     t                    }|                    d          }|                    d           |                     t          |                                          d           |d         }|                     |j	        d           |                     t          |                                          d           |d         }|                     |j	        d           |                     t          |                                          d           |d         }|                     |j	        d	           |                     t          |                                          d           |d         }|                     |j	        d           |                     |j
        d            |                     t          |                                          d           |d         }|                     |j	        |           |                     |j
        d           |                     |j        d
           d S rz   )r
   rq   r   r   r   contentr   rt   ru   r   r   r{   )r   rq   r   r|   rv   r}   r~   Ts           r   test_contentzMeldAPITests.test_content  s   111111  --MM-((			1222T--//00!444G'''Q]]__--q111aD'''Q]]__--q111aD'''Q]]__--q111aD...&&&Q]]__--q111aD(((!@AAAe,,,,,r   c                     ddl m} |                     t                    }|                    d          }|                    dddd           |                     |j        d	dd
ddddddd|di           d S )Nr   _MELD_IDform1r7   12#)r#   bazgactionr#   r   r   methodPOSTr   )r
   r   r   _COMPLEX_XHTMLr   
attributesr   ri   )r   r   r   r|   s       r   test_attributeszMeldAPITests.test_attributes  s    222222  00MM'""	C3s;;;%sCVXcg$ 	  	  	  	  	 r   c                 H   ddl m} ddlm} |                     t
                    }|                    d          }|                     |dd           |dd          	           |                     |j	        d
 |dd          ddd |dd          |di           d S )Nr   r   	as_stringr   r7   latin1encodingr   )r#   r   r#   r   r   r   )
r
   r   supervisor.compatr   r   r   r   r   r   ri   )r   r   r   r   r|   s        r   test_attributes_unicodez$MeldAPITests.test_attributes_unicode  s    222222//////  00MM'""	58<<<%IcH=== 	 	? 	? 	?))EH555VXyyx'H'H'Hg$ 	  	  	  	  	 r   c                 t    |                      d          }|                     t          |j        d           d S )N<root></root>r,   )r#   )r   assertRaises
ValueErrorr   )r   r   s     r   $test_attributes_nonstringtype_raisesz1MeldAPITests.test_attributes_nonstringtype_raises  s8      11*do1=====r   N)__name__
__module____qualname__r   r   r    r$   r2   r5   r9   r@   rn   rx   r   r   r   r   r   r=   r   r   r   r   7  s        ' ' '( ( (, , ,9 9 9
3 
3 
33 3 3+ + +1 1 15G 5G 5Gn5 5 5- - -*- - -0     
  
  
 > > > > >r   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z dS ) MeldElementInterfaceTestsc                     ddl m} |S )Nr   )_MeldElementInterface)r
   r   )r   r   s     r   _getTargetClassz)MeldElementInterfaceTests._getTargetClass   s    ??????$$r   c                 :    |                                  } ||i |S N)r   )r   argkwklasss       r   _makeOnez"MeldElementInterfaceTests._makeOne  s(    $$&&uc R   r   c                 &   |                      di           }ddlm} |                      d|di          }|                      d|di          }|                      d|di          }|                      d|di          }|                    |           |                    |           |                    |           |                    |           dd	d
ddd
g}|                    |          D ]E\  }}	|	d         |                    d          _        |	d         |                    d          _        F|                     t          |          d           |d         }
|                     t          |
          d           |
d         }|                     t          |          d           |d         }|d         }|                     |j        d           |                     |j        d	           |d         }|                     t          |          d           |d         }|                     t          |          d           |d         }|d         }|                     |j        d           |                     |j        d           d S )Nr   r   r   r   recordr   r)   r&   r'   r(   r*   r+   re   r,   )	r   r
   r   appendr.   r   r   r   rt   )r   r   r   r   r   r   r)   r/   r0   r1   item1record1name1desc1item2record2name2desc2s                     r   test_repeatz%MeldElementInterfaceTests.test_repeat  s   }}VR((222222}}Vhv%677x(8)<==}}Vhv%677mmMH]3KLLdk"""FD&jAA"'::< ++d++ 	D 	DJGQ,-fIGV$$)34]3CG]++00TA&&&QUQ'''(Wq)))

^444Z000QUQ'''(Wq)))

Z000W-----r   c                    |                      dddi          }|                    d           |                     t          |j                  d           |j        d         }|                     |j        |           |                     |j        d           |                     |j        d           ddlm	} |                     |j
        |           d S )	Ndividthedivhellor,   r   Frp   r   r   r   rt   	_childrenparentr   r{   r
   rq   r   r   elreplacenoderq   s       r   test_content_simple_nostructurez9MeldElementInterfaceTests.test_content_simple_nostructure/  s    ]]54/22


7R\**A...l1o+R000)7333.666111111'22222r   c                    |                      dddi          }|                    dd           |                     t          |j                  d           |j        d         }|                     |j        |           |                     |j        d           |                     |j        d           dd	lm	} |                     |j
        |           d S )
Nr   r   r   r   Tr{   r,   r   rp   r   r   s       r   test_content_simple_structurez7MeldElementInterfaceTests.test_content_simple_structure:  s    ]]54/22


7d
+++R\**A...l1o+R000)7333.555111111'22222r   c                     ddl m} |                     d|di          }|                     |                    d          |           d S )Nr   r   r   r   )r
   r   r   r   r   )r   r   r   s      r   test_findmeld_simplez.MeldElementInterfaceTests.test_findmeld_simpleE  sT    222222]]58H"566X..33333r   c                     ddl m} |                     d|di          }|                     d|di          }|                    |           |                     |                    d          |           d S )Nr   r   r   r   spanthespanr
   r   r   r   r   r   )r   r   r   r   s       r   !test_findmeld_simple_oneleveldownz;MeldElementInterfaceTests.test_findmeld_simple_oneleveldownJ  s{    222222]]58H"566}}Vhy%9::
		$Y//66666r   c                 H   ddl m} |                     d|di          }|                     d|di          }|                     d|di          }|                    |           |                    |           |                     |                    d          |           d S )	Nr   r   r   r   r   r   r;   thear   )r   r   r   r   r;   s        r   "test_findmeld_simple_twolevelsdownz<MeldElementInterfaceTests.test_findmeld_simple_twolevelsdownQ  s    222222]]58H"566}}Vhy%9::MM#011A
		$V,,a00000r   c                     |                      dddi          }|                     |j        d            |                     |j        d           |                     |j        ddi           d S )Nr   r   r   )r   r   r   r   ri   )r   ifaces     r   	test_ctorz#MeldElementInterfaceTests.test_ctorZ  sk    ed8_55t,,,E***X77777r   c                     |                      dddi          }|                                }|                     t          |          d           |                     |d         |           d S )Nr   r   r   r,   r   )r   getiteratorr   rt   )r   r   iterators      r   test_getiterator_simplez1MeldElementInterfaceTests.test_getiterator_simple`  sd    mmED?33??$$X***!c*****r   c                    |                      dddi          }|                      di           }|                      dddi          }|                      dddi          }d|_        d	|_        |                    |           |                    |           |                    |           |                                }|                     t          |          d
           |                     |d         |           |                     |d         |           |                     |d         |           |                     |d         |           d S )Nr   r   r   r   r   span33abc     r   r,   re      r   r   tailr   r   r   rt   r   r   r   span2r   its         r   test_getiteratorz*MeldElementInterfaceTests.test_getiteratorf  s7   mmED?33}}VR((ftCj11gSz22



4EU__R!$$$A$$$A%%%A&&&A&&&&&r   c                    |                      dddi          }|                      di           }|                      dddi          }|                      dddi          }d|_        d	|_        |                    |           |                    |           |                    |           |                    d
          }|                     t          |          d           |                     |d         |           |                     |d         |           |                     |d         |           |                     |d         |           d S )Nr   r   r   r   r   r   r   r   r   )r   r   r   r,   re   r   r   r   s         r   test_getiterator_tag_ignoredz6MeldElementInterfaceTests.test_getiterator_tag_ignoredx  s;   mmED?33}}VR((ftCj11gSz22



4EU___''R!$$$A$$$A%%%A&&&A&&&&&r   c                    |                      dddi          }|                      di           }|                    |           |                     |d         j        d           |                     |j        |           d S )Nr   r   r   r   r   )r   r   r   r   r   r   r   r   s      r   test_appendz%MeldElementInterfaceTests.test_append  sx    mmED?33}}VR((

4QV,,,c*****r   c                    |                      dddi          }|                      di           }|                      dddi          }|                    |           ||d<   |                     |d         j        d           |                     |d         j        ddi           |                     |d         j        |           d S )Nr   r   r   r   r   r   )r   r   r   r   ri   r   r   r   r   r   s       r   test__setitem__z)MeldElementInterfaceTests.test__setitem__  s    mmED?33}}VR((ftCj11

4AQV,,,Qc
333Q,,,,,r   c                 x   |                      dddi          }|                      di           }|                      dddi          }|                    |           |                    d|           |                     |d         j        d           |                     |d         j        ddi           |                     |d         j        |           |                     |d         j        d           |                     |d         j        i            |                     |d         j        |           d S )Nr   r   r   r   r   r   r,   )r   r   insertr   r   ri   r   r   s       r   test_insertz%MeldElementInterfaceTests.test_insert  s   mmED?33}}VR((ftCj11

4

1eQV,,,Qc
333Q,,,QV,,,Q+++Q,,,,,r   c                     |                      dddi          }d|_        d|_        |                      di           }|                    |           |                                 d S )Nr   r   r   r   z   r   )r   r   r   r   rg   r   s      r   test_clone_simplez+MeldElementInterfaceTests.test_clone_simple  s]    mmED?33}}VR((

4		r   c                    |                      dddi          }|                      di           }|                      dddi          }|                      dddi          }d|_        d	|_        |                    |           |                    |           |                    |           |                                }|                     |j        |j                   |                     |j        |j                   |                     |d
         j        |d
         j                   |                     |d
         j        |d
         j                   |                     |d
         d
         j        |d
         d
         j                   |                     |d
         d
         j        |d
         d
         j                   |                     |d
         d
         d
         j        |d
         d
         d
         j                   |                     |d
         d
         d
         j        |d
         d
         d
         j                   |                     |d
         d
         d
         j        |d
         d
         d
         j                   |                     |d
         d
         d
         j        |d
         d
         d
         j                   |                     t          |          t          |                     |                     t          |d
                   t          |d
                              |                     t          |d
         d
                   t          |d
         d
                              |                     t          |d
         d
         d
                   t          |d
         d
         d
                              d S )Nr   r   r   r   r   r   r   r   r   r   )
r   r   r   r   rg   r   r   ri   assertNotEqualr   )r   r   r   r   r   div2s         r   
test_clonez$MeldElementInterfaceTests.test_clone  s   mmED?33}}VR((ftCj11gSz22



4EUyy{{$(+++T[111QT!W[111QQ777QQ
777Q)471:+<===Q1)471:a=+<===Q1,d1gajm.BCCCQ1*DGAJqM,>???Q1*DGAJqM,>???BsGGRXX...Bs1vJJ47444Bs1vayMM2d1gaj>>:::Bs1vay|,,baA.?.?@@@@@r   c                     |                      di           }|                     |j        d            |                                 |                     |j        d            d S )Nr   )r   r   r   deparent)r   r   s     r   test_deparent_noparentz0MeldElementInterfaceTests.test_deparent_noparent  sX    mmE2&&T***T*****r   c                    |                      di           }|                     |j        d            |                      di           }|                    |           |                     |j        d            |                     |j        |           |                     |d         |           |                                 |                     |j        d            |                     t          |j        d           d S )Nr   childr   )r   r   r   r   r   r   
IndexError__getitem__)r   r   r   s      r   test_deparent_withparentz2MeldElementInterfaceTests.test_deparent_withparent  s    x,,---gr**e---v...E***t,,,*f&8!<<<<<r   c                    |                      di           }|                      di           }|                      di           }|                      di           }|||f}||dd<   |                     |j        |           |                     |j        |           |                     |j        |           |                     |j        t	          |                     d S )Nr   child1child2child3r   re   )r   r   r   r   r4   r   r   r  r  r  childrens         r   test_setslicez'MeldElementInterfaceTests.test_setslice  s    x,,x,,x,,x,,FF+qs/////////)4>>:::::r   c                    |                      di           }|                      di           }|                      di           }|                      di           }|||f}||dd<   |dd= |                     |j        d            |                     |j        d            |                     |j        |           |                     t          |j                  d           d S )Nr   r  r  r  r   re   r,   )r   r   r   rt   r   r  s         r   test_delslicez'MeldElementInterfaceTests.test_delslice  s    x,,x,,x,,x,,FF+qs1Q3K------///V-..22222r   c                 8   |                      di           }|                      di           }|                    |           |                    |           |                     |j        d            |                     t          |j                  d           d S )Nr   r  r   )r   r   remover   r   rt   r   )r   r   r  s      r   test_removez%MeldElementInterfaceTests.test_remove  s    x,,x,,ff---V-..22222r   c                    ddl m} |                     d|di          }|                     d|di          }|                     d|di          }|                     d|di          }|                     d|d	i          }|                     d|d
i          }|                     d|di          }|                     di           }	|                     d|di          }
|                    |           |                    |           |                    |           |                    |	           |	                    |           |                    |           |                    |           |                    |
           d }|                      ||                                          dg           |                      ||                                          ddg           |                      ||                                          g d           |                      ||                                          g d           |                      ||	                                          g d           |                      ||                                          g d           |                      ||                                          g d           |                      ||                                          g d           |                      ||
                                          ddg           d S )Nr   r   r   div1r   span1r   r   span4span5span6r   c                     d | D             S )Nc                 6    g | ]}|                                 S r=   meldid.0xs     r   
<listcomp>zGMeldElementInterfaceTests.test_lineage.<locals>.ids.<locals>.<listcomp>  s     ,,,AQXXZZ,,,r   r=   )rv   s    r   idsz3MeldElementInterfaceTests.test_lineage.<locals>.ids  s    ,,,,,,r   )r   r  r  )r   r   r  r  )Nr   r   r  r  )r  Nr   r   r  r  )r  r  Nr   r   r  r  )r  r  r  Nr   r   r  r  )r
   r   r   r   r   lineage)r   r   r  r  r   r   r  r  r  r"   r   r  s               r   test_lineagez&MeldElementInterfaceTests.test_lineage  s   222222}}UXf$566fx&899fx&899fx&899fx&899fx&899fx&899--++}}Vhv%677EUUWuUUD	- 	- 	-T\\^^,,vh777U]]__--/@AAAU]]__--/I/I/IJJJU]]__-- 0< 0< 0< 	= 	= 	=W__..// 2: 2: 2: 	; 	; 	; 	U]]__-- 0@ 0@ 0@ 	A 	A 	A 	U]]__-- 0@ 0@ 0@ 	A 	A 	A 	U]]__-- 0D 0D 0D 	E 	E 	E 	T\\^^,,vv.>?????r   c                    ddl m} |                     dddi          }|                     di           }|                     dddi          }|                     dddi          }|                    |           |                    |           |                    |           |                                }|                     | |d	d
                     d S )Nr   as_bytesr   r   r  r   r   r   zM<div id="div1"><span><span id="2"></span></span><div2 id="div2"></div2></div>r   r   )r   r  r   r   	shortreprr   )r   r  r   r   r   r   rs          r   test_shortreprz(MeldElementInterfaceTests.test_shortrepr)  s    ......mmED=11}}VR((ftCj11}}Vd6]33

4E

4MMOOH 5?GI I I	J 	J 	J 	J 	Jr   c                     ddl m} ddlm}  |t                    }|                                }|                     | |dd                     d S )Nr   r   r  z<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
     [...]
</head>
  <!--  a comment  -->
   [...]
</html>r   r   )r
   r   r   r  r   r   r   )r   r   r  r   r!  s        r   test_shortrepr2z)MeldElementInterfaceTests.test_shortrepr27  s    999999......~..NNH  $,- - -	. 	. 	. 	. 	.r   c                    ddl m} ddl m  |t                    }|                                }|                     ddi          }|                    |           |                    d          }|                                 |                    d          }|                                 |                    |           |	                    |          }|d         }fd	|d
         D             }	fd|d         D             }
fd|d         D             }|	
                                 |

                                 |
                                 |                     |	dg           |                     |
g d           |                     |dg           |d         }fd|d
         D             }	fd|d         D             }
fd|d         D             }|	
                                 |

                                 |
                                 |                     |	dg           |                     |
dg           |                     |dg           d S )Nr   r   r   r   newdivtrtitle	unreducedc                 *    g | ]}|j                  S r=   ri   r  r  r   s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>V       DDDQahx(DDDr   addedc                 *    g | ]}|j                  S r=   r+  r,  s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>W       GGGaqx)GGGr   removedc                 *    g | ]}|j                  S r=   r+  r,  s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>X  r-  r   moved)td1td2r'  reducedc                 *    g | ]}|j                  S r=   r+  r,  s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>b  r-  r   c                 *    g | ]}|j                  S r=   r+  r,  s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>c  r0  r   c                 *    g | ]}|j                  S r=   r+  r,  s     r   r  z<MeldElementInterfaceTests.test_diffmeld1.<locals>.<listcomp>d  r-  r   )r
   r   r   r   rg   r   r   r   r   diffmeldsortr   )r   r   r   rg   r   r'  r(  diffchanges	addedtagsremovedtags	movedtagsr   s               @r   test_diffmeld1z(MeldElementInterfaceTests.test_diffmeld1F  s   999999222222~..

mmEHX#677S^^D!!
w''U }}U##{#DDDD''2BDDD	GGGG793EGGGDDDD''2BDDD	H:...%9%9%9:::WI... y/DDDD''2BDDD	GGGG793EGGGDDDD''2BDDD	H:...dV,,,WI.....r   c                    d}d}ddl m}  ||          } ||          }|                    |          }d |d         d         D             }dg}|                     ||           d	 |d         d
         D             }g }|                     ||           d |d         d         D             }g }|                     ||           d |d         d         D             }dg}|                     ||           d |d         d
         D             }g }|                     ||           d |d         d         D             }g }|                     ||           d S )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   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>       DDD!((**DDDr   r)  r3  bc                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>  rD  r   r.  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>       FFF!((**FFFr   r1  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>       BBB!((**BBBr   r6  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>  rJ  r   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld2.<locals>.<listcomp>  rD  r   r
   r   r:  r   	r   sourcetargetr   source_roottarget_rootr=  actualexpecteds	            r   test_diffmeld2z(MeldElementInterfaceTests.test_diffmeld2l  s    	;:::::&&v..&&v..&&{33 EDgk&:7&CDDD56***DDgk&:7&CDDD6***FFgk&:9&EFFF6*** CBgi&8&ABBB56***BBgi&8&ABBB6***DDgi&8&CDDD6*****r   c                    d}d}ddl m}  ||          } ||          }|                    |          }d |d         d         D             }dd	g}|                     ||           d
 |d         d         D             }ddg}|                     ||           d |d         d         D             }ddg}|                     ||           d |d         d         D             }dg}|                     ||           d |d         d         D             }dg}|                     ||           d |d         d         D             }dg}|                     ||           d S )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   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rD  r   r)  r3  rE  cc                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rD  r   r.  r1   ec                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rH  r   r1  zyc                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rJ  r   r6  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rJ  r   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld3.<locals>.<listcomp>  rD  r   rM  rN  s	            r   test_diffmeld3z(MeldElementInterfaceTests.test_diffmeld3  s   
 	;:::::&&v..&&v..&&{33 EDgk&:7&CDDD:6***DDgk&:7&CDDD:6***FFgk&:9&EFFF:6*** CBgi&8&ABBB56***BBgi&8&ABBB56***DDgi&8&CDDD56*****r   c                    d}d}ddl m}  ||          } ||          }|                    |          }d |d         d         D             }dd	g}|                     ||           d
 |d         d         D             }ddg}|                     ||           d |d         d         D             }g d}|                     ||           d |d         d         D             }dg}|                     ||           d |d         d         D             }dg}|                     ||           d |d         d         D             }ddg}|                     ||           d S )N!  
        <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   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>  rD  r   r)  r3  r;   rE  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>  rD  r   r.  mnc                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>  rH  r   r1  )rX  r1   r\  r]  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>   rJ  r   r6  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>  rJ  r   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld4.<locals>.<listcomp>  rD  r   rX  r\  rM  rN  s	            r   test_diffmeld4z(MeldElementInterfaceTests.test_diffmeld4  s    	;:::::&&v..&&v..&&{33 EDgk&:7&CDDD:6***DDgk&:7&CDDD:6***FFgk&:9&EFFF'''6*** CBgi&8&ABBB56***BBgi&8&ABBB56***DDgi&8&CDDD:6*****r   c                    d}d}ddl m}  ||          } ||          }|                    |          }d |d         d         D             }g d}|                     ||           d	 |d         d
         D             }g }|                     ||           d |d         d         D             }g }|                     ||           d |d         d         D             }ddg}|                     ||           d |d         d
         D             }g }|                     ||           d |d         d         D             }g }|                     ||           d S )Nrc  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   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>3  rD  r   r)  r3  )r;   rE  rX  r1   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>7  rD  r   r.  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>;  rH  r   r1  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>@  rJ  r   r6  r;   rX  c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>D  rJ  r   c                 6    g | ]}|                                 S r=   r  r  s     r   r  z<MeldElementInterfaceTests.test_diffmeld5.<locals>.<listcomp>H  rD  r   rM  rN  s	            r   test_diffmeld5z(MeldElementInterfaceTests.test_diffmeld5  s   $ 	;:::::&&v..&&v..&&{33 EDgk&:7&CDDD'''6***DDgk&:7&CDDD6***FFgk&:9&EFFF6*** CBgi&8&ABBB:6***BBgi&8&ABBB6***DDgi&8&CDDD6*****r   N)!r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r"  r$  rA  rU  ra  rl  rt  r=   r   r   r   r     s       % % %! ! !%. %. %.N	3 	3 	3	3 	3 	34 4 4
7 7 71 1 18 8 8+ + +' ' '$' ' '$+ + +- - -- - -  A A A8+ + +
= 
= 
=
; 
; 
;3 3 33 3 3'@ '@ '@TJ J J. . .$/ $/ $/L*+ *+ *+Z5+ 5+ 5+n:+ :+ :+x>+ >+ >+ >+ >+r   r   c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ParserTestsc                     ddl m}  || }|S r   r	   )r   argsr   r   s       r   _parsezParserTests._parseO  s%    999999%r   c                     ddl m}  || }|S r   r   )r   rx  r   r   s       r   _parse_htmlzParserTests._parse_htmlT  s&    ::::::&r   c                    ddl m} |                     t                    }|                     |j        d           |                     |j        d            |d         }|                     |j        d           |                     |j        |           |                     |j        |         d           |d         }|                     |j        d           |                     |j        |           |                     |j        |         d           |d         }|d         }|                     |j        d           |                     |j        |           |                     |j        |         d           |                     |j        d           |                     |j        |           |                     |j        |         d           d S )	Nr   r   r   r4   r   r,   r   r)   )r
   r   ry  r   r   r   r   ri   )r   r   r   l1str   r   r)   s          r   test_parse_simple_xmlz!ParserTests.test_parse_simple_xmlY  s   222222{{;''6***d+++Aw6***d+++X.777Aw6***d+++X.777Aw1g6***d+++X.777-888+T222+H5}EEEEEr   c                    d}ddl m} |                     t                    }|                     |j        |dz             |                     |j        i            |                     |j        d            |d         }|                     |j        |dz             |                     |j        |         d           |                     |j        |           d S )N {http://www.w3.org/1999/xhtml}%sr   r   htmlbody)r
   r   ry  _SIMPLE_XHTMLr   r   ri   r   )r   xhtml_nsr   r   r  s        r   test_parse_simple_xhtmlz#ParserTests.test_parse_simple_xhtmlo  s    5222222{{=))8f#4555b)))d+++Aw8f#4555X.777d+++++r   c                    d}ddl m} |                     t                    }|                     |j        |dz             |                     |j        i            |                     |j        d            |d         }|                     |j        |dz             |                     |j        i            |                     |j        |           |d         }|                     |j        |dz             |                     |j        d         d           |                     |j        |           |d	         }|                     |j        |d
z             |                     |j        |         d
           |                     |j        |           |d         }|                     |j        |dz             |                     |j        i            |                     |j        |           |d         }|                     |j        |dz             |                     |j        ddi           |                     |j        |           |d	         }	|                     |	j        |dz             |                     |	j        |         d           |                     |	j        |           |	d         }
|                     |
j        |dz             |                     |
j        |         d           |                     |
j        d         d           |                     |
j        d         d           |                     |
j        |	           |
d         }|                     |j        |dz             |                     |j        |
           |
d	         }|                     |j        |dz             |                     |j        |         d           |                     |j        d         d           |                     |j        |
           |d         }|                     |j        |dz             |                     |j        |         d           |                     |j        |           |d         }|                     |j        |dz             |                     |j        |         d           |                     |j        d         d           |                     |j        |           |d         }|                     |j        |d z             |                     |j        |         d!           |                     |j        |           |d	         }|                     |j        |d z             |                     |j        |         d"           |                     |j        |           d S )#Nr  r   r   r  headmetar   text/html; charset=ISO-8859-1r,   r(  re   r  r   z{http://foo/bar}bazslabcontent_wellformr   r   .r   r   imgtabletable1border0tbodyr'  classr#   tdr4  r5  )r
   r   ry  r   r   r   ri   r   )r   r  r   r   r  r  r(  r  r  r   r  r  r  r  r'  r4  r5  s                    r   test_parse_complex_xhtmlz$ParserTests.test_parse_complex_xhtml|  sn   5222222{{>**8f#4555b)))d+++Aw8f#4555b)))d+++Aw8f#4555Y/8	: 	: 	:d+++QHw$6777h/999t,,,Aw8f#4555b)))d+++Aw8e#3444'<f&EFFFd+++Aw8e#3444X.???d+++Aw8f#4555X.888X.444X.777d+++1g(U"2333T***QHw$6777h/:::h/555t,,,aHw$6777h/999u---1XD1118,d3337+U333E***e(T/222H-u555R(((e(T/222H-u555R(((((r   c                 ,   ddl m} ddl m} |                     t                    }|                     |j        d           |                     |j        i            |                     |j        d            |d         }|                     |j        d           |                     |j        i            |                     |j        |           |d         }|                     |j        d           |                     |j        d         d           |d	         }|                     |j        d
           |                     |j        |         d
           |                     |j        |           |d	         }|                     |j        d           |                     |j        i            |                     |j        |           |d         }|                     |j        |           |d         }	|                     |	j        d           |                     |	j        ddddd           |                     |	j        |           |d         }
|                     |
j        d           |d         }|                     |j        d           d S )Nr   r   )Commentr  r  r  r   r  r,   r(  r  r   r  ztext-align: left; width: 100px;r   r   )styler  cellpaddingcellspacing   r;      r  )	r
   r   r  r{  	_NVU_HTMLr   r   ri   r   )r   r   r  r   r  r  r(  r  commentr  hrefr  s               r   test_nvu_htmlzParserTests.test_nvu_html  s   222222111111	**6***b)))d+++Aw6***b)))d+++Aw6***Y/8	: 	: 	:QG,,,h/999t,,,Aw6***b)))d+++q'g...QG,,,(I146969	(; (; 	< 	< 	<
 	t,,,Aw3'''1g%(((((r   c                 V    d}d|z  }|                      t          | j        |           d S Nz(https://github.com/Supervisor/supervisorzF<html xmlns:meld="%s" meld:id="repeat"><body meld:id="repeat"/></html>)r   r   ry  r   meld_nsrepeateds      r   !test_dupe_meldids_fails_parse_xmlz-ParserTests.test_dupe_meldids_fails_parse_xml  s7    <68?@*dk8<<<<<r   c                 V    d}d|z  }|                      t          | j        |           d S r  )r   r   r{  r  s      r   "test_dupe_meldids_fails_parse_htmlz.ParserTests.test_dupe_meldids_fails_parse_html  s8    <68?@*d&6AAAAAr   N)r   r   r   ry  r{  r~  r  r  r  r  r  r=   r   r   rv  rv  N  s          
  
F F F,, , ,H) H) H)T') ') ')T= = =B B B B Br   rv  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )	UtilTestsc                 \    ddl m} d} ||          }d}|                     ||           d S )Nr   insert_doctyper   z<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><root></root>r
   r  r   r   r  origrS  rT  s        r   test_insert_xhtml_doctypez#UtilTests.test_insert_xhtml_doctype  sL    888888%% \*****r   c                 \    ddl m} d} ||          }d}|                     ||           d S )Nr   r  5<?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>r  r  s        r   !test_insert_doctype_after_xmldeclz+UtilTests.test_insert_doctype_after_xmldecl  sL    888888F%% D*****r   c                 \    ddl m} d} ||          }d}|                     ||           d S )Nr   )insert_meld_ns_declr  zk<?xml version="1.0" encoding="latin-1"?><root xmlns:meld="https://github.com/Supervisor/supervisor"></root>)r
   r  r   )r   r  r  rS  rT  s        r   test_insert_meld_ns_declz"UtilTests.test_insert_meld_ns_decl  sM    ======F$$T** A*****r   c                 \    ddl m} d} ||          }d}|                     ||           d S )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>r
   r  r   )r   r  r  rS  rT  s        r   'test_prefeed_preserves_existing_meld_nsz1UtilTests.test_prefeed_preserves_existing_meld_ns  sJ    111111U S*****r   c                 X    ddl m} d} ||          }|                     ||           d S )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>r  )r   r  r  rS  s       r   'test_prefeed_preserves_existing_doctypez1UtilTests.test_prefeed_preserves_existing_doctype  sE    111111 B&&&&&r   N)r   r   r   r  r  r  r  r  r=   r   r   r  r    s_        + + ++ + ++ + ++ + +' ' ' ' 'r   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d(S ))WriterTestsc                 (    ddl m}  ||          }|S r   r	   )r   xmlr   r   s       r   ry  zWriterTests._parse!  s(    999999s##r   c                 (    ddl m}  ||          }|S r   r   )r   r  r   r   s       r   r{  zWriterTests._parse_html&  s)    ::::::$$r   c                     	 ddl m} n#  ddlm} Y nxY w |            } ||fi | |                    d           |                                }|S )Nr   )BytesIO)StringIO)ior  r  seekread)r   fnr   r  outrS  s         r   _writezWriterTests._write+  s|    	5"""""""	544444444gii
3"s   	 c                 (     | j         |j        fi |S r   )r  	write_xmlr   noder   s      r   
_write_xmlzWriterTests._write_xml6  s    t{4>00R000r   c                 (     | j         |j        fi |S r   )r  
write_htmlr  s      r   _write_htmlzWriterTests._write_html9  s    t{4?11b111r   c                 (     | j         |j        fi |S r   )r  write_xhtmlr  s      r   _write_xhtmlzWriterTests._write_xhtml<  s    t{4+22r222r   c                     ddl m} t           ||d                    }t           ||d                    }|                     ||           d S Nr   r   r   r   r   r   normalize_xmlr   r   r;   rE  r   s       r   assertNormalizedXMLEqualz$WriterTests.assertNormalizedXMLEqual?  h    //////))A999::))A999::Ar   c                     ddl m} t           ||d                    }t           ||d                    }|                     ||           d S r  r  r  s       r   assertNormalizedHTMLEqualz%WriterTests.assertNormalizedHTMLEqualE  r  r   c                    |                      t                    }|                     |          }d}|                     ||           |                    d                              d          D ]_\  }}t          |d                   |                    d          _        t          |d                   |                    d          _        `|                     |          }d}|                     ||           d S )	Nz<?xml version="1.0"?><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>r   ))r,   re   r   r   r,   r)   z<?xml version="1.0"?><root>
  <list>
    <item>
       <name>1</name>
       <description>2</description>
    </item>
  </list>
</root>)ry  r   r  r  r   r.   strr   )r   r   rS  rT  r   r/   s         r   test_write_simple_xmlz!WriterTests.test_write_simple_xmlK  s    {{;''&& 	%%fh777f--44X>> 	; 	;HB'*47||BKK$.1$q'llBKK&&++&& 	%%fh77777r   c                     |                      t                    }|                     |          }d}|                     ||           d S )N<!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>ry  r  r  r  r   r   rS  rT  s       r   test_write_simple_xhtmlz#WriterTests.test_write_simple_xhtmlf  sJ    {{=))""4(( s%%fh77777r   c                     |                      t                    }|                     |          }d}|                     ||           d S )Nz<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <body>Hello!</body>
</html>)ry  r  r  r  r  s       r   test_write_simple_xhtml_as_htmlz+WriterTests.test_write_simple_xhtml_as_htmll  sK    {{=))!!$'' 	&&vx88888r   c                     |                      t                    }|                     |          }d}|                     ||           d S )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>)ry  r   r  r  r  s       r    test_write_complex_xhtml_as_htmlz,WriterTests.test_write_complex_xhtml_as_htmlu  sL    {{>**!!$''"H 	&&vx88888r   c                     |                      t                    }|                     |          }d}|                     ||           d S )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>)ry  r   r  r  r  s       r   !test_write_complex_xhtml_as_xhtmlz-WriterTests.test_write_complex_xhtml_as_xhtml  sN     {{>**""4(("F 	%%fh77777r   c                     ddl m} |                     t                    }|                     |          }d}|                      ||d          |           d S )Nr   r   z<!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>r   r   )r   r   ry  _EMPTYTAGS_HTMLr  r   )r   r   r   rS  rT  s        r   test_write_emptytags_htmlz%WriterTests.test_write_emptytags_html  sl    //////{{?++!!$'' 	6H===xHHHHHr   c                     |                      t                    }|                     |          }d}|                     ||           d S )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>)ry  _BOOLEANATTRS_XHTMLr  r  r  s       r   %test_write_booleanattrs_xhtml_as_htmlz1WriterTests.test_write_booleanattrs_xhtml_as_html  sL    {{.//!!$''" 	&&vx88888r   c                     |                      t                    }|                     |d          }d}|                     ||           d S )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  s       r    test_write_simple_xhtml_pipelinez,WriterTests.test_write_simple_xhtml_pipeline  sO    {{=))""4$"77 v%%fh77777r   c                     |                      t                    }|                     |d          }d}|                     ||           d S )NTr  a  <?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>ry  r   r  r  r  s       r   test_write_simple_xml_pipelinez*WriterTests.test_write_simple_xml_pipeline  M    {{;''55 	%%fh77777r   c                     |                      t                    }|                     |d          }d}|                     ||           d S )Nlatin-1r   z<?xml version="1.0" encoding="latin-1"?><root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>r  r  s       r   'test_write_simple_xml_override_encodingz3WriterTests.test_write_simple_xml_override_encoding  sM    {{;''	:: 	%%fh77777r   c                     |                      t                    }|                     |d          }d}|                     ||           d S )NTfragment<root>
  <list>
    <item>
       <name>Name</name>
       <description>Description</description>
    </item>
  </list>
</root>r  r  s       r   !test_write_simple_xml_as_fragmentz-WriterTests.test_write_simple_xml_as_fragment  r  r   c                     |                      t                    }ddlm} |                     ||j                  }d}|                     ||           d S )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>ry  r   r
   r  r  xhtmlr  r   r   r  rS  rT  s        r   "test_write_simple_xml_with_doctypez.WriterTests.test_write_simple_xml_with_doctype  sa    {{;''111111w}== 	%%fh77777r   c                     |                      t                    }ddlm} |                     |d|j                  }d}|                     ||           d S )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	  r  s        r   +test_write_simple_xml_doctype_nodeclarationz7WriterTests.test_write_simple_xml_doctype_nodeclaration-  sk    {{;''1111115)0 ! 8 8 	%%fh77777r   c                     |                      t                    }ddlm} |                     |d|j        d          }d}|                     ||           d S )Nr   r  Tr  r  r  r  r	  r  s        r   <test_write_simple_xml_fragment_kills_doctype_and_declarationzHWriterTests.test_write_simple_xml_fragment_kills_doctype_and_declaration<  so    {{;''1111114)0 ! G G 	%%fh77777r   c                     |                      t                    }|                     |dd          }d}|                     ||           d S )Nr  T)r   r  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  s       r   )test_write_simple_xhtml_override_encodingz5WriterTests.test_write_simple_xhtml_override_encodingK  sQ    {{=))""4)"NN [%%fh77777r   c                     |                      t                    }|                     |d          }d}|                     ||           d S NTr   <html><body>Hello!</body></html>r  r  s       r   #test_write_simple_xhtml_as_fragmentz/WriterTests.test_write_simple_xhtml_as_fragmentQ  sL    {{=))""4$"779%%fh77777r   c                     |                      t                    }ddlm} |                     ||j                  }d}|                     ||           d S )Nr   r  r  ry  r  r
   r  r  r
  r  r  s        r   $test_write_simple_xhtml_with_doctypez0WriterTests.test_write_simple_xhtml_with_doctypeW  sc    {{=))111111""4"?? s%%fh77777r   c                     |                      t                    }ddlm} |                     |d|j                  }d}|                     ||           d S )Nr   r  Fr  r  r  r  s        r   -test_write_simple_xhtml_doctype_nodeclarationz9WriterTests.test_write_simple_xhtml_doctype_nodeclaration^  sl    {{=))111111""4U)0 # 8 8 s%%fh77777r   c                     |                      t                    }ddlm} |                     |d|j        d          }d}|                     ||           d S )Nr   r  Tr  r  r  r  s        r   >test_write_simple_xhtml_fragment_kills_doctype_and_declarationzJWriterTests.test_write_simple_xhtml_fragment_kills_doctype_and_declarationf  sm    {{=))111111""4T)0 # G G9%%fh77777r   c                     |                      t                    }|                     |d          }d}|                     ||           d S r  ry  r  r  r  r  s       r   (test_write_simple_xhtml_as_html_fragmentz4WriterTests.test_write_simple_xhtml_as_html_fragmentn  sL    {{=))!!$!669%%fh77777r   c                     |                      t                    }|                     |          }d}|                     ||           d S )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  s       r   ,test_write_simple_xhtml_with_doctype_as_htmlz8WriterTests.test_write_simple_xhtml_with_doctype_as_htmlt  sK    {{=))!!$''$ 	%%fh77777r   c                     |                      t                    }ddlm} |                     ||j                  }d}|                     ||           d S )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>)ry  r  r
   r  r  html_strictr  r  s        r   +test_write_simple_xhtml_as_html_new_doctypez7WriterTests.test_write_simple_xhtml_as_html_new_doctype|  se    {{=))111111!!$0C!DD$ 	%%fh77777r   c                 b    ddl m} |                     |j        t          f| j        d           d S )Nr   )expatz.<html><head></head><body>&fleeb;</body></html>)xml.parsersr*  r   errorSyntaxErrorry  )r   r*  s     r   test_unknown_entityzWriterTests.test_unknown_entity  sK    %%%%%%5;4dkJ	L 	L 	L 	L 	Lr   c                     |                      t                    }|                    d          }|                    dd           |                     |          }d}|                     ||           d S )Nr)   description &<foo>&amp;<bar>Fr   z<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          <description>description &amp;&lt;foo>&amp;&lt;bar></description>
        </item>
        </list>
        </root>ry  r   r   r   r  r  r   r   r|   rS  rT  s        r   test_content_nostructurez$WriterTests.test_content_nostructure  q    {{;''MM-((			0E	BBB&& 	%%fh77777r   c                     |                      t                    }|                    d          }|                    dd           |                     |          }d}|                     ||           d S )Nr)   description &<foo> <bar>Tr   z<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          <description>description &<foo> <bar></description>
        </item>
        </list>
        </root>r1  r2  s        r   test_content_structurez"WriterTests.test_content_structure  q    {{;''MM-((			,	===&& 	%%fh77777r   c                     |                      t                    }|                    d          }|                    dd           |                     |          }d}|                     ||           d S )Nr)   r0  Fr   z<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          description &amp;&lt;foo>&amp;&lt;bar>
        </item>
        </list>
        </root>ry  r   r   rs   r  r  r2  s        r   test_replace_nostructurez$WriterTests.test_replace_nostructure  r4  r   c                     |                      t                    }|                    d          }|                    dd           |                     |          }d}|                     ||           d S )Nr)   r6  Tr   z<?xml version="1.0"?>
        <root>
        <list>
        <item>
        <name>Name</name>
          description &<foo> <bar>
        </item>
        </list>
        </root>r:  r2  s        r   test_replace_structurez"WriterTests.test_replace_structure  r8  r   c                 v    ddl m} ddlm} d}|                      |dd           ||                     d S )Nr   r  _escape_cdataO< > &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;r   r   )r   r  r
   r@  r   )r   r  r@  r;   s       r   test_escape_cdatazWriterTests.test_escape_cdata  s{    ......777777>H J&( ( ( M!		 	 	 	 	r   c                     ddl m} ddlm} ddlm}  | |dd          d          }|                      |dd           ||d	                     d S )
Nr   r?  r  r      r   r   &#128;ascii)r
   r@  r   r  r   r   )r   r@  r  r   r;   s        r   test_escape_cdata_unicodeerrorz*WriterTests.test_escape_cdata_unicodeerror  s    777777......//////Ihhv999HMMM(X>>>&q'22	4 	4 	4 	4 	4r   c                 x    ddl m} ddlm} d}|                      |dd           ||d                      d S )Nr   _escape_attribr  rA  zp&lt; > &lt;&amp; &amp;&apos; &amp;&amp; &amp;foo &quot;&quot; http://www.example.com?foo=bar&amp;bang=baz &#123;r   r   )r
   rJ  r   r  r   )r   rJ  r  r;   s       r   test_escape_attribzWriterTests.test_escape_attrib  s    888888......>H J '( ( ( N1d##	% 	% 	% 	% 	%r   c                     ddl m} ddlm} ddlm}  | |dd          d          }|                      |dd           ||d	                     d S )
Nr   rI  r  r   rD  r   r   rE  rF  )r
   rJ  r   r  r   r   )r   rJ  r  r   r;   s        r   test_escape_attrib_unicodeerrorz+WriterTests.test_escape_attrib_unicodeerror  s    888888......//////Ihhv999HMMM(X>>>'733	5 	5 	5 	5 	5r   N)*r   r   r   ry  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r   r#  r%  r(  r.  r3  r7  r;  r=  rB  rG  rK  rM  r=   r   r   r  r     se         
  
	 	 	1 1 12 2 23 3 3    8 8 868 8 89 9 9'9 '9 '9R-8 -8 -8^I I I9 9 9,8 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 88 8 8L L L8 8 8 8 8 8 8 8 8 8 8 8 	 	 	4 4 4
% 
% 
%5 5 5 5 5r   r  c                 ^    t          j        dd|           } t          j        dd|           } | S )Nz[ \t]+ z/>>resubss    r   normalize_htmlrV    s-    
y#q!!A
uc1AHr   c                     t          j        dd|           } t          j        dd|           } t          j        dd|           } | S )Nz\s+rO  z(?s)\s+<<z(?s)>\s+rP  rQ  rT  s    r   r  r    s@    
vsAA
{C##A
{C##AHr   c                  T    t          j        t          j        t                             S r   )unittestfindTestCasessysmodulesr   r=   r   r   
test_suiter^    s    !#+h"7888r   c                  0    t          j        d           d S )Nr^  )defaultTest)rZ  mainr=   r   r   ra  ra     s    Ml++++++r   __main__)rZ  rR  r\  r   r  r  r  _ENTITIES_XHTMLr   r  rf   TestCaser   r   rv  r  r  rV  r  r^  ra  r   r=   r   r   <module>re     s    				 




 "$L%	Nm ^F> F> F> F> F>8$ F> F> F>PK	+ K	+ K	+ K	+ K	+ 1 K	+ K	+ K	+^lB lB lB lB lB(# lB lB lB\"' "' "' "' "'! "' "' "'HP5 P5 P5 P5 P5(# P5 P5 P5d  
  9 9 9, , , zDFFFFF r   