U ¯Dx`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ú2/tmp/pip-target-zr53vnty/lib/python/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.assertSoupEqualscCs8d}|jD](}|r.| ||j¡| ||j¡|}q dS)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 Csþd}|jdkrh|jdks,td ||jd¡ƒ‚|jdksJtd ||jd¡ƒ‚|jdkshtd ||jd¡ƒ‚d}d}d}t|jƒd}|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|ksxtd  |j|d|j|dj|¡ƒ‚|dk rÈ|j|ks¨td  ||j||jj¡ƒ‚|j|ksÈtd  ||j|¡ƒ‚t |t ƒr|jr|  |d ¡}|jdkstd  ||jd¡ƒ‚|dk r|}n|}||krF|jdksFtd  ||jd¡ƒ‚|d7}qˆ|dk r^|n|}|dkrp|}|sö|dk rö|}|dkr´|jdksòtd  ||jd¡ƒ‚qòn4|jdk rè|j|jksòtd  ||j|j¡ƒ‚qò|j}q„dS|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Útargetrrrr5ts  ÿÿ ÿÿ ÿÿ    ÿÿ ÿÿÿÿ ÿÿ ÿÿ ÿÿÿÿ ÿÿ  ÿÿ   ÿÿ ÿÿ zSoupTest.linkage_validator)N)F) Ú__name__Ú __module__Ú __qualname__Úpropertyrrrr)r.r5rrrrrAs   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. cCs0dD]&}| d¡}| |¡}| d|j¡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ÚlinkZmenuitemÚmetaÚparamÚsourceÚtrackÚwbrZspacerÚframeÚTN)rÚnew_tagr"Úis_empty_element)rrrrPrrrÚ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) rr4ÚstyleÚstringr r'Úscriptr r"©rrrrrÚtest_special_string_containersýsÿÿz7HTMLTreeBuilderSmokeTest.test_special_string_containerscCsF| d¡}t |d¡}t |¡}| |jt¡| | ¡| ¡¡dS©Nz fooé©rÚpickleÚdumpsÚloadsr"Ú __class__rr#©rÚtreeZdumpedZloadedrrrÚ!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_doctyper3r"r^rÚencoder2Úp©rÚdoctype_fragmentZ doctype_strrÚdoctyperrrÚassertDoctypeHandleds  þz-HTMLTreeBuilderSmokeTest.assertDoctypeHandledÚDOCTYPEcCs,d||f}|d}| |¡}| d¡|fS)z5Generate and parse a document with the given doctype.zz

foo

rb)rrf)rriZdoctype_stringrjrrrrrre'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©rkrrrrÚtest_normal_doctypes.s ÿz-HTMLTreeBuilderSmokeTest.test_normal_doctypescCs(| d¡}|jd}| d| ¡¡dS)Nz rrO)rr3r"Ústrip)rrrjrrrÚtest_empty_doctype4s  z+HTMLTreeBuilderSmokeTest.test_empty_doctypecCstdD]j}| d|¡\}}|jd}| |jt¡| |d¡| | d¡dt|ƒ…d¡| |jjdd¡qdS)N)rjZDocTypermrrbsrcrdrhrrrÚ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"rn)rrjrrrÚtest_public_doctype_with_urlNsz5HTMLTreeBuilderSmokeTest.test_public_doctype_with_urlcCs| d¡dS)Nz$foo SYSTEM "http://www.example.com/"rnrrrrÚtest_system_doctypeRsz,HTMLTreeBuilderSmokeTest.test_system_doctypecCs| d¡dS)Nz#xsl:stylesheet SYSTEM "htmlent.dtd"rnrrrrÚtest_namespaced_system_doctypeUsz7HTMLTreeBuilderSmokeTest.test_namespaced_system_doctypecCs| d¡dS)Nz#xsl:stylesheet PUBLIC "htmlent.dtd"rnrrrrÚ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.óÓ Hello. Goodbye. úutf-8ó óN)rr"rfÚ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.contentrYzns1:fooN©rr"r2Zfind_allr|rrrÚtest_namespaced_htmljs z-HTMLTreeBuilderSmokeTest.test_namespaced_htmlcCsBd}| |¡}| || ¡¡d}| |¡}| || d¡¡dS)Nzsrb)rr"r#rfr|rrrÚ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ÚdeepcopyrrrrrÚ 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. ú

ú

N)rZ assertFalsergrQr"ÚstrrVrrrÚ!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. ú

r…zzz
ú
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

r‰N)rÚ assertTruerArQr"r†rVrrrÚ#test_br_is_always_empty_element_tag›s zrŠrrrrÚtest_nested_formatting_elements¥sz8HTMLTreeBuilderSmokeTest.test_nested_formatting_elementscCs(d}| |¡}| d| d¡d¡dS)Nz¯ Ordinary HEAD element test Hello, world! ztext/javascriptrUÚtype)rr"Úfind)rrmrrrrÚtest_double_head¨s z)HTMLTreeBuilderSmokeTest.test_double_headcCsjd}| |¡| |¡}|jdd}| |jt¡|jdd}| ||j¡|jdd}| ||j¡dS)Nz

foobaz

Zfoobar)ÚtextrcÚbaz)r)rrr"r^rr*r+)rrrÚcommentrcr“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

NrŠ)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"rgÚbrT)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
NrŠ)rrrrrÚtest_correctly_nested_tablesìsþÿz5HTMLTreeBuilderSmokeTest.test_correctly_nested_tablescCs@d}| |¡}| ddg|jd¡| |j|jddd¡dS)Nz
rcÚbarÚclassÚdivzfoo bar)Úclass_)rr"r rr|rrrÚ*test_multivalued_attribute_with_whitespaces zCHTMLTreeBuilderSmokeTest.test_multivalued_attribute_with_whitespacecCs(d}| |¡}| dg|jjd¡dS)Nz1
ÚcssrŸ)rr"r r|rrrÚ(test_deeply_nested_multivalued_attribute s zAHTMLTreeBuilderSmokeTest.test_deeply_nested_multivalued_attributecCs(d}| |¡}| ddg|jd¡dS)NzÚar›rŸ)rr"rmr|rrrÚ"test_multivalued_attribute_on_htmls z;HTMLTreeBuilderSmokeTest.test_multivalued_attribute_on_htmlcCs| dd¡dS)NzzrŠ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_referencessþzLHTMLTreeBuilderSmokeTest.test_strings_resembling_character_entity_referencescCs| dd¡dS)Nz

Bob's Bar

z

Bob's Bar

rŠrrrrÚtest_apos_entity'sþz)HTMLTreeBuilderSmokeTest.test_apos_entitycCs"d}| |¡}| d|jj¡dS)Nz%

“Hello” -☃

u“Hello†-☃©rr"rgrTr|rrrÚ*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Šr¬rrrÚ*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_markGsÿzEHTMLTreeBuilderSmokeTest.test_quot_entity_converted_to_quotation_markcCs,d}| d|¡| d|¡| d|¡dS)Nu�z�z�z �rŠr¬rrrÚ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

rgN)rr"Úh2rTr*rrgr.rVrrrÚ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


NrŠrrrrrRXs cCs,d}| |¡}| d|jj¡| |¡dS)ú8Prevent recurrence of a bug in the html5lib treebuilder.z? foo N)rZassertNotEqualrmÚbodyr.©rÚcontentrrrrÚ#test_head_tag_between_head_and_body_s z N)rr.Úarticler¶rrrÚ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Ù4ú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"rfrm)rrrrmrrrÚtest_basic_namespaces{s ÿÿz.HTMLTreeBuilderSmokeTest.test_basic_namespacescCs(d}| |¡}| ddg|jd¡dS)NsrcržrŸ)rr"r¥r|rrrÚ-test_multivalued_attribute_value_becomes_listŠs zFHTMLTreeBuilderSmokeTest.test_multivalued_attribute_value_becomes_listcCs"d}| |¡}| d|jj¡dS)NuDSacré bleu!õ Sacré bleu!)rr"rµrTr|rrrÚ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.r›z&A bold statement)Z parse_onlyz boldN)r rr"r#)rZstrainerrrrrÚtest_soupstraineržs ÿz*HTMLTreeBuilderSmokeTest.test_soupstrainercCs| dd¡dS)NzzrŠrrrrÚ7test_single_quote_attribute_values_become_double_quotes¥sÿzPHTMLTreeBuilderSmokeTest.test_single_quote_attribute_values_become_double_quotescCsd}| |¡dS)Nú'arŠ)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)NrÅzBrawls happen at "Bob's Bar"Úattrz:a)rrcr)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.fooz2foorŠ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)Nú-

<<sacré bleu!>>

õ#

<<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’rª)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¥rTrVrrrÚ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)NrËrÌrx)rfrr"rg)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-1rxz ISO-Latin-1)rfrr{r")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-jisrxÚeuc_jp)r#rr"rf)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

íåìùú iso8859-8)Z from_encoding)rÙz iso-8859-8rx)rZoriginal_encodingr'r"rfr#)rZhebrew_documentrrrrÚtest_real_hebrew_documentsÿþz2HTMLTreeBuilderSmokeTest.test_real_hebrew_documentcCs`d}d|}| |¡}| dddi¡}|d}| d|¡| t|tƒ¡| d| d ¡¡dS) NzEúj %s Shift-JIS markup goes here.rIz http-equivz Content-typer·ztext/html; charset=x-sjisztext/html; charset=utf8rb)rrr"rŒr4rrf)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'rÛrIÚencoding)ÚidÚcharsetzx-sjisrb)rrr"rŒr4rrf)rrÜr×rrÝrárrrÚ3test_html5_style_meta_tag_reflects_current_encoding/sý  zLHTMLTreeBuilderSmokeTest.test_html5_style_meta_tag_reflects_current_encodingcCsTdD]J}| |¡}tD]6}|dkr$q| |¡}d|ks:t‚| d¡|kst‚qqdS)N)sB©ÚidnaÚmbcsÚoemZ undefinedZ string_escapez string-escapesmeta charset=""Úascii©rr rfr'©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 textržrcztext)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#rVrrrÚ$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_DOCUMENTr5rVrrrÚtest_worst_casems z(HTMLTreeBuilderSmokeTest.test_worst_caseN)rl)Br:r;r<Ú__doc__rRrWrarkrerorqrrrsrtrurvr}rr€rƒr‡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¡| | ¡| ¡¡dSrXrZr_rrrravs    z9XMLTreeBuilderSmokeTest.test_pickle_and_unpickle_identitycCs| d¡}| | ¡d¡dS)Nús. ©rr"rfrVrrrÚtest_docstring_generateds  ÿz0XMLTreeBuilderSmokeTest.test_docstring_generatedcCs$d}| |¡}| || d¡¡dS)Ns, rbrör|rrrÚtest_xml_declaration„s z,XMLTreeBuilderSmokeTest.test_xml_declarationcCsNd}| |¡}tD]6}|dkr q| |¡}d|ks6t‚| d¡|kst‚qdS)Ns rãsrçrè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< rbrör|rrrr€œs z3XMLTreeBuilderSmokeTest.test_processing_instructioncCs$d}| |¡}| | d¡|¡dS)zGA real XHTML document should come out *exactly* the same as it went in.rwrxNrör|rrrr}¡s  ÿz0XMLTreeBuilderSmokeTest.test_real_xhtml_documentcCs"d}| |¡}| || ¡¡dS)Ns rö©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 > >)rrUrTrfrŒ)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!rÁ)rr"ÚrootrTr|rrrrÂÄs z7XMLTreeBuilderSmokeTest.test_can_parse_unicode_documentcCs$d}| |¡}| t|jƒ|¡dS)Nzƒb2012-07-02T20:33:42Zcd)rr"r†Zrssr|rrrÚtest_popping_namespaced_tagÉs  ÿz3XMLTreeBuilderSmokeTest.test_popping_namespaced_tagcCs | d¡}| | d¡d¡dS)NrõÚlatin1s/ rörVrrrÚ(test_docstring_includes_correct_encodingÏs  þz@XMLTreeBuilderSmokeTest.test_docstring_includes_correct_encodingcCs$d}| |¡}| | d¡|¡dS)z 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000rxNrör|rrrÚtest_large_xml_documentÕs z/XMLTreeBuilderSmokeTest.test_large_xml_documentcCs| dd¡| d¡dS)Nrˆr„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†rgr|rrrÚtest_closing_namespaced_tagés z3XMLTreeBuilderSmokeTest.test_closing_namespaced_tagcCs$d}| |¡}| t|jƒ|¡dS)Nzs©rr"r†rcr|rrrÚtest_namespaced_attributesîs z2XMLTreeBuilderSmokeTest.test_namespaced_attributescCs$d}| |¡}| t|jƒ|¡dS)Nzbarrr|rrrÚ(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 éÚtagrYzns1:tagr/zns2:tagÚvalue)Úkeyr~rúrrrÚtest_find_by_prefixed_nameøs z2XMLTreeBuilderSmokeTest.test_find_by_prefixed_namecCs2d}| |¡}|j}t |¡}| |j|j¡dS)Nzf )rÚdocumentrr"Úprefix)rÚxmlrr Z duplicaterrrÚ!test_copy_tag_preserves_namespaces   z9XMLTreeBuilderSmokeTest.test_copy_tag_preserves_namespacecCs| t¡}| |¡dSrïrðrVrrrròs z'XMLTreeBuilderSmokeTest.test_worst_caseN)r:r;r<rar÷rørùr€r}rürýrÂrÿrrrrrrrr rròrrrrrôts(      rôc@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) ÚHTML5TreeBuilderSmokeTestz2Smoke test for a tree builder that supports HTML5.cCsdSrrrrrrr}#sz2HTML5TreeBuilderSmokeTest.test_real_xhtml_documentcCs"d}| |¡}| d|jj¡dS)Nz
r»)rr"r¥Ú namespacer|rrrÚtest_html_tags_have_namespace(s z7HTML5TreeBuilderSmokeTest.test_html_tags_have_namespacecCs6d}| |¡}d}| ||jj¡| ||jj¡dS)Nzr¾)rr"ÚsvgrZcircle©rrrrrrrÚtest_svg_tags_have_namespace-s  z6HTML5TreeBuilderSmokeTest.test_svg_tags_have_namespacecCs6d}| |¡}d}| ||jj¡| ||jj¡dS)Nz5r½)rr"ÚmathrZmsqrtrrrrÚ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"?rm)rrŒr4r3rr"r*rr|rrrÚ$test_xml_declaration_becomes_comment<s  z>HTML5TreeBuilderSmokeTest.test_xml_declaration_becomes_commentN) r:r;r<rór}rrrrrrrrr s rcsdd„‰‡‡fdd„}|S)Nc_sdSrr)ÚtestÚargsrrrrÚnothingDszskipIf..nothingcsˆrˆS|SdSrr)Z test_item©Ú conditionrrrÚ decoratorGszskipIf..decoratorr)rÚreasonr rrrÚskipIfCsr")róÚ __license__r[rÚ functoolsZunittestrZbs4rZ bs4.elementrrrrr r r r r Z bs4.builderrrrñrÚobjectr>rôrr"rrrrÚs.  , %'-#