
    +g7                        S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	J
r
JrJrJr  SSKJr  SSKJr   " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r / S'Qr! " S( S)\5      r" " S* S+\5      r#g),a8  Tests 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.
    N)BeautifulSoup)builder_registry)!AttributeResemblesVariableWarningCDataCommentNavigableStringTag)SoupStrainer   )SoupTestc                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)TestFind   z&Basic tests of the find() method.
    c                 h    U R                  S5      nUR                  S5      R                  S:X  d   eg )Nz <a>1</a><b>2</b><a>3</a><b>4</b>b2)soupfindstringselfr   s     [/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/bs4/tests/test_tree.pytest_find_tagTestFind.test_find_tag"   s-    yy;<yy~$$+++    c                 P    U R                  S5      nUR                  SS9S:X  d   eg )Nu   <h1>Räksmörgås</h1>   Räksmörgåsr   )r   r   r   s     r   test_unicode_text_findTestFind.test_unicode_text_find&   s*    yy12yyy0OCCCr   c                 z    U R                  S5      n[        U5        SUR                  SS9R                  :X  d   eg )Nu&   <h1 id="Räksmörgås">here it is</h1>z
here it isr   id)r   strr   textr   s     r   test_unicode_attribute_find$TestFind.test_unicode_attribute_find*   s7    yyABD	tyyOy<AAAAAr   c                 d    U R                  S5      nS[        UR                  5       5      :X  d   eg)z)Test an optimization that finds all tags.<a>foo</a><b>bar</b>   Nr   lenfind_allr   s     r   test_find_everythingTestFind.test_find_everything/   s*    yy/0C((((r   c                 f    U R                  S5      nS[        UR                  S5      5      :X  d   eg)z;Test an optimization that finds all tags with a given name.z<a>foo</a><b>bar</b><a>baz</a>r*   aNr+   r   s     r   test_find_everything_with_name'TestFind.test_find_everything_with_name4   s-    yy9:Cc*++++r   c                 "   U R                  S5      nSUR                  5       R                  :X  d   eSUR                  S5      R                  5       R                  :X  d   eSUR                  S5      R	                  5       R                  :X  d   eg )Nz<div></div><p></p>divpr   r   namefind_previous_siblingfind_next_siblingr   s     r   test_find_with_no_arguments$TestFind.test_find_with_no_arguments9   sv    yy-.		(((((		#<<>CCCCCdii&88:?????r   c                 "   U R                  S5      nSUR                  5       R                  :X  d   eSUR                  S5      R                  5       R                  :X  d   eSUR                  S5      R	                  5       R                  :X  d   eg )Nz"text<div>text</div>text<p>text</p>r5   r6   r7   r   s     r   +test_find_with_no_arguments_only_finds_tags4TestFind.test_find_with_no_arguments_only_finds_tags?   sv    yy=>		(((((		#<<>CCCCCdii&88:?????r    N)__name__
__module____qualname____firstlineno____doc__r   r   r&   r.   r2   r;   r>   __static_attributes__r@   r   r   r   r      s.    ,DB
)
,
@@r   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)TestFindAllF   z%Basic tests of the find_all() method.c                 0   U R                  S5      nS[        UR                  R                  5       5      :X  d   eS[        UR	                  S5      R                  5       5      :X  d   eS[        UR	                  S5      R                  5       5      :X  d   eg )Nz/<body>text<div>text</div>text<p>text</p></body>r*   r   r6   r5   )r   r,   bodyr-   r   find_previous_siblingsfind_next_siblingsr   s     r   /test_find_all_with_no_arguments_only_finds_tags;TestFindAll.test_find_all_with_no_arguments_only_finds_tagsI   sz    yyJKC		**,----C		#==?@@@@C		%(;;=>>>>r   c                    U R                  S5      nUR                  SS9S/:X  d   eUR                  SS/S9SS/:X  d   eUR                  [        R                  " S5      S9/ SQ:X  d   eUR                  SS9/ SQ:X  d   eg)	z'You can search the tree for text nodes.u   <html>Foo<b>bar</b>»</html>barr   Fooz.*)rR   rQ      »TN)r   r-   recompiler   s     r   test_find_all_text_nodes$TestFindAll.test_find_all_text_nodesO   s    yy9:}}E}*ug555 }}UEN}3u~EEE}}BJJt$4}59OOOO}}D})-CCCCr   c                 4   U R                  S5      nU R                  UR                  SSS9/ SQ5        U R                  UR                  SSS9S/5        U R                  UR                  SSS9/ S	Q5        U R                  UR                  SS
S9/ S	Q5        g)z7You can limit the number of items returned by find_all.z(<a>1</a><a>2</a><a>3</a><a>4</a><a>5</a>r1      limit)1r   3r   r\   
   )r\   r   r]   45r   Nr   assert_selectsr-   r   s     r   test_find_all_limitTestFindAll.test_find_all_limit\   s    yyCDDMM#QM7IDMM#QM7#?DMM#RM8:ST 	DMM#QM79RSr   c                     U R                  S5      nU R                  U" SSS9S/5        U R                  UR                  SS9S/5        g )	Nz!<a>1</a><b>2<a id='foo'>3</a></b>r1   r   rZ   r\   foor"   r]   )r   rb   r   r   s     r   %test_calling_a_tag_is_calling_findall1TestFindAll.test_calling_a_tag_is_calling_findallf   sG    yy<=DA.6DFFeF,se4r   c                 F   U R                  S5      n/ nUR                  U5        [        R                  " SS9 n/ UR	                  U5      :X  d   eUu  nUR
                  [        :X  d   e[        UR                  5      nUS:X  d   e S S S 5        g ! , (       d  f       g = f)N<a></a>TrecordzLIgnoring nested list [[...]] to avoid the possibility of infinite recursion.)	r   appendwarningscatch_warningsr-   filename__file__r$   message)r   r   selfrefwwarningmsgs         r   Ttest_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursion`TestFindAll.test_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursionk   s     yy#w $$D1Qw////IW##x///goo&Cabb 211s   AB
B c                     U R                  S5      nUR                  S5      n[        US5      (       d   eUR                  S5      n[        US5      (       d   eUR                  SS9n[        US5      (       d   eg)z%All find_all calls return a ResultSetrj   r1   sourceTrf   r   N)r   r-   hasattrr   r   results      r   test_find_all_resultset#TestFindAll.test_find_all_resultset   su    yy#s#vx((((t$vx((((e,vx((((r   r@   N)rA   rB   rC   rD   rE   rN   rV   rc   rg   rw   r~   rF   r@   r   r   rH   rH   F   s%    /?DT5
(
)r   rH   c                       \ rS rSrS rSrg)TestFindAllBasicNamespaces   c                     U R                  S5      nSUR                  S5      R                  :X  d   eSUR                  SS0S9R                  :X  d   eg )Nz0<mathml:msqrt>4</mathml:msqrt><a svg:fill="red">r_   zmathml:msqrtr1   zsvg:fillredattrs)r   r   r   r8   r   s     r   test_find_by_namespaced_name7TestFindAllBasicNamespaces.test_find_by_namespaced_name   sR    yyKLdii/66666diiz5&9i:?????r   r@   N)rA   rB   rC   rD   r   rF   r@   r   r   r   r      s    @r   r   c                   ^    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rS rS rS rSrg)TestFindAllByName   z&Test ways of finding tags by tag name.Nc                 0    U R                  S5      U l        g )Nz<a>First tag.</a>
                                  <b>Second tag.</b>
                                  <c>Third <a>Nested tag.</a> tag.</c>r   treer   s    r   setup_methodTestFindAllByName.setup_method   s    II J K	r   c                 ^    U R                  U R                  R                  S5      SS/5        g Nr1   
First tag.Nested tag.rb   r   r-   r   s    r   test_find_all_by_tag_name+TestFindAllByName.test_find_all_by_tag_name   s&    DII..s3lM5RSr   c                 2   U R                  U R                  R                  SSS9S/5        U R                  U R                  R                  SSS9SS/5        U R                  U R                  R                  S[        R                  " S5      S9SS/5        g )Nr1   r   r   Tr   tagrb   r   r-   rT   rU   r   s    r   test_find_all_by_name_and_text0TestFindAllByName.test_find_all_by_name_and_text   s    IIs<8<.	
 	IIs40<2O	
 	IIs2::e+<==)	
r   c                 p    U R                  U R                  R                  R                  S5      S/5        g )Nr1   r   )rb   r   cr-   r   s    r   !test_find_all_on_non_root_element3TestFindAllByName.test_find_all_on_non_root_element   s'    DIIKK005Gr   c                 J    U R                  U R                  S5      SS/5        g r   )rb   r   r   s    r   %test_calling_element_invokes_find_all7TestFindAllByName.test_calling_element_invokes_find_all   s    DIIcN\=,IJr   c                 p    U R                  U R                  R                  [        S5      5      SS/5        g r   )rb   r   r-   r
   r   s    r   test_find_all_by_tag_strainer/TestFindAllByName.test_find_all_by_tag_strainer   s.    II|C01L-3P	
r   c                 b    U R                  U R                  R                  SS/5      / SQ5        g )Nr1   r   r   zSecond tag.r   r   r   s    r   test_find_all_by_tag_names,TestFindAllByName.test_find_all_by_tag_names   s)    IISz*,X	
r   c                 d    U R                  U R                  R                  SSS.5      / SQ5        g )NT)r1   r   r   r   r   s    r   test_find_all_by_tag_dict+TestFindAllByName.test_find_all_by_tag_dict   s*    IIT568	
r   c                     U R                  U R                  R                  [        R                  " S5      5      / SQ5        g )Nz^[ab]$r   r   r   s    r   test_find_all_by_tag_re)TestFindAllByName.test_find_all_by_tag_re   s.    IIrzz(348	
r   c                 r    S nU R                  S5      nU R                  UR                  U5      SS/5        g )Nc                 >    U R                   U R                  S5      :H  $ )Nr#   )r8   getr   s    r   id_matches_nameRTestFindAllByName.test_find_all_with_tags_matching_method.<locals>.id_matches_name   s    88swwt},,r   z<a id="a">Match 1.</a>
                            <a id="1">Does not match.</a>
                            <b id="b">Match 2.</a>zMatch 1.zMatch 2.ra   )r   r   r   s      r   'test_find_all_with_tags_matching_method9TestFindAllByName.test_find_all_with_tags_matching_method   s<    	- yy 6 7 	DMM/:Z<TUr   c                 R   U R                  S5      nUR                  SS5      nUR                  S[        R                  " S5      5      nUR	                  SSS/5      u  pESUR
                  :X  d   eSUR
                  :X  d   eSUR
                  :X  d   eSUR
                  :X  d   eg )NzH<div class='a b'>1</div><div class='a c'>2</div><div class='a d'>3</div>r5   za dza br]   r\   )r   r   rT   rU   r-   r   )r   r   r1r2r3r4s         r   %test_find_with_multi_valued_attribute7TestFindAllByName.test_find_with_multi_valued_attribute   s    yyV
 YYue$YYubjj01uuen5biibiibiibiir   r   returnN)rA   rB   rC   rD   rE   r   r   r   r   r   r   r   r   r   r   r   rF   r@   r   r   r   r      sA    0K
T
HK






V
 r   r   c                   t    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rSrg)TestFindAllByAttribute   c                 h    U R                  S5      nU R                  UR                  SS9SS/5        g )Nz
                         <a id="first">Matching a.</a>
                         <a id="second">
                          Non-matching <b id="first">Matching b.</b>a.
                         </a>firstr"   zMatching a.zMatching b.ra   r   r   s     r   test_find_all_by_attribute_name6TestFindAllByAttribute.test_find_all_by_attribute_name   s9     yy ! "
 	DMMWM5}7UVr   c                 X   SR                  S5      nSR                  S5      nU R                  U5      nUR                  /UR                  US9:X  d   eUR                  /UR                  UR	                  S5      S9:X  d   eUR                  /(       d   UR                  US/S95       eg )Nu   םולשutf8u   <a title="םולש"></a>)titlezsomething else)encoder   r1   r-   decode)r   peacedatar   s       r   %test_find_all_by_utf8_attribute_value<TestFindAllByAttribute.test_find_all_by_utf8_attribute_value   s    !!&))008yyx4==u=5555x4==u||F/C=DDDDxGe5E-FGGxr   c                     U R                  S5      nU R                  UR                  SS9S/5        U R                  UR                  SS0S9S/5        U R                  UR                  SS	0S9S
/5        g )Na0  
                         <a name="name1" class="class1">Name match.</a>
                         <a name="name2" class="class2">Class match.</a>
                         <a name="name3" class="class3">Non-match.</a>
                         <name1>A tag called 'name1'.</name1>
                         name1r8   zA tag called 'name1'.r8   r   zName match.classclass2zClass match.ra   r   s     r   test_find_all_by_attribute_dict6TestFindAllByAttribute.test_find_all_by_attribute_dict   s}     yy   	DMMwM7:Q9RSDMM0AMB]OTDMM(0CMD~FVWr   c                     U R                  S5      nU R                  UR                  SSS9S/5        U R                  UR                  SSS9S/5        U R                  UR                  SS	S9S/5        U R                  UR                  SS5      S/5        U R                  UR                  SS
9SS/5        U R                  UR                  SS5      S/5        U R                  UR                  SS	5      S/5        g )Nz
                         <a class="1">Class 1.</a>
                         <a class="2">Class 2.</a>
                         <b class="1">Class 1.</b>
                         <c class="3 4">Class 3 and 4.</c>
                         r1   r\   class_zClass 1.r   r]   zClass 3 and 4.r_   r   ra   r   s     r   test_find_all_by_class-TestFindAllByAttribute.test_find_all_by_class  s    yy   	DMM#cM:ZLIDMM#cM:=M<NODMM#cM:=M<NO 	DMM#s3j\BDMMM4z:6NODMM#s36F5GHDMM#s36F5GHr   c                 p   U R                  S5      nUR                  S[        R                  " S5      S9nU R	                  US/5        UR                  S[        R                  " S5      S9nU R	                  US/5        UR                  S[        R                  " S5      S9nU R	                  US/5        g )Nz#<gar class='foo bar'>Found it</gar>garor   Found itr1   zo b)r   r-   rT   rU   rb   )r   r   fs      r   0test_find_by_class_when_multiple_classes_presentGTestFindAllByAttribute.test_find_by_class_when_multiple_classes_present  s    yy>?MM%

3M8A
|,MM%

3M8A
|, MM%

5(9M:A
|,r   c                 *   U R                  S5      nU R                  UR                  S[        R                  " S5      5      S/5        S nU R                  UR                  SU5      / 5        S nU R                  UR                  SU5      S/5        g )Nz<a class='bar'>Found it</a>r1   bar   c                     [        U 5      S:  $ NrY   r,   values    r   big_attribute_valuenTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_class.<locals>.big_attribute_value/  s    u:>!r   c                     [        U 5      S:*  $ r   r   r   s    r   small_attribute_valuepTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_class.<locals>.small_attribute_value4  s    u:?"r   r   rb   r-   rT   rU   )r   r   r   r   s       r   :test_find_all_with_non_dictionary_for_attrs_finds_by_classQTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_class*  s    yy67DMM#rzz$/?@:,O	" 	DMM#/BCRH	# 	DMM#/DE
|Tr   c                 X   U R                  S5      nUR                  S5      u  p#X#/(       d   UR                  SS5      5       eU/(       d   UR                  SS5      5       eU/UR                  SSS9:X  d   eU/UR                  SS5      :X  d   e/ UR                  SS5      :X  d   eg )Nz*<a class="foo bar"></a><a class="foo"></a>r1   rf   rQ   zfoo barr   zbar foor   r-   )r   r   r1   a2s       r   :test_find_all_with_string_for_attrs_finds_multiple_classesQTestFindAllByAttribute.test_find_all_with_string_for_attrs_finds_multiple_classes9  s    yyEFc"w1c511ws-DMM#u--s sdmmC	m::::sdmmC3333T]]3	2222r   c                     U R                  S5      n[        SS0S9nU R                  UR                  U5      S/5        g )Nzi
                         <a id="first">Match.</a>
                         <a id="second">Non-match.</a>r#   r   r   zMatch.)r   r
   rb   r-   )r   r   strainers      r   'test_find_all_by_attribute_soupstrainer>TestFindAllByAttribute.test_find_all_by_attribute_soupstrainerE  s@    yy : ;  tWo6DMM(3hZ@r   c                 h    U R                  S5      nU R                  UR                  SS S9S/5        g )N<a id="1">ID present.</a>
                            <a>No ID present.</a>
                            <a id="">ID is empty.</a>r1   r"   zNo ID present.ra   r   s     r   $test_find_all_with_missing_attribute;TestFindAllByAttribute.test_find_all_with_missing_attributeM  s:     yy 9 : 	DMM#$M7:J9KLr   c                 h    U R                  S5      nU R                  UR                  SS9SS/5        g )Nr  Tr"   zID present.zID is empty.ra   r   s     r   $test_find_all_with_defined_attribute;TestFindAllByAttribute.test_find_all_with_defined_attributeU  s9     yy 9 : 	DMMTM2]N4STr   c                     U R                  S5      nSS/nU R                  UR                  SS9U5        U R                  UR                  SS9U5        g )Nz[<a id=1>Unquoted attribute.</a>
                            <a id="1">Quoted attribute.</a>zUnquoted attribute.zQuoted attribute.r   r"   r\   ra   )r   r   expecteds      r   $test_find_all_with_numeric_attribute;TestFindAllByAttribute.test_find_all_with_numeric_attribute]  sY    yy ? @ *+>?DMMQM/:DMMSM18<r   c                     U R                  S5      nU R                  UR                  / SQS9SS/5        U R                  UR                  / S9/ 5        g )Nz<a id="1">1</a>
                            <a id="2">2</a>
                            <a id="3">3</a>
                            <a>No ID.</a>)r\   r]   r_   r"   r\   r]   ra   r   s     r   (test_find_all_with_list_attribute_values?TestFindAllByAttribute.test_find_all_with_list_attribute_valuesf  sU     yy - . 	DMM_M=SzJ 	DMMRM0"5r   c                     U R                  S5      nU R                  UR                  [        R                  " S5      S9SS/5        g )Nz<a id="a">One a.</a>
                            <a id="aa">Two as.</a>
                            <a id="ab">Mixed as and bs.</a>
                            <a id="b">One b.</a>
                            <a>No ID.</a>z^a+$r"   zOne a.zTwo as.r   r   s     r   5test_find_all_with_regular_expression_attribute_valueLTestFindAllByAttribute.test_find_all_with_regular_expression_attribute_valuer  sB     yy - . 	DMMRZZ-?M@8YBWXr   c                     U R                  S5      nUR                  nU/UR                  SSS9:X  d   e/ UR                  SSS9:X  d   eg )Nz<b>foo</b><b>bar</b><a>foo</a>r1   rf   r   rQ   r   r1   r-   r   r   r1   s      r   'test_find_by_name_and_containing_string>TestFindAllByAttribute.test_find_by_name_and_containing_string~  sR    yy9:FFsdmmCm6666T]]3u]5555r   c                 p    U R                  S5      nUR                  S5      UR                  SSS9:X  d   eg )Nz"<a>foo</a><a><b><c>foo</c></b></a>r1   rf   r   r   r   s     r   =test_find_by_name_and_containing_string_when_string_is_buriedTTestFindAllByAttribute.test_find_by_name_and_containing_string_when_string_is_buried  s5    yy=>}}S!T]]3u]%EEEEr   c                     U R                  S5      nUR                  nU/UR                  SSS9:X  d   e/ UR                  SSS9:X  d   eg )Nz"<b id="1">foo</b><a id="2">foo</a>r*   rf   )r#   r   r   rQ   r  r  s      r   ,test_find_by_attribute_and_containing_stringCTestFindAllByAttribute.test_find_by_attribute_and_containing_string  sR    yy=>FFsdmmqm7777T]]a]6666r   r@   N)rA   rB   rC   rD   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  rF   r@   r   r   r   r      s\    WHX$I(-U
3AMU=
6
Y6F7r   r   c                       \ rS rSrSrS rSrg)
TestSmoothi  zTest Tag.smooth.c                 "   U R                  S5      nUR                  nUR                  S5        UR                  S5        UR                  [        S5      5        UR                  [        S5      5        UR                  S5        U R	                  5       n[        XS5      nUR                  S5        UR                  S	5        UR                  U5        S UR                  R                  L d   eS
[        UR                  5      :X  d   eUR                  5         S[        UR                  5      :X  d   eSUR                  S   :X  d   eSUR                  R                  :X  d   eSUR                  S   :X  d   eSUR                  S   :X  d   eg )Nz<div>a</div>r   r   z	Comment 1z	Comment 2dspanr\   r         abcr   12r   r*   )r   r5   rm   r   default_builderr	   r   r   r,   contentssmooth)r   r   r5   builderr   s        r   test_smoothTestSmooth.test_smooth  sG   yy(hh

3

3

7;'(

7;'(

3&&(4&)CC

4 sxx&&&C%%%%

C%%%%
 Q''' sxx&&&
 cll1o---cll1o---r   r@   N)rA   rB   rC   rD   rE   r)  rF   r@   r   r   r  r    s
    &.r   r  c                       \ rS rSrSrS rSrg)	TestIndexi  zTest Tag.indexc                 0   U R                  S5      nUR                  n[        UR                  5       H  u  p4X2R	                  U5      :X  a  M   e   [
        R                  " [        5         UR	                  S5        S S S 5        g ! , (       d  f       g = f)Nah  <div>
                            <a>Identical</a>
                            <b>Not identical</b>
                            <a>Identical</a>

                            <c><d>Identical with child</d></c>
                            <b>Also not identical</b>
                            <c><d>Identical with child</d></c>
                            </div>r   )r   r5   	enumerater&  indexpytestraises
ValueError)r   r   r5   ielements        r   
test_indexTestIndex.test_index  sm    yy & ' hh#CLL1JA		'**** 2]]:&JJqM '&&s   ,B
Br@   N)rA   rB   rC   rD   rE   r5  rF   r@   r   r   r,  r,    s
    r   r,  c                   X    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rS rS rSrg)TestParentOperationsi  z;Test navigation and searching through an element's parents.Nc                 f    U R                  S5      U l        U R                  R                  U l        g )Na<  <ul id="empty"></ul>
                                 <ul id="top">
                                  <ul id="middle">
                                   <ul id="bottom">
                                    <b id="start">Start here</b>
                                   </ul>
                                  </ul>)r   r   r   startr   s    r   r   !TestParentOperations.setup_method  s(    II + ,	 YY[[
r   c                     U R                   R                  S   S:X  d   eU R                   R                  R                  S   S:X  d   eU R                   R                  R                  R                  S   S:X  d   eg )Nr#   bottommiddletop)r:  parentr   s    r   test_parent TestParentOperations.test_parent  sk    zz  &(222zz  ''-999zz  ''..t4===r   c                 n    U R                   R                  S   nUR                  U R                   :X  d   eg )Nr   )r   r&  r@  )r   top_tags     r   %test_parent_of_top_tag_is_soup_object:TestParentOperations.test_parent_of_top_tag_is_soup_object  s,    ))$$Q'~~***r   c                 :    S U R                   R                  L d   eg N)r   r@  r   s    r   test_soup_object_has_no_parent3TestParentOperations.test_soup_object_has_no_parent  s    tyy'''''r   c                     U R                  U R                  R                  S5      / SQ5        U R                  U R                  R                  SSS9S/5        U R                  R                  SS9/ :X  d   eg )Nulr=  r>  r?  r>  r"   r:  )assert_selects_idsr:  find_parentsr   s    r   test_find_parents&TestParentOperations.test_find_parents  sm    JJ##D)+F	
 	

 7 7 7 JXJWzz&&'&2b888r   c                     U R                   R                  SSS9S   S:X  d   eU R                   R                  SS9b   eg )NrL  r?  r"   r#   r:  )r:  find_parentr   s    r   test_find_parent%TestParentOperations.test_find_parent  sG    zz%%du%5d;uDDDzz%%%1999r   c                 n    U R                   R                  SS9nUR                  R                  S:X  d   eg )N
Start herer   r   )r   r   r@  r8   r   r%   s     r   test_parent_of_text_element0TestParentOperations.test_parent_of_text_element  s.    yy~~\~2{{3&&&r   c                 j    U R                   R                  SS9nUR                  S5      S   S:X  d   eg )NrW  r   rL  r#   r=  )r   r   rS  rX  s     r   test_text_element_find_parent2TestParentOperations.test_text_element_find_parent  s4    yy~~\~2%d+x777r   c                     U R                   R                   Vs/ s H  nUc  M  SUR                  ;   d  M  US   PM!     nnU/ SQ:X  d   eg s  snf )Nr#   rM  )r:  parentsr   )r   r@  r_  s      r   test_parent_generator*TestParentOperations.test_parent_generator  s^     **,,
, &*fll&: F4L, 	 

 5555
   AA	Ac                     U R                   R                   Vs/ s H  nUc  M  SUR                  ;   d  M  US   PM!     nnU/ SQ:X  d   eg s  snf )Nr#   )r:  r=  r>  r?  )r:  self_and_parentsr   )r   r@  resultss      r   test_self_and_parent_generator3TestParentOperations.test_self_and_parent_generator  s^     **55
5 &*fll&: F4L5 	 

 >>>>
rb  )r:  r   r   )rA   rB   rC   rD   rE   r   rA  rE  rI  rP  rT  rY  r\  r`  rf  rF   r@   r   r   r8  r8    s7    E!>
+(9:'86?r   r8  c                       \ rS rSrSS jrSrg)ProximityTesti  Nc                 0    U R                  S5      U l        g )Nz<html id="start"><head id="headtag"></head><body id="bodytag"><b id="1">One</b><b id="2">Two</b><b id="3">Three</b></body></html>r   r   s    r   r   ProximityTest.setup_method  s    II P
	r   r   r   rA   rB   rC   rD   r   rF   r@   r   r   ri  ri    s    
r   ri  c                   V   ^  \ rS rSrSU 4S jjrS rS rS rS rS r	S r
S	 rS
rU =r$ )TestNextOperationsi  c                 `   > [         [        U ]  5         U R                  R                  U l        g rH  )superrn  r   r   r   r:  r   	__class__s    r   r   TestNextOperations.setup_method  s      $46YY[[
r   c                     U R                   R                  S:X  d   eU R                   R                  R                  S   S:X  d   eg )NOner#   r   )r:  next_elementr   s    r   	test_nextTestNextOperations.test_next  s=    zz&&%///zz&&33D9S@@@r   c                 T    U R                   R                  SS9nUR                  b   eg NThreer   )r   r   rv  )r   lasts     r   test_next_of_last_item_is_none1TestNextOperations.test_next_of_last_item_is_none   s(    yy~~W~-  (((r   c                 6    U R                   R                  b   eg rH  )r   rv  r   s    r   test_next_of_root_is_none,TestNextOperations.test_next_of_root_is_none$  s    yy%%---r   c                     U R                  U R                  R                  S5      SS/5        U R                  R                  SS9  U R                  U R                  R                  SS9S/5        g )Nr   Twor{  rY   r"   )rb   r:  find_all_nextr   s    r   test_find_all_next%TestNextOperations.test_find_all_next(  s_    DJJ44S9E7;KL

  A &DJJ444:WIFr   c                     U R                   R                  S5      S   S:X  d   eU R                   R                  SS9S:X  d   eg )Nr   r#   r   r{  r   )r:  	find_nextr   s    r   test_find_next!TestNextOperations.test_find_next-  sD    zz##C(.#555zz##7#3w>>>r   c                     U R                   R                  SS9nUR                  S5      R                  S:X  d   eU R	                  UR                  S5      SS/5        g )Nru  r   r   r  r{  )r   r   r  r   rb   r  rX  s     r   test_find_next_for_text_element2TestNextOperations.test_find_next_for_text_element1  sS    yy~~U~+~~c"))U222D..s3eW5EFr   c                    U R                   R                  SS9nUR                   Vs/ s H  o"PM     nnUu  pEUS   S:X  d   eUS:X  d   eUR                   Vs/ s H  o"PM     nnUSS  U:X  d   eUS   U:X  d   eg s  snf s  snf )Nr  r   r#   r]   r{  r   r   )r   r   next_elementsself_and_next_elements)r   r:  node
successorsr   r&  successors2s          r   test_next_generators'TestNextOperations.test_next_generators6  s    		e,',':':;':td':
;"4yC7"""(-(D(DE(Dt(DE12*,,,1~&&& < Fs   A>Br:  r   )rA   rB   rC   rD   r   rw  r}  r  r  r  r  r  rF   __classcell__rr  s   @r   rn  rn    s3    !A).G
?G

' 
'r   rn  c                   V   ^  \ rS rSrSU 4S jjrS rS rS rS rS r	S r
S	 rS
rU =r$ )TestPreviousOperationsiC  c                 f   > [         [        U ]  5         U R                  R	                  SS9U l        g rz  )rp  r  r   r   r   endrq  s    r   r   #TestPreviousOperations.setup_methodD  s'    $d8:99>>>1r   c                     U R                   R                  S   S:X  d   eU R                   R                  R                  S:X  d   eg )Nr#   r]   r  )r  previous_elementr   s    r   test_previous$TestPreviousOperations.test_previousH  s=    xx((.#555xx((99UBBBr   c                 X    U R                   R                  S5      nUR                  b   eg )Nhtml)r   r   r  )r   r   s     r   #test_previous_of_first_item_is_none:TestPreviousOperations.test_previous_of_first_item_is_noneL  s&    		v&%%---r   c                 6    U R                   R                  b   eg rH  )r   r  r   s    r   test_previous_of_root_is_none4TestPreviousOperations.test_previous_of_root_is_noneP  s    yy))111r   c                     U R                  U R                  R                  S5      / SQ5        U R                  U R                  R                  SS9S/5        g )Nr   r{  r  ru  r   r"   ru  )rb   r  find_all_previousr   s    r   test_find_all_previous-TestPreviousOperations.test_find_all_previousT  sH     	DHH66s;=TUDHH66!6<ugFr   c                     U R                   R                  S5      S   S:X  d   eU R                   R                  SS9S:X  d   eg )Nr   r#   r]   ru  r   )r  find_previousr   s    r   test_find_previous)TestPreviousOperations.test_find_previous[  sD    xx%%c*40C777xx%%U%3u<<<r   c                     U R                   R                  SS9nUR                  S5      R                  S:X  d   eU R	                  UR                  S5      / SQ5        g )Nr{  r   r   r  )r   r   r  r   rb   r  rX  s     r   #test_find_previous_for_text_element:TestPreviousOperations.test_find_previous_for_text_element_  sQ    yy~~W~-!!#&--888D22379PQr   c                     U R                   R                  SSS9nU R                  UR                  / SQ5        U R                  UR                  / SQ5        g )Nr   ru  r   )bodytagheadtagr:  )r\   r  r  r:  )r   r   rN  previous_elementsself_and_previous_elements)r   r:  s     r   test_previous_generators/TestPreviousOperations.test_previous_generatorsd  sF    		s51 7 79XY @ @Bfgr   r  r   )rA   rB   rC   rD   r   r  r  r  r  r  r  r  rF   r  r  s   @r   r  r  C  s5    2C.2G=R
h hr   r  c                       \ rS rSrSS jrSrg)SiblingTestij  Nc                     Sn[         R                  " S5      R                  SU5      nU R                  U5      U l        g )Na  <html>
                    <span id="1">
                     <span id="1.1"></span>
                    </span>
                    <span id="2">
                     <span id="2.1"></span>
                    </span>
                    <span id="3">
                     <span id="3.1"></span>
                    </span>
                    <span id="4"></span>
                    </html>z\n\s* )rT   rU   subr   r   )r   markups     r   r   SiblingTest.setup_methodk  s6     H%))"f5IIf%	r   r   r   rl  r@   r   r   r  r  j  s    &r   r  c                   V   ^  \ rS rSrSU 4S jjrS rS rS rS rS r	S r
S	 rS
rU =r$ )TestNextSiblingi~  c                 f   > [         [        U ]  5         U R                  R	                  SS9U l        g )Nr\   r"   )rp  r  r   r   r   r:  rq  s    r   r   TestNextSibling.setup_method  s&    ot13YY^^s^+
r   c                 6    U R                   R                  b   eg rH  )r   next_siblingr   s    r   !test_next_sibling_of_root_is_none1TestNextSibling.test_next_sibling_of_root_is_none  s    yy%%---r   c                     U R                   R                  S   S:X  d   eU R                   R                  R                  S   S:X  d   eU R                   R                  S   S:X  d   eg )Nr#   r   r]   1.1)r:  r  rv  r   s    r   test_next_sibling!TestNextSibling.test_next_sibling  sa    zz&&t,333zz&&33D9S@@@ zz&&t,555r   c                     U R                   R                  R                  b   eU R                   R                  SS9nUR                  b   eU R                   R                  SS9nUR                  b   eg )Nr  r"   r_   )r   r  r  r   )r   nested_span	last_spans      r   test_next_sibling_may_not_exist/TestNextSibling.test_next_sibling_may_not_exist  sh    yy~~**222iinnn.''///IINNcN*	%%---r   c                 L    U R                   R                  S5      S   S:X  d   eg )Nr   r#   r   )r:  r:   r   s    r   test_find_next_sibling&TestNextSibling.test_find_next_sibling  s$    zz++F3D9S@@@r   c                     U R                  U R                  R                  S5      / SQ5        U R                  U R                  R                  SS9S/5        g )Nr   r   r]   r_   r]   r"   )rN  r:  rM   r   s    r   test_next_siblings"TestNextSibling.test_next_siblings  sE    

 = =f EW

 = = = EuMr   c                     U R                  U R                  R                  / SQ5        U R                  U R                  R                  / SQ5        g )Nr  )r\   r   r]   r_   )rN  r:  next_siblingsself_and_next_siblingsr   s    r   test_next_siblings_generators-TestNextSibling.test_next_siblings_generators  s7    

 8 8/J

 A ACWXr   c                 F   U R                  S5      nUR                  SS9nUR                  R                  S:X  d   eUR                  R                  S:X  d   eU R	                  UR                  S5      S/5        UR                  SS9S:X  d   eUR                  SS9b   eg )NFoo<b>bar</b>bazrR   r   r   bazrQ   nonesuch)r   r   r  r8   rb   rM   r:   r   r   r:  s      r   "test_next_sibling_for_text_element2TestNextSibling.test_next_sibling_for_text_element  s    yy+,			'!!&&#---!!..%777E44S9E7C&&e&4===&&j&9AAAr   r  r   )rA   rB   rC   rD   r   r  r  r  r  r  r  r  rF   r  r  s   @r   r  r  ~  s5    ,.6.AN
YB Br   r  c                   V   ^  \ rS rSrSU 4S jjrS rS rS rS rS r	S r
S	 rS
rU =r$ )TestPreviousSiblingi  c                 f   > [         [        U ]  5         U R                  R	                  SS9U l        g )Nr_   r"   )rp  r  r   r   r   r  rq  s    r   r    TestPreviousSibling.setup_method  s'    !45799>>S>)r   c                 6    U R                   R                  b   eg rH  )r   previous_siblingr   s    r   %test_previous_sibling_of_root_is_none9TestPreviousSibling.test_previous_sibling_of_root_is_none  s    yy))111r   c                     U R                   R                  S   S:X  d   eU R                   R                  R                  S   S:X  d   eU R                   R                  S   S:X  d   eg )Nr#   r]   r   z3.1)r  r  r  r   s    r   test_previous_sibling)TestPreviousSibling.test_previous_sibling  sa    xx((.#555xx((99$?3FFF xx((.%777r   c                     U R                   R                  R                  b   eU R                   R                  SS9nUR                  b   eU R                   R                  SS9nUR                  b   eg )Nr  r"   r\   )r   r  r  r   )r   r  
first_spans      r   #test_previous_sibling_may_not_exist7TestPreviousSibling.test_previous_sibling_may_not_exist  sh    yy~~..666iinnn.++333YY^^s^+
**222r   c                 L    U R                   R                  S5      S   S:X  d   eg )Nr   r#   r]   )r  r9   r   s    r   test_find_previous_sibling.TestPreviousSibling.test_find_previous_sibling  s$    xx--f5d;sBBBr   c                     U R                  U R                  R                  S5      / SQ5        U R                  U R                  R                  SS9S/5        g )Nr   r]   r   r\   r\   r"   )rN  r  rL   r   s    r   test_previous_siblings*TestPreviousSibling.test_previous_siblings  sJ    HH++F3_	
 	 ? ?3 ? G#Or   c                     U R                  U R                  R                  / SQ5        U R                  U R                  R                  / SQ5        g )Nr  )r_   r]   r   r\   )rN  r  previous_siblingsself_and_previous_siblingsr   s    r   !test_previous_siblings_generators5TestPreviousSibling.test_previous_siblings_generators  s7     : :OL C CEYZr   c                 F   U R                  S5      nUR                  SS9nUR                  R                  S:X  d   eUR                  R                  S:X  d   eU R	                  UR                  S5      S/5        UR                  SS9S:X  d   eUR                  SS9b   eg )Nr  r  r   r   rR   rQ   r  )r   r   r  r8   rb   rL   r9   r  s      r   &test_previous_sibling_for_text_element:TestPreviousSibling.test_previous_sibling_for_text_element  s    yy+,			'%%**c111%%66%???E88=wG**%*8EAAA****=EEEr   r  r   )rA   rB   rC   rD   r   r  r  r  r  r  r  r  rF   r  r  s   @r   r  r    s5    *283CP[F Fr   r  c                   (   \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS r\R6                  R9                  SS S /5      S 5       r\R6                  R9                  SS S/S S /45      S! 5       rS" rS# r S$ r!S% r"S& r#S' r$S( r%S) r&S* r'S+ r(S, r)S- r*S. r+S/ r,S0 r-S1 r.S2 r/S3 r0S4 r1S5 r2S6 r3S7 r4S8 r5\R6                  R9                  S9/ S:Q5      S; 5       r6S< r7S= r8S> r9S? r:S@ r;SAr<gB)CTestTreeModificationi  c                 Z   U R                  S5      nSUR                  S'   UR                  5       U R                  S5      :X  d   eUR                  S	 UR                  5       U R                  S5      :X  d   eSUR                  S'   UR                  5       U R                  S5      :X  d   eg )	Nz<a id="1"></a>r*   r#   z<a id="2"></a>rj   rf   id2z<a id2="foo"></a>)r   r1   r   document_forr   s     r   test_attribute_modification0TestTreeModification.test_attribute_modification  s    yy)*t{{} 1 12B CCCCFF4L{{} 1 1) <<<<u{{} 1 12E FFFFr   c                 D   [         R                  " S5      " 5       nU R                  SUS9n[        X!S5      n[        X!S5      nSUS'   UR                  R                  SU5        UR                  R                  S	U5        UR                  R                  5       S
:X  d   eg )Nr  z<body></body>r(  r1   olzhttp://foo.com/hrefr   r   s4   <body><a href="http://foo.com/"></a><ol></ol></body>)r   lookupr   r	   rK   insertr   )r   r(  r   r1   r  s        r   test_new_tag_creation*TestTreeModification.test_new_tag_creation  s    "))&13yy'y:s#%%&			A		BIIFG	
Gr   c                    SnU R                  U5      nUR                  SS9nUR                  nUR                  SS9R                  UR                  5        UR                  U:X  d   eUR                  5       U R                  S5      :X  d   eg )NzT<p id="1">Don't leave me <b>here</b>.</p>
                <p id="2">Don't leave!</p>r   r"   zD<p id="1">Don't leave me .</p>
<p id="2">Don't leave!<b>here</b></p>)r   r   r   rm   r@  r   r
  )r   docr   second_parabolds        r   !test_append_to_contents_moves_tag6TestTreeModification.test_append_to_contents_moves_tag  s    /yy~ii3i'vv 			S	  ( {{k))){{} 1 1X!
 
 	
 
r   c                    U R                  S5      nUR                  S5      nUR                  UR                  S5      5      nUR                  S:X  d   eUR                  SUR                  S5      5      u  nUR                  S:X  d   eUR                  S5      nUS:X  d   eUR                  SS5      nUSS/:X  d   eUR                  S	S
5      nUS	S
/:X  d   eUR                  SS/5      nUSS/:X  d   eUR                  5       S:X  d   eg )Nz<html></html>r  headr   r   r`   r]   r_   67893456789)
r   r   rm   new_tagr8   r  insert_beforeinsert_afterextendget_text)	r   r   r  r  r   text5text34text67text89s	            r   &test_insertion_returns_inserted_things;TestTreeModification.test_insertion_returns_inserted_things  s   yy)yy {{4<</0yyF"""++ag!67zzW$$$S!||$$S#.#s#####C-#s###sCj)#s###~~9,,,r   c                     SnU R                  U5      nUR                  nUR                  UR                  5      nX4:X  d   eg )Nz<a></a><b><c></c></b>)r   r1   replace_withr   r   r%   r   r1   new_as        r   1test_replace_with_returns_thing_that_was_replacedFTestTreeModification.test_replace_with_returns_thing_that_was_replaced  s9    &yyFFtvv&zzr   c                 p    SnU R                  U5      nUR                  nUR                  5       nX4:X  d   eg )N<a><b></b><c></c></a>)r   r1   unwrapr/  s        r   +test_unwrap_returns_thing_that_was_replaced@TestTreeModification.test_unwrap_returns_thing_that_was_replaced   s2    &yyFF
zzr   c                    U R                  S5      nUR                  nUR                  5         S UR                  L d   e[        R
                  " [        5         UR                  5         S S S 5        [        R
                  " [        5         UR                  UR                  5        S S S 5        g ! , (       d  f       NM= f! , (       d  f       g = f)Nz<a><b>Foo</b></a><c>Bar</c>)
r   r1   extractr@  r0  r1  r2  r5  r.  r   r  s      r   Itest_replace_with_and_unwrap_give_useful_exception_when_tag_has_no_parent^TestTreeModification.test_replace_with_and_unwrap_give_useful_exception_when_tag_has_no_parent'  s    yy67FF			qxx]]:&HHJ ']]:&NN466" '& '&&&s   B1C1
B?
Cc                     SnU R                  U5      nUR                  nUR                  R                  U5      nXC:X  d   eUR                  5       U R	                  U5      :X  d   eg )Nz-<a><b></b><c>Foo<d></d></c></a><a><e></e></a>)r   r   r.  r   r
  )r   r%   r   r   r}   s        r   test_replace_tag_with_itself1TestTreeModification.test_replace_tag_with_itself1  sZ    >yyFF$$Q'{{{{} 1 1$ 7777r   c                     SnU R                  U5      n[        R                  " [        5         UR                  R                  UR                  5        S S S 5        g ! , (       d  f       g = fN<a><b></b></a>)r   r0  r1  r2  r   r.  r1   r   r%   r   s      r   1test_replace_tag_with_its_parent_raises_exceptionFTestTreeModification.test_replace_tag_with_its_parent_raises_exception9  sB    yy]]:&FF' '&&s   &A
A+c                     SnU R                  U5      n[        R                  " [        5         UR                  R                  SUR                  5        S S S 5        g ! , (       d  f       g = f)NrA  r   )r   r0  r1  r2  r1   r  rB  s      r   ,test_insert_tag_into_itself_raises_exceptionATestTreeModification.test_insert_tag_into_itself_raises_exception?  sB    yy]]:&FFMM!TVV$ '&&s   'A
A,c           	         U R                  S5      nUR                  SUR                  SSS9UR                  SSS95      u  p#SUR                  :X  d   eSUR                  :X  d   e[	        UR
                  5      u  pBp5SUR                  :X  d   eSUR                  :X  d   eSUR                  :X  d   eSUR                  :X  d   eg )	N-<p>And now, a word:</p><p>And we're back.</p>r   r6   p2r   p3And now, a word:And we're back.)r   r  r"  r   listchildren)r   r   rJ  rK  p1p4s         r   test_insert_multiple_elements2TestTreeModification.test_insert_multiple_elementsE  s    yyHIQS >SY]@^_ryy   ryy   dmm,!RYY...ryy   ryy    BII---r   c                    U R                  S5      nSnU R                  U5      nUR                  SU5      u  pESUR                  :X  d   eSUR                  :X  d   eUR                   H  n[	        U[
        5      (       d  M   e   [        UR                  5      u  ptpXSUR                  :X  d   eSUR                  :X  d   eSUR                  :X  d   eSUR                  :X  d   eg)	zInserting one BeautifulSoup object into another actually inserts all
of its children -- you'll never combine BeautifulSoup objects.
rI  z<p>p2</p><p>p3</p>r   rJ  rK  rL  rM  N)r   r  r   descendants
isinstancer   rN  rO  )	r   r   r%   	to_insertrJ  rK  r3  rP  rQ  s	            r   1test_insert_beautifulsoup_object_inserts_childrenFTestTreeModification.test_insert_beautifulsoup_object_inserts_childrenQ  s     yyHI#IIdO	Q	*ryy   ryy   !!A!!]3333 " dmm,!RYY...ryy   ryy    BII---r   c                     U R                  S5      nUR                  nUR                  SS5        UR                  u  p4UR	                  S5        UR	                  S5        SUR
                  R                  :X  d   eg )Nz<p><a>one</a><b>three</b></p>r   twor  three)r   r1   r  r&  r.  r   r   )r   r   r1   leftrights        r   3test_replace_with_maintains_next_element_throughoutHTestTreeModification.test_replace_with_maintains_next_element_throughoutf  si    yy89FF	E jj"2 $&&--'''r   c                 6   U R                  S5      nUR                  SS9R                  S5        UR                  SS9nUR                  nUR                  U:X  d   eUR
                  U:X  d   eUR                  R                  U:X  d   eUR                  b   eg )Nz<b>Argh!</b>Argh!r   Hooray!)r   r   r.  r   r  r@  rv  )r   r   new_textr   s       r   test_replace_final_node,TestTreeModification.test_replace_final_nodet  s    yy(			!..y999I9.FF((A---!###((55AAA$$,,,r   c                    U R                  S5      nUR                  R                  SS5        UR                  5       U R	                  S5      :X  d   eUR                  SS9nUR                  S:X  d   eUR                  R                  U:X  d   eUR                  S:X  d   eUR                  R                  U:X  d   eUR                  b   eUR                  UR                  :X  d   eg )Nz<a><b>Argh!</b><c></c></a>r   rc  z!<a><b>Argh!Hooray!</b><c></c></a>r   rb  )r   r   r  r   r
  r   r  rv  r  r  r   )r   r   rd  s      r   test_consecutive_text_nodes0TestTreeModification.test_consecutive_text_nodes~  s     yy56a#{{} 1 12U VVVV99I9.((G333((55AAA((G333((55AAA$$,,,$$...r   c                 $   U R                  S5      nUR                  R                  SS5        UR                  R                  SS5        SS/UR                  R                  :X  d   eUR                  R                  S   R                  S:X  d   eg )Nrj   r   rQ   rf   )r   r1   r  r&  rv  r   s     r   test_insert_string'TestTreeModification.test_insert_string  so    yy#aau~000vvq!..%777r   c                     U R                  S5      nUR                  R                  S5      nUS:X  d   eUR                  R                  5       S:X  d   eg )Nz<b>1</b>r   z	<b>12</b>)r   r   rm   r   r|   s      r   test_append TestTreeModification.test_append  sF    yy$s#}}vv}}+---r   c                    U R                  5       nU R                  SUS9n[        X!S5      nUR                  SS5        UR                  R                  SU5        UR                  5       U R                  S5      :X  d   eUR                  nUR                  U:X  d   eUR                  U:X  d   eUR                  SS	9nUR                  U:X  d   eUR                  U:X  d   eUR                  nUR                  U:X  d   eUR                  U:X  d   eUR                  SS	9nUR                  U:X  d   eUR                  U:X  d   eUR                  U:X  d   eg )
Nz%<a><b>Find</b><c>lady!</c><d></d></a>r  magictagr   ther   z=<a><b>Find</b><magictag>the</magictag><c>lady!</c><d></d></a>Findr   )r%  r   r	   r  r1   r   r
  r   r  r  r   rv  r  r   r@  )r   r(  r   	magic_tagb_tagr   c_tagrr  s           r   test_insert_tag$TestTreeModification.test_insert_tag  s_   &&(yy@'yRz2	E"a#{{} 1 1K!
 
 	
 

 !!Y...))U222zzz(  I---))T111%%...%%222nnEn*zzY&&&5(((%%,,,r   c                     SnU R                  U5      nUR                  R                  SUR                  5        XR	                  5       :X  d   eg )Nz<a>b<c></c>d</a>r   )r   r1   r  r   r   r   r   r   s      r   %test_insert_into_the_current_location:TestTreeModification.test_insert_into_the_current_location  s<    !yya {{}$$$r   c                     SnU R                  U5      nUR                  R                  UR                  5        XR	                  5       :X  d   eg r@  )r   r1   rm   r   r   rz  s      r   *test_append_child_thats_already_at_the_end?TestTreeModification.test_append_child_thats_already_at_the_end  s:    yydff{{}$$$r   c                    SnU R                  U5      nUR                  UR                  UR                  UR                  UR
                  UR                  /nUR                  R                  U5        SUR                  5       :X  d   eg )Nz1<a><b><c><d><e><f><g></g></f></e></d></c></b></a>z1<a><g></g><f></f><e></e><d></d><c></c><b></b></a>)
r   gr   er  r   r   r1   r%  r   r   r   r   elementss       r   #test_extend_with_a_list_of_elements8TestTreeModification.test_extend_with_a_list_of_elements  sb    ByyFFDFFDFFDFFDFFDFFChBdkkmSSSr   c                     SnU R                  U5      nSS[        S5      S/nUR                  R                  U5        SUR	                  5       :X  d   eg )Nrj   r   r   r  r  z<a>bcde</a>)r   r   r1   r%  r   r  s       r   "test_extend_with_a_list_of_strings7TestTreeModification.test_extend_with_a_list_of_strings  sK    yyoc2C8h---r   get_tagsc                     U $ rH  r@   r   s    r   <lambda>TestTreeModification.<lambda>  s    cr   c                     U R                   $ rH  )r&  r   s    r   r  r    s    s||r   c                     SnU R                  U5      nUR                  SSS9nUR                  SSS9nU" U5      nUR                  U5        SUR                  5       :X  d   eSUR                  5       :X  d   eg )NzS<body><div id="d1"><a>1</a><a>2</a><a>3</a><a>4</a></div><div id="d2"></div></body>r5   d1r"   d2z<div id="d1"></div>z3<div id="d2"><a>1</a><a>2</a><a>3</a><a>4</a></div>)r   r   r%  r   )r   r  r   r   r  r  tagss          r   &test_extend_with_another_tags_contents;TestTreeModification.test_extend_with_another_tags_contents  st    dyyYYuY&YYuY&|
		$$		333D		SSSr   zstring_source,resultc                 .    U R                   R                  $ rH  )r1   r   r   s    r   r  r    s    $&&--r   z<a></a><b>1</b>c                     g)Nabcder@   r  s    r   r  r    s    'r   z<a>1</a><b>abcde</b>c                 |   SnU R                  U5      n[        R                  " SS9 nU" U5      nUR                  R	                  U5        UR
                  R                  5       U:X  d   eUu  nUR                  [        :X  d   e[        UR                  5      nUS:X  d   e S S S 5        g ! , (       d  f       g = f)Nz<div><a>1</a><b></b></div>Trk   zIA single non-Tag item was passed into Tag.extend. Use Tag.append instead.)r   rn   ro   r   r%  r5   decode_contentsrp   rq   r$   rr   )	r   string_sourcer}   r   r   rt   r   ru   rv   s	            r   )test_extend_with_a_single_non_tag_element>TestTreeModification.test_extend_with_a_single_non_tag_element  s     ,yy$$D1Q"4(FFFMM&!88++-777IW##x///goo&C^__ 211s   A;B--
B;c                     SnU R                  U5      nUR                  R                  SUR                  5        SUR	                  5       :X  d   eg )Nz<a><b></b><c></c><d></d></a>r   z<a><d></d><b></b><c></c></a>)r   r1   r  r  r   rz  s      r   $test_move_tag_to_beginning_of_parent9TestTreeModification.test_move_tag_to_beginning_of_parent  s>    -yya ->>>r   c                     U R                  S5      nUR                  R                  SS5        [        UR                  5      S:X  d   eg )Nz<br/>r   Contentsz<br>Contents</br>)r   brr  r$   r   s     r   &test_insert_works_on_empty_element_tag;TestTreeModification.test_insert_works_on_empty_element_tag  s;    
 yy!q*%477|2222r   c                 2   U R                  S5      nUR                  R                  S5        UR                  R                  S5        UR	                  5       U R                  S5      :X  d   eUR                  R                  UR                  5        UR	                  5       U R                  S5      :X  d   eUR                  n[        R                  " [        5         UR                  U5        S S S 5        UR                  5         [        R                  " [        5         UR                  S5        S S S 5        U R                  S5      nUR                  R                  UR                  S5      5        g ! , (       d  f       N= f! , (       d  f       N[= f)	Nr)   BAZQUUXzQUUX<a>foo</a>BAZ<b>bar</b>QUUX<b>bar</b><a>foo</a>BAZnope<a>r1   )r   r   r#  r1   r   r
  r0  r1  r2  r9  r"  r   r   r   s      r   test_insert_before'TestTreeModification.test_insert_before  s   yy/0U#V${{} 1 12O PPPPTVV${{} 1 12O PPPP FF]]:&OOA ' 	
		]]:&OOF# ' yyT\\#./ '&
 '&   E7!F7
F
Fc                 z   U R                  S5      nUR                  R                  SSS5        UR                  R                  SSS5        UR	                  5       U R                  S5      :X  d   eUR                  R                  UR                  S5        UR	                  5       U R                  S5      :X  d   eg )Nr)   r   r  z$QUUX BAZ<a>foo</a>BAZ QUUX<b>bar</b>FOOz'QUUX BAZ<b>bar</b>FOO<a>foo</a>BAZ QUUX)r   r   r#  r1   r   r
  r   s     r   test_insert_multiple_before0TestTreeModification.test_insert_multiple_before   s    yy/0UC0VS%0{{} 1 12!
 
 	
 
 	TVVU+{{} 1 15!
 
 	
 
r   c                 2   U R                  S5      nUR                  R                  S5        UR                  R                  S5        UR	                  5       U R                  S5      :X  d   eUR                  R                  UR                  5        UR	                  5       U R                  S5      :X  d   eUR                  n[        R                  " [        5         UR                  U5        S S S 5        UR                  5         [        R                  " [        5         UR                  S5        S S S 5        U R                  S5      nUR                  R                  UR                  S5      5        g ! , (       d  f       N= f! , (       d  f       N[= f)	Nr)   r  r  z<a>foo</a>QUUX<b>bar</b>BAZr  r  r  r1   )r   r   r$  r1   r   r
  r0  r1  r2  r9  r#  r"  r  s      r   test_insert_after&TestTreeModification.test_insert_after-  s   yy/0E"F#{{} 1 12O PPPPDFF#{{} 1 12O PPPP FF]]:&NN1 ' 	
		]]:&NN6" ' yyT\\#./ '&
 '&r  c                 z   U R                  S5      nUR                  R                  SSS5        UR                  R                  SSS5        UR	                  5       U R                  S5      :X  d   eUR                  R                  UR                  S5        UR	                  5       U R                  S5      :X  d   eg )Nr)   r  r  r  z$<a>foo</a>QUUX BAZ<b>bar</b>BAZ QUUXzFOO z(QUUX BAZ<b>bar</b><a>foo</a>FOO BAZ QUUX)r   r   r$  r1   r   r
  r   s     r   test_insert_multiple_after/TestTreeModification.test_insert_multiple_afterE  s    yy/0E3/FC/{{} 1 12!
 
 	
 
 	DFFF+{{} 1 16!
 
 	
 
r   c                    U R                  S5      nUR                  S5      nUR                  S5      n[        R                  " [
        5         UR                  U5        S S S 5        [        R                  " [        5         UR                  U5        S S S 5        [        R                  " [
        5         UR                  U5        S S S 5        g ! , (       d  f       Nw= f! , (       d  f       NT= f! , (       d  f       g = fNr  r1   )r   r"  
new_stringr0  r1  r2  r$  NotImplementedErrorr   r   r   r   s       r   :test_insert_after_raises_exception_if_after_has_no_meaningOTestTreeModification.test_insert_after_raises_exception_if_after_has_no_meaningQ  s    yy}ll3$]]:&$ ']]./c" 0]]:&S! '&	 '&//&&$   CC"6C3
C"
C03
Dc                    U R                  S5      nUR                  S5      nUR                  S5      n[        R                  " [
        5         UR                  U5        S S S 5        [        R                  " [        5         UR                  U5        S S S 5        [        R                  " [
        5         UR                  U5        S S S 5        g ! , (       d  f       Nw= f! , (       d  f       NT= f! , (       d  f       g = fr  )r   r"  r  r0  r1  r2  r#  r  r  s       r   Ftest_insert_before_raises_notimplementederror_if_before_has_no_meaning[TestTreeModification.test_insert_before_raises_notimplementederror_if_before_has_no_meaning\  s    yy}ll3$]]:&  % ']]./s# 0]]:&c" '&	 '&//&&r  c                 V   U R                  S5      nUR                  S5      u  p#UR                  U5        UR                  5       U R	                  S5      :X  d   eUR
                  b   eUR
                  UR                  :X  d   eUR                  S:X  d   eUR                  S:X  d   eg )Nz;<p>There's <b>no</b> business like <b>show</b> business</p>r   z0<p>There's  business like <b>no</b> business</p>noz	 business)	r   r-   r.  r   r
  r@  r6   rv  r  )r   r   r  shows       r   test_replace_with&TestTreeModification.test_replace_withg  s    yyVW==%"{{} 1 1>!
 
 	
 
 {{"""yyDFF"""$&&&+---r   c                    [        SS9n[        R                  " [        5         UR	                  S5        S S S 5        U R                  S5      R                  n[        R                  " [        5         UR                  R	                  U5        S S S 5        [        R                  " [        5         UR                  R	                  SUS5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N`= f! , (       d  f       g = f)Nr1   r   z
won't workrA  string1string2)r	   r0  r1  r2  r.  r   r1   r   )r   a_tags     r   test_replace_with_errors-TestTreeModification.test_replace_with_errorst  s    ]]:&|, ' 		*+--]]:&GG  ' ' ]]:&GG  E9= '& '&
 '& '&s#   C3C)1C:
C&)
C7:
Dc                    SnU R                  U5      nUR                  S5      nSUl        UR                  S5      nUR                  S5      nSnUR                  R	                  X4Xe5        UR                  5       S:X  d   eUR                  R                  U:X  d   eUR                  R                  U:X  d   eUR                  R                  U:X  d   eUR                  R                  U:X  d   eg )Nr4  r  zText In D Tagr  r   zRandom Textz;<a><b></b><d>Text In D Tag</d><e></e>Random Text<f></f></a>)r   r"  r   r   r.  r   r   rv  )r   r   r   d_tage_tagf_taga_strings          r   test_replace_with_multiple/TestTreeModification.test_replace_with_multiple  s    &yyS!&S!S! E(:KKMLM	
M vv""e+++||((E111!!((H444!!..%777r   c                     SnU R                  U5      nUR                  R                  UR                  5        SUR	                  5       :X  d   eg )Nr4  z<a><c></c></a>)r   r   r.  r   r   rz  s      r   test_replace_first_child-TestTreeModification.test_replace_first_child  >    &yyDFF#4;;=000r   c                     SnU R                  U5      nUR                  R                  UR                  5        SUR	                  5       :X  d   eg )Nr4  rA  )r   r   r.  r   r   rz  s      r   test_replace_last_child,TestTreeModification.test_replace_last_child  r  r   c                    U R                  S5      nUR                  nUR                  nUR                  U5        UR	                  5       U R                  S5      :X  d   eUR                  b   eUR                  SS9R                  b   eUR                  b   eUR                  b   eUR                  b   eUR                  UR                  :X  d   eUR                  S:X  d   eUR                  R                  UR                  :X  d   eUR                  b   eUR                  SS9nUR                  nUR                  U:X  d   eUR                  U:X  d   eUR                  U:X  d   eUR                  U:X  d   eg )NzQ<a>We<b>reserve<c>the</c><d>right</d></b></a><e>to<f>refuse</f><g>service</g></e>z-<a>We<f>refuse</f></a><e>to<g>service</g></e>r^  r   Weto)r   r   r   r.  r   r
  r@  r   rv  r  r  r  r1   r  r  )r   r   
remove_tagmove_tagto_textg_tags         r   test_nested_tag_replace_with1TestTreeModification.test_nested_tag_replace_with  s   yyc
 VV
66){{} 1 1;!
 
 	
 

   (((g.;;CCC**222&&...**222 $&&(((((D000$$11TVV;;;$$,,, ))4)(##u,,,##u,,,%%000%%000r   c                     U R                  S5      nUR                  R                  5         UR                  b   eUR                  R                  S:X  d   eg )NzI
            <p>Unneeded <em>formatting</em> is unneeded</p>
            zUnneeded formatting is unneeded)r   emr5  r6   r%   r   s     r   test_unwrap TestTreeModification.test_unwrap  sJ    yy   	wwvv{{????r   c                     U R                  S5      nUR                  R                  UR                  S5      5      nUR	                  5       S:X  d   eUR	                  5       U R                  S5      :X  d   eg )NzI wish I was bold.r   <b>I wish I was bold.</b>)r   r   wrapr"  r   r
  )r   r   r   s      r   	test_wrapTestTreeModification.test_wrap  sc    yy-.  c!23||~!<<<<{{} 1 12M NNNNr   c                     U R                  S5      nUR                  R                  R                  UR                  5        UR	                  5       U R                  S5      :X  d   eg )Nz<b></b>I wish I was bold.r  )r   r   r  r  r   r
  r   s     r   %test_wrap_extracts_tag_from_elsewhere:TestTreeModification.test_wrap_extracts_tag_from_elsewhere  sM    yy45  ({{} 1 12M NNNNr   c                    U R                  S5      nUR                  R                  R                  UR                  5        S[	        UR                  R
                  5      :X  d   eUR                  5       U R                  S5      :X  d   eg )Nz+<b>I like being bold.</b>I wish I was bold.r*   z+<b>I like being bold.I wish I was bold.</b>)r   r   r  r  r,   r&  r   r
  r   s     r   &test_wrap_puts_new_contents_at_the_end;TestTreeModification.test_wrap_puts_new_contents_at_the_end  sp    yyFG  (C(((({{} 1 19!
 
 	
 
r   c                    U R                  S5      n[        UR                  R                  5      S:X  d   eUR	                  SS9R                  5       nUR                  5       S:X  d   eUR                  5       S:X  d   e[        UR                  R                  5      S:X  d   eUR                  b   eUR                  b   eUR                  R                  b   eUR	                  SS	9nUR	                  S
S	9nUR                  U:X  d   eUR                  U:X  d   eUR                  U:X  d   eUR                  U:X  d   eg )NzR<html><body>Some content. <div id="nav">Nav crap</div> More content.</body></html>rY   navr"   z6<html><body>Some content.  More content.</body></html>z<div id="nav">Nav crap</div>r*   zSome content. r   z More content.)r   r,   rK   r&  r   r9  r   r@  r  rv  r  r  )r   r   	extracted	content_1	content_2s        r   test_extract!TestTreeModification.test_extract  sG   yy`
 499%%&!+++III'//1	{{} XXXX!%CCCC 499%%&!+++'''))111%%22::: II%5I6	II%5I6	%%222%%222))Y666))Y666r   c                    U R                  S5      nUR                  R                  nUR                  S5      nUR                  S5      nUR                  R	                  U5        UR
                  R	                  U5        UR                  5         UR                  5         X1R                  R                  :X  d   eXAR
                  R                  :X  d   eg )Nr)   rf   rQ   )r   r1   r   r  rm   r   r9  )r   r   foo_1foo_2bar_2s        r   4test_extract_distinguishes_between_identical_stringsITestTreeModification.test_extract_distinguishes_between_identical_strings  s    yy/0&&ee
 	%%%%%%r   c                     U R                  S5      nUR                  S5       Vs/ s H  o!R                  R                  5       PM       nS[	        UR
                  5      :X  d   eg s  snf )Nzv
<html>
<head>
<script>foo</script>
</head>
<body>
 <script>bar</script>
 <a></a>
</body>
<script>baz</script>
</html>scriptz<body>

<a></a>
</body>)r   r-   r  r9  r$   rK   )r   r   r3  s      r   "test_extract_multiples_of_same_tag7TestTreeModification.test_extract_multiples_of_same_tag
  s[    yy 
 
 )-h(?@(?1			(?@+s499~=== 	As   #A&c                     U R                  S5      nUR                  S5      R                  5         S UR                  S5      L d   eg )Nz<html>
<body>hi</body>
</html>rK   )r   r   r9  r   s     r   Btest_extract_works_when_element_is_surrounded_by_identical_stringsWTestTreeModification.test_extract_works_when_element_is_surrounded_by_identical_strings  s=    yyAB		&!!#tyy((((r   c                 N   U R                  S5      nUR                  nUR                  R                  5         [	        UR                  R
                  5      S:X  d   e[        US5      (       d   eUR                  nUR                  SS9  S[	        UR
                  5      :X  d   eg)zTag.clear()z4<p><a>String <em>Italicized</em></a> and another</p>r   r&  T)	decomposeN)r   r1   r6   clearr,   r&  r{   r  )r   r   r1   r  s       r   
test_clearTestTreeModification.test_clear  s    yyOPFF466??#q(((q*%%%% TT	$C$$$$r   zmethod_name,expected_result))rU  9<div><em>child1</em><p id="start"></p><p>child3</p></div>)r  zH<div><em>child1</em><p id="start"><a>Second <em>child</em></a></p></div>)r  r  )rO  r  )r  r  )r  zF<div><p id="start"><a>Second <em>child</em></a></p><p>child3</p></div>)r_  r  c                     U R                  S5      n[        UR                  U5      nU H  nUR                  5         M     X#R	                  5       :X  d   eg )NzU<div><em>child1</em><p id='start'><a>Second <em>child</em></a></p><p>child3</p></div>)r   getattrr6   r9  r   )r   method_nameexpected_resultr   iteratorr3  s         r   test_extract_during_iteration2TestTreeModification.test_extract_during_iteration,  sL    : yyc
 466;/AIIK ++-///r   c                 B   U R                  S5      nUR                  S5      u  p#UR                  nUR                  R                  nX#XE4 H  nSUR
                  L a  M   e   UR                  5         X$U4 H  nSUR
                  L a  M   e   SUR
                  L d   eg )Nz;<p><a>String <em>Italicized</em></a></p><p>Another para</p>r6   FT)r   r-   r1   r  r   
decomposedr  )r   r   rP  rJ  r1   r%   r3  s          r   test_decompose#TestTreeModification.test_decomposeQ  s    yyVWs#DDuu||!"AALL((( # 	A1<<'''  %%%r   c                     U R                  S5      nUR                  nUR                  R                  nSUR                  L d   eUR                  5         SUR                  L d   eSUR                  5       :X  d   eg )Nz'<div><p>String 1</p><p>String 2</p></p>FTz!<div><p></p><p>String 2</p></div>)r   r5   r6   r   r  r  r   )r   r   r5   r%   s       r   test_decompose_string*TestTreeModification.test_decompose_stringa  si    yyBChhuu||'''t&&&2cjjlBBBr   c                     U R                  S5      nSUR                  l        UR                  R                  S/:X  d   eSUR                  l        UR                  R                  S/:X  d   eg)zTag.string = 'string'z<a></a> <b><c></c></b>rf   rQ   N)r   r1   r   r&  r   r   s     r   test_string_set$TestTreeModification.test_string_setj  sW    yy12vv5')))vv5')))r   c                     U R                  S5      nUR                  R                  UR                  l        UR                  R                  5       S:X  d   eg )Nz<a><b>foo</b><c>bar</c>s   <a><b>bar</b><c>bar</c></a>)r   r   r   r   r1   r   r   s     r   /test_string_set_does_not_affect_original_stringDTestTreeModification.test_string_set_does_not_affect_original_stringr  s=    yy23vv}}"@@@@r   c                     U R                  S5      n[        S5      nX!R                  l        [	        UR                  R                  [        5      (       d   eg )Nrj   rf   )r   r   r1   r   rV  )r   r   cdatas      r   )test_set_string_preserves_class_of_string>TestTreeModification.test_set_string_preserves_class_of_stringw  s=    yy#e$&&--////r   r@   N)=rA   rB   rC   rD   r  r  r  r+  r1  r6  r:  r=  rC  rF  rR  rX  r_  re  rh  rk  rn  rw  r{  r~  r  r  r0  markparametrizer  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'  rF   r@   r   r   r  r    s   G

"-&#8(%
..*(-/&8.-:%%T. [[Z/;S)TUT VT [['):;!#9:	
?302
00

	"	#.>8$11#1J@OO

72& >)
% [[%	
2
032
0& C*A
0r   r  )r   r-   rS  rO  r  r  r  r  r:   rM   r9   rL   c                   X    \ rS rSr\R
                  R                  S\5      S 5       rSr	g)TestDeprecatedArgumentsi  r  c                 *   U R                  S5      n[        UR                  U5      n[        R                  " SS9 nU" SS9  Uu  nUR
                  [        :X  d   e[        UR                  5      nUS:X  d   e S S S 5        g ! , (       d  f       g = f)N<a>some</a><b>markup</b>Trk   r  )r%   zOThe 'text' argument to find()-type methods is deprecated. Use 'string' instead.)	r   r  r   rn   ro   rp   rq   r$   rr   r   r  r   methodrt   ru   rv   s          r   test_find_type_method_string4TestDeprecatedArguments.test_find_type_method_string  s    yy34-$$D1Q!IW##x///goo&Cdee 211s   >B
Br@   N)
rA   rB   rC   rD   r0  r)  r*  all_find_type_methodsr1  rF   r@   r   r   r,  r,    s'    [[],AB Cr   r,  c                   X    \ rS rSr\R
                  R                  S\5      S 5       rSr	g)TestWarningsi  r  c                 l   U R                  S5      n[        UR                  U5      n[        R                  " SS9 nU" SS9  Uu  nUR
                  [        :X  d   e[        UR                  [        5      (       d   e[        UR                  5      nSU;   d   e S S S 5        g ! , (       d  f       g = f)Nr.  Trk   u)_classzN'_class' is an unusual attribute name and is a common misspelling for 'class_')r   r  r   rn   ro   rp   rq   rV  rr   r   r$   r/  s          r   test_suspicious_syntax_warning+TestWarnings.test_suspicious_syntax_warning  s    yy34-$$D1Q#IW##x///goo/PQQQQgoo&C` 211s   AB%%
B3r@   N)
rA   rB   rC   rD   r0  r)  r*  r3  r9  rF   r@   r   r   r5  r5    s'    [[],AB Cr   r5  )$rE   r0  rT   rn   bs4r   bs4.builderr   bs4.elementr   r   r   r   r	   
bs4.filterr
   r  r   r   rH   r   r   r   r  r,  r8  ri  rn  r  r  r  r  r  r3  r,  r5  r@   r   r   <module>r?     s     	   (  $
%@x %@PC)( C)L@ @M  M `k7X k7\). ).X (<?8 <?~
H 
)' )'X$h] $hN&( &(,Bk ,B^.F+ .Fb]
08 ]
0@  h  8 r   