ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ _[c@sdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z ddl m Z mZmZmZmZmZmZmZddlmZmZe jdek Ze jd ek Zd efd YZd efd YZdefdYZdefdYZdefdYZ defdYZ!defdYZ"defdYZ#defdYZ$de$fdYZ%de$fdYZ&d efd!YZ'd"e'fd#YZ(d$e'fd%YZ)d&efd'YZ*d(efd)YZ+d*efd+YZ,d,efd-YZ-d.efd/YZ.d0efd1YZ/d2efd3YZ0d4efd5YZ1d6efd7YZ2dS(8s8Tests for Beautiful Soup's tree traversal methods. The tree traversal methods are the main advantage of using Beautiful Soup over just using a parser. Different parsers will build different Beautiful Soup trees given the same markup, but all Beautiful Soup trees can be traversed with the methods tested here. i(t set_traceN(t BeautifulSoup(tbuilder_registrytHTMLParserTreeBuilder(tPY3KtCDatatCommentt DeclarationtDoctypetNavigableStringt SoupStrainertTag(tSoupTesttskipIftxmltlxmltTreeTestcBseZdZdZRS(cCs*|jg|D]}|j^q |dS(sMake 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(t assertEqualtstring(tselfttagst should_matchttag((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt assertSelects+scCs+|jg|D]}|d^q |dS(sMake 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. tidN(R(RRRR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytassertSelectsIDs4s(t__name__t __module__RR(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR)s tTestFindcBs;eZdZdZdZdZdZdZRS(sBasic tests of the find() method. find() just calls find_all() with limit=1, so it's not tested all that thouroughly here. cCs/|jd}|j|jdjddS(Ns 1234tbt2(tsoupRtfindR(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt test_find_tagEscCs/|jd}|j|jddddS(Nu

Räksmörgås

Ru Räksmörgås(RRR (RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_unicode_text_findIscCs<|jd}t||jd|jddjdS(Nu&

here it is

s here it isRu Räksmörgås(RtstrRR ttext(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_unicode_attribute_findMs cCs/|jd}|jdt|jdS(s)Test an optimization that finds all tags.sfoobariN(RRtlentfind_all(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_everythingSscCs2|jd}|jdt|jddS(s;Test an optimization that finds all tags with a given name.sfoobarbazitaN(RRR&R'(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_everything_with_nameXs(RRt__doc__R!R"R%R(R*(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR>s     t TestFindAllcBs;eZdZdZdZdZdZdZRS(s%Basic tests of the find_all() method.cCs|jd}|j|jdddg|j|jdddg|j|jdddgddg|j|jdtjdddd g|j|jdtddd gd S( s'You can search the tree for text nodes.sFoobarRtbarubarR$tFoouFoos.*u»N(RRR'tretcompiletTrue(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_text_nodes`s"cCs|jd}|j|jddddddg|j|jddddg|j|jddd dddd d g|j|jddd dddd d gd S(s7You can limit the number of items returned by find_all.s(12345R)tlimitit1Rt3ii t4t5iN(RRR'(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_limitps("(cCsQ|jd}|j|ddddg|j|jdddgdS( Ns!123R)R3iR4RtfooR5(RRR(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%test_calling_a_tag_is_calling_findall|scCs?|jd}g}|j||jg|j|dS(Ns(RtappendRR'(RRtl((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytTtest_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursions cCs|jd}|jd}|jt|d|jt}|jt|d|jdd}|jt|ddS(s%All find_all calls return a ResultSetsR)tsourceR$R9N(RR't assertTruethasattrR1(RRtresult((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_resultsets(RRR+R2R8R:R=RB(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR,]s    tTestFindAllBasicNamespacescBseZdZRS(cCsU|jd}|jd|jdj|jd|jdidd6jdS(Ns04R6s mathml:msqrtR)tattrstredssvg:fill(RRR Rtname(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_by_namespaced_names(RRRG(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRCstTestFindAllByNamecBsqeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( s&Test ways of finding tags by tag name.cCs)tt|j|jd|_dS(NsFirst tag. Second tag. Third Nested tag. tag.(tsuperRtsetUpRttree(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJscCs&|j|jjdddgdS(NR)s First tag.s Nested tag.(RRKR'(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_tag_namescCs|j|jjddddg|j|jjddtddg|j|jjddtjdddgdS(NR)R$s First tag.s Nested tag.R(RRKR'R1R/R0(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_name_and_texts"cCs&|j|jjjddgdS(NR)s Nested tag.(RRKtcR'(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!test_find_all_on_non_root_elementscCs#|j|jdddgdS(NR)s First tag.s Nested tag.(RRK(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%test_calling_element_invokes_find_allscCs,|j|jjtdddgdS(NR)s First tag.s Nested tag.(RRKR'R (R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_tag_strainerscCs/|j|jjddgdddgdS(NR)Rs First tag.s Second tag.s Nested tag.(RRKR'(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_tag_namesscCs7|j|jjitd6td6dddgdS(NR)Rs First tag.s Second tag.s Nested tag.(RRKR'R1(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_tag_dictscCs2|j|jjtjddddgdS(Ns^[ab]$s First tag.s Second tag.s Nested tag.(RRKR'R/R0(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_tag_rescCs;d}|jd}|j|j|ddgdS(NcSs|j|jdkS(NR(RFtget(R((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytid_matches_namessMatch 1. Does not match. Match 2.sMatch 1.sMatch 2.(RRR'(RRVRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'test_find_all_with_tags_matching_methods   cCs|jd}|jdd}|jdtjd}|jdddg\}}|jd|j|jd|j|jd|j|jd|jdS(NsH
1
2
3
tdivsa dsa bR5R4(RR R/R0R'RR(RRtr1tr2tr3tr4((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%test_find_with_multi_valued_attributes (RRR+RJRLRMRORPRQRRRSRTRWR](((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRHs         tTestFindAllByAttributecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZRS(cCs5|jd}|j|jddddgdS(Ns Matching a. Non-matching Matching b.a. Rtfirsts Matching a.s Matching b.(RRR'(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_attribute_names cCsdjd}djd}|j|}|j|jg|jd||j|jg|jd|jd|j|jg|jd|dgdS(Nuםולשtutf8uttitlessomething else(tencodeRRR)R'tdecode(RtpeacetdataR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%test_find_all_by_utf8_attribute_values "+cCs~|jd}|j|jdddg|j|jdidd6dg|j|jdidd6d gdS( Ns0 Name match. Class match. Non-match. A tag called 'name1'. RFtname1sA tag called 'name1'.RDs Name match.tclass2tclasss Class match.(RRR'(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_attribute_dicts   cCs|jd}|j|jddddg|j|jddddg|j|jddd dg|j|jdddg|j|jd dddg|j|jdddg|j|jdd dgdS( Ns Class 1. Class 2. Class 1. Class 3 and 4. R)tclass_R4sClass 1.RNR5sClass 3 and 4.R6RD(RRR'(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyttest_find_all_by_classs """"cCs|jd}|jddtjd}|j|dg|jddtjd}|j|dg|jddtjd}|j|dgdS(Ns#Found ittgarRltosFound itR)so b(RR'R/R0R(RRKtf((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt0test_find_by_class_when_multiple_classes_present-scCs|jd}|j|jdtjddgd}|j|jd|gd}|j|jd|dgdS(NsFound itR)tbasFound itcSst|dkS(Ni(R&(tvalue((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytbig_attribute_value@scSst|dkS(Ni(R&(Rs((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytsmall_attribute_valueEs(RRR'R/R0(RRRtRu((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt:test_find_all_with_non_dictionary_for_attrs_finds_by_class;s(  cCs|jd}|jd\}}|j||g|jdd|j|g|jdd|j|g|jddd|j|g|jdd|jg|jdddS(Ns*R)R9R-Rlsfoo barsbar foo(RR'R(RRR)ta2((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt:test_find_all_with_string_for_attrs_finds_multiple_classesKs""cCsE|jd}tdidd6}|j|j|dgdS(Nsi Match. Non-match.RDR_RsMatch.(RR RR'(RRKtstrainer((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'test_find_all_by_attribute_soupstrainerWs cCs5|jd}|j|jddddgdS(NsID present. No ID present. ID is empty.R)RsNo ID present.(RRR'tNone(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$test_find_all_with_missing_attribute_s cCs5|jd}|j|jdtddgdS(NsID present. No ID present. ID is empty.Rs ID present.s ID is empty.(RRR'R1(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$test_find_all_with_defined_attributegs cCsW|jd}ddg}|j|jdd||j|jdd|dS(Ns[Unquoted attribute. Quoted attribute.sUnquoted attribute.sQuoted attribute.RiR4(RRR'(RRKtexpected((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$test_find_all_with_numeric_attributeps   cCs>|jd}|j|jddddgddgdS(Ns1 2 3 No ID.RR4R5R6(RRR'(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(test_find_all_with_list_attribute_valuesys cCs>|jd}|j|jdtjdddgdS(NsOne a. Two as. Mixed as and bs. One b. No ID.Rs^a+$sOne a.sTwo as.(RRR'R/R0(RRK((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt5test_find_all_with_regular_expression_attribute_values cCs||jd}|j}|j|g|jddd|jg|jddd|jg|jddddS(NsfoobarfooR)R$R9R-(RR)RR'(RRR)((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'test_find_by_name_and_containing_strings  "cCs;|jd}|j|jd|jddddS(Ns"foofooR)R$R9(RRR'(RR((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt=test_find_by_name_and_containing_string_when_string_is_buriedscCsc|jd}|j}|j|g|jdddd|jg|jdddddS(Ns"foofooRiR$R9iR-(RR)RR'(RRR)((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,test_find_by_attribute_and_containing_strings %(RRR`RgRkRmRqRvRxRzR|R}RRRRRR(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR^s          t TestIndexcBseZdZdZRS(sTest Tag.indexcCsk|jd}|j}x6t|jD]%\}}|j||j|q(W|jt|jddS(Nsh
Identical Not identical Identical Identical with child Also not identical Identical with child
i(RRXt enumeratetcontentsRtindext assertRaisest ValueError(RRKRXtitelement((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt test_indexs   (RRR+R(((s7/usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRstTestParentOperationscBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s;Test navigation and searching through an element's parents.cCs8tt|j|jd|_|jj|_dS(Ns1