B ª`j³ã@sÎdZdZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z mZmZmZmZmZddlmZeZdZGd d „d ejƒZGd d „d eƒZGd d„deƒZGdd„deƒZdd„ZdS)zHelper classes for tests.ÚMITéN)ÚTestCase)Ú BeautifulSoup) ÚCharsetMetaAttributeValueÚCommentÚContentMetaAttributeValueÚDoctypeÚPYTHON_SPECIFIC_ENCODINGSÚ SoupStrainerÚScriptÚ StylesheetÚTag)ÚHTMLParserTreeBuilderu- A bare string
HTML5 does allow CDATA sections in SVG
A tag
A
tag that supposedly has contents.
AT&T
This numeric entity is missing the final semicolon:
, that attribute value was closed by the subsequent tag
a
This document contains (do you see it?)
This document ends with That attribute value was bogus
The doctype is invalid because it contains extra whitespace
That boolean attribute had no value
Here's a nonexistent entity: &#foo; (do you see it?)
This document ends before the entity finishes: >

Paragraphs shouldn't contain block display elements, but this one does:

you see?

Multiple values for the same attribute.
Here's a table
This tag contains nothing but whitespace:

This p tag is cut off by

the end of the blockquote tag
Here's a nested table:
foo
This table contains bare markup
This document contains a surprise doctype
Mixed case tags are folded to lowercase
Tag name contains Unicode characters
Attribute name contains Unicode characters
c@sDeZdZedd„ƒZdd„Zdd„Zddd „Zd d „Zdd d„Z dS)ÚSoupTestcCstS)N)Údefault_builder)Úself©rúk/private/var/folders/fw/jsxvvqfs4sz4tdnfdvg5typ5vk77qg/T/pip-install-p7nfy4dm/beautifulsoup4/bs4/testing.pyrCszSoupTest.default_buildercKs"| d|j¡}t|fd|i|—ŽS)z*Build a Beautiful Soup object from markup.Úbuilder)Úpoprr)rÚmarkupÚkwargsrrrrÚsoupGsz SoupTest.soupcKs|jf|Ž |¡S)z[Turn an HTML fragment into a document. The details depend on the builder. )rZtest_fragment_to_document)rrrrrrÚ document_forLszSoupTest.document_forNcCst|j}t||d}|dkr|}| | ¡| |¡¡tdd„t|j ¡ƒDƒƒsTt ‚| |j gdd„|j Dƒ¡dS)N)rcss|]}|dkVqdS)rNr)Ú.0Úvrrrú asz,SoupTest.assertSoupEquals..cSsg|] }|j‘qSr)Úname)rÚxrrrú fsz-SoupTest.assertSoupEquals..) rrÚ assertEqualÚdecoderÚallÚlistZopen_tag_counterÚvaluesÚAssertionErrorZ ROOT_TAG_NAMEZtagStack)rZto_parseZcompare_parsed_torÚobjrrrÚassertSoupEqualsSs  zSoupTest.assertSoupEqualscCs<d}x2|jD](}|r0| ||j¡| ||j¡|}q WdS)zyEnsure that next_element and previous_element are properly set for all descendants of the given element. N)Z descendantsr Ú next_elementÚprevious_element)rÚelementZearlierÚerrrÚassertConnectednessis  zSoupTest.assertConnectednessFc Csd}|jdkrh|jdks,td ||jd¡ƒ‚|jdksJtd ||jd¡ƒ‚|jdkshtd ||jd¡ƒ‚d}d}d}t|jƒd}xÐ|jD]Ä}d}|dkr |jdk rÌ|j|ksÊtd ||j|¡ƒ‚|j|ksètd ||j|¡ƒ‚|jdksÌtd ||jd¡ƒ‚nÂ|j|j|dks>td  ||j|j|d¡ƒ‚|j|dj|ks|td  |j|d|j|dj|¡ƒ‚|dk rÌ|j|ks¬td  ||j||jj¡ƒ‚|j|ksÌtd  ||j|¡ƒ‚t |t ƒr |jr |  |d ¡}|jdks td  ||jd¡ƒ‚|dk r|}n|}||krJ|jdksJtd  ||jd¡ƒ‚|d7}qŒW|dk rd|n|}|dkrv|}|sü|dk rü|}xl|dkrº|jdks¶td  ||jd¡ƒ‚Pn2|jdk rì|j|jksêtd  ||j|j¡ƒ‚P|j}qŒWdS|SdS)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) Úparentr)r%ÚformatZprevious_siblingZ next_siblingÚlenÚcontentsr(Ú isinstancer Úlinkage_validator) rÚelZ_recursive_callZ descendantÚidxÚchildZ last_childZlast_idxÚtargetrrrr3ts’        "         zSoupTest.linkage_validator)N)F) Ú__name__Ú __module__Ú __qualname__Úpropertyrrrr'r,r3rrrrrAs    rc@s eZdZdZdd„Zdd„Zdd„Zdd „Zdd d „Zd d„Z dd„Z dd„Z dd„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)dOd„ZdPdQ„Z*dRdS„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„Zdzd{„Z?d|d}„Z@d~d„ZAd€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. cCs4x.dD]&}| d¡}| |¡}| d|j¡qWdS)zmVerify that all HTML4 and HTML5 empty element (aka void element) tags are handled correctly. )ÚareaÚbaseÚbrÚcolÚembedÚhrÚimgÚinputÚkeygenÚlinkZmenuitemÚmetaÚparamÚsourceÚtrackÚwbrZspacerÚframeÚTN)rÚnew_tagr Úis_empty_element)rrrrNrrrÚtest_empty_element_tagsñs   z0HTMLTreeBuilderSmokeTest.test_empty_element_tagscCsp| d¡}t|jjtƒst‚t|jjtƒs.t‚| d¡}t|jjtƒsJt‚| d|jj¡t|jjtƒslt‚dS)Nz7zz) rr2ÚstyleÚstringr r%Úscriptr r )rrrrrÚtest_special_string_containersýsz7HTMLTreeBuilderSmokeTest.test_special_string_containerscCsF| d¡}t |d¡}t |¡}| |jt¡| | ¡| ¡¡dS)Nz fooé)rÚpickleÚdumpsÚloadsr Ú __class__rr!)rÚtreeÚdumpedÚloadedrrrÚ!test_pickle_and_unpickle_identity s    z:HTMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identitycCsh| |¡\}}|jd}| |jt¡| ||¡| | d¡dt|ƒ…|¡| |jjdd¡dS)z8Assert that a given doctype string is handled correctly.rÚutf8NÚfoo)Ú_document_with_doctyper1r rYrÚencoder0Úp)rÚdoctype_fragmentÚ doctype_strrÚdoctyperrrÚassertDoctypeHandleds  z-HTMLTreeBuilderSmokeTest.assertDoctypeHandledÚDOCTYPEcCs,d||f}|d}| |¡}| d¡|fS)z5Generate and parse a document with the given doctype.zz

foo

r^)rra)rrcZdoctype_stringrerrrrrr`'s  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)rf)rrrrÚtest_normal_doctypes.s z-HTMLTreeBuilderSmokeTest.test_normal_doctypescCs(| d¡}|jd}| d| ¡¡dS)Nz rrM)rr1r Ústrip)rrrerrrÚtest_empty_doctype4s  z+HTMLTreeBuilderSmokeTest.test_empty_doctypecCsxxrdD]j}| d|¡\}}|jd}| |jt¡| |d¡| | d¡dt|ƒ…d¡| |jjdd¡qWdS)N)reZDocTyperhrr^sr_)r`r1r rYrrar0rb)rrcrdrrerrrÚtest_mixed_case_doctype9s    z0HTMLTreeBuilderSmokeTest.test_mixed_case_doctypecCsd}| |¡dS)Nznhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")rf)rrerrrÚtest_public_doctype_with_urlNsz5HTMLTreeBuilderSmokeTest.test_public_doctype_with_urlcCs| d¡dS)Nz$foo SYSTEM "http://www.example.com/")rf)rrrrÚtest_system_doctypeRsz,HTMLTreeBuilderSmokeTest.test_system_doctypecCs| d¡dS)Nz#xsl:stylesheet SYSTEM "htmlent.dtd")rf)rrrrÚtest_namespaced_system_doctypeUsz7HTMLTreeBuilderSmokeTest.test_namespaced_system_doctypecCs| d¡dS)Nz#xsl:stylesheet PUBLIC "htmlent.dtd")rf)rrrrÚtest_namespaced_public_doctypeYsz7HTMLTreeBuilderSmokeTest.test_namespaced_public_doctypecCs4d}| |¡}| | d¡ dd¡| dd¡¡dS)zJA real XHTML document should come out more or less the same as it went in.sÓ Hello. Goodbye. zutf-8ó óN)rr raÚreplace)rrrrrrÚtest_real_xhtml_document]s  z1HTMLTreeBuilderSmokeTest.test_real_xhtml_documentcCs(d}| |¡}| dt| d¡ƒ¡dS)ztWhen a namespaced XML document is parsed as HTML it should be treated as HTML with weird tag names. s.contentrUzns1:fooN)rr r0Úfind_all)rrrrrrÚtest_namespaced_htmljs z-HTMLTreeBuilderSmokeTest.test_namespaced_htmlcCsBd}| |¡}| || ¡¡d}| |¡}| || d¡¡dS)Nzsr^)rr r!ra)rrrrrrÚtest_processing_instructionrs   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Údeepcopyr)rrrrÚ test_deepcopysz&HTMLTreeBuilderSmokeTest.test_deepcopycCs.| d¡}| |jj¡| t|jƒd¡dS)z©A

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. z

z

N)rZ assertFalserbrOr Ústr)rrrrrÚ!test_p_tag_is_never_empty_element‡s 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. z

z

zzz
z
N)r')rrrrÚtest_unclosed_tags_get_closed‘s  z6HTMLTreeBuilderSmokeTest.test_unclosed_tags_get_closedcCs.| d¡}| |jj¡| t|jƒd¡dS)zÂA
tag is designated as an empty-element tag. Some parsers treat

as one
tag, some parsers as two tags, but it should always be an empty-element tag. z

z
N)rÚ assertTruer?rOr r{)rrrrrÚ#test_br_is_always_empty_element_tag›s z)r')rrrrÚtest_nested_formatting_elements¥sz8HTMLTreeBuilderSmokeTest.test_nested_formatting_elementscCs(d}| |¡}| d| d¡d¡dS)Nz¯ Ordinary HEAD element test Hello, world! ztext/javascriptrSÚtype)rr Úfind)rrhrrrrÚtest_double_head¨s  z)HTMLTreeBuilderSmokeTest.test_double_headcCsjd}| |¡| |¡}|jdd}| |jt¡|jdd}| ||j¡|jdd}| ||j¡dS)Nz

foobaz

Zfoobar)Útextr_Úbaz)r'rr‚r rYrr(r))rrrÚcommentr_r…rrrÚ test_comment¹s     z%HTMLTreeBuilderSmokeTest.test_commentcCstd}d}| |¡| |¡| |¡}| |j ¡|¡| |¡}| |j ¡|¡| d¡}| |j ¡d¡dS)zWhitespace must be preserved in
 and zN)r'rr ÚpreZprettifyÚtextarea)rZ
pre_markupZtextarea_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.zInside a B tagz!

A nested tag

z/

A doubly nested tag

N)r')rZb_tagZ nested_b_tagZdouble_nested_b_tagrrrÚtest_nested_inline_elementsÚs   z4HTMLTreeBuilderSmokeTest.test_nested_inline_elementscCs6| d¡}|j}| |jjjd¡| |jjd¡dS)zBlock elements can be nested.z*

Foo

ZFooN)rÚ blockquoter rbÚbrR)rrrŒrrrÚ test_nested_block_level_elementsås z9HTMLTreeBuilderSmokeTest.test_nested_block_level_elementscCsd}| |d¡| d¡dS)z$One table can go inside another one.z[zh
Here's another table:
foo
Here's another table:
foo
z{
Foo
Bar
Baz
N)r')rrrrrÚtest_correctly_nested_tablesìs z5HTMLTreeBuilderSmokeTest.test_correctly_nested_tablescCs@d}| |¡}| ddg|jd¡| |j|jddd¡dS)Nz
r_ÚbarÚclassÚdivzfoo bar)Úclass_)rr r’r‚)rrrrrrÚ*test_multivalued_attribute_with_whitespaces zCHTMLTreeBuilderSmokeTest.test_multivalued_attribute_with_whitespacecCs(d}| |¡}| dg|jjd¡dS)Nz1
Úcssr‘)rr r’)rrrrrrÚ(test_deeply_nested_multivalued_attribute s zAHTMLTreeBuilderSmokeTest.test_deeply_nested_multivalued_attributecCs(d}| |¡}| ddg|jd¡dS)NzÚarr‘)rr rh)rrrrrrÚ"test_multivalued_attribute_on_htmls z;HTMLTreeBuilderSmokeTest.test_multivalued_attribute_on_htmlcCs| dd¡dS)Nzz)r')rrrrÚ3test_angle_brackets_in_attribute_values_are_escapedszLHTMLTreeBuilderSmokeTest.test_angle_brackets_in_attribute_values_are_escapedcCs| dd¡dS)Nz$

• AT&T is in the s&p 500

u)

• AT&T is in the s&p 500

)r')rrrrÚ3test_strings_resembling_character_entity_referencesszLHTMLTreeBuilderSmokeTest.test_strings_resembling_character_entity_referencescCs| dd¡dS)Nz

Bob's Bar

z

Bob's Bar

)r')rrrrÚtest_apos_entity'sz)HTMLTreeBuilderSmokeTest.test_apos_entitycCs"d}| |¡}| d|jj¡dS)Nz%

“Hello” -☃

u“Hello†-☃)rr rbrR)rrrrrrÚ*test_entities_in_foreign_document_encoding-s zCHTMLTreeBuilderSmokeTest.test_entities_in_foreign_document_encodingcCs8d}| d|¡| d|¡| d|¡| d|¡dS)Nu

z

z

z

z

)r')rÚexpectrrrÚ0test_entities_in_attributes_converted_to_unicode9s    zIHTMLTreeBuilderSmokeTest.test_entities_in_attributes_converted_to_unicodecCs8d}| d|¡| d|¡| d|¡| d|¡dS)Nu

piñata

z

piñata

z

piñata

z

piñata

z

piñata

)r')rrrrrÚ*test_entities_in_text_converted_to_unicode@s    zCHTMLTreeBuilderSmokeTest.test_entities_in_text_converted_to_unicodecCs| dd¡dS)Nz#

I said "good day!"

z

I said "good day!"

)r')rrrrÚ,test_quot_entity_converted_to_quotation_markGszEHTMLTreeBuilderSmokeTest.test_quot_entity_converted_to_quotation_markcCs,d}| d|¡| d|¡| d|¡dS)Nu�z�z�z �)r')rrrrrÚtest_out_of_range_entityKs  z1HTMLTreeBuilderSmokeTest.test_out_of_range_entitycCs<| d¡}| d|jjjj¡| d|jj¡| |¡dS)zDMostly to prevent a recurrence of a bug in the html5lib treebuilder.z!

foo

rbN)rr Úh2rRr(rrbr,)rrrrrÚtest_multipart_stringsQs 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


z


N)r')rrrrrPXs cCs,d}| |¡}| d|jj¡| |¡dS)z8Prevent recurrence of a bug in the html5lib treebuilder.z? foo N)rZassertNotEqualrhÚbodyr,)rÚcontentrrrrÚ#test_head_tag_between_head_and_body_s z N)rr,Úarticle)rr¥rrrrÚtest_multiple_copies_of_a_tagjs  z6HTMLTreeBuilderSmokeTest.test_multiple_copies_of_a_tagcCs^d}| |¡}| || ¡¡|j}| d|jd¡| d|jd¡| d|jd¡dS) z†Parsers don't need to *understand* namespaces, but at the very least they should not choke on namespaces or lose data.sÙ4zhttp://www.w3.org/1999/xhtmlÚxmlnsz"http://www.w3.org/1998/Math/MathMLz xmlns:mathmlzhttp://www.w3.org/2000/svgz xmlns:svgN)rr rarh)rrrrhrrrÚtest_basic_namespaces{s z.HTMLTreeBuilderSmokeTest.test_basic_namespacescCs(d}| |¡}| ddg|jd¡dS)Nsr_rr‘)rr r—)rrrrrrÚ-test_multivalued_attribute_value_becomes_listŠs zFHTMLTreeBuilderSmokeTest.test_multivalued_attribute_value_becomes_listcCs"d}| |¡}| d|jj¡dS)NuDSacré bleu!u Sacré bleu!)rr r¤rR)rrrrrrÚtest_can_parse_unicode_document–s z8HTMLTreeBuilderSmokeTest.test_can_parse_unicode_documentcCs*tdƒ}|jd|d}| | ¡d¡dS)z2Parsers should be able to work with SoupStrainers.rz&A bold statement)Z parse_onlyz boldN)r rr r!)rZstrainerrrrrÚtest_soupstraineržsz*HTMLTreeBuilderSmokeTest.test_soupstrainercCs| dd¡dS)Nzz)r')rrrrÚ7test_single_quote_attribute_values_become_double_quotes¥szPHTMLTreeBuilderSmokeTest.test_single_quote_attribute_values_become_double_quotescCsd}| |¡dS)Nz'a)r')rr„rrrÚ7test_attribute_values_with_nested_quotes_are_left_alone©szPHTMLTreeBuilderSmokeTest.test_attribute_values_with_nested_quotes_are_left_alonecCs.d}| |¡}d|jd<| |j ¡d¡dS)Nz'azBrawls happen at "Bob's Bar"Úattrz:a)rr_r'r!)rr„rrrrÚ:test_attribute_values_with_double_nested_quotes_get_quoted­s   zSHTMLTreeBuilderSmokeTest.test_attribute_values_with_double_nested_quotes_get_quotedcCs| dd¡| dd¡dS)Nz+z/z.fooz2foo)r')rrrrÚ.test_ampersand_in_attribute_value_gets_escapedµs zGHTMLTreeBuilderSmokeTest.test_ampersand_in_attribute_value_gets_escapedcCs| d¡dS)Nz/)r')rrrrÚ7test_escaped_ampersand_in_attribute_value_is_left_alone½szPHTMLTreeBuilderSmokeTest.test_escaped_ampersand_in_attribute_value_is_left_alonecCsd}d}| ||¡dS)Nz-

<<sacré bleu!>>

u#

<<sacré bleu!>>

)r')rr„ÚexpectedrrrÚ1test_entities_in_strings_converted_during_parsingÀszJHTMLTreeBuilderSmokeTest.test_entities_in_strings_converted_during_parsingcCs"d}| |¡}| |jjd¡dS)Ns

‘Foo’

u ‘Foo’)rr rbrR)rÚquoterrrrÚ)test_smart_quotes_converted_on_the_way_inÇs  zBHTMLTreeBuilderSmokeTest.test_smart_quotes_converted_on_the_way_incCs| d¡}| |jjd¡dS)Nz  u  )rr r—rR)rrrrrÚ0test_non_breaking_spaces_converted_on_the_way_inÐs zIHTMLTreeBuilderSmokeTest.test_non_breaking_spaces_converted_on_the_way_incCs0d}d d¡}| |¡}| |j d¡|¡dS)Nz-

<<sacré bleu!>>

u#

<<sacré bleu!>>

zutf-8)rarr rb)rr„r´rrrrÚ&test_entities_converted_on_the_way_outÔs  z?HTMLTreeBuilderSmokeTest.test_entities_converted_on_the_way_outcCsHd}| d¡}| |¡}| d¡}| dd¡}| d¡}| ||¡dS)Nu„

Sacré bleu!

z iso-8859-1zutf-8z ISO-Latin-1)rarrsr )rÚ unicode_htmlZiso_latin_htmlrÚresultr´rrrÚtest_real_iso_latin_documentÚs     z5HTMLTreeBuilderSmokeTest.test_real_iso_latin_documentcCsLd}| d¡}| |¡}| | d¡| d¡¡| | d¡| d¡¡dS)Nsk
‚±‚ê‚ÍShift-JIS‚ŃR[ƒfƒBƒ“ƒO‚³‚ꂽ“ú–{Œê‚̃tƒ@ƒCƒ‹‚Å‚·B
z shift-jiszutf-8Úeuc_jp)r!rr ra)rÚshift_jis_htmlrºrrrrÚtest_real_shift_jis_documentõs   z5HTMLTreeBuilderSmokeTest.test_real_shift_jis_documentcCsBd}|j|dd}|jdks t‚| | d¡| d¡ d¡¡dS)Ns›Hebrew (ISO 8859-8) in Visual Directionality

Hebrew (ISO 8859-8) in Visual Directionality

íåìùz iso8859-8)Z from_encoding)z iso8859-8z iso-8859-8zutf-8)rZoriginal_encodingr%r rar!)rZhebrew_documentrrrrÚtest_real_hebrew_documents z2HTMLTreeBuilderSmokeTest.test_real_hebrew_documentcCs`d}d|}| |¡}| dddi¡}|d}| d|¡| t|tƒ¡| d| d ¡¡dS) NzEzj %s Shift-JIS markup goes here.rGz http-equivz Content-typer¥ztext/html; charset=x-sjisztext/html; charset=utf8r^)rr‚r r~r2rra)rÚmeta_tagr¾rÚ parsed_metar¥rrrÚ'test_meta_tag_reflects_current_encodings  z@HTMLTreeBuilderSmokeTest.test_meta_tag_reflects_current_encodingcCs^d}d|}| |¡}|jddd}|d}| d|¡| t|tƒ¡| d| d¡¡dS) Nz'zj %s Shift-JIS markup goes here.rGÚencoding)ÚidÚcharsetzx-sjisr^)rr‚r r~r2rra)rrÁr¾rrÂrÆrrrÚ3test_html5_style_meta_tag_reflects_current_encoding/s  zLHTMLTreeBuilderSmokeTest.test_html5_style_meta_tag_reflects_current_encodingcCs\xVdD]N}| |¡}x>tD]6}|dkr(q| |¡}d|ks>t‚| d¡|kst‚qWqWdS)N)sB)ÚidnaÚmbcsÚoemÚ undefinedÚ string_escapez string-escapesmeta charset=""Úascii)rr rar%)rrrrÄÚencodedrrrÚ2test_python_specific_encodings_not_used_in_charsetGs     zKHTMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_charsetcCs*| d¡}d|jd<| d|j ¡¡dS)Nz textrr_ztext)rr—r r!)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 ¡¡dS)Nz0

text1

text2
z)

text1

text2
)rr r¤r!)rrrrrÚ$test_closing_tag_with_no_opening_tagcs z=HTMLTreeBuilderSmokeTest.test_closing_tag_with_no_opening_tagcCs| t¡}| |¡dS)z3Test the worst case (currently) for linking issues.N)rÚ BAD_DOCUMENTr3)rrrrrÚtest_worst_casems z(HTMLTreeBuilderSmokeTest.test_worst_caseN)rg)Br8r9r:Ú__doc__rPrTr]rfr`rirkrlrmrnrorprtrvrwrzr|r}rr€rƒr‡rŠr‹rŽrr”r–r˜r™ršr›rœržrŸr r¡r£r¦r¨rªr«r¬r­r®r¯r±r²r³rµr·r¸r¹r¼r¿rÀrÃrÇrÏrÑrÒrÔrrrrr<çs€                r<c@s¬eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)S)*ÚXMLTreeBuilderSmokeTestcCsF| d¡}t |d¡}t |¡}| |jt¡| | ¡| ¡¡dS)Nz foorU)rrVrWrXr rYrr!)rrZr[r\rrrr]vs    z9XMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identitycCs| d¡}| | ¡d¡dS)Nzs. )rr ra)rrrrrÚtest_docstring_generateds z0XMLTreeBuilderSmokeTest.test_docstring_generatedcCs$d}| |¡}| || d¡¡dS)Ns, r^)rr ra)rrrrrrÚtest_xml_declaration„s z,XMLTreeBuilderSmokeTest.test_xml_declarationcCsRd}| |¡}x>tD]6}|dkr"q| |¡}d|ks8t‚| d¡|kst‚qWdS)Ns )rÈrÉrÊrËrÌz string-escapesrÍ)rr rar%)rrrrÄrÎrrrÚ:test_python_specific_encodings_not_used_in_xml_declaration‰s    zRXMLTreeBuilderSmokeTest.test_python_specific_encodings_not_used_in_xml_declarationcCs$d}| |¡}| || d¡¡dS)Ns< r^)rr ra)rrrrrrrwœs z3XMLTreeBuilderSmokeTest.test_processing_instructioncCs$d}| |¡}| | d¡|¡dS)zGA real XHTML document should come out *exactly* the same as it went in.sÓ Hello. Goodbye. zutf-8N)rr ra)rrrrrrrt¡s z0XMLTreeBuilderSmokeTest.test_real_xhtml_documentcCs"d}| |¡}| || ¡¡dS)Ns )rr ra)rÚdocrrrrÚtest_nested_namespaces­s z.XMLTreeBuilderSmokeTest.test_nested_namespacescCs0d}t|dƒ}d|j_| ¡}| d|k¡dS)Nz/ zlxml-xmlzconsole.log("< < hey > > ");s< < hey > >)rrSrRrar~)rrÚrrÎrrrÚ5test_formatter_processes_script_tag_for_xml_documents¸s  zMXMLTreeBuilderSmokeTest.test_formatter_processes_script_tag_for_xml_documentscCs"d}| |¡}| d|jj¡dS)Nu?Sacré bleu!u Sacré bleu!)rr ÚrootrR)rrrrrrr¬Äs z7XMLTreeBuilderSmokeTest.test_can_parse_unicode_documentcCs$d}| |¡}| t|jƒ|¡dS)Nzƒb2012-07-02T20:33:42Zcd)rr r{Zrss)rrrrrrÚtest_popping_namespaced_tagÉs z3XMLTreeBuilderSmokeTest.test_popping_namespaced_tagcCs | d¡}| | d¡d¡dS)NzÚlatin1s/ )rr ra)rrrrrÚ(test_docstring_includes_correct_encodingÏs z@XMLTreeBuilderSmokeTest.test_docstring_includes_correct_encodingcCs$d}| |¡}| | d¡|¡dS)z 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000zutf-8N)rr ra)rrrrrrÚtest_large_xml_documentÕs z/XMLTreeBuilderSmokeTest.test_large_xml_documentcCs| dd¡| d¡dS)Nz

z

z

foo

)r')rrrrÚ9test_tags_are_empty_element_if_and_only_if_they_are_emptyÞs zQXMLTreeBuilderSmokeTest.test_tags_are_empty_element_if_and_only_if_they_are_emptycCs8d}| |¡}|j}| d|d¡| d|d¡dS)Nz£This tag is in the a namespaceThis tag is in the b namespacezhttp://example.com/zxmlns:azhttp://example.net/zxmlns:b)rrÝr )rrrrÝrrrÚtest_namespaces_are_preservedâs  z5XMLTreeBuilderSmokeTest.test_namespaces_are_preservedcCs$d}| |¡}| t|jƒ|¡dS)NzN

20010504

)rr r{rb)rrrrrrÚtest_closing_namespaced_tagés z3XMLTreeBuilderSmokeTest.test_closing_namespaced_tagcCs$d}| |¡}| t|jƒ|¡dS)Nzs)rr r{r_)rrrrrrÚtest_namespaced_attributesîs z2XMLTreeBuilderSmokeTest.test_namespaced_attributescCs$d}| |¡}| t|jƒ|¡dS)Nzbar)rr r{r_)rrrrrrÚ(test_namespaced_attributes_xml_namespaceós z@XMLTreeBuilderSmokeTest.test_namespaced_attributes_xml_namespacecCsˆd}| |¡}| dt| d¡ƒ¡| dt| d¡ƒ¡| dt| d¡ƒ¡| dt|jddd ƒ¡| dt| ddg¡ƒ¡dS) Na foo bar baz éÚtagrUzns1:tagr-zns2:tagÚvalue)Úkey)rr r0ru)rrÚrrrrÚtest_find_by_prefixed_nameøs  z2XMLTreeBuilderSmokeTest.test_find_by_prefixed_namecCs2d}| |¡}|j}t |¡}| |j|j¡dS)Nzf )rÚdocumentrxr Úprefix)rÚxmlrrèZ duplicaterrrÚ!test_copy_tag_preserves_namespaces   z9XMLTreeBuilderSmokeTest.test_copy_tag_preserves_namespacecCs| t¡}| |¡dS)z3Test the worst case (currently) for linking issues.N)rrÓr3)rrrrrrÔs z'XMLTreeBuilderSmokeTest.test_worst_caseN)r8r9r:r]r×rØrÙrwrtrÛrÜr¬rÞràrárârãrärårærërïrÔrrrrrÖts(      rÖc@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) ÚHTML5TreeBuilderSmokeTestz2Smoke test for a tree builder that supports HTML5.cCsdS)Nr)rrrrrt#sz2HTML5TreeBuilderSmokeTest.test_real_xhtml_documentcCs"d}| |¡}| d|jj¡dS)Nz
zhttp://www.w3.org/1999/xhtml)rr r—Ú namespace)rrrrrrÚtest_html_tags_have_namespace(s z7HTML5TreeBuilderSmokeTest.test_html_tags_have_namespacecCs6d}| |¡}d}| ||jj¡| ||jj¡dS)Nzzhttp://www.w3.org/2000/svg)rr ÚsvgrñZcircle)rrrrñrrrÚtest_svg_tags_have_namespace-s  z6HTML5TreeBuilderSmokeTest.test_svg_tags_have_namespacecCs6d}| |¡}d}| ||jj¡| ||jj¡dS)Nz5z"http://www.w3.org/1998/Math/MathML)rr ÚmathrñZmsqrt)rrrrñrrrÚtest_mathml_tags_have_namespace5s  z9HTML5TreeBuilderSmokeTest.test_mathml_tags_have_namespacecCsPd}| |¡}| t|jdtƒ¡| |jdd¡| d|jdjj¡dS)Nz3rz$?xml version="1.0" encoding="utf-8"?rh)rr~r2r1rr r(r)rrrrrrÚ$test_xml_declaration_becomes_comment<s  z>HTML5TreeBuilderSmokeTest.test_xml_declaration_becomes_commentN) r8r9r:rÕrtròrôrör÷rrrrrð s rðcsdd„‰‡‡fdd„}|S)Nc_sdS)Nr)ÚtestÚargsrrrrÚnothingDszskipIf..nothingcsˆrˆS|SdS)Nr)Z test_item)Ú conditionrúrrÚ decoratorGszskipIf..decoratorr)rûÚreasonrür)rûrúrÚskipIfCsrþ)rÕÚ __license__rVrxÚ functoolsZunittestrZbs4rZ bs4.elementrrrrr r r r r Z bs4.builderrrrÓrÚobjectr<rÖrðrþrrrrÚs.  , $'-#