zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
U
¡ý°d¼ã@sˆdZddlmZddlZddlZddlZddlmZddlm    Z    m
Z
ddl m Z m Z mZmZmZmZmZmZmZmZmZddlmZGd    d
„d
eƒZGd d „d eƒZGd d„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZ Gdd„deƒZ!Gdd„de!ƒZ"Gdd„de!ƒZ#Gdd „d eƒZ$Gd!d"„d"e$ƒZ%Gd#d$„d$e$ƒZ&Gd%d&„d&eƒZ'Gd'd(„d(eƒZ(dS))a8Tests 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.
é)Ú    set_traceN)Ú BeautifulSoup)Úbuilder_registryÚHTMLParserTreeBuilder) ÚCDataÚCommentÚ DeclarationÚDoctypeÚ    FormatterÚNavigableStringÚScriptÚ SoupStrainerÚ
StylesheetÚTagÚTemplateStringé)ÚSoupTestc@s8eZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd S) ÚTestFindzˆBasic tests of the find() method.
 
    find() just calls find_all() with limit=1, so it's not tested all
    that thouroughly here.
    cCs"| d¡}| d¡jdkst‚dS)Nz <a>1</a><b>2</b><a>3</a><b>4</b>ÚbÚ2)ÚsoupÚfindÚstringÚAssertionError©Úselfr©rúJd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\bs4/tests/test_tree.pyÚ test_find_tag-s
zTestFind.test_find_tagcCs"| d¡}|jdddkst‚dS)Nu<h1>RäksmörgÃ¥s</h1>õ RäksmörgÃ¥s©r)rrrrrrrÚtest_unicode_text_find1s
zTestFind.test_unicode_text_findcCs,| d¡}t|ƒd|jddjks(t‚dS)Nu&<h1 id="RäksmörgÃ¥s">here it is</h1>z
here it isr©Úid)rÚstrrÚtextrrrrrÚtest_unicode_attribute_find5s
z$TestFind.test_unicode_attribute_findcCs"| d¡}dt| ¡ƒkst‚dS)z)Test an optimization that finds all tags.ú<a>foo</a><b>bar</b>éN©rÚlenÚfind_allrrrrrÚtest_find_everything;s
zTestFind.test_find_everythingcCs$| d¡}dt| d¡ƒks t‚dS)z;Test an optimization that finds all tags with a given name.z<a>foo</a><b>bar</b><a>baz</a>r(ÚaNr)rrrrÚtest_find_everything_with_name@s
z'TestFind.test_find_everything_with_nameN)    Ú__name__Ú
__module__Ú __qualname__Ú__doc__rr!r&r,r.rrrrr&s rc@s8eZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd S) Ú TestFindAllz%Basic tests of the find_all() method.cCsz| d¡}|jdddgks t‚|jddgdddgks<t‚|jt d¡ddddgks\t‚|jdddddgksvt‚dS)    z'You can search the tree for text nodes.u<html>Foo<b>bar</b>»</html>Úbarr ÚFooz.*õ»TN)rr+rÚreÚcompilerrrrÚtest_find_all_text_nodesHs
 
 z$TestFindAll.test_find_all_text_nodescCs‚| d¡}| |jddddddg¡| |jddddg¡| |jdd    ddddd
d g¡| |jdd ddddd
d g¡d S)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>r-é©ÚlimitÚ1rÚ3ré
Ú4Ú5rN©rÚassert_selectsr+rrrrÚtest_find_all_limitVs
 ÿ ÿzTestFindAll.test_find_all_limitcCs:| d¡}| |ddddg¡| |jdddg¡dS)    Nz!<a>1</a><b>2<a id='foo'>3</a></b>r-rr;r=Úfoor"r>)rrCrrrrrÚ%test_calling_a_tag_is_calling_findallbs
z1TestFindAll.test_calling_a_tag_is_calling_findallcCs.| d¡}g}| |¡g| |¡ks*t‚dS)Nú<a></a>)rÚappendr+r)rrÚlrrrÚTtest_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursiongs
 
z`TestFindAll.test_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursioncCsX| d¡}| d¡}t|dƒs"t‚| d¡}t|dƒs:t‚|jdd}t|dƒsTt‚dS)z%All find_all calls return a ResultSetrGr-ÚsourceTrEr N)rr+Úhasattrr)rrÚresultrrrÚtest_find_all_resultsetqs
 
 
 z#TestFindAll.test_find_all_resultsetN)    r/r0r1r2r9rDrFrJrNrrrrr3Es  
r3c@seZdZdd„ZdS)ÚTestFindAllBasicNamespacescCs<| d¡}d| d¡jkst‚d|jddidjks8t‚dS)Nz0<mathml:msqrt>4</mathml:msqrt><a svg:fill="red">r@z mathml:msqrtr-zsvg:fillÚred©Úattrs)rrrrÚnamerrrrÚtest_find_by_namespaced_name€s
z7TestFindAllBasicNamespaces.test_find_by_namespaced_nameN)r/r0r1rTrrrrrO~srOc@sheZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dd„Z dd„Z dd„ZdS)ÚTestFindAllByNamez&Test ways of finding tags by tag name.cCs| d¡|_dS)Nz<a>First tag.</a>
                                  <b>Second tag.</b>
                                  <c>Third <a>Nested tag.</a> tag.</c>©rÚtree©rrrrÚ setup_method‰szTestFindAllByName.setup_methodcCs| |j d¡ddg¡dS©Nr-ú
First tag.ú Nested tag.©rCrWr+rXrrrÚtest_find_all_by_tag_nameŽs
ÿz+TestFindAllByName.test_find_all_by_tag_namecCs\| |jjddddg¡| |jjdddddg¡| |jjdt d¡dddg¡dS)Nr-r[r Tr\Útag©rCrWr+r7r8rXrrrÚtest_find_all_by_name_and_text“sÿÿþz0TestFindAllByName.test_find_all_by_name_and_textcCs| |jj d¡dg¡dS)Nr-r\)rCrWÚcr+rXrrrÚ!test_find_all_on_non_root_elementŸsz3TestFindAllByName.test_find_all_on_non_root_elementcCs| | d¡ddg¡dSrZ)rCrWrXrrrÚ%test_calling_element_invokes_find_all£sz7TestFindAllByName.test_calling_element_invokes_find_allcCs | |j tdƒ¡ddg¡dSrZ)rCrWr+r rXrrrÚtest_find_all_by_tag_strainer¦sþz/TestFindAllByName.test_find_all_by_tag_strainercCs"| |j ddg¡dddg¡dS)Nr-rr[ú Second tag.r\r]rXrrrÚtest_find_all_by_tag_names«sþz,TestFindAllByName.test_find_all_by_tag_namescCs$| |j dddœ¡dddg¡dS)NT)r-rr[rfr\r]rXrrrÚtest_find_all_by_tag_dict°sþz+TestFindAllByName.test_find_all_by_tag_dictcCs$| |j t d¡¡dddg¡dS)Nz^[ab]$r[rfr\r`rXrrrÚtest_find_all_by_tag_reµsþz)TestFindAllByName.test_find_all_by_tag_recCs,dd„}| d¡}| | |¡ddg¡dS)NcSs|j| d¡kS©Nr#)rSÚget©r_rrrÚid_matches_name½szRTestFindAllByName.test_find_all_with_tags_matching_method.<locals>.id_matches_namezƒ<a id="a">Match 1.</a>
                            <a id="1">Does not match.</a>
                            <b id="b">Match 2.</a>zMatch 1.zMatch 2.rB)rrmrWrrrÚ'test_find_all_with_tags_matching_methodºs 
ÿz9TestFindAllByName.test_find_all_with_tags_matching_methodcCsx| d¡}| dd¡}| dt d¡¡}| dddg¡\}}d|jksJt‚d|jksXt‚d|jksft‚d|jkstt‚dS)NzH<div class='a b'>1</div><div class='a c'>2</div><div class='a d'>3</div>Údivza dza br>r=)rrr7r8r+rr)rrZr1Zr2Zr3Zr4rrrÚ%test_find_with_multi_valued_attributeÇsÿ z7TestFindAllByName.test_find_with_multi_valued_attributeN)r/r0r1r2rYr^rarcrdrergrhrirnrprrrrrU†s  rUc@sŒeZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!S)"ÚTestFindAllByAttributecCs&| d¡}| |jddddg¡dS)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.rB©rrWrrrÚtest_find_all_by_attribute_nameÖs
ÿz6TestFindAllByAttribute.test_find_all_by_attribute_namecCstd d¡}d d¡}| |¡}|jg|j|dks6t‚|jg|j| d¡dksTt‚|jgspt|j|dgdƒ‚dS)NuםולשÚutf8u<a title="םולש"></a>)Útitlezsomething else)Úencoderr-r+rÚdecode)rZpeaceÚdatarrrrÚ%test_find_all_by_utf8_attribute_valueás 
 
 
z<TestFindAllByAttribute.test_find_all_by_utf8_attribute_valuecCsX| d¡}| |jdddg¡| |jddiddg¡| |jdd    idd
g¡dS) 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>
                         Zname1©rSzA tag called 'name1'.rSrQz Name match.ÚclassZclass2z Class match.rBrsrrrÚtest_find_all_by_attribute_dictés
ÿÿÿz6TestFindAllByAttribute.test_find_all_by_attribute_dictcCs°| d¡}| |jddddg¡| |jddddg¡| |jdd    ddg¡| | dd¡dg¡| |jdd
ddg¡| | dd¡dg¡| | dd    ¡dg¡dS) 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>
                         r-r=©Úclass_zClass 1.rbr>zClass 3 and 4.r@rQrBrsrrrÚtest_find_all_by_classþs
    z-TestFindAllByAttribute.test_find_all_by_classcCst| d¡}|jdt d¡d}| |dg¡|jdt d¡d}| |dg¡|jdt d¡d}| |dg¡dS)Nz#<gar class='foo bar'>Found it</gar>ZgarÚor~úFound itr-zo b)rr+r7r8rC)rrWÚfrrrÚ0test_find_by_class_when_multiple_classes_presents
zGTestFindAllByAttribute.test_find_by_class_when_multiple_classes_presentcCsd| d¡}| | dt d¡¡dg¡dd„}| | d|¡g¡dd„}| | d|¡dg¡dS)    Nz<a class='bar'>Found it</a>r-Úbar‚cSs t|ƒdkS©Nr:©r*©ÚvaluerrrÚbig_attribute_value%sznTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_class.<locals>.big_attribute_valuecSs t|ƒdkSr†r‡rˆrrrÚsmall_attribute_value*szpTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_class.<locals>.small_attribute_value©rrCr+r7r8)rrrŠr‹rrrÚ:test_find_all_with_non_dictionary_for_attrs_finds_by_class s
 
ÿzQTestFindAllByAttribute.test_find_all_with_non_dictionary_for_attrs_finds_by_classcCsŒ| d¡}| d¡\}}||gs0t| dd¡ƒ‚|gsFt| dd¡ƒ‚|g|jdddks^t‚|g| dd¡kstt‚g| dd¡ksˆt‚dS)Nz*<a class="foo bar"></a><a class="foo"></a>r-rEr4zfoo barr~zbar foo©rr+r)rrr-Za2rrrÚ:test_find_all_with_string_for_attrs_finds_multiple_classes0s
zQTestFindAllByAttribute.test_find_all_with_string_for_attrs_finds_multiple_classescCs0| d¡}tddid}| | |¡dg¡dS)Nzi
                         <a id="first">Match.</a>
                         <a id="second">Non-match.</a>r#rrrQzMatch.)rr rCr+)rrWÚstrainerrrrÚ'test_find_all_by_attribute_soupstrainer<s
z>TestFindAllByAttribute.test_find_all_by_attribute_soupstrainercCs&| d¡}| |jddddg¡dS)Nú<a id="1">ID present.</a>
                            <a>No ID present.</a>
                            <a id="">ID is empty.</a>r-r"zNo ID present.rBrsrrrÚ$test_find_all_with_missing_attributeDs
z;TestFindAllByAttribute.test_find_all_with_missing_attributecCs&| d¡}| |jddddg¡dS)Nr’Tr"z ID present.z ID is empty.rBrsrrrÚ$test_find_all_with_defined_attributeLs
 
 
ÿz;TestFindAllByAttribute.test_find_all_with_defined_attributecCs>| d¡}ddg}| |jdd|¡| |jdd|¡dS)Nz[<a id=1>Unquoted attribute.</a>
                            <a id="1">Quoted attribute.</a>zUnquoted attribute.zQuoted attribute.rr"r=rB)rrWÚexpectedrrrÚ$test_find_all_with_numeric_attributeUs
z;TestFindAllByAttribute.test_find_all_with_numeric_attributecCs,| d¡}| |jdddgdddg¡dS)Nz‘<a id="1">1</a>
                            <a id="2">2</a>
                            <a id="3">3</a>
                            <a>No ID.</a>r=r>r@r"rBrsrrrÚ(test_find_all_with_list_attribute_values^s
ÿz?TestFindAllByAttribute.test_find_all_with_list_attribute_valuescCs,| d¡}| |jt d¡dddg¡dS)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"zOne a.zTwo as.rŒrsrrrÚ5test_find_all_with_regular_expression_attribute_valuehs
ÿzLTestFindAllByAttribute.test_find_all_with_regular_expression_attribute_valuecCsB| d¡}|j}|g|jdddks(t‚g|jdddks>t‚dS)Nz<b>foo</b><b>bar</b><a>foo</a>r-rEr r4©rr-r+r©rrr-rrrÚ'test_find_by_name_and_containing_stringus
z>TestFindAllByAttribute.test_find_by_name_and_containing_stringcCs*| d¡}| d¡|jdddks&t‚dS)Nz"<a>foo</a><a><b><c>foo</c></b></a>r-rEr rŽrrrrÚ=test_find_by_name_and_containing_string_when_string_is_buried|s
zTTestFindAllByAttribute.test_find_by_name_and_containing_string_when_string_is_buriedcCsB| d¡}|j}|g|jdddks(t‚g|jdddks>t‚dS)Nz"<b id="1">foo</b><a id="2">foo</a>r(rE)r#rrr4r™ršrrrÚ,test_find_by_attribute_and_containing_string€s
zCTestFindAllByAttribute.test_find_by_attribute_and_containing_stringN)r/r0r1rtrzr}r€r„rrr‘r“r”r–r—r˜r›rœrrrrrrqÔs           
 rqc@seZdZdZdd„ZdS)Ú
TestSmoothzTest Tag.smooth.cCs| d¡}|j}| d¡| d¡| tdƒ¡| tdƒ¡| d¡| ¡}t||dƒ}| d¡| d    ¡| |¡d|jjksŒt‚d
t    |j
ƒksžt‚|  ¡d t    |j
ƒks¸t‚d |j
d ksÊt‚d|jjksÚt‚d|j
dksìt‚d|j
dksþt‚dS)Nz <div>a</div>rrbz    Comment 1z    Comment 2ÚdÚspanr=rééÚabcrZ12rr() rrorHrÚdefault_builderrr rrr*ÚcontentsZsmooth)rrroÚbuilderr rrrÚ test_smooth‹s(
 
 
 
 
 
 
zTestSmooth.test_smoothN)r/r0r1r2r§rrrrržˆsržc@seZdZdZdd„ZdS)Ú    TestIndexzTest Tag.indexc    CsZ| d¡}|j}t|jƒD]\}}|| |¡kst‚qt t¡| d¡W5QRXdS)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)    rroÚ    enumerater¥ÚindexrÚpytestÚraisesÚ
ValueError)rrWroÚiÚelementrrrÚ
test_index¶s 
     zTestIndex.test_indexN)r/r0r1r2r°rrrrr¨´sr¨c@sXeZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dd„Z dS)ÚTestParentOperationsz;Test navigation and searching through an element's parents.cCs| d¡|_|jj|_dS)Na1<ul id="empty"></ul>
                                 <ul id="top">
                                  <ul id="middle">
                                   <ul id="bottom">
                                    <b>Start here</b>
                                   </ul>
                                  </ul>)rrWrÚstartrXrrrrYÊs z!TestParentOperations.setup_methodcCsF|jjddkst‚|jjjddks*t‚|jjjjddksBt‚dS)Nr#ÚbottomÚmiddleÚtop)r²ÚparentrrXrrrÚ test_parentÕsz TestParentOperations.test_parentcCs |jjd}|j|jkst‚dS)Nr)rWr¥r¶r)rZtop_tagrrrÚ%test_parent_of_top_tag_is_soup_objectÚs z:TestParentOperations.test_parent_of_top_tag_is_soup_objectcCsd|jjkst‚dS©N)rWr¶rrXrrrÚtest_soup_object_has_no_parentÞsz3TestParentOperations.test_soup_object_has_no_parentcCs8| |j d¡dddg¡| |jjddddg¡dS)NÚulr³r´rµr")Úassert_selects_idsr²Ú find_parentsrXrrrÚtest_find_parentsás
ÿÿz&TestParentOperations.test_find_parentscCs8|j d¡ddkst‚|jjdddddks4t‚dS)Nr»r#r³rµr")r²Ú find_parentrrXrrrÚtest_find_parentçsz%TestParentOperations.test_find_parentcCs"|jjdd}|jjdkst‚dS)Nú
Start herer r)rWrr¶rSr©rr%rrrÚtest_parent_of_text_elementësz0TestParentOperations.test_parent_of_text_elementcCs(|jjdd}| d¡ddks$t‚dS)NrÁr r»r#r³)rWrr¿rrÂrrrÚtest_text_element_find_parentïsz2TestParentOperations.test_text_element_find_parentcCs*dd„|jjDƒ}|s&tdddkgƒ‚dS)NcSs&g|]}|dk    rd|jkr|d‘qSrjrQ)Ú.0r¶rrrÚ
<listcomp>ôs
ÿz>TestParentOperations.test_parent_generator.<locals>.<listcomp>r³r´rµ)r²Úparentsr)rrÇrrrÚtest_parent_generatorósz*TestParentOperations.test_parent_generatorN) r/r0r1r2rYr·r¸rºr¾rÀrÃrÄrÈrrrrr±Çs r±c@seZdZdd„ZdS)Ú ProximityTestcCs| d¡|_dS)Nzg<html id="start"><head></head><body><b id="1">One</b><b id="2">Two</b><b id="3">Three</b></body></html>rVrXrrrrYûsÿzProximityTest.setup_methodN©r/r0r1rYrrrrrÉùsrÉcsTeZdZ‡fdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
‡Z S)ÚTestNextOperationscstt|ƒ ¡|jj|_dSr¹)ÚsuperrËrYrWrr²rX©Ú    __class__rrrYszTestNextOperations.setup_methodcCs*|jjdkst‚|jjjddks&t‚dS)NÚOner#r)r²Ú next_elementrrXrrrÚ    test_nextszTestNextOperations.test_nextcCs |jjdd}|jdkst‚dS©NÚThreer )rWrrÐr)rÚlastrrrÚtest_next_of_last_item_is_none
sz1TestNextOperations.test_next_of_last_item_is_nonecCs|jjdkst‚dSr¹)rWrÐrrXrrrÚtest_next_of_root_is_nonesz,TestNextOperations.test_next_of_root_is_nonecCsB| |j d¡ddg¡|jjdd| |jjdddg¡dS)NrÚTworÓr:r")rCr²Ú find_all_nextrXrrrÚtest_find_all_nextsz%TestNextOperations.test_find_all_nextcCs2|j d¡ddkst‚|jjdddks.t‚dS)Nrr#rrÓr )r²Ú    find_nextrrXrrrÚtest_find_nextsz!TestNextOperations.test_find_nextcCs<|jjdd}| d¡jdks"t‚| | d¡ddg¡dS)NrÏr rr×rÓ)rWrrÚrrrCrØrÂrrrÚtest_find_next_for_text_elementsz2TestNextOperations.test_find_next_for_text_elementcCsF|jjdd}dd„|jDƒ}|\}}|ddks6t‚|dksBt‚dS)Nr×r cSsg|]}|‘qSrr©rÅÚnoderrrrÆ"sz:TestNextOperations.test_next_generator.<locals>.<listcomp>r#r>rÓ)rWrZ next_elementsr)rr²Ú
successorsr_r¥rrrÚtest_next_generator s
z&TestNextOperations.test_next_generator) r/r0r1rYrÑrÕrÖrÙrÛrÜràÚ __classcell__rrrÍrrËs rËcsTeZdZ‡fdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
‡Z S)ÚTestPreviousOperationscs"tt|ƒ ¡|jjdd|_dSrÒ)rÌrârYrWrÚendrXrÍrrrY*sz#TestPreviousOperations.setup_methodcCs*|jjddkst‚|jjjdks&t‚dS)Nr#r>r×)rãÚprevious_elementrrXrrrÚ test_previous.sz$TestPreviousOperations.test_previouscCs|j d¡}|jdkst‚dS)NÚhtml)rWrrär)rrrrrrÚ#test_previous_of_first_item_is_none2s z:TestPreviousOperations.test_previous_of_first_item_is_nonecCs|jjdkst‚dSr¹)rWrärrXrrrÚtest_previous_of_root_is_none6sz4TestPreviousOperations.test_previous_of_root_is_nonecCs6| |j d¡dddg¡| |jjdddg¡dS)NrrÓr×rÏrr")rCrãÚfind_all_previousrXrrrÚtest_find_all_previous:s
 
ÿz-TestPreviousOperations.test_find_all_previouscCs2|j d¡ddkst‚|jjdddks.t‚dS)Nrr#r>rÏr )rãÚ find_previousrrXrrrÚtest_find_previousBsz)TestPreviousOperations.test_find_previouscCs>|jjdd}| d¡jdks"t‚| | d¡dddg¡dS)NrÓr rr×rÏ)rWrrërrrCrérÂrrrÚ#test_find_previous_for_text_elementFs ÿz:TestPreviousOperations.test_find_previous_for_text_elementcCsh|jjdd}dd„|jDƒ}|\}}}}|ddks:t‚|jdksHt‚|jdksVt‚|jd    ksdt‚dS)
NrÏr cSsg|]}|‘qSrrrÝrrrrÆNszBTestPreviousOperations.test_previous_generator.<locals>.<listcomp>r#r=ÚbodyÚheadræ)rWrZprevious_elementsrrS)rr²Z predecessorsrrîrïrærrrÚtest_previous_generatorLs z.TestPreviousOperations.test_previous_generator) r/r0r1rYrårçrèrêrìrírðrárrrÍrrâ(s râc@seZdZdd„ZdS)Ú SiblingTestcCs&d}t d¡ d|¡}| |¡|_dS)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*Ú)r7r8ÚsubrrW)rÚmarkuprrrrY[szSiblingTest.setup_methodNrÊrrrrrñYsrñcsLeZdZ‡fdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    ‡Z
S)ÚTestNextSiblingcs"tt|ƒ ¡|jjdd|_dS)Nr=r")rÌrõrYrWrr²rXrÍrrrYpszTestNextSibling.setup_methodcCs|jjdkst‚dSr¹)rWÚ next_siblingrrXrrrÚ!test_next_sibling_of_root_is_nonetsz1TestNextSibling.test_next_sibling_of_root_is_nonecCsB|jjddkst‚|jjjddks*t‚|jjddks>t‚dS)Nr#rr>ú1.1)r²rörrÐrXrrrÚtest_next_siblingwsz!TestNextSibling.test_next_siblingcCsN|jjjdkst‚|jjdd}|jdks.t‚|jjdd}|jdksJt‚dS)Nrør"r@)rWrærörr)rÚ nested_spanZ    last_spanrrrÚtest_next_sibling_may_not_exist~s
z/TestNextSibling.test_next_sibling_may_not_existcCs|j d¡ddkst‚dS)Nr r#r)r²Úfind_next_siblingrrXrrrÚtest_find_next_sibling‡sz&TestNextSibling.test_find_next_siblingcCs6| |j d¡dddg¡| |jjdddg¡dS)Nr rr>r@r")r¼r²Úfind_next_siblingsrXrrrÚtest_next_siblingsŠsÿz"TestNextSibling.test_next_siblingscCsv| d¡}|jdd}|jjdks&t‚|jjdks6t‚| | d¡dg¡|jdddks^t‚|jdddksrt‚dS)NúFoo<b>bar</b>bazr5r rÚbazr4Únonesuch)rrrörSrrCrþrü©rrr²rrrÚ"test_next_sibling_for_text_elements
 z2TestNextSibling.test_next_sibling_for_text_element) r/r0r1rYr÷rùrûrýrÿrrárrrÍrrõns     rõcsLeZdZ‡fdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    ‡Z
S)ÚTestPreviousSiblingcs"tt|ƒ ¡|jjdd|_dS)Nr@r")rÌrrYrWrrãrXrÍrrrYsz TestPreviousSibling.setup_methodcCs|jjdkst‚dSr¹)rWÚprevious_siblingrrXrrrÚ%test_previous_sibling_of_root_is_none¡sz9TestPreviousSibling.test_previous_sibling_of_root_is_nonecCsB|jjddkst‚|jjjddks*t‚|jjddks>t‚dS)Nr#r>rz3.1)rãrrrärXrrrÚtest_previous_sibling¤sz)TestPreviousSibling.test_previous_siblingcCsN|jjjdkst‚|jjdd}|jdks.t‚|jjdd}|jdksJt‚dS)Nrør"r=)rWrærrr)rrúZ
first_spanrrrÚ#test_previous_sibling_may_not_exist«s
z7TestPreviousSibling.test_previous_sibling_may_not_existcCs|j d¡ddkst‚dS)Nr r#r>)rãÚfind_previous_siblingrrXrrrÚtest_find_previous_sibling´sz.TestPreviousSibling.test_find_previous_siblingcCs6| |j d¡dddg¡| |jjdddg¡dS)Nr r>rr=r")r¼rãÚfind_previous_siblingsrXrrrÚtest_previous_siblings·sÿz*TestPreviousSibling.test_previous_siblingscCsv| d¡}|jdd}|jjdks&t‚|jjdks6t‚| | d¡dg¡|jdddks^t‚|jdddksrt‚dS)Nrrr rr5r4r)rrrrSrrCr r
rrrrÚ&test_previous_sibling_for_text_element½s
 z:TestPreviousSibling.test_previous_sibling_for_text_element) r/r0r1rYrrr    r r rrárrrÍrr›s     rc@sŽeZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zej d#d$d%„d&d%„g¡d'd(„ƒZd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Z d;d<„Z!d=d>„Z"d?d@„Z#dAdB„Z$dCdD„Z%dEdF„Z&dGdH„Z'dIdJ„Z(dKdL„Z)dMdN„Z*dOdP„Z+dQdR„Z,dSdT„Z-dUdV„Z.dWdX„Z/dYdZ„Z0d[d\„Z1d]d^„Z2d_S)`ÚTestTreeModificationcCsl| d¡}d|jd<| ¡| d¡ks*t‚|jd=| ¡| d¡ksHt‚d|jd<| ¡| d¡ksht‚dS)    Nz<a id="1"></a>r(r#z<a id="2"></a>rGrEZid2z<a id2="foo"></a>)rr-rxÚ document_forrrrrrÚtest_attribute_modificationÊs
 
 
z0TestTreeModification.test_attribute_modificationcCslt d¡ƒ}|jd|d}t||dƒ}t||dƒ}d|d<|j d|¡|j d    |¡|j ¡d
ksht‚dS) Nræz <body></body>©r¦r-Úolzhttp://foo.com/Úhrefrrs4<body><a href="http://foo.com/"></a><ol></ol></body>)rÚlookuprrrîÚinsertrwr)rr¦rr-rrrrÚtest_new_tag_creationÓs   z*TestTreeModification.test_new_tag_creationcCs\d}| |¡}|jdd}|j}|jdd |j¡|j|ksBt‚| ¡| d¡ksXt‚dS)NzT<p id="1">Don't leave me <b>here</b>.</p>
                <p id="2">Don't leave!</p>rr"zD<p id="1">Don't leave me .</p>
<p id="2">Don't leave!<b>here</b></p>)rrrrHr¶rrxr)rÚdocrZ second_paraZboldrrrÚ!test_append_to_contents_moves_tagÝs
 
ÿz6TestTreeModification.test_append_to_contents_moves_tagcCs0d}| |¡}|j}| |j¡}||ks,t‚dS)Nz<a></a><b><c></c></b>)rr-Ú replace_withrbr©rr%rr-Únew_arrrÚ1test_replace_with_returns_thing_that_was_replacedïs
 
 zFTestTreeModification.test_replace_with_returns_thing_that_was_replacedcCs,d}| |¡}|j}| ¡}||ks(t‚dS)Nú<a><b></b><c></c></a>)rr-ÚunwraprrrrrÚ+test_unwrap_returns_thing_that_was_replacedös
 
z@TestTreeModification.test_unwrap_returns_thing_that_was_replacedc    Csj| d¡}|j}| ¡d|jks&t‚t t¡| ¡W5QRXt t¡|     |j
¡W5QRXdS)Nz<a><b>Foo</b></a><c>Bar</c>) rr-Úextractr¶rr«r¬r­rrrbršrrrÚItest_replace_with_and_unwrap_give_useful_exception_when_tag_has_no_parentýs
  z^TestTreeModification.test_replace_with_and_unwrap_give_useful_exception_when_tag_has_no_parentcCs:d}| |¡}|j}|j |¡| ¡| |¡ks6t‚dS)Nz-<a><b></b><c>Foo<d></d></c></a><a><e></e></a>)rrbrrxrr)rr%rrbrrrÚtest_replace_tag_with_itselfs
 
 z1TestTreeModification.test_replace_tag_with_itselfc    Cs6d}| |¡}t t¡|j |j¡W5QRXdS©Nú<a><b></b></a>)rr«r¬r­rrr-©rr%rrrrÚ1test_replace_tag_with_its_parent_raises_exceptions
 zFTestTreeModification.test_replace_tag_with_its_parent_raises_exceptionc    Cs8d}| |¡}t t¡|j d|j¡W5QRXdS)Nr%r)rr«r¬r­r-rr&rrrÚ,test_insert_tag_into_itself_raises_exceptions
 zATestTreeModification.test_insert_tag_into_itself_raises_exceptionc    CsŒ| d¡}d}| |¡}| d|¡|jD]}t|tƒr*t‚q*t|jƒ\}}}}d|jks^t‚d|jkslt‚d|jkszt‚d|jksˆt‚dS)    z”Inserting one BeautifulSoup object into another actually inserts all
        of its children -- you'll never combine BeautifulSoup objects.
        z-<p>And now, a word:</p><p>And we're back.</p>z<p>p2</p><p>p3</p>rzAnd now, a word:Úp2Úp3zAnd we're back.N)    rrZ descendantsÚ
isinstancerrÚlistÚchildrenr)    rrr%Z    to_insertr®Úp1r)r*Zp4rrrÚ1test_insert_beautifulsoup_object_inserts_childrens
 
 
zFTestTreeModification.test_insert_beautifulsoup_object_inserts_childrencCsX| d¡}|j}|jd}| dd¡|j\}}| d¡| d¡d|jjksTt‚dS)Nz<p><a>one</a><b>three</b></p>rrZtworòZthree)rr-r¥rÚ replaceWithrrr)rrr-rÚleftÚrightrrrÚ3test_replace_with_maintains_next_element_throughout.s
 
 
 
 
zHTestTreeModification.test_replace_with_maintains_next_element_throughoutcCsl| d¡}|jdd d¡|jdd}|j}|j|ks<t‚|j|ksJt‚|jj|ksZt‚|jdksht‚dS)Nz <b>Argh!</b>úArgh!r úHooray!)rrrrrärr¶rÐ)rrÚnew_textrrrrÚtest_replace_final_node=s
 z,TestTreeModification.test_replace_final_nodecCs˜| d¡}|j dd¡| ¡| d¡ks.t‚|jdd}|jdksHt‚|jj|ksXt‚|j    dksft‚|j    j
|ksvt‚|j
dks„t‚|j|j ks”t‚dS)Nz<a><b>Argh!</b><c></c></a>rr5z!<a><b>Argh!Hooray!</b><c></c></a>r r4) rrrrxrrrrärÐrrörb)rrr6rrrÚtest_consecutive_text_nodesGs
 
ÿ
 z0TestTreeModification.test_consecutive_text_nodescCsT| d¡}|j dd¡|j dd¡ddg|jjks:t‚|jjdjdksPt‚dS)NrGrr4rE)rr-rr¥rrÐrrrrÚtest_insert_string\s
 
z'TestTreeModification.test_insert_stringcCsø| ¡}|jd|d}t||dƒ}| dd¡|j d|¡| ¡| d¡ksRt‚|j}|j    |ksft‚|j
|kstt‚|j dd    }|j |ksŽt‚|j |ksœt‚|j}|j    |ks°t‚|j
|ks¾t‚|j dd    }|j|ksØt‚|j |ksæt‚|j |ksôt‚dS)
Nz%<a><b>Find</b><c>lady!</c><d></d></a>rZmagictagrÚtherz=<a><b>Find</b><magictag>the</magictag><c>lady!</c><d></d></a>ZFindr )r¤rrrr-rxrrrrörrrÐrärbr¶)rr¦rZ    magic_tagZb_tagrZc_tagr:rrrÚtest_insert_tages0ÿ  
ÿ
  z$TestTreeModification.test_insert_tagcCs0d}| |¡}|j |j¡|| ¡ks,t‚dSr$)rr-rHrrxr©rryrrrrÚ*test_append_child_thats_already_at_the_endƒs
z?TestTreeModification.test_append_child_thats_already_at_the_endcCsJd}| |¡}|j|j|j|j|j|jg}|j |¡d|     ¡ksFt
‚dS)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Ÿrbrr-Úextendrxr)rryrrIrrrÚ test_extend‰s
 
 z TestTreeModification.test_extendÚget_tagscCs|Sr¹rrlrrrÚ<lambda>‘ózTestTreeModification.<lambda>cCs|jSr¹)r¥rlrrrrC‘rDcCs`d}| |¡}|jddd}|jddd}||ƒ}| |¡d| ¡ksLt‚d| ¡ks\t‚dS)NzS<body><div id="d1"><a>1</a><a>2</a><a>3</a><a>4</a></div><div id="d2"></div></body>roÚd1r"Úd2z<div id="d1"></div>z3<div id="d2"><a>1</a><a>2</a><a>3</a><a>4</a></div>)rrr@rxr)rrBryrrErFÚtagsrrrÚ&test_extend_with_another_tags_contentss
 
z;TestTreeModification.test_extend_with_another_tags_contentscCs2d}| |¡}|j d|j¡d| ¡ks.t‚dS)Nz<a><b></b><c></c><d></d></a>rz<a><d></d><b></b><c></c></a>)rr-rrŸrxrr<rrrÚ$test_move_tag_to_beginning_of_parents
z9TestTreeModification.test_move_tag_to_beginning_of_parentcCs.| d¡}|j dd¡t|jƒdks*t‚dS)Nz<br/>rZContentsz<br>Contents</br>)rÚbrrr$rrrrrÚ&test_insert_works_on_empty_element_tag£s
z;TestTreeModification.test_insert_works_on_empty_element_tagc    CsÊ| d¡}|j d¡|j d¡| ¡| d¡ks8t‚|j |j¡| ¡| d¡ks\t‚|j}t t    ¡| |¡W5QRX| 
¡t t    ¡| d¡W5QRX| d¡}|j |  d¡¡dS)    Nr'ÚBAZÚQUUXzQUUX<a>foo</a>BAZ<b>bar</b>úQUUX<b>bar</b><a>foo</a>BAZÚnopeú<a>r-) rrÚ insert_beforer-rxrrr«r¬r­r!Únew_tag©rrrrrrÚtest_insert_before¬s 
 
ÿ
 
z'TestTreeModification.test_insert_beforecCsj| d¡}|j ddd¡|j ddd¡| ¡| d¡ks@t‚|j |jd¡| ¡| d¡ksft‚dS)Nr'rLú rMz$QUUX BAZ<a>foo</a>BAZ QUUX<b>bar</b>ZFOOz'QUUX BAZ<b>bar</b>FOO<a>foo</a>BAZ QUUX)rrrQr-rxrrrrrrÚtest_insert_multiple_beforeÇs
 
ÿ
 
ÿz0TestTreeModification.test_insert_multiple_beforec    CsÊ| d¡}|j d¡|j d¡| ¡| d¡ks8t‚|j |j¡| ¡| d¡ks\t‚|j}t t    ¡| |¡W5QRX| 
¡t t    ¡| d¡W5QRX| d¡}|j  |  d¡¡dS)    Nr'rLrMz<a>foo</a>QUUX<b>bar</b>BAZrNrOrPr-) rrÚ insert_afterr-rxrrr«r¬r­r!rQrRrSrrrÚtest_insert_afterÔs 
 
ÿ
 
z&TestTreeModification.test_insert_aftercCsj| d¡}|j ddd¡|j ddd¡| ¡| d¡ks@t‚|j |jd¡| ¡| d¡ksft‚dS)Nr'rLrUrMz$<a>foo</a>QUUX BAZ<b>bar</b>BAZ QUUXzFOO z(QUUX BAZ<b>bar</b><a>foo</a>FOO BAZ QUUX)rrrWr-rxrrrrrrÚtest_insert_multiple_afterîs
 
ÿ
 
ÿz/TestTreeModification.test_insert_multiple_afterc    Cs‚| d¡}| d¡}| d¡}t t¡| |¡W5QRXt t¡| |¡W5QRXt t¡| |¡W5QRXdS©Nròr-)rrRÚ
new_stringr«r¬r­rWÚNotImplementedError©rrr_rrrrÚ:test_insert_after_raises_exception_if_after_has_no_meaningús
 
 
   zOTestTreeModification.test_insert_after_raises_exception_if_after_has_no_meaningc    Cs‚| d¡}| d¡}| d¡}t t¡| |¡W5QRXt t¡| |¡W5QRXt t¡| |¡W5QRXdSrZ)rrRr[r«r¬r­rQr\r]rrrÚFtest_insert_before_raises_notimplementederror_if_before_has_no_meanings
 
 
   z[TestTreeModification.test_insert_before_raises_notimplementederror_if_before_has_no_meaningcCsv| d¡}| d¡\}}| |¡| ¡| d¡ks8t‚|jdksFt‚|j|jksVt‚|jdksdt‚|j    dksrt‚dS)Nz;<p>There's <b>no</b> business like <b>show</b> business</p>rz0<p>There's  business like <b>no</b> business</p>Únoz     business)
rr+rrxrrr¶ÚprÐrö)rrr`ÚshowrrrÚtest_replace_withsÿ
 
ÿ
z&TestTreeModification.test_replace_withc    Cs‚tdd}t t¡| d¡W5QRX| d¡j}t t¡|j |¡W5QRXt t¡|j d|d¡W5QRXdS)Nr-r{z
won't workr%Zstring1Zstring2)rr«r¬r­rrr-r)rZa_tagrrrÚtest_replace_with_errorss
    z-TestTreeModification.test_replace_with_errorscCsœd}| |¡}| d¡}d|_| d¡}| d¡}d}|j ||||¡| ¡dksXt‚|jj|ksht‚|jj|ksxt‚|jj|ksˆt‚|jj|ks˜t‚dS)NrrŸ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>)    rrRrrbrrxrrrÐ)rryrZd_tagZe_tagZf_tagZa_stringrrrÚtest_replace_with_multiple-s
 
 
 
z/TestTreeModification.test_replace_with_multiplecCs0d}| |¡}|j |j¡d| ¡ks,t‚dS)Nrz<a><c></c></a>)rrrrbrxrr<rrrÚtest_replace_first_child<s
z-TestTreeModification.test_replace_first_childcCs0d}| |¡}|j |j¡d| ¡ks,t‚dS)Nrr%)rrbrrrxrr<rrrÚtest_replace_last_childBs
z,TestTreeModification.test_replace_last_childcCs| d¡}|j}|j}| |¡| ¡| d¡ks6t‚|jdksDt‚|jddj    dksZt‚|j
dksht‚|j dksvt‚|j dks„t‚|j|j ks”t‚|j
dks¢t‚|j    j    |jks´t‚|j dksÂt‚|jdd}|j}|j    |ksât‚|j |ksðt‚|j
|ksþt‚|j |kst‚dS)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>r2r ZWeÚto)rrrƒrrxrrr¶rrÐrärörr-r?r>)rrZ
remove_tagZmove_tagZto_textZg_tagrrrÚtest_nested_tag_replace_withHs0ÿ
 
ÿ
 z1TestTreeModification.test_nested_tag_replace_withcCs6| d¡}|j ¡|jdks"t‚|jjdks2t‚dS)NzI
            <p>Unneeded <em>formatting</em> is unneeded</p>
            zUnneeded formatting is unneeded)rÚemrrrar%rsrrrÚ test_unwrapls
 
z TestTreeModification.test_unwrapcCsF| d¡}|j | d¡¡}| ¡dks,t‚| ¡| d¡ksBt‚dS)NzI wish I was bold.rú<b>I wish I was bold.</b>)rrÚwraprRrxrr)rrr‰rrrÚ    test_wrapts
zTestTreeModification.test_wrapcCs4| d¡}|jj |j¡| ¡| d¡ks0t‚dS)Nz<b></b>I wish I was bold.rl)rrrörmrxrrrrrrÚ%test_wrap_extracts_tag_from_elsewherezs
z:TestTreeModification.test_wrap_extracts_tag_from_elsewherecCsH| d¡}|jj |j¡dt|jjƒks.t‚| ¡| d¡ksDt‚dS)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>)    rrrörmr*r¥rrxrrrrrÚ&test_wrap_puts_new_contents_at_the_ends 
 
ÿz;TestTreeModification.test_wrap_puts_new_contents_at_the_endcCsâ| d¡}t|jjƒdkst‚|jdd ¡}| ¡dks>t‚| ¡dksNt‚t|jjƒdksbt‚|jdkspt‚|j    dks~t‚|j
j
dksŽt‚|jdd    }|jd
d    }|j
|ks´t‚|j |ksÂt‚|j    |ksÐt‚|j |ksÞt‚dS) NzR<html><body>Some content. <div id="nav">Nav crap</div> More content.</body></html>r:Únavr"z6<html><body>Some content.  More content.</body></html>z<div id="nav">Nav crap</div>r(zSome content. r z More content.) rr*rîr¥rrr!rxr¶rärÐrör)rrZ    extractedZ    content_1Z    content_2rrrÚ test_extract‡s"ÿ  z!TestTreeModification.test_extractcCsz| d¡}|jj}|jj}| d¡}| d¡}|j |¡|j |¡| ¡| ¡||jjksft‚||jjksvt‚dS)Nr'rEr4)rr-rrr[rHr!r)rrZfoo_1Zbar_1Zfoo_2Zbar_2rrrÚ4test_extract_distinguishes_between_identical_stringsŸs
 
 
  zITestTreeModification.test_extract_distinguishes_between_identical_stringscs8| d¡‰‡fdd„ˆ d¡Dƒdtˆjƒks4t‚dS)Nzv
<html>
<head>
<script>foo</script>
</head>
<body>
 <script>bar</script>
 <a></a>
</body>
<script>baz</script>
</html>csg|]}ˆj ¡‘qSr)Úscriptr!)rÅr®©rrrrƼszKTestTreeModification.test_extract_multiples_of_same_tag.<locals>.<listcomp>rtz<body>
 
<a></a>
</body>)rr+r$rîrrXrrurÚ"test_extract_multiples_of_same_tag°s
z7TestTreeModification.test_extract_multiples_of_same_tagcCs.| d¡}| d¡ ¡d| d¡ks*t‚dS)Nz<html>
<body>hi</body>
</html>rî)rrr!rrrrrÚBtest_extract_works_when_element_is_surrounded_by_identical_stringsÀs
ÿzWTestTreeModification.test_extract_works_when_element_is_surrounded_by_identical_stringscCsd| d¡}|j}|j ¡t|jjƒdks.t‚t|dƒs<t‚|j}|jdddt|jƒks`t‚dS)z Tag.clear()z4<p><a>String <em>Italicized</em></a> and another</p>rr¥T)Ú    decomposeN)    rr-raÚclearr*r¥rrLrj)rrr-rjrrrÚ
test_clearÉs
 
 zTestTreeModification.test_clearcCs~| d¡}| d¡\}}|j}|jj}||||fD]}d|jks2t‚q2| ¡|||fD]}d|jksXt‚qXd|jkszt‚dS)Nz;<p><a>String <em>Italicized</em></a></p><p>Another para</p>raFT)rr+r-rjrZ
decomposedrrx)rrr.r)r-r%r®rrrÚtest_decomposeØs
z#TestTreeModification.test_decomposecCsB| d¡}d|j_|jjdgks$t‚d|j_|jjdgks>t‚dS)zTag.string = 'string'z<a></a> <b><c></c></b>rEr4N)rr-rr¥rrrrrrÚtest_string_setès
 
z$TestTreeModification.test_string_setcCs,| d¡}|jj|j_|j ¡dks(t‚dS)Nz<a><b>foo</b><c>bar</c>s<a><b>bar</b><c>bar</c></a>)rrbrrr-rwrrrrrÚ/test_string_set_does_not_affect_original_stringðs
 zDTestTreeModification.test_string_set_does_not_affect_original_stringcCs0| d¡}tdƒ}||j_t|jjtƒs,t‚dS)NrGrE)rrr-rr+r)rrÚcdatarrrÚ)test_set_string_preserves_class_of_stringõs
z>TestTreeModification.test_set_string_preserves_class_of_stringN)3r/r0r1rrrrr r"r#r'r(r/r3r7r8r9r;r=rAr«ÚmarkÚ parametrizerHrIrKrTrVrXrYr^r_rcrdrerfrgrirkrnrorprrrsrvrwrzr{r|r}rrrrrrÈsb    
 
 
    ÿ
 
        $    rc@sBeZdZej ddddddddd    d
d d d g ¡dd„ƒZdd„ZdS)ÚTestDeprecatedArgumentsÚ method_namerr+r¿r½rÚrØrërérürþr
r c    Csf| d¡}t|j|ƒ}tjdd:}|dd|\}|jtksBt‚t|j    ƒ}|dksXt‚W5QRXdS)Nz<a>some</a><b>markup</b>T©Úrecordrô©r%zOThe 'text' argument to find()-type methods is deprecated. Use 'string' instead.)
rÚgetattrrÚwarningsÚcatch_warningsÚfilenameÚ__file__rr$Úmessage)rrƒrÚmethodÚwÚwarningÚmsgrrrÚtest_find_type_method_stringþs    
 
 
z4TestDeprecatedArguments.test_find_type_method_stringc    Cs^tjddH}tdd}|jdks&t‚|\}t|jƒ}|jtksDt‚|dksPt‚W5QRXdS)NTr„r%r†zXThe 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead.)    rˆr‰r r%rr$rŒrŠr‹)rrŽrrrrrrÚ$test_soupstrainer_constructor_strings
 
z<TestDeprecatedArguments.test_soupstrainer_constructor_stringN)r/r0r1r«r€rr‘r’rrrrr‚üs$üÿ
 
r‚))r2Úpdbrr«r7rˆZbs4rZ bs4.builderrrZ bs4.elementrrrr    r
r r r rrrròrrr3rOrUrqržr¨r±rÉrËrârñrõrrr‚rrrrÚ<module>s:
 4 9N5,2(1--8