HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/bs4/tests/__pycache__/__init__.cpython-310.pyc
o

�h��@s`dZdZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZmZmZeZz
ddlmZdZWneyUd	ZYnwzddlZdZWneyid	ZYnwzddlZdZ ej!j"Z"Wn
ey�d	Z d
Z"YnwdZ#Gdd
�d
e$�Z%Gdd�de$�Z&Gdd�de&�Z'Gdd�de&�Z(Gdd�de'�Z)dS)zHelper classes for tests.�MIT�N)�
BeautifulSoup)	�CharsetMetaAttributeValue�Comment�ContentMetaAttributeValue�Doctype�PYTHON_SPECIFIC_ENCODINGS�SoupStrainer�Script�
Stylesheet�Tag)�DetectsXMLParsedAsHTML�HTMLParserTreeBuilder�XMLParsedAsHTMLWarning)�SelectorSyntaxErrorTF)ru-
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">
c@sXeZdZedd��Zdd�Zdd�Zddd	�ZeZd
d�Z	dd
d�Z
dd�Zdd�ZdS)�SoupTestcCstS�N)�default_builder��self�r�E/usr/local/CyberCP/lib/python3.10/site-packages/bs4/tests/__init__.pyr^szSoupTest.default_buildercKs"|�d|j�}t|fd|i|��S)z*Build a Beautiful Soup object from markup.�builder)�poprr)r�markup�kwargsrrrr�soupbsz
SoupTest.soupcKs|jdi|���|�S)z[Turn an HTML fragment into a document.

        The details depend on the builder.
        Nr)r�test_fragment_to_document)rrrrrr�document_forgszSoupTest.document_forNcCst|j}t||d�}|dur|}|��|�|�ksJ�tdd�t|j���D��s*J�|jgdd�|j	D�ks8J�dS)ziParse some markup using Beautiful Soup and verify that
        the output markup is as expected.
        )rNcss�|]}|dkVqdS)rNr)�.0�vrrr�	<genexpr>s�z'SoupTest.assert_soup.<locals>.<genexpr>cS�g|]}|j�qSr)�name)r�xrrr�
<listcomp>��z(SoupTest.assert_soup.<locals>.<listcomp>)
rr�decoder�all�list�open_tag_counter�values�
ROOT_TAG_NAME�tagStack)r�to_parse�compare_parsed_tor�objrrr�assert_soupns  zSoupTest.assert_soupcCs8d}|jD]}|r||jksJ�||jksJ�|}qdS)zyEnsure that next_element and previous_element are properly
        set for all descendants of the given element.
        N)�descendants�next_element�previous_element)r�element�earlier�errr�assertConnectedness�s
�zSoupTest.assertConnectednessFc		Cs�d}|jdur4|jdusJd�||jd���|jdus%Jd�||jd���|jdus4Jd�||jd���d}d}d}t|j�d}|jD]�}d}|dkr|jdur~|j|us`Jd�||j|���|j|usoJd�||j|���|jdus~Jd�||jd���n\|j|j|dus�Jd	�||j|j|d���|j|dj|us�Jd
�|j|d|j|dj|���|dur�|j|us�Jd�||j||jj���|j|us�Jd�||j|���t|t	�r�|jr�|�
|d
�}|jdus�Jd
�||jd���|dur�|}n|}||k�r|jdu�sJd
�||jd���|d7}qD|du�r"|n|}|du�r+|}|�sn|du�rn|}	|du�rN|jdu�sKJd�||jd���	dS|jdu�ri|j|ju�sfJd�||j|j���	dS|j}�q6|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)�parentr4�format�previous_sibling�next_sibling�len�contentsr3�
isinstancer�linkage_validator)	r�el�_recursive_call�
descendant�idx�child�
last_child�last_idx�targetrrrrA�s�
������

�����������������
��


��
�
����zSoupTest.linkage_validatorcC�dd�|D�|ksJ�dS)z�Make 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.
        cSr"r��string�r�tagrrrr%r&z+SoupTest.assert_selects.<locals>.<listcomp>Nr�r�tags�should_matchrrr�assert_selects�zSoupTest.assert_selectscCrJ)z�Make 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.
        cSsg|]}|d�qS��idrrMrrrr%sz/SoupTest.assert_selects_ids.<locals>.<listcomp>NrrOrrr�assert_selects_ids
rSzSoupTest.assert_selects_idsr)F)
�__name__�
__module__�__qualname__�propertyrrrr1�assertSoupEqualsr8rArRrVrrrrr\s


r	rc@sheZdZej�ddiedgd�ddgig�dd��Zej�dedgd	�ddgig�d
d��Zdd
�Z	dS)�TreeBuilderSmokeTest�multi_valued_attributesN�class)�b�*�notclasscCs(d}|j||d�}|jddksJ�dS)NzC<html xmlns="http://www.w3.org/1999/xhtml"><a class="a b c"></html>�r]r^za b c�r�a�rr]rrrrr�test_attribute_not_multi_valuedsz4TreeBuilderSmokeTest.test_attribute_not_multi_valued)rdcCs,d}|j||d�}|jdgd�ksJ�dS)Nz<a class="a b c">rbr^)rdr_�crcrerrr�test_attribute_multi_valued#s
�z0TreeBuilderSmokeTest.test_attribute_multi_valuedcCsd}d}|�|�}dS)Nz<![if word]>content<![endif]>z<!DOCTYPE html]ff>)r�rrrrrr�test_invalid_doctype-sz)TreeBuilderSmokeTest.test_invalid_doctype)
rWrXrY�pytest�mark�parametrize�dictrfrhrjrrrrr\s�
�
r\c@seZdZdZdd�Zdd�Zdd�Zdd	�Zd�dd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQd�ZdRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0d^d_�Z1d`da�Z2dbdc�Z3ddde�Z4dfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9dpdq�Z:drds�Z;dtdu�Z<dvdw�Z=dxdy�Z>dzd{�Z?d|d}�Z@d~d�ZAd�d��ZBd�S)��HTMLTreeBuilderSmokeTestaCA 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.
    cCs0dD]}|�d�}|�|�}|jdksJ�qdS)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�TN)r�new_tag�is_empty_element)rr#rr�rrr�test_empty_element_tags<s


�z0HTMLTreeBuilderSmokeTest.test_empty_element_tagscCsp|�d�}t|jjt�sJ�t|jjt�sJ�|�d�}t|jjt�s%J�|jjdks-J�t|jjt�s6J�dS)Nz7<style>Some CSS</style><script>Some Javascript</script>z<style><!--Some CSS--></style>z<!--Some CSS-->)rr@�stylerLr�scriptr
�rrrrr�test_special_string_containersHs��z7HTMLTreeBuilderSmokeTest.test_special_string_containerscC�F|�d�}t�|d�}t�|�}|jtksJ�|��|��ks!J�dS�Nz
<a><b>foo</a>��r�pickle�dumps�loads�	__class__rr'�r�tree�dumped�loadedrrr�!test_pickle_and_unpickle_identityX�


z:HTMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identitycCsh|�|�\}}|jd}|jtksJ�||ksJ�|�d�dt|��|ks(J�|jjddks2J�dS)z8Assert that a given doctype string is handled correctly.r�utf8N�foo��_document_with_doctyper?r�r�encoder>�p�r�doctype_fragment�doctype_strr�doctyperrr�assertDoctypeHandledas
z-HTMLTreeBuilderSmokeTest.assertDoctypeHandled�DOCTYPEcCs,d||f}|d}|�|�}|�d�|fS)z5Generate and parse a document with the given doctype.z<!%s %s>z
<p>foo</p>r��rr�)rr��doctype_stringr�rrrrrr�os
z/HTMLTreeBuilderSmokeTest._document_with_doctypecCs|�d�|�d�dS)z?Make sure normal, everyday HTML doctypes are handled correctly.�htmlz4html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"N�r�rrrr�test_normal_doctypesvs
�z-HTMLTreeBuilderSmokeTest.test_normal_doctypescCs(|�d�}|jd}d|��ksJ�dS)Nz
<!DOCTYPE>rr�)rr?�strip)rrr�rrr�test_empty_doctype|s

z+HTMLTreeBuilderSmokeTest.test_empty_doctypecCstdD]5}|�d|�\}}|jd}|jtksJ�|dksJ�|�d�dt|��dks-J�|jjddks7J�qdS)N)r��DocTyper�rr�s<!DOCTYPE html>r�r�r�rrr�test_mixed_case_doctype�s�
�z0HTMLTreeBuilderSmokeTest.test_mixed_case_doctypecC�d}|�|�dS)Nznhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"r�)rr�rrr�test_public_doctype_with_url��z5HTMLTreeBuilderSmokeTest.test_public_doctype_with_urlcC�|�d�dS)Nz$foo SYSTEM "http://www.example.com/"r�rrrr�test_system_doctype��z,HTMLTreeBuilderSmokeTest.test_system_doctypecCr�)Nz#xsl:stylesheet SYSTEM "htmlent.dtd"r�rrrr�test_namespaced_system_doctype��z7HTMLTreeBuilderSmokeTest.test_namespaced_system_doctypecCr�)Nz#xsl:stylesheet PUBLIC "htmlent.dtd"r�rrrr�test_namespaced_public_doctype�r�z7HTMLTreeBuilderSmokeTest.test_namespaced_public_doctypecCsld}tjdd��
}|�|�}Wd�n1swY|�d��dd�|�dd�ks.J�|gks4J�dS)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�
�)�warnings�catch_warningsrr��replace�rr�wrrrr�test_real_xhtml_document�s�"z1HTMLTreeBuilderSmokeTest.test_real_xhtml_documentcCs`d}tjdd��
}|�|�}Wd�n1swYdt|�d��ks(J�g|ks.J�dS)Ns.<ns1:foo>content</ns1:foo><ns1:foo/><ns2:foo/>Tr�r�zns1:foo)r�r�rr>�find_allr�rrr�test_namespaced_html�s�z-HTMLTreeBuilderSmokeTest.test_namespaced_htmlcCsxd}tjdd��}|�|�}|jjdksJ�Wd�n1s wY|\}t|jt�s0J�t|j�tj	ks:J�dS)Ns7<?xml version="1.0" encoding="utf-8"?><tag>string</tag>Tr�rL)
r�r�rrNrLr@�messager�str�MESSAGE)rrr�r�warningrrr�test_detect_xml_parsed_as_html�s
�z7HTMLTreeBuilderSmokeTest.test_detect_xml_parsed_as_htmlcCsBd}|�|�}||��ksJ�d}|�|�}||�d�ksJ�dS)Nz<?PITarget PIContent?>s<?PITarget PIContent?>r�)rr'r�rirrr�test_processing_instruction�s

z4HTMLTreeBuilderSmokeTest.test_processing_instructioncCst�|j�dS)z�Make 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�deepcopyrrrrr�
test_deepcopy�sz&HTMLTreeBuilderSmokeTest.test_deepcopycCs,|�d�}|jjrJ�t|j�dksJ�dS)z�A <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)rr�r�r�r�rrr�!test_p_tag_is_never_empty_element��
z:HTMLTreeBuilderSmokeTest.test_p_tag_is_never_empty_elementcCs(|�dd�|�dd�|�dd�dS)z�A 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�r1rrrr�test_unclosed_tags_get_closed�sz6HTMLTreeBuilderSmokeTest.test_unclosed_tags_get_closedcCs,|�d�}|jjsJ�t|j�dksJ�dS)z�A <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)rrrr�r�r�rrr�#test_br_is_always_empty_element_tag�r�z<HTMLTreeBuilderSmokeTest.test_br_is_always_empty_element_tagcCr�)Nz<em><em></em></em>r�rrrr�test_nested_formatting_elementsr�z8HTMLTreeBuilderSmokeTest.test_nested_formatting_elementscCs(d}|�|�}d|�d�dksJ�dS)Nz�<!DOCTYPE html>
<html>
<head>
<title>Ordinary HEAD element test</title>
</head>
<script type="text/javascript">
alert("Help!");
</script>
<body>
Hello, world!
</body>
</html>
ztext/javascriptr��type)r�find)rr�rrrr�test_double_heads

z)HTMLTreeBuilderSmokeTest.test_double_headcCsjd}|�|�|�|�}|jdd�}|jtksJ�|jdd�}||jks&J�|jdd�}||jks3J�dS)Nz<p>foo<!--foobar-->baz</p>�foobarrKr��baz)r1rr�r�rr3r4)rrr�commentr�r�rrr�test_comments

z%HTMLTreeBuilderSmokeTest.test_commentcCstd}d}|�|�|�|�|�|�}|j��|ksJ�|�|�}|j��|ks*J�|�d�}|j��dks8J�dS)zWhitespace 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)r1r�pre�prettify�textarea)r�
pre_markup�textarea_markuprrrr�-test_preserved_whitespace_in_pre_and_textarea&s




zFHTMLTreeBuilderSmokeTest.test_preserved_whitespace_in_pre_and_textareacCs.d}|�|�d}|�|�d}|�|�dS)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_tagrrr�test_nested_inline_elements8s

z4HTMLTreeBuilderSmokeTest.test_nested_inline_elementscCs6|�d�}|j}|jjjdksJ�|jjdksJ�dS)zBlock elements can be nested.z*<blockquote><p><b>Foo</b></p></blockquote>�FooN)r�
blockquoter�r_rL)rrr�rrr� test_nested_block_level_elementsCs
z9HTMLTreeBuilderSmokeTest.test_nested_block_level_elementscCsd}|�|d�|�d�dS)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�)rrrrr�test_correctly_nested_tablesJs��z5HTMLTreeBuilderSmokeTest.test_correctly_nested_tablescCs@d}|�|�}ddg|jdksJ�|j|jddd�ksJ�dS)Nz<div class=" foo bar	 "></a>r��barr^�divzfoo bar)�class_)rr�r�rirrr�*test_multivalued_attribute_with_whitespace^s
zCHTMLTreeBuilderSmokeTest.test_multivalued_attribute_with_whitespacecCs(d}|�|�}dg|jjdksJ�dS)Nz1<table><div><div class="css"></div></div></table>�cssr^)rr�rirrr�(test_deeply_nested_multivalued_attributej�
zAHTMLTreeBuilderSmokeTest.test_deeply_nested_multivalued_attributecC�(d}|�|�}ddg|jdksJ�dS)Nz<html class="a b"></html>rdr_r^)rr�rirrr�"test_multivalued_attribute_on_htmlrr�z;HTMLTreeBuilderSmokeTest.test_multivalued_attribute_on_htmlcC�|�dd�dS)Nz<a b="<a>"></a>z<a b="&lt;a&gt;"></a>r�rrrr�3test_angle_brackets_in_attribute_values_are_escapedzszLHTMLTreeBuilderSmokeTest.test_angle_brackets_in_attribute_values_are_escapedcCr�)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�rrrr�3test_strings_resembling_character_entity_references}s�zLHTMLTreeBuilderSmokeTest.test_strings_resembling_character_entity_referencescCr�)Nz<p>Bob&apos;s Bar</p>z<p>Bob's Bar</p>r�rrrr�test_apos_entity�s�z)HTMLTreeBuilderSmokeTest.test_apos_entitycC�"d}|�|�}d|jjksJ�dS)Nz%<p>&#147;Hello&#148; &#45;&#9731;</p>u“Hello” -☃�rr�rLrirrr�*test_entities_in_foreign_document_encoding�s
zCHTMLTreeBuilderSmokeTest.test_entities_in_foreign_document_encodingcC�8d}|�d|�|�d|�|�d|�|�d|�dS)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�expectrrr�0test_entities_in_attributes_converted_to_unicode��
zIHTMLTreeBuilderSmokeTest.test_entities_in_attributes_converted_to_unicodecCr�)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�r�rrr�*test_entities_in_text_converted_to_unicode�rzCHTMLTreeBuilderSmokeTest.test_entities_in_text_converted_to_unicodecCr�)Nz#<p>I said &quot;good day!&quot;</p>z<p>I said "good day!"</p>r�rrrr�,test_quot_entity_converted_to_quotation_mark���zEHTMLTreeBuilderSmokeTest.test_quot_entity_converted_to_quotation_markcCs,d}|�d|�|�d|�|�d|�dS)Nu�z&#10000000000000;z&#x10000000000000;z
&#1000000000;r�r�rrr�test_out_of_range_entity�sz1HTMLTreeBuilderSmokeTest.test_out_of_range_entitycCs<|�d�}d|jjjjksJ�d|jjksJ�|�|�dS)zDMostly to prevent a recurrence of a bug in the html5lib treebuilder.z!<html><h2>
foo</h2><p></p></html>r�N)r�h2rLr3r#r�r8r�rrr�test_multipart_strings�s
z/HTMLTreeBuilderSmokeTest.test_multipart_stringscCs|�dd�|�dd�dS)zqVerify consistent handling of empty-element tags,
        no matter how they come in through the markup.
        z<br/><br/><br/>z<br /><br /><br />Nr�rrrrr��scCs,d}|�|�}|jjdusJ�|�|�dS)�8Prevent recurrence of a bug in the html5lib treebuilder.z?<html><head></head>
  <link></link>
  <body>foo</body>
</html>
N)rr��bodyr8�r�contentrrrr�#test_head_tag_between_head_and_body�s
z<HTMLTreeBuilderSmokeTest.test_head_tag_between_head_and_bodycCsd}|�|�}|�|j�dS)rz�<!DOCTYPE html>
<html>
 <body>
   <article id="a" >
   <div><a href="1"></div>
   <footer>
     <a href="2"></a>
   </footer>
  </article>
  </body>
</html>
N)rr8�articler	rrr�test_multiple_copies_of_a_tag�s
z6HTMLTreeBuilderSmokeTest.test_multiple_copies_of_a_tagcCs^d}|�|�}||��ksJ�|j}d|jdksJ�d|jdks$J�d|jdks-J�dS)	z�Parsers 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)rr�r�)rrrr�rrr�test_basic_namespaces�s
z.HTMLTreeBuilderSmokeTest.test_basic_namespacescCr�)Ns<a class="foo bar">r�r�r^rcrirrr�-test_multivalued_attribute_value_becomes_list�s
zFHTMLTreeBuilderSmokeTest.test_multivalued_attribute_value_becomes_listcCr�)NuD<html><head><meta encoding="euc-jp"></head><body>Sacré bleu!</body>�Sacré bleu!)rrrLrirrr�test_can_parse_unicode_document�s
z8HTMLTreeBuilderSmokeTest.test_can_parse_unicode_documentcCs*td�}|jd|d�}|��dksJ�dS)z2Parsers should be able to work with SoupStrainers.r_z&A <b>bold</b> <meta/> <i>statement</i>)�
parse_onlyz<b>bold</b>N)r	rr')r�strainerrrrr�test_soupstrainer�s
�z*HTMLTreeBuilderSmokeTest.test_soupstrainercCr�)Nz<foo attr='bar'></foo>z<foo attr="bar"></foo>r�rrrr�7test_single_quote_attribute_values_become_double_quotesrzPHTMLTreeBuilderSmokeTest.test_single_quote_attribute_values_become_double_quotescCr�)N�'<foo attr='bar "brawls" happen'>a</foo>r�)r�textrrr�7test_attribute_values_with_nested_quotes_are_left_aloner�zPHTMLTreeBuilderSmokeTest.test_attribute_values_with_nested_quotes_are_left_alonecCs.d}|�|�}d|jd<|�|j��d�dS)NrzBrawls happen at "Bob's Bar"�attrz:<foo attr="Brawls happen at &quot;Bob's Bar&quot;">a</foo>)rr�r1r')rrrrrr�:test_attribute_values_with_double_nested_quotes_get_quoted	s

�zSHTMLTreeBuilderSmokeTest.test_attribute_values_with_double_nested_quotes_get_quotedcCs|�dd�|�dd�dS)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�rrrr�.test_ampersand_in_attribute_value_gets_escapeds��zGHTMLTreeBuilderSmokeTest.test_ampersand_in_attribute_value_gets_escapedcCr�)Nz/<a href="http://example.org?a=1&amp;b=2;3"></a>r�rrrr�7test_escaped_ampersand_in_attribute_value_is_left_aloner�zPHTMLTreeBuilderSmokeTest.test_escaped_ampersand_in_attribute_value_is_left_alonecCsd}d}|�||�dS)N�-<p>&lt;&lt;sacr&eacute;&#32;bleu!&gt;&gt;</p>�#<p>&lt;&lt;sacré bleu!&gt;&gt;</p>r�)rr�expectedrrr�1test_entities_in_strings_converted_during_parsingszJHTMLTreeBuilderSmokeTest.test_entities_in_strings_converted_during_parsingcCs"d}|�|�}|jjdksJ�dS)Ns<p>�Foo�</p>u	‘Foo’r�)r�quoterrrr�)test_smart_quotes_converted_on_the_way_in#s
zBHTMLTreeBuilderSmokeTest.test_smart_quotes_converted_on_the_way_incCs|�d�}|jjdks
J�dS)Nz<a>&nbsp;&nbsp;</a>u  )rrdrLr�rrr�0test_non_breaking_spaces_converted_on_the_way_in*�
zIHTMLTreeBuilderSmokeTest.test_non_breaking_spaces_converted_on_the_way_incCs0d}d�d�}|�|�}|j�d�|ksJ�dS)Nr!r"r�)r�rr�)rrr#rrrr�&test_entities_converted_on_the_way_out.s

z?HTMLTreeBuilderSmokeTest.test_entities_converted_on_the_way_outcCsHd}|�d�}|�|�}|�d�}|�dd�}|�d�}||ks"J�dS)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�rr�)r�unicode_html�iso_latin_htmlr�resultr#rrr�test_real_iso_8859_document4s



z4HTMLTreeBuilderSmokeTest.test_real_iso_8859_documentcCsLd}|�d�}|�|�}|�d�|�d�ksJ�|�d�|�d�ks$J�dS)Nsk<html><head></head><body><pre>�����Shift-JIS�ŃR�[�f�B���O���ꂽ���{��̃t�@�C���ł��B</pre></body></html>z	shift-jisr��euc_jp)r'rr�)r�shift_jis_htmlr*rrrr�test_real_shift_jis_documentPs�

z5HTMLTreeBuilderSmokeTest.test_real_shift_jis_documentcCsBd}|j|dd�}|jdvsJ�|�d�|�d��d�ksJ�dS)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-8)�
from_encoding)r1z
iso-8859-8r�)r�original_encodingr�r')r�hebrew_documentrrrr�test_real_hebrew_documentas��z2HTMLTreeBuilderSmokeTest.test_real_hebrew_documentcCs^d}d|}|�|�}|�dddi�}|d}d|ksJ�t|t�s$J�d|�d	�ks-J�dS)
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-typer
ztext/html; charset=x-sjisztext/html; charset=utf8r�)rr�r@rr�)r�meta_tagr/r�parsed_metar
rrr�'test_meta_tag_reflects_current_encodingns�
z@HTMLTreeBuilderSmokeTest.test_meta_tag_reflects_current_encodingcCs\d}d|}|�|�}|jddd�}|d}d|ksJ�t|t�s#J�d|�d�ks,J�dS)	Nz'<meta id="encoding" charset="x-sjis" />r6r{�encodingrT�charsetzx-sjisr�)rr�r@rr�)rr7r/rr8r;rrr�3test_html5_style_meta_tag_reflects_current_encoding�s�
zLHTMLTreeBuilderSmokeTest.test_html5_style_meta_tag_reflects_current_encodingcCsTdD]%}|�|�}tD]}|dvrq|�|�}d|vsJ�|�d�|vs&J�qqdS)N)sB<meta charset="utf8"></head><meta id="encoding" charset="utf-8" />��idna�mbcs�oem�	undefined�
string_escapez
string-escapesmeta charset=""�ascii�rrr��rrrr:�encodedrrr�2test_python_specific_encodings_not_used_in_charset�s

��zKHTMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_charsetcCs*|�d�}d|jd<d|j��ksJ�dS)Nz<a>text</a>r�r�z<a foo="bar">text</a>)rrdr')r�datarrr�5test_tag_with_no_attributes_can_have_attributes_added�s

zNHTMLTreeBuilderSmokeTest.test_tag_with_no_attributes_can_have_attributes_addedcCs |�d�}d|j��ksJ�dS)Nz0<body><div><p>text1</p></span>text2</div></body>z)<body><div><p>text1</p>text2</div></body>)rrr'r�rrr�$test_closing_tag_with_no_opening_tag�s
z=HTMLTreeBuilderSmokeTest.test_closing_tag_with_no_opening_tagcC�|�t�}|�|�dS�z3Test the worst case (currently) for linking issues.N�r�BAD_DOCUMENTrAr�rrr�test_worst_case��
z(HTMLTreeBuilderSmokeTest.test_worst_caseN)r�)CrWrXrY�__doc__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�r�r�r�r�r�rrrrrr
rrrrrrrrr r$r&r'r)r-r0r5r9r<rGrIrJrOrrrrro2s�	







roc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+S),�XMLTreeBuilderSmokeTestcCr�r�r�r�rrrr��r�z9XMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identitycCs|�d�}|��dks
J�dS)N�<root/>s.<?xml version="1.0" encoding="utf-8"?>
<root/>r�r�rrr�test_docstring_generated�r(z0XMLTreeBuilderSmokeTest.test_docstring_generatedcC�$d}|�|�}||�d�ksJ�dS)Ns,<?xml version="1.0" encoding="utf8"?>
<foo/>r�r�rirrr�test_xml_declaration��
z,XMLTreeBuilderSmokeTest.test_xml_declarationcCsNd}|�|�}tD]}|dvrq	|�|�}d|vsJ�|�d�|vs$J�q	dS)Ns<?xml version="1.0"?>
<foo/>r=s<?xml version="1.0"?>rCrDrErrr�:test_python_specific_encodings_not_used_in_xml_declaration�s

�zRXMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_xml_declarationcCrU)Ns<<?xml version="1.0" encoding="utf8"?>
<?PITarget PIContent?>r�r�rirrrr��rWz3XMLTreeBuilderSmokeTest.test_processing_instructioncC�$d}|�|�}|�d�|ksJ�dS)zGA real XHTML document should come out *exactly* the same as it went in.r�r�Nr�rirrrr��s
z0XMLTreeBuilderSmokeTest.test_real_xhtml_documentcCs"d}|�|�}||��ksJ�dS)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�docrrrr�test_nested_namespacess
z.XMLTreeBuilderSmokeTest.test_nested_namespacescCs.d}t|d�}d|j_|��}d|vsJ�dS)Nz/
  <script type="text/javascript">
  </script>
zlxml-xmlzconsole.log("< < hey > > ");s&lt; &lt; hey &gt; &gt;)rr�rLr�)rr[rrFrrr�5test_formatter_processes_script_tag_for_xml_documentss

zMXMLTreeBuilderSmokeTest.test_formatter_processes_script_tag_for_xml_documentscCr�)Nu?<?xml version="1.0" encoding="euc-jp"><root>Sacré bleu!</root>r�r�rootrLrirrrr�
z7XMLTreeBuilderSmokeTest.test_can_parse_unicode_documentcCr�)NuB<?xml version="1.0" encoding="euc-jp"><root>Sacré bleu!</root>rr^rirrr�1test_can_parse_unicode_document_begining_with_bom r`zIXMLTreeBuilderSmokeTest.test_can_parse_unicode_document_begining_with_bomcC�$d}|�|�}t|j�|ksJ�dS)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>)rr��rssrirrr�test_popping_namespaced_tag%rWz3XMLTreeBuilderSmokeTest.test_popping_namespaced_tagcCs |�d�}|�d�dksJ�dS)NrS�latin1s/<?xml version="1.0" encoding="latin1"?>
<root/>r�r�rrr�(test_docstring_includes_correct_encoding*s
z@XMLTreeBuilderSmokeTest.test_docstring_includes_correct_encodingcCrY)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�rirrr�test_large_xml_document.s
z/XMLTreeBuilderSmokeTest.test_large_xml_documentcCs|�dd�|�d�dS)Nr�r�z
<p>foo</p>r�rrrr�9test_tags_are_empty_element_if_and_only_if_they_are_empty6szQXMLTreeBuilderSmokeTest.test_tags_are_empty_element_if_and_only_if_they_are_emptycCs8d}|�|�}|j}d|dksJ�d|dksJ�dS)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>zhttp://example.com/zxmlns:azhttp://example.net/zxmlns:b)rr_)rrrr_rrr�test_namespaces_are_preserved:s

z5XMLTreeBuilderSmokeTest.test_namespaces_are_preservedcCrb)NzN<p xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:date>20010504</dc:date></p>)rr�r�rirrr�test_closing_namespaced_tagArWz3XMLTreeBuilderSmokeTest.test_closing_namespaced_tagcCrb)Nzs<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><bar xsi:schemaLocation="http://www.example.com"/></foo>�rr�r�rirrr�test_namespaced_attributesFrWz2XMLTreeBuilderSmokeTest.test_namespaced_attributescCrb)Nz<foo xml:lang="fr">bar</foo>rkrirrr�(test_namespaced_attributes_xml_namespaceKrWz@XMLTreeBuilderSmokeTest.test_namespaced_attributes_xml_namespacecCsVd}|�|�}dt|�d��ksJ�dt|�d��ksJ�dt|�d��ks(J�	dS)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>
�rNr�zns1:tagr9zns2:tag)rr>r�rZrrr�test_find_by_prefixed_namePs
	z2XMLTreeBuilderSmokeTest.test_find_by_prefixed_namecCs2d}|�|�}|j}t�|�}|j|jksJ�dS)Nzf<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://example.com/ns0"/>)r�documentr��prefix)r�xmlrrN�	duplicaterrr�!test_copy_tag_preserves_namespacefs


z9XMLTreeBuilderSmokeTest.test_copy_tag_preserves_namespacecCrKrLrMr�rrrrOqrPz'XMLTreeBuilderSmokeTest.test_worst_caseN)rWrXrYr�rTrVrXr�r�r\r]rrardrfrgrhrirjrlrmrortrOrrrrrR�s,	rRc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�HTML5TreeBuilderSmokeTestz2Smoke test for a tree builder that supports HTML5.cCsdSrrrrrrr�{sz2HTML5TreeBuilderSmokeTest.test_real_xhtml_documentcCr�)Nz<a>r)rrd�	namespacerirrr�test_html_tags_have_namespace�r`z7HTML5TreeBuilderSmokeTest.test_html_tags_have_namespacecC�6d}|�|�}d}||jjksJ�||jjksJ�dS)Nz<svg><circle/></svg>r)r�svgrv�circle�rrrrvrrr�test_svg_tags_have_namespace��

z6HTML5TreeBuilderSmokeTest.test_svg_tags_have_namespacecCrx)Nz<math><msqrt>5</msqrt></math>r)r�mathrv�msqrtr{rrr�test_mathml_tags_have_namespace�r}z9HTML5TreeBuilderSmokeTest.test_mathml_tags_have_namespacecCsNd}|�|�}t|jdt�sJ�|jddksJ�d|jdjjks%J�dS)Nz3<?xml version="1.0" encoding="utf-8"?><html></html>rz$?xml version="1.0" encoding="utf-8"?r�)rr@r?rr3r#rirrr�$test_xml_declaration_becomes_comment�s

z>HTML5TreeBuilderSmokeTest.test_xml_declaration_becomes_commentN)	rWrXrYrQr�rwr|r�r�rrrrruxsru)*rQ�__license__r�r��	functoolsr�rk�bs4r�bs4.elementrrrrrr	r
rr�bs4.builderr
rrr�	soupsiever�SOUP_SIEVE_PRESENT�ImportError�html5lib�HTML5LIB_PRESENT�
lxml.etree�lxml�LXML_PRESENT�etree�LXML_VERSIONrN�objectrr\rorRrurrrr�<module>sX,���%< ,