
    XHh                        U d Z dZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZm Z m!Z!m"Z" 	 ddl#m$Z$ dZ%ejN                  jQ                  d      duZ)	 ddl*Z+dZ,e+jZ                  j\                  Z.eZ/e"e   e0d<   dZ1e2e0d<    G d de3      Z4 G d de4      Z5 G d de5      Z6 G d de5      Z7 G d de6      Z8y# e&$ r dZ%Y w xY w# e&$ r dZ,dZ.Y aw xY w)zHelper classes for tests.MIT    N)BeautifulSoup)
AttributeValueListCharsetMetaAttributeValueCommentContentMetaAttributeValueDoctypePageElementPYTHON_SPECIFIC_ENCODINGSScript
StylesheetTag)SoupStrainer)XMLParsedAsHTMLWarning)_IncomingMarkup)TreeBuilder)HTMLParserTreeBuilder)AnyIterableOptionalTupleType)SelectorSyntaxErrorTFhtml5lib)r   default_builderu-
  A bare string
<!DOCTYPE xsl:stylesheet SYSTEM "htmlent.dtd">
<!DOCTYPE xsl:stylesheet PUBLIC "htmlent.dtd">
<div><![CDATA[A CDATA section where it doesn't belong]]></div>
<div><svg><![CDATA[HTML5 does allow CDATA sections in SVG]]></svg></div>
<div>A <meta> tag</div>
<div>A <br> tag that supposedly has contents.</br></div>
<div>AT&T</div>
<div><textarea>Within a textarea, markup like <b> tags and <&<&amp; should be treated as literal</textarea></div>
<div><script>if (i < 2) { alert("<b>Markup within script tags should be treated as literal.</b>"); }</script></div>
<div>This numeric entity is missing the final semicolon: <x t="pi&#241ata"></div>
<div><a href="http://example.com/</a> that attribute value never got closed</div>
<div><a href="foo</a>, </a><a href="bar">that attribute value was closed by the subsequent tag</a></div>
<! This document starts with a bogus declaration ><div>a</div>
<div>This document contains <!an incomplete declaration <div>(do you see it?)</div>
<div>This document ends with <!an incomplete declaration
<div><a style={height:21px;}>That attribute value was bogus</a></div>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">The doctype is invalid because it contains extra whitespace
<div><table><td nowrap>That boolean attribute had no value</td></table></div>
<div>Here's a nonexistent entity: &#foo; (do you see it?)</div>
<div>This document ends before the entity finishes: &gt
<div><p>Paragraphs shouldn't contain block display elements, but this one does: <dl><dt>you see?</dt></p>
<b b="20" a="1" b="10" a="2" a="3" a="4">Multiple values for the same attribute.</b>
<div><table><tr><td>Here's a table</td></tr></table></div>
<div><table id="1"><tr><td>Here's a nested table:<table id="2"><tr><td>foo</td></tr></table></td></div>
<div>This tag contains nothing but whitespace: <b>    </b></div>
<div><blockquote><p><b>This p tag is cut off by</blockquote></p>the end of the blockquote tag</div>
<div><table><div>This table contains bare markup</div></table></div>
<div><div id="1">
 <a href="link1">This link is never closed.
</div>
<div id="2">
 <div id="3">
   <a href="link2">This link is closed.</a>
  </div>
</div></div>
<div>This document contains a <!DOCTYPE surprise>surprise doctype</div>
<div><a><B><Cd><EFG>Mixed case tags are folded to lowercase</efg></CD></b></A></div>
<div><our☃>Tag name contains Unicode characters</our☃></div>
<div><a ☃="snowman">Attribute name contains Unicode characters</a></div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
BAD_DOCUMENTc                       e Zd Zedee   fd       Zdedede	fdZ
dededefdZ	 dded	ee   ddfd
ZeZdeddfdZ	 ddededee   fdZdee   dee   ddfdZdee   dee   ddfdZy)SoupTestreturnc                     t         S N)r   selfs    K/var/www/html/planif/env/lib/python3.12/site-packages/bs4/tests/__init__.pyr   zSoupTest.default_builderf   s        markupkwargsc                 V    |j                  d| j                        }t        |fd|i|S )z*Build a Beautiful Soup object from markup.builder)popr   r   )r#   r&   r'   r)   s       r$   soupzSoupTest.soupj   s-    **Y(<(<=V?W???r%   c                 D     | j                   di |j                  |      S )z[Turn an HTML fragment into a document.

        The details depend on the builder.
         )r   test_fragment_to_document)r#   r&   r'   s      r$   document_forzSoupTest.document_foro   s%    
 $t##-f-GGOOr%   Nto_parsecompare_parsed_toc                    | j                   }t        ||      }|t        |t              sJ |}|j	                         | j                  |      k(  sJ t        d t        |j                  j                               D              sJ |j                  g|j                  D cg c]  }|j                   c}k(  sJ yc c}w )ziParse some markup using Beautiful Soup and verify that
        the output markup is as expected.
        r)   Nc              3   &   K   | ]	  }|d k(    yw)r   Nr-   ).0vs     r$   	<genexpr>z'SoupTest.assert_soup.<locals>.<genexpr>   s     Ga16Gs   )r   r   
isinstancestrdecoder/   alllistopen_tag_countervaluesROOT_TAG_NAMEtagStackname)r#   r0   r1   r)   objxs         r$   assert_soupzSoupTest.assert_soupv   s     &&Hg6$h,,, ( zz|t001BCCCC G4(<(<(C(C(E#FGGGG !!"s||&D!qvv&DDDD&Ds   #B>elementc                 v    d}|j                   D ](  }|r"||j                  k(  sJ ||j                  k(  sJ |}* y)zyEnsure that next_element and previous_element are properly
        set for all descendants of the given element.
        N)descendantsnext_elementprevious_element)r#   rE   earlieres       r$   assertConnectednesszSoupTest.assertConnectedness   sN     $$ 	AG00000!"4"4444G		r%   el_recursive_callc           	         d}|j                   |j                  "J dj                  ||j                  d             |j                  "J dj                  ||j                  d             |j                  "J dj                  ||j                  d             d}d}d}t        |j                        dz
  }|j                  D ]l  }d}|dk(  r|j                   |j                  |u s"J dj                  ||j                  |             |j                  |u s"J dj                  ||j                  |             |j                  IJ dj                  ||j                  d             |j                  |j                  |dz
     u s2J d	j                  ||j                  |j                  |dz
                  |j                  |dz
     j                  |u sBJ d
j                  |j                  |dz
     |j                  |dz
     j                  |             |u|j                  |u s7J dj                  ||j                  ||j                   j                               |j                  |u s"J dj                  ||j                  |             t        |t              rP|j                  rD| j                  |d      }|J |j                  "J d
j                  ||j                  d             ||}n|}||k(  r.|j                  "J d
j                  ||j                  d             |dz  }o ||n|}||}|s||}	 |0|j                  "J dj                  ||j                  d             	 y|j                  F|j                  |j                  u s,J dj                  ||j                  |j                               	 y|j                   }|S )z.Ensure proper linkage throughout the document.Nz3Bad previous_element
NODE: {}
PREV: {}
EXPECTED: {}z3Bad previous_sibling
NODE: {}
PREV: {}
EXPECTED: {}z/Bad next_sibling
NODE: {}
NEXT: {}
EXPECTED: {}r      z/Bad next_element
NODE: {}
NEXT: {}
EXPECTED: {}z2Bad previous_sibling
NODE: {}
PREV {}
EXPECTED: {}z1Bad previous_sibling
NODE: {}
PREV {}
EXPECTED {}z-Bad next_sibling
NODE: {}
NEXT {}
EXPECTED {}z=Bad previous_element
NODE: {}
PREV {}
EXPECTED {}
CONTENTS {}z-Bad next_element
NODE: {}
NEXT {}
EXPECTED {}T)parentrI   formatprevious_siblingnext_siblinglencontentsrH   r8   r   linkage_validator)	r#   rM   rN   
descendantidxchild
last_childlast_idxtargets	            r$   rW   zSoupTest.linkage_validator   ss    
 99##+GNNB''+
 ##+GNNB''+
 'CJJBOOT'
 
r{{#a'[[ H	EJ ax99(50KRRBOOU0
 .."4OVVu55r4
 ..6NUUu55t6 **bkk#'.BBIPP5112;;sQw3GB
 KKa(55>ELLKKa("++cAg*>*K*KU>
 )..*<Zaau55z5<<CXCX<
 #//58IPP"J$;$;U8
 %%%..!33E4@
!--- ++3ELL
 7 73 %'
"
 h&&.ELL5--t. 1HCQH	T )4
%=E5#4$&F>**2IPPu1142   ((4**f.A.AAIPPu1163F3FA     * Lr%   tagsshould_matchc                 L    |D cg c]  }|j                    c}|k(  sJ yc c}w )zMake sure that the given tags have the correct text.

        This is used in tests that define a bunch of tags, each
        containing a single string, and then select certain strings by
        some mechanism.
        Nstringr#   r^   r_   tags       r$   assert_selectszSoupTest.assert_selects   s$     '++s

+|;;;+s   !c                 >    |D cg c]  }|d   	 c}|k(  sJ yc c}w )zMake sure that the given tags have the correct IDs.

        This is used in tests that define a bunch of tags, each
        containing a single string, and then select certain strings by
        some mechanism.
        idNr-   rc   s       r$   assert_selects_idszSoupTest.assert_selects_ids)  s$     &**cD	*l:::*s   r!   )F)__name__
__module____qualname__propertyr   r   r   r   r   r   r+   r9   r/   r   rD   assertSoupEqualsr   rL   boolr
   rW   r   re   rh   r-   r%   r$   r   r   e   s   k!2  @? @c @m @
P3 P# P# P MQE'E<DSME	E4 #	3 	4 	 05AA(,A	+	AF<8C= < <RV <	;SM	;19#	;		;r%   r   c                       e Zd Zej                  j                  ddi  edg      ddgig      d        Zej                  j                  d edg      ddgig      d	        Zd
 Z	d Z
d Zd Zy)TreeBuilderSmokeTestmulti_valued_attributesNclass)b*notclassc                 V    d}| j                  ||      }|j                  d   dk(  sJ y )NzC<html xmlns="http://www.w3.org/1999/xhtml"><a class="a b c"></html>rq   rr   za b cr+   ar#   rq   r&   r+   s       r$   test_attribute_not_multi_valuedz4TreeBuilderSmokeTest.test_attribute_not_multi_valued8  s3     Wyy9PyQvvg')))r%   )ry   c                 Z    d}| j                  ||      }|j                  d   g dk(  sJ y )Nz<a class="a b c">rw   rr   )ry   rs   crx   rz   s       r$   test_attribute_multi_valuedz0TreeBuilderSmokeTest.test_attribute_multi_valued@  s2     %yy9PyQvvg/111r%   c                 P    d}| j                  |       d}| j                  |       y )Nz<![if word]>content<![endif]>z<!DOCTYPE html]ff>)r+   r#   r&   s     r$   test_invalid_doctypez)TreeBuilderSmokeTest.test_invalid_doctypeH  s&     1		&%		&r%   c                 ~    d}| j                  |t        d            }t        d |j                  D              rJ y )Nz<!DOCTYPE html>
<html>
</html>html)rA   
parse_onlyc              3   <   K   | ]  }t        |t                y wr!   )r8   r	   )r5   rC   s     r$   r7   z=TreeBuilderSmokeTest.test_doctype_filtered.<locals>.<genexpr>S  s     H!z!W-Hs   )r+   r   anyrG   r#   r&   r+   s      r$   test_doctype_filteredz*TreeBuilderSmokeTest.test_doctype_filteredP  s;    3yyLf,EyFHt7G7GHHHHHr%   c                     G d dt               }d}| j                  |      }| j                  ||      }|j                  }t	        |j
                  |      sJ d|d   k(  sJ d|d	<   d|d	   k(  sJ d
}||j                         k(  sJ y )Nc                   (     e Zd Zdedef fdZ xZS )NTreeBuilderSmokeTest.test_custom_attribute_dict_class.<locals>.MyAttributeDictkeyvaluec                 &    t         |   |d       y )N
OVERRIDDEN)super__setitem__)r#   r   r   	__class__s      r$   r   zZTreeBuilderSmokeTest.test_custom_attribute_dict_class.<locals>.MyAttributeDict.__setitem__W  s     #C6r%   )ri   rj   rk   r9   r   r   __classcell__r   s   @r$   MyAttributeDictr   V  s    7s 73 7 7r%   r   "<a attr1="val1" attr2="val2">f</a>)attribute_dict_classr3   r   attr1Tattr3zA<a attr1="OVERRIDDEN" attr2="OVERRIDDEN" attr3="OVERRIDDEN">f</a>)dictr   r+   ry   r8   attrsr:   )r#   r   r&   r)   r+   rd   expects          r$    test_custom_attribute_dict_classz5TreeBuilderSmokeTest.test_custom_attribute_dict_classU  s    	7d 	7 6&&O&Lyyy1ff#))_555s7|+++Gs7|+++T%%%r%   c                      G d dt               }| j                  dt        dg      i|      }d}| j                  ||      }|j                  }|d   d	k(  sJ |d   d
dgk(  sJ t        |d   |      sJ y )Nc                        e Zd Z fdZ xZS )_TreeBuilderSmokeTest.test_custom_attribute_value_list_class.<locals>.MyCustomAttributeValueListc                 F    t        |   |i | | j                  d       y )Nextra)r   __init__append)r#   argsr'   r   s      r$   r   zhTreeBuilderSmokeTest.test_custom_attribute_value_list_class.<locals>.MyCustomAttributeValueList.__init__j  s!     $1&1G$r%   )ri   rj   rk   r   r   r   s   @r$   MyCustomAttributeValueListr   i  s    % %r%   r   rt   attr2)rq   attribute_value_list_classr   r3   r   val1val2r   )r   r   setr+   ry   r8   )r#   r   r)   r&   r+   rd   s         r$   &test_custom_attribute_value_list_classz;TreeBuilderSmokeTest.test_custom_attribute_value_list_classh  s    	%); 	%
 &&%(#wi.$9'A ' 
 6yyy1ff7|v%%%7|0000#g,(BCCCr%   )ri   rj   rk   pytestmarkparametrizer   r{   r~   r   r   r   r   r-   r%   r$   rp   rp   5  s     [[!D"dgY.?#
|AT#U**
 [[!DG9$5gY7G#H22
I
&&Dr%   rp   c            	          e Zd ZdZd Zd Zd Zd Zdeddfd	Z		 dGded
ede
eef   f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. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdF ZHy)HHTMLTreeBuilderSmokeTestaC  A basic test of a treebuilder's competence.

    Any HTML treebuilder, present or future, should be able to pass
    these tests. With invalid markup, there's room for interpretation,
    and different parsers can handle it differently. But with the
    markup in these tests, there's not much room for interpretation.
    c                     dD ]4  }| j                  d      }|j                  |      }|j                  du r4J  | j                  dd       | j                  dd       y)zmVerify that all HTML4 and HTML5 empty element (aka void element) tags
        are handled correctly.
        )areabasebrcolembedhrimginputkeygenlinkmenuitemmetaparamsourcetrackwbrspacerframe Tz<br/><br/><br/>z<br /><br /><br />N)r+   new_tagis_empty_elementrD   )r#   rA   r+   r   s       r$   test_empty_element_tagsz0HTMLTreeBuilderSmokeTest.test_empty_element_tags  sj    
 	4D( 99R=Dll4(G++t333-	40 	*,=>-/@Ar%   c                    | j                  d      }t        |j                  j                  t              sJ t        |j
                  j                  t              sJ | j                  d      }t        |j                  j                  t              sJ |j                  j                  dk(  sJ t        |j                  j                  t              sJ y )Nz7<style>Some CSS</style><script>Some Javascript</script>z<style><!--Some CSS--></style>z<!--Some CSS-->)r+   r8   stylerb   r   scriptr   r#   r+   s     r$   test_special_string_containersz7HTMLTreeBuilderSmokeTest.test_special_string_containers  s    yyRS$**++Z888$++,,f555yy9:$**++Z888 zz  $5555$**++Z888r%   c                    | j                  d      }t        j                  |t        j                        }t        j                  |      }|j
                  t        k(  sJ |j                         |j                         k(  sJ y )N<a><b>foo</a>)r+   pickledumpsHIGHEST_PROTOCOLloadsr   r   r:   r#   treedumpedloadeds       r$   !test_pickle_and_unpickle_identityz:HTMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identity  sd     yy)dF$;$;<f%=000}}$++-///r%   c                     d}| j                  |      }t        j                  |t        j                        }t        j                  |      }|j
                  j                  du sJ y )Nz
<!DOCTYPE html>
<html lang="en">
<head><title>blabla</title></head>
<body><?xml encoding="utf-8" ?><html></html></body>
</html>
F)r+   r   r   r   r   r)   is_xml)r#   r&   r+   pickleds       r$   #test_pickle_and_unpickle_bad_markupz<HTMLTreeBuilderSmokeTest.test_pickle_and_unpickle_bad_markup  sU     yy ,,tV%<%<=||G$||""e+++r%   doctype_fragmentr   Nc                    | j                  |      \  }}|j                  d   }|j                  t        k(  sJ ||k(  sJ |j	                  d      dt        |       |k(  sJ |j                  J |j                  j                  d   dk(  sJ y)z8Assert that a given doctype string is handled correctly.r   utf8Nfoo_document_with_doctyperV   r   r	   encoderU   pr#   r   doctype_strr+   doctypes        r$   assertDoctypeHandledz-HTMLTreeBuilderSmokeTest.assertDoctypeHandled  s     778HIT --"  G+++****{{6"#5S%56+EEE vv!!!vvq!U***r%   doctype_stringc                 f    d|d|d}|dz   }| j                  |      }|j                  d      |fS )z5Generate and parse a document with the given doctype.z<! >z
<p>foo</p>r   r+   r   )r#   r   r   r   r&   r+   s         r$   r   z/HTMLTreeBuilderSmokeTest._document_with_doctype  s;     !/0@A>)yy ~~f%t++r%   c                 H    | j                  d       | j                  d       y)z?Make sure normal, everyday HTML doctypes are handled correctly.r   z4html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Nr   r"   s    r$   test_normal_doctypesz-HTMLTreeBuilderSmokeTest.test_normal_doctypes  s!    !!&)!!B	
r%   c                 n    | j                  d      }|j                  d   }d|j                         k(  sJ y )Nz
<!DOCTYPE>r   r   )r+   rV   strip)r#   r+   r   s      r$   test_empty_doctypez+HTMLTreeBuilderSmokeTest.test_empty_doctype  s2    yy&--"W]]_$$$r%   c                    dD ]  }| j                  d|      \  }}|j                  d   }|j                  t        k(  sJ |dk(  sJ |j	                  d      d t        |       dk(  sJ |j                  j                  d   dk(  rJ  y )N)r   DocTyper   r   r   s   <!DOCTYPE html>r   r   r   s        r$   test_mixed_case_doctypez0HTMLTreeBuilderSmokeTest.test_mixed_case_doctype  s     6 	/ $ ; ;FDT UK mmA&G$$///f$$$;;v&'9[)9:>PPPP 66??1%...	/r%   c                 *    d}| j                  |       y )Nznhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"r   )r#   r   s     r$   test_public_doctype_with_urlz5HTMLTreeBuilderSmokeTest.test_public_doctype_with_url  s     C!!'*r%   c                 &    | j                  d       y )Nz$foo SYSTEM "http://www.example.com/"r   r"   s    r$   test_system_doctypez,HTMLTreeBuilderSmokeTest.test_system_doctype  s    !!"HIr%   c                 &    | j                  d       y )Nz#xsl:stylesheet SYSTEM "htmlent.dtd"r   r"   s    r$   test_namespaced_system_doctypez7HTMLTreeBuilderSmokeTest.test_namespaced_system_doctype      !!"GHr%   c                 &    | j                  d       y )Nz#xsl:stylesheet PUBLIC "htmlent.dtd"r   r"   s    r$   test_namespaced_public_doctypez7HTMLTreeBuilderSmokeTest.test_namespaced_public_doctype  r   r%   c                     d}t        j                  d      5 }| j                  |      }ddd       j                  d      j	                  dd      |j	                  dd      k(  sJ g k(  sJ y# 1 sw Y   GxY w)zJA real XHTML document should come out more or less the same as it went in.   <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Hello.</title></head>
<body>Goodbye.</body>
</html>TrecordNutf-8   
r%   )warningscatch_warningsr+   r   replacer#   r&   wr+   s       r$   test_real_xhtml_documentz1HTMLTreeBuilderSmokeTest.test_real_xhtml_document  s{     $$D1 	%Q99V$D	%{{7#++E376>>%QT;UUUU Bww	% 	%s   A11A:c                     d}t        j                  d      5 }| j                  |      }d d d        dt        j	                  d            k(  sJ g k(  sJ y # 1 sw Y   0xY w)Ns.   <ns1:foo>content</ns1:foo><ns1:foo/><ns2:foo/>Tr     zns1:foo)r  r  r+   rU   find_allr
  s       r$   test_namespaced_htmlz-HTMLTreeBuilderSmokeTest.test_namespaced_html  sh     G$$D1 	%Q99V$D	% Ci01111 Qww	% 	%s   AA#c                 H   d}t        j                  d      5 }| j                  |      }|j                  j                  dk(  sJ 	 d d d        \  }t        |j                  t              sJ t        |j                        t        j                  k(  sJ y # 1 sw Y   RxY w)Ns7   <?xml version="1.0" encoding="utf-8"?><tag>string</tag>Tr  rb   )
r  r  r+   rd   rb   r8   messager   r9   MESSAGE)r#   r&   r  r+   warnings        r$   test_detect_xml_parsed_as_htmlz7HTMLTreeBuilderSmokeTest.test_detect_xml_parsed_as_html$  s     P$$D1 	/Q99V$D88??h...	/ 	'//+ABBB7??#'='E'EEEE	/ 	/s   -BB!c                     d}| j                  |      }||j                         k(  sJ d}| j                  |      }||j                  d      k(  sJ y )Nz<?PITarget PIContent?>s   <?PITarget PIContent?>r   )r+   r:   r   r   s      r$   test_processing_instructionz4HTMLTreeBuilderSmokeTest.test_processing_instruction4  sU    
 .yy &&&.yy V,,,,r%   c                 B    t        j                  | j                         y)zMake sure you can copy the tree builder.

        This is important because the builder is part of a
        BeautifulSoup object, and we want to be able to copy that.
        N)copydeepcopyr   r"   s    r$   test_deepcopyz&HTMLTreeBuilderSmokeTest.test_deepcopyA  s     	d**+r%   c                     | j                  d      }|j                  j                  rJ t        |j                        dk(  sJ y)zA <p> tag is never designated as an empty-element tag.

        Even if the markup shows it as an empty-element tag, it
        shouldn't be presented that way.
        <p/><p></p>N)r+   r   r   r9   r   s     r$   !test_p_tag_is_never_empty_elementz:HTMLTreeBuilderSmokeTest.test_p_tag_is_never_empty_elementI  s;     yy 66****466{i'''r%   c                 p    | j                  dd       | j                  dd       | j                  dd       y)zA tag that's not closed by the end of the document should be closed.

        This applies to all tags except empty-element tags.
        <p>r  z<b>z<b></b>z<br><br/>NrD   r"   s    r$   test_unclosed_tags_get_closedz6HTMLTreeBuilderSmokeTest.test_unclosed_tags_get_closedS  s4    
 		*	*)r%   c                     | j                  d      }|j                  j                  sJ t        |j                        dk(  sJ y)zA <br> tag is designated as an empty-element tag.

        Some parsers treat <br></br> as one <br/> tag, some parsers as
        two tags, but it should always be an empty-element tag.
        z	<br></br>r"  N)r+   r   r   r9   r   s     r$   #test_br_is_always_empty_element_tagz<HTMLTreeBuilderSmokeTest.test_br_is_always_empty_element_tag]  s;     yy%ww''''477|w&&&r%   c                 &    | j                  d       y )Nz<em><em></em></em>r#  r"   s    r$   test_nested_formatting_elementsz8HTMLTreeBuilderSmokeTest.test_nested_formatting_elementsg  s    -.r%   c                 \    d}| j                  |      }d|j                  d      d   k(  sJ y )Nz<!DOCTYPE html>
<html>
<head>
<title>Ordinary HEAD element test</title>
</head>
<script type="text/javascript">
alert("Help!");
</script>
<body>
Hello, world!
</body>
</html>
ztext/javascriptr   type)r+   find)r#   r   r+   s      r$   test_double_headz)HTMLTreeBuilderSmokeTest.test_double_headj  s4     yy DIIh$7$????r%   c                 &   d}| j                  |       | j                  |      }|j                  d      }|j                  t        k(  sJ |j                  d      }||j
                  k(  sJ |j                  d      }||j                  k(  sJ y )Nz<p>foo<!--foobar-->baz</p>foobarra   r   baz)rD   r+   r+  r   r   rH   rI   )r#   r&   r+   commentr   r/  s         r$   test_commentz%HTMLTreeBuilderSmokeTest.test_comment{  s    - yy ))8),  G+++ iiui%#*****iiui%#.....r%   c                 p   d}d}| j                  |       | j                  |       | j                  |      }|j                  j                         |k(  sJ | j                  |      }|j                  j                         |k(  sJ | j                  d      }|j                  j                         dk(  sJ y)zWhitespace must be preserved in <pre> and <textarea> tags,
        even if that would mean not prettifying the markup.
        z<pre>a   z</pre>
z <textarea> woo
woo  </textarea>
z<textarea></textarea>z<textarea></textarea>
N)rD   r+   preprettifytextarea)r#   
pre_markuptextarea_markupr+   s       r$   -test_preserved_whitespace_in_pre_and_textareazFHTMLTreeBuilderSmokeTest.test_preserved_whitespace_in_pre_and_textarea  s     *
>$)yy$xx  "j000yy)}}%%'?:::yy01}}%%'+DDDDr%   c                 v    d}| j                  |       d}| j                  |       d}| j                  |       y)z+Inline elements can be nested indefinitely.z<b>Inside a B tag</b>z!<p>A <i>nested <b>tag</b></i></p>z/<p>A <a>doubly <i>nested <b>tag</b></i></a></p>Nr#  )r#   b_tagnested_b_tagdouble_nested_b_tags       r$   test_nested_inline_elementsz4HTMLTreeBuilderSmokeTest.test_nested_inline_elements  s=    ':&O,-r%   c                     | j                  d      }|j                  }|j                  j                  j                  dk(  sJ |j                  j                  dk(  sJ y)zBlock elements can be nested.z*<blockquote><p><b>Foo</b></p></blockquote>FooN)r+   
blockquoter   rs   rb   )r#   r+   r@  s      r$    test_nested_block_level_elementsz9HTMLTreeBuilderSmokeTest.test_nested_block_level_elements  sN    yyEF__
||~~$$---||""e+++r%   c                 N    d}| j                  |d       | j                  d       y)z$One table can go inside another one.z[<table id="1"><tr><td>Here's another table:<table id="2"><tr><td>foo</td></tr></table></td>zh<table id="1"><tr><td>Here's another table:<table id="2"><tr><td>foo</td></tr></table></td></tr></table>z{<table><thead><tr><td>Foo</td></tr></thead><tbody><tr><td>Bar</td></tr></tbody><tfoot><tr><td>Baz</td></tr></tfoot></table>Nr#  r   s     r$   test_correctly_nested_tablesz5HTMLTreeBuilderSmokeTest.test_correctly_nested_tables  s9     	 	!	
 	;	
r%   c                     d}| j                  |      }ddg|j                  d   k(  sJ |j                  |j                  dd      k(  sJ y )Nz<div class=" foo bar	 "></a>r   barrr   divzfoo bar)class_)r+   rF  r+  r   s      r$   *test_multivalued_attribute_with_whitespacezCHTMLTreeBuilderSmokeTest.test_multivalued_attribute_with_whitespace  sS     0yy u~'!2222 xx499U99====r%   c                 h    d}| j                  |      }dg|j                  j                  d   k(  sJ y )Nz1<table><div><div class="css"></div></div></table>cssrr   )r+   rF  r   s      r$   (test_deeply_nested_multivalued_attributezAHTMLTreeBuilderSmokeTest.test_deeply_nested_multivalued_attribute  s5     Eyy w$((,,w////r%   c                 V    d}| j                  |      }ddg|j                  d   k(  sJ y )Nz<html class="a b"></html>ry   rs   rr   )r+   r   r   s      r$   "test_multivalued_attribute_on_htmlz;HTMLTreeBuilderSmokeTest.test_multivalued_attribute_on_html  s2     -yy SzTYYw////r%   c                 (    | j                  dd       y )Nz<a b="<a>"></a>z<a b="&lt;a&gt;"></a>r#  r"   s    r$   3test_angle_brackets_in_attribute_values_are_escapedzLHTMLTreeBuilderSmokeTest.test_angle_brackets_in_attribute_values_are_escaped  s    *,CDr%   c                 (    | j                  dd       y )Nz$<p>&bull; AT&T is in the s&p 500</p>u)   <p>• AT&amp;T is in the s&amp;p 500</p>r#  r"   s    r$   3test_strings_resembling_character_entity_referenceszLHTMLTreeBuilderSmokeTest.test_strings_resembling_character_entity_references  s     	2:	
r%   c                 (    | j                  dd       y )Nz<p>Bob&apos;s Bar</p>z<p>Bob's Bar</p>r#  r"   s    r$   test_apos_entityz)HTMLTreeBuilderSmokeTest.test_apos_entity  s    #	
r%   c                 `    d}| j                  |      }d|j                  j                  k(  sJ y )Nz%<p>&#147;Hello&#148; &#45;&#9731;</p>u   “Hello” -☃r+   r   rb   r   s      r$   *test_entities_in_foreign_document_encodingzCHTMLTreeBuilderSmokeTest.test_entities_in_foreign_document_encoding  s-     9yy !TVV]]222r%   c                     d}| j                  d|       | j                  d|       | j                  d|       | j                  d|       y )Nu   <p id="piñata"></p>z<p id="pi&#241;ata"></p>z<p id="pi&#xf1;ata"></p>z<p id="pi&#Xf1;ata"></p>z<p id="pi&ntilde;ata"></p>r#  r#   r   s     r$   0test_entities_in_attributes_converted_to_unicodezIHTMLTreeBuilderSmokeTest.test_entities_in_attributes_converted_to_unicode  sK    H3V<3V<3V<5v>r%   c                     d}| j                  d|       | j                  d|       | j                  d|       | j                  d|       y )Nu   <p>piñata</p>z<p>pi&#241;ata</p>z<p>pi&#xf1;ata</p>z<p>pi&#Xf1;ata</p>z<p>pi&ntilde;ata</p>r#  rX  s     r$   *test_entities_in_text_converted_to_unicodezCHTMLTreeBuilderSmokeTest.test_entities_in_text_converted_to_unicode  sK    B-v6-v6-v6/8r%   c                 (    | j                  dd       y )Nz#<p>I said &quot;good day!&quot;</p>z<p>I said "good day!"</p>r#  r"   s    r$   ,test_quot_entity_converted_to_quotation_markzEHTMLTreeBuilderSmokeTest.test_quot_entity_converted_to_quotation_mark  s    13N	
r%   c                 t    d}| j                  d|       | j                  d|       | j                  d|       y )Nu   �z&#10000000000000;z&#x10000000000000;z&#1000000000;r#  rX  s     r$   test_out_of_range_entityz1HTMLTreeBuilderSmokeTest.test_out_of_range_entity  s9    ,,f5-v6&1r%   c                     | j                  d      }d|j                  j                  j                  j                  k(  sJ d|j
                  j                  k(  sJ | j                  |       y)zDMostly to prevent a recurrence of a bug in the html5lib treebuilder.z!<html><h2>
foo</h2><p></p></html>r   N)r+   h2rb   rH   rA   r   rL   r   s     r$   test_multipart_stringsz/HTMLTreeBuilderSmokeTest.test_multipart_strings  sW    yy=>dggnn1166666dffkk!!!  &r%   c                     d}| j                  |      }d|j                  j                         k(  sJ d}| j                  |      }d|j                  j                         k(  sJ y )Nz<p>a &nosuchentity b</p>z<p>a &amp;nosuchentity b</p>z<p>a &nosuchentity; b</p>z<p>a &amp;nosuchentity; b</p>)r+   r   r:   r   s      r$   test_invalid_html_entityz1HTMLTreeBuilderSmokeTest.test_invalid_html_entity  sZ    
 ,yy -@@@,yy .$&&--/AAAr%   c                 |    d}| j                  |      }|j                  j                  J | j                  |       y)8Prevent recurrence of a bug in the html5lib treebuilder.z?<html><head></head>
  <link></link>
  <body>foo</body>
</html>
N)r+   r   bodyrL   r#   contentr+   s      r$   #test_head_tag_between_head_and_bodyz<HTMLTreeBuilderSmokeTest.test_head_tag_between_head_and_body,  s;    
 yy!yy~~)))  &r%   c                 `    d}| j                  |      }| j                  |j                         y)rf  z<!DOCTYPE html>
<html>
 <body>
   <article id="a" >
   <div><a href="1"></div>
   <footer>
     <a href="2"></a>
   </footer>
  </article>
  </body>
</html>
N)r+   rL   articlerh  s      r$   test_multiple_copies_of_a_tagz6HTMLTreeBuilderSmokeTest.test_multiple_copies_of_a_tag7  s+     yy!  .r%   c                     d}| j                  |      }||j                         k(  sJ d|j                  d   k(  sJ d|j                  d   k(  sJ d|j                  d   k(  sJ y)	zParsers don't need to *understand* namespaces, but at the
        very least they should not choke on namespaces or lose
        data.s   <html xmlns="http://www.w3.org/1999/xhtml" xmlns:mathml="http://www.w3.org/1998/Math/MathML" xmlns:svg="http://www.w3.org/2000/svg"><head></head><body><mathml:msqrt>4</mathml:msqrt><b svg:fill="red"></b></body></html>http://www.w3.org/1999/xhtmlxmlns"http://www.w3.org/1998/Math/MathMLzxmlns:mathmlhttp://www.w3.org/2000/svgz	xmlns:svgN)r+   r   r   r   s      r$   test_basic_namespacesz.HTMLTreeBuilderSmokeTest.test_basic_namespacesH  sq    
 nyy &&&-71CCCC3tyy7PPPP+tyy/EEEEr%   c                 V    d}| j                  |      }ddg|j                  d   k(  sJ y )Ns   <a class="foo bar">r   rE  rr   rx   r   s      r$   -test_multivalued_attribute_value_becomes_listzFHTMLTreeBuilderSmokeTest.test_multivalued_attribute_value_becomes_listT  s/    'yy u~000r%   c                 `    d}| j                  |      }d|j                  j                  k(  sJ y )NuD   <html><head><meta encoding="euc-jp"></head><body>Sacré bleu!</body>   Sacré bleu!)r+   rg  rb   r   s      r$   test_can_parse_unicode_documentz8HTMLTreeBuilderSmokeTest.test_can_parse_unicode_document`  s0     yyy 499#3#3333r%   c                 j    t        d      }| j                  d|      }|j                         dk(  sJ y)z2Parsers should be able to work with SoupStrainers.rs   z&A <b>bold</b> <meta/> <i>statement</i>r   z<b>bold</b>N)r   r+   r:   )r#   strainerr+   s      r$   test_soupstrainerz*HTMLTreeBuilderSmokeTest.test_soupstrainerh  s3    $yyAhyW{{}---r%   c                 (    | j                  dd       y )Nz<foo attr='bar'></foo>z<foo attr="bar"></foo>r#  r"   s    r$   7test_single_quote_attribute_values_become_double_quoteszPHTMLTreeBuilderSmokeTest.test_single_quote_attribute_values_become_double_quotesn  s    13KLr%   c                 *    d}| j                  |       y )N'<foo attr='bar "brawls" happen'>a</foo>r#  )r#   texts     r$   7test_attribute_values_with_nested_quotes_are_left_alonezPHTMLTreeBuilderSmokeTest.test_attribute_values_with_nested_quotes_are_left_aloneq  s    <r%   c                     d}| j                  |      }d|j                  d<   | j                  |j                  j                         d       y )Nr  zBrawls happen at "Bob's Bar"attrz:<foo attr="Brawls happen at &quot;Bob's Bar&quot;">a</foo>)r+   r   rD   r:   )r#   r  r+   s      r$   :test_attribute_values_with_double_nested_quotes_get_quotedzSHTMLTreeBuilderSmokeTest.test_attribute_values_with_double_nested_quotes_get_quotedu  sA    <yy:HHOOM	
r%   c                 L    | j                  dd       | j                  dd       y )Nz+<this is="really messed up & stuff"></this>z/<this is="really messed up &amp; stuff"></this>z.<a href="http://example.org?a=1&b=2;3">foo</a>z2<a href="http://example.org?a=1&amp;b=2;3">foo</a>r#  r"   s    r$   .test_ampersand_in_attribute_value_gets_escapedzGHTMLTreeBuilderSmokeTest.test_ampersand_in_attribute_value_gets_escaped~  s,    9=	

 	<@	
r%   c                 &    | j                  d       y )Nz/<a href="http://example.org?a=1&amp;b=2;3"></a>r#  r"   s    r$   7test_escaped_ampersand_in_attribute_value_is_left_alonezPHTMLTreeBuilderSmokeTest.test_escaped_ampersand_in_attribute_value_is_left_alone  s    JKr%   c                 0    d}d}| j                  ||       y )N-<p>&lt;&lt;sacr&eacute;&#32;bleu!&gt;&gt;</p>#   <p>&lt;&lt;sacré bleu!&gt;&gt;</p>r#  )r#   r  expecteds      r$   1test_entities_in_strings_converted_during_parsingzJHTMLTreeBuilderSmokeTest.test_entities_in_strings_converted_during_parsing  s#     ?R 	 	x(r%   c                 d    d}| j                  |d      }|j                  j                  dk(  sJ y )Ns   <p>Foo</p>zwindows-1252from_encodingu	   ‘Foo’rU  )r#   quoter+   s      r$   )test_smart_quotes_converted_on_the_way_inzBHTMLTreeBuilderSmokeTest.test_smart_quotes_converted_on_the_way_in  s:     &yyny=FFMMQR	
Rr%   c                 \    | j                  d      }|j                  j                  dk(  sJ y )Nz<a>&nbsp;&nbsp;</a>u     )r+   ry   rb   r   s     r$   0test_non_breaking_spaces_converted_on_the_way_inzIHTMLTreeBuilderSmokeTest.test_non_breaking_spaces_converted_on_the_way_in  s(    yy./vv}} 8888r%   c                     d}dj                  d      }| j                  |      }|j                  j                  d      |k(  sJ y )Nr  r  r  )r   r+   r   )r#   r  r  r+   s       r$   &test_entities_converted_on_the_way_outz?HTMLTreeBuilderSmokeTest.test_entities_converted_on_the_way_out  sD    >Y``
 yyvv}}W%111r%   c                     d}|j                  d      }| j                  |      }|j                  d      }|j                  dd      }|j                  d      }||k(  sJ y )Nu   <html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="Content-type"/></head><body><p>Sacré bleu!</p></body></html>z
iso-8859-1r  z
ISO-8859-1)r   r+   r	  )r#   unicode_htmliso_latin_htmlr+   resultr  s         r$   test_real_iso_8859_documentz4HTMLTreeBuilderSmokeTest.test_real_iso_8859_document  sp    
 ~ &,,\: yy( W%
  ''g> ??7+ !!!r%   c                     d}|j                  d      }| j                  |      }|j                  d      |j                  d      k(  sJ |j                  d      |j                  d      k(  sJ y )Nsk   <html><head></head><body><pre>Shift-JISŃR[fBOꂽ{̃t@CłB</pre></body></html>	shift-jisr  euc_jp)r:   r+   r   )r#   shift_jis_htmlr  r+   s       r$   test_real_shift_jis_documentz5HTMLTreeBuilderSmokeTest.test_real_shift_jis_document  sr    $ 	 &,,[9yy& {{7#|':':7'CCCC{{8$(;(;H(EEEEr%   c                     d}| j                  |d      }|j                  dv sJ |j                  d      |j                  d      j                  d      k(  sJ y )Ns   <html><head><title>Hebrew (ISO 8859-8) in Visual Directionality</title></head><body><h1>Hebrew (ISO 8859-8) in Visual Directionality</h1></body></html>	iso8859-8r  )r  z
iso-8859-8r  )r+   original_encodingr   r:   )r#   hebrew_documentr+   s      r$   test_real_hebrew_documentz2HTMLTreeBuilderSmokeTest.test_real_hebrew_document  sg     EyyyD %%)DDDD{{7#"";/66w?
 	
 
r%   c                    d}d|z  }| j                  |      }|j                  dddi      }|d   }d|k(  sJ t        |t              sJ d|j	                  d	      k(  sJ d
|j                  d	      v sJ d|j                  d      v sJ y )NzE<meta content="text/html; charset=x-sjis" http-equiv="Content-type"/>j<html><head>
%s
<meta http-equiv="Content-language" content="ja"/></head><body>Shift-JIS markup goes here.r   z
http-equivzContent-typeri  ztext/html; charset=x-sjisztext/html; charset=utf8r   s   charset=utf8s   charset=shift-jisr  )r+   r+  r8   r   substitute_encodingr   )r#   meta_tagr  r+   parsed_metari  s         r$   'test_meta_tag_reflects_current_encodingz@HTMLTreeBuilderSmokeTest.test_meta_tag_reflects_current_encoding  s     W 	7 	
 yy( ii~(FGi(*g555 '#<=== )G,G,G,OOOO +"4"4V"<<<<#{'9'9+'FFFFr%   c                    d}d|z  }| j                  |      }|j                  dd      }|d   }d|k(  sJ t        |t              sJ d|j	                  d      k(  sJ d	|j                  d      v sJ d
|j                  d      v sJ y )Nz'<meta id="encoding" charset="x-sjis" />r  r   encoding)rg   charsetzx-sjisr   s   charset="utf8"s   charset="shift-jis"r  )r+   r+  r8   r   r  r   )r#   r  r  r+   r  r  s         r$   3test_html5_style_meta_tag_reflects_current_encodingzLHTMLTreeBuilderSmokeTest.test_html5_style_meta_tag_reflects_current_encoding  s     =7 	
 yy( ii:i6i(7""" '#<=== 44V<<<< !K$6$6v$>>>>%););K)HHHHr%   c                     dD ]O  }| j                  |      }t        D ]3  }|dv r|j                  |      }d|v sJ |j                  d      |vr3J  Q y )N)sB   <meta charset="utf8"></head><meta id="encoding" charset="utf-8" />idnambcsoem	undefinedstring_escapezstring-escapes   meta charset=""asciir+   r   r   r#   r&   r+   r  encodeds        r$   2test_python_specific_encodings_not_used_in_charsetzKHTMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_charset&  sw    

 	?F 99V$D5 ?    ++h/)W444w/w>>>?		?r%   c                     | j                  d      }d|j                  d<   d|j                  j                         k(  sJ y )Nz<a>text</a>rE  r   z<a foo="bar">text</a>)r+   ry   r:   )r#   datas     r$   5test_tag_with_no_attributes_can_have_attributes_addedzNHTMLTreeBuilderSmokeTest.test_tag_with_no_attributes_can_have_attributes_added@  s5    yy'u&$&&--/999r%   c                 d    | j                  d      }d|j                  j                         k(  sJ y )Nz0<body><div><p>text1</p></span>text2</div></body>z)<body><div><p>text1</p>text2</div></body>)r+   rg  r:   r   s     r$   $test_closing_tag_with_no_opening_tagz=HTMLTreeBuilderSmokeTest.test_closing_tag_with_no_opening_tagE  s.    
 yyKL:dii>N>N>PPPPr%   c                 P    | j                  t              }| j                  |       yz3Test the worst case (currently) for linking issues.Nr+   r   rW   r   s     r$   test_worst_casez(HTMLTreeBuilderSmokeTest.test_worst_caseM        yy&t$r%   )DOCTYPE)Iri   rj   rk   __doc__r   r   r   r   r9   r   r   bytesr   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r$  r&  r(  r,  r1  r8  r=  rA  rC  rH  rK  rM  rO  rQ  rS  rV  rY  r[  r]  r_  rb  rd  rj  rm  rs  ru  rx  r{  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r-   r%   r$   r   r   z  s   B>
90,+S +T +  <E, #,58,	um#	$,
%
/ +JII 	F -,(*'/@"/E$	.,
0
>00E


3?9

2'B	'/"
F14.M
	
L)
92"8F$

GFI<?4:
Q%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y)XMLTreeBuilderSmokeTestc                     | j                  d      }t        j                  |d      }t        j                  |      }|j                  t
        k(  sJ |j                         |j                         k(  sJ y )Nr   r  )r+   r   r   r   r   r   r:   r   s       r$   r   z9XMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identityU  s^     yy)dA&f%=000}}$++-///r%   c                 P    | j                  d      }|j                         dk(  sJ y )N<root/>s.   <?xml version="1.0" encoding="utf-8"?>
<root/>r   r   s     r$   test_docstring_generatedz0XMLTreeBuilderSmokeTest.test_docstring_generated^  s%    yy#{{} RRRRr%   c                 V    d}| j                  |      }||j                  d      k(  sJ y )Ns,   <?xml version="1.0" encoding="utf8"?>
<foo/>r   r   r   s      r$   test_xml_declarationz,XMLTreeBuilderSmokeTest.test_xml_declarationb  s,    Eyy V,,,,r%   c                     d}| j                  |      }t        D ]3  }|dv r|j                  |      }d|v sJ |j                  d      |vr3J  y )Ns   <?xml version="1.0"?>
<foo/>r  s   <?xml version="1.0"?>r  r  r  s        r$   :test_python_specific_encodings_not_used_in_xml_declarationzRXMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_xml_declarationg  sk     6yy 1 	;H   kk(+G+w666??7+7:::	;r%   c                 V    d}| j                  |      }||j                  d      k(  sJ y )Ns<   <?xml version="1.0" encoding="utf8"?>
<?PITarget PIContent?>r   r   r   s      r$   r  z3XMLTreeBuilderSmokeTest.test_processing_instruction~  s,    Uyy V,,,,r%   c                 V    d}| j                  |      }|j                  d      |k(  sJ y)zGA real XHTML document should come out *exactly* the same as it went in.r  r  Nr   r   s      r$   r  z0XMLTreeBuilderSmokeTest.test_real_xhtml_document  s0     yy {{7#v---r%   c                 T    d}| j                  |      }||j                         k(  sJ y )Ns  <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<parent xmlns="http://ns1/">
<child xmlns="http://ns2/" xmlns:ns3="http://ns3/">
<grandchild ns3:attr="value" xmlns="http://ns4/"/>
</child>
</parent>r   r#   docr+   s      r$   test_nested_namespacesz.XMLTreeBuilderSmokeTest.test_nested_namespaces  s,     yy~dkkm###r%   c                 n    d}t        |d      }d|j                  _        |j                         }d|v sJ y )Nz/
  <script type="text/javascript">
  </script>
zlxml-xmlzconsole.log("< < hey > > ");s   &lt; &lt; hey &gt; &gt;)r   r   rb   r   )r#   r  r+   r  s       r$   5test_formatter_processes_script_tag_for_xml_documentszMXMLTreeBuilderSmokeTest.test_formatter_processes_script_tag_for_xml_documents  s>     S*- <++-)W444r%   c                 `    d}| j                  |      }d|j                  j                  k(  sJ y )Nu?   <?xml version="1.0" encoding="euc-jp"><root>Sacré bleu!</root>rw  r+   rootrb   r   s      r$   rx  z7XMLTreeBuilderSmokeTest.test_can_parse_unicode_document  s-    syy 499#3#3333r%   c                 `    d}| j                  |      }d|j                  j                  k(  sJ y )NuB   ﻿<?xml version="1.0" encoding="euc-jp"><root>Sacré bleu!</root>rw  r  r   s      r$   1test_can_parse_unicode_document_begining_with_bomzIXMLTreeBuilderSmokeTest.test_can_parse_unicode_document_begining_with_bom  s0     Gyy 499#3#3333r%   c                 ^    d}| j                  |      }t        |j                        |k(  sJ y )Nz<rss xmlns:dc="foo"><dc:creator>b</dc:creator><dc:date>2012-07-02T20:33:42Z</dc:date><dc:rights>c</dc:rights><image>d</image></rss>)r+   r9   rssr   s      r$   test_popping_namespaced_tagz3XMLTreeBuilderSmokeTest.test_popping_namespaced_tag  s.     Wyy 488}&&&r%   c                 R    | j                  d      }|j                  d      dk(  sJ y )Nr  latin1s/   <?xml version="1.0" encoding="latin1"?>
<root/>r   r   s     r$   (test_docstring_includes_correct_encodingz@XMLTreeBuilderSmokeTest.test_docstring_includes_correct_encoding  s*    yy#KK!%XX	
Xr%   c                 V    d}| j                  |      }|j                  d      |k(  sJ y)z<A large XML document should come out the same as it went in.s4  <?xml version="1.0" encoding="utf-8"?>
<root>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</root>r  Nr   r   s      r$   test_large_xml_documentz/XMLTreeBuilderSmokeTest.test_large_xml_document  s3     	
 yy {{7#v---r%   c                 J    | j                  dd       | j                  d       y )Nr!  r  z
<p>foo</p>r#  r"   s    r$   9test_tags_are_empty_element_if_and_only_if_they_are_emptyzQXMLTreeBuilderSmokeTest.test_tags_are_empty_element_if_and_only_if_they_are_empty  s     '&r%   c                 j    d}| j                  |      }|j                  }d|d   k(  sJ d|d   k(  sJ y )Nz<root xmlns:a="http://example.com/" xmlns:b="http://example.net/"><a:foo>This tag is in the a namespace</a:foo><b:foo>This tag is in the b namespace</b:foo></root>zhttp://example.com/zxmlns:azhttp://example.net/zxmlns:b)r+   r  )r#   r&   r+   r  s       r$   test_namespaces_are_preservedz5XMLTreeBuilderSmokeTest.test_namespaces_are_preserved  sE     wyy yy$Y777$Y777r%   c                 ^    d}| j                  |      }t        |j                        |k(  sJ y )NzN<p xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:date>20010504</dc:date></p>)r+   r9   r   r   s      r$   test_closing_namespaced_tagz3XMLTreeBuilderSmokeTest.test_closing_namespaced_tag  s+    ayy 466{f$$$r%   c                 ^    d}| j                  |      }t        |j                        |k(  sJ y )Nzs<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><bar xsi:schemaLocation="http://www.example.com"/></foo>r+   r9   r   r   s      r$   test_namespaced_attributesz2XMLTreeBuilderSmokeTest.test_namespaced_attributes  s.     Gyy 488}&&&r%   c                 ^    d}| j                  |      }t        |j                        |k(  sJ y )Nz<foo xml:lang="fr">bar</foo>r  r   s      r$   (test_namespaced_attributes_xml_namespacez@XMLTreeBuilderSmokeTest.test_namespaced_attributes_xml_namespace  s+    /yy 488}&&&r%   c                     d}| j                  |      }dt        |j                  d            k(  sJ dt        |j                  d            k(  sJ dt        |j                  d            k(  sJ 	 y )Na  <?xml version="1.0" encoding="utf-8"?>
<Document xmlns="http://example.com/ns0"
    xmlns:ns1="http://example.com/ns1"
    xmlns:ns2="http://example.com/ns2">
    <ns1:tag>foo</ns1:tag>
    <ns1:tag>bar</ns1:tag>
    <ns2:tag key="value">baz</ns2:tag>
</Document>
   rd   r  zns1:tagrP   zns2:tag)r+   rU   r  r  s      r$   test_find_by_prefixed_namez2XMLTreeBuilderSmokeTest.test_find_by_prefixed_name  sv     yy~ Ce,---- Ci01111Ci01111r%   c                     d}| j                  |      }|j                  }t        j                  |      }|j                  |j                  k(  sJ y )Nzf<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://example.com/ns0"/>)r+   documentr  prefix)r#   xmlr+   rd   	duplicates        r$   !test_copy_tag_preserves_namespacez9XMLTreeBuilderSmokeTest.test_copy_tag_preserves_namespace  sH    2 yy~mmIIcN	 zzY-----r%   c                 P    | j                  t              }| j                  |       yr  r  r   s     r$   r  z'XMLTreeBuilderSmokeTest.test_worst_case  r  r%   N)ri   rj   rk   r   r  r  r  r  r  r  r  rx  r  r  r  r  r  r  r  r  r  r  r  r  r-   r%   r$   r  r  T  sl    0S-
;.-
	.	$
54
4
'

.'8%
'
'
=,	.%r%   r  c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)HTML5TreeBuilderSmokeTestz2Smoke test for a tree builder that supports HTML5.c                      y r!   r-   r"   s    r$   r  z2HTML5TreeBuilderSmokeTest.test_real_xhtml_document	  s     	r%   c                 `    d}| j                  |      }d|j                  j                  k(  sJ y )Nz<a>ro  )r+   ry   	namespacer   s      r$   test_html_tags_have_namespacez7HTML5TreeBuilderSmokeTest.test_html_tags_have_namespace  s-    yy -1A1AAAAr%   c                     d}| j                  |      }d}||j                  j                  k(  sJ ||j                  j                  k(  sJ y )Nz<svg><circle/></svg>rr  )r+   svgr  circler#   r&   r+   r  s       r$   test_svg_tags_have_namespacez6HTML5TreeBuilderSmokeTest.test_svg_tags_have_namespace  sJ    'yy 0	DHH.....DKK11111r%   c                     d}| j                  |      }d}||j                  j                  k(  sJ ||j                  j                  k(  sJ y )Nz<math><msqrt>5</msqrt></math>rq  )r+   mathr  msqrtr  s       r$   test_mathml_tags_have_namespacez9HTML5TreeBuilderSmokeTest.test_mathml_tags_have_namespace  sJ    0yy 8	DII/////DJJ00000r%   c                     d}| j                  |      }t        |j                  d   t              sJ |j                  d   dk(  sJ d|j                  d   j                  j
                  k(  sJ y )Nz3<?xml version="1.0" encoding="utf-8"?><html></html>r   z$?xml version="1.0" encoding="utf-8"?r   )r+   r8   rV   r   rH   rA   r   s      r$   $test_xml_declaration_becomes_commentz>HTML5TreeBuilderSmokeTest.test_xml_declaration_becomes_comment!  si    Fyy $--*G444}}Q#IIIIq)66;;;;;r%   N)	ri   rj   rk   r  r  r  r  r  r  r-   r%   r$   r  r    s    <
B
21<r%   r  )9r  __license__r   	importlibr  r  r   bs4r   bs4.elementr   r   r   r   r	   r
   r   r   r   r   
bs4.filterr   bs4.builderr   bs4._typingr   r   bs4.builder._htmlparserr   typingr   r   r   r   r   	soupsiever   SOUP_SIEVE_PRESENTImportErrorutil	find_specHTML5LIB_PRESENT
lxml.etreelxmlLXML_PRESENTetreeLXML_VERSIONr   __annotations__r   r9   objectr   rp   r   r  r  r-   r%   r$   <module>r$     s4             $ ( # 9 - >>++J7tC L::**L
 &;k" :"c "JM;v M;`BD8 BDJW%3 W%to%2 o%d < 8  <k&    LLs$   %C0 C= 0C:9C:=	D	D	