
    ,hk                     6   d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZmZ ddlmZmZmZmZmZmZmZ ddlZddlmZmZmZ ddlmZmZmZ ddlZ	 dd	l
mZmZ d
Z ejF                  d   dk(  xr ejF                  dk  Z$ G d de      Z% G d de      Z& G d de      Z& G d de      Z' G d dejP                        Z) G d de      Z* G d dejP                        Z+ G d de      Z, G d dejP                        Z-y# e!$ rZ"dZ Y dZ"["dZ"["ww xY w)z#Tests of Beautiful Soup as a whole.    )	set_traceN)BeautifulSoupBeautifulStoneSoup)TreeBuilderParserRejectedMarkup)CharsetMetaAttributeValueCommentContentMetaAttributeValueSoupStrainerNamespacedAttributeTagNavigableString)EntitySubstitutionUnicodeDammitEncodingDetector)default_builderSoupTestskipIf)LXMLTreeBuilderLXMLTreeBuilderForXMLTF   )r      c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestConstructorc                 v    d}| j                  |      }| j                  d|j                  j                         y )Nu   <h1>éé</h1>u   éésoupassertEqualh1stringselfdatar   s      U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/bs4/tests/test_soup.pytest_short_unicode_inputz(TestConstructor.test_short_unicode_input3   s,    yy0    c                 v    d}| j                  |      }| j                  d|j                  j                         y )Nz<h1>foo bar</h1>zfoo barr   r!   s      r$   test_embedded_nullz"TestConstructor.test_embedded_null8   s,    "yyTWW^^4r&   c                     dj                  d      }| j                  |dg      }| j                  d|j                         y N   Räksmörgåsutf-8)exclude_encodingszwindows-1252)encoder   r   original_encoding)r"   	utf8_datar   s      r$   test_exclude_encodingsz&TestConstructor.test_exclude_encodings=   s<    #**73	yywiy@)?)?@r&   c                     G d dt               }t        dd      }t        j                  d      5  t	        dd|i|}d d d        t        j                  |      sJ | j                  t        d	      |j                  j                         | j                  d
|j                  j                          |di |}t        j                  d      5 }t	        d|d      }d d d        t        d   j                        }|j                  d      sJ | j                  ||j                         | j                  ||j                         y # 1 sw Y   xY w# 1 sw Y   zxY w)Nc                   8    e Zd Zd Zd Zd Zd Zd ZexZZ	d Z
y)7TestConstructor.test_custom_builder_class.<locals>.Mockc                 J    || _         d| _        d| _        g | _        g | _        y )NTF)called_withis_xmlstore_line_numberscdata_list_attributespreserve_whitespace_tags)r"   kwargss     r$   __init__z@TestConstructor.test_custom_builder_class.<locals>.Mock.__init__F   s)    #) "*/'-/*02-r&   c                      y N )r"   r   s     r$   initialize_soupzGTestConstructor.test_custom_builder_class.<locals>.Mock.initialize_soupL       r&   c                     || _         y r>   )fedr"   markups     r$   feedz<TestConstructor.test_custom_builder_class.<locals>.Mock.feedN   s	    !r&   c                      y r>   r?   r"   s    r$   resetz=TestConstructor.test_custom_builder_class.<locals>.Mock.resetP   rA   r&   c                      y r>   r?   )r"   ignores     r$   rK   z>TestConstructor.test_custom_builder_class.<locals>.Mock.ignoreR   rA   r&   c              ?      K   d y w)N)prepared markupzoriginal encodingzdeclared encodingzcontains replacement charactersr?   r"   argsr;   s      r$   prepare_markupzFTestConstructor.test_custom_builder_class.<locals>.Mock.prepare_markupU   s     tts   N)__name__
__module____qualname__r<   r@   rF   rI   rK   set_up_substitutionscan_be_empty_elementrP   r?   r&   r$   Mockr4   E   s-    3":@@ #7ur&   rV   valueT)varconvertEntitiesrecord builder)rX   rM   )r]   ignored_valuer   zCKeyword arguments to the BeautifulSoup constructor will be ignored.)r\   r?   )objectdictwarningscatch_warningsr   
isinstancer]   r   r6   rC   strmessage
startswith)r"   rV   r;   r   r]   wmsgs          r$   test_custom_builder_classz)TestConstructor.test_custom_builder_classB   s7   	u6 	u&  !	
 $$D1 	= <T<V<D	=$,,--'*DLL,D,DE*DLL,<,<=
 ..$$D1 	Q G4D	 !A$,,~~cdd$,,/!4!45#	= 	=	 	s   EEEE&c                 l     G d dt               }d }dd l}| j                  t        dt        d|       y )Nc                       e Zd Zd Zy):TestConstructor.test_parser_markup_rejection.<locals>.Mockc                     t        d      )NzNope.)r   rN   s      r$   rF   z?TestConstructor.test_parser_markup_rejection.<locals>.Mock.feedu   s    *733r&   N)rQ   rR   rS   rF   r?   r&   r$   rV   rl   t   s    4r&   rV   c              ?   <   K   t         d d df t         d d df y w)NF)rE   rN   s      r$   rP   zDTestConstructor.test_parser_markup_rejection.<locals>.prepare_markupx   s&      $e++$e++s   r   zoThe markup you provided was rejected by the parser. Trying a different parser or a different encoding may help.r\   )r]   )r   reassertRaisesRegexr   r   )r"   rV   rP   ro   s       r$   test_parser_markup_rejectionz,TestConstructor.test_parser_markup_rejectionq   s8    	4; 	4	, 	 }2t 	 	
r&   c                    d}| j                  |      }|j                  }| j                  d|d          | j                  ddg|d          | j                  |t        d       }| j                  d|j                  d          ddiddifD ]m  }t	        j
                  d	
      5 }| j                  |d |      }d d d        |j                  }| j                  ddg|d          | j                  d|d          o y # 1 sw Y   DxY w)Nz&<a id=" an id " class=" a class "></a>z an id idaclass)r]   multi_valued_attributesz	 a class *TrZ   an)r   rt   r   r   ra   rb   )r"   rE   r   rt   
switcheroorg   s         r$   test_cdata_list_attributesz*TestConstructor.test_cdata_list_attributes   s    :yy  FFAdG,#w74
 yyRVyWdffWo6  ;d4 	6J((5 [ yyzyZ[ AdD\1T73[!G*5	6[ [s   $C<<D	c           	           G d dt                G d dt               G d dt              | j                  dt         t        t        i      }t	        fd	|j                         D              sJ y )
Nc                       e Zd Zy)9TestConstructor.test_replacement_classes.<locals>.TagPlusNrQ   rR   rS   r?   r&   r$   TagPlusr}          r&   r   c                       e Zd Zy)<TestConstructor.test_replacement_classes.<locals>.StringPlusNr~   r?   r&   r$   
StringPlusr      r   r&   r   c                       e Zd Zy)=TestConstructor.test_replacement_classes.<locals>.CommentPlusNr~   r?   r&   r$   CommentPlusr      r   r&   r   z<a><b>foo</b>bar</a><!--whee-->)element_classesc              3   <   K   | ]  }t        |f        y wr>   )rc   ).0xr   r   r   s     r$   	<genexpr>z;TestConstructor.test_replacement_classes.<locals>.<genexpr>   s'      
 q7J<=
s   )r   r   r	   r   allrecursiveChildGenerator)r"   r   r   r   r   s     @@@r$   test_replacement_classesz(TestConstructor.test_replacement_classes   s}    	c 		 		' 	 yy-W  
  
113
 
 	
 
r&   N)
rQ   rR   rS   r%   r(   r1   ri   rq   rz   r   r?   r&   r$   r   r   1   s'    1
5
A
-6^
(6:
r&   r   c                   8    e Zd Zd	dZd Zd Zd Zd Zd Zd Z	y)
TestWarningsc                 j    |j                  t        j                  d d       }| j                  |       y )NP   )rf   r   NO_PARSER_SPECIFIED_WARNING
assertTrue)r"   sis_therevs       r$   _no_parser_specifiedz!TestWarnings._no_parser_specified   s)    LLBB3BGHr&   c                     t        j                  d      5 }| j                  d      }d d d        t        d   j                        }| j                  |       y # 1 sw Y   3xY w)NTrZ   <a><b></b></a>r   ra   rb   r   rd   re   _assert_no_parser_specifiedr"   rg   r   rh   s       r$   #test_warning_if_no_parser_specifiedz0TestWarnings.test_warning_if_no_parser_specified   sV    $$D1 	/Q99-.D	/!A$,,((-	/ 	/s   AA$c                     t        j                  d      5 }| j                  dd      }d d d        t        d   j                        }| j                  |       y # 1 sw Y   3xY w)NTrZ   r   htmlr   r   r   s       r$   *test_warning_if_parser_specified_too_vaguez7TestWarnings.test_warning_if_parser_specified_too_vague   sX    $$D1 	7Q99-v6D	7!A$,,((-	7 	7s   AA%c                     t        j                  d      5 }| j                  dd      }d d d        | j                  g        y # 1 sw Y   xY w)NTrZ   r   html.parser)ra   rb   r   r   )r"   rg   r   s      r$   ,test_no_warning_if_explicit_parser_specifiedz9TestWarnings.test_no_warning_if_explicit_parser_specified   sH    $$D1 	>Q99-}=D	>Q	> 	>s   AAc                 N   t        j                  d      5 }| j                  dt        d            }d d d        t	        d   j
                        }| j                  d|v        | j                  d|v        | j                  d	j                                y # 1 sw Y   hxY w)
NTrZ   r   b)parseOnlyTheser   r   
parse_onlys   <b></b>)	ra   rb   r   r   rd   re   r   r   r.   r   s       r$   )test_parseOnlyThese_renamed_to_parse_onlyz6TestWarnings.test_parseOnlyThese_renamed_to_parse_only   s    $$D1 	QQ99-l3>O9PD	Q!A$,,(C/0+,T[[]3	Q 	Qs   BB$c                 8   t        j                  d      5 }d}| j                  |d      }d d d        t        d   j                        }| j                  d|v        | j                  d|v        | j                  dj                         y # 1 sw Y   dxY w)	NTrZ   s   éutf8)fromEncodingr   r   from_encoding)ra   rb   r   rd   re   r   r   r/   )r"   rg   r   r   rh   s        r$   *test_fromEncoding_renamed_to_from_encodingz7TestWarnings.test_fromEncoding_renamed_to_from_encoding   s    $$D1 	8QD99T97D	8 !A$,,#-.3./!7!78	8 	8s   BBc                 J    | j                  t        | j                  dd       y )Nz<a>T)no_such_argument)assertRaises	TypeErrorr   rH   s    r$   "test_unrecognized_keyword_argumentz/TestWarnings.test_unrecognized_keyword_argument   s#    tyy%$ 	 	@r&   N)T)
rQ   rR   rS   r   r   r   r   r   r   r   r?   r&   r$   r   r      s&    .. 
49@r&   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)r   c                    t        j                         }|j                  }	 t        j                  d      5 }| j                  |      }d d d        t        d   j                        }| j                  d|v        |j                          t        j                  d      5 }| j                  |      }d d d        | j                  dt        |             y # 1 sw Y   xY w# |j                          w xY w# 1 sw Y   FxY w)NTrZ   r   zlooks like a filename)tempfileNamedTemporaryFilenamera   rb   r   rd   re   r   closer   len)r"   
filehandlefilenamerg   r   rh   s         r$   test_disk_file_warningz#TestWarnings.test_disk_file_warning   s    002
??	((5 +yy*+adll#COO3s:; $$D1 	'Q99X&D	'CF#+ +
 	' 	's.   C% C
3C% #C:C"C% %C7:Dc                     t        j                  d      5 }| j                  d      }d d d        | j                  t	        d D                     y # 1 sw Y   +xY w)NTrZ   s   http://www.crummybytes.com/c              3   J   K   | ]  }d t        |j                        v   ywzlooks like a URLNrd   re   r   rg   s     r$   r   z?TestWarnings.test_url_warning_with_bytes_url.<locals>.<genexpr>  %      # /#aii.@ #   !#ra   rb   r   r   anyr"   warning_listr   s      r$   test_url_warning_with_bytes_urlz,TestWarnings.test_url_warning_with_bytes_url   sX    $$D1 	=\99;<D	= 	 #!# # 	$		= 	=   AAc                     t        j                  d      5 }| j                  d      }d d d        | j                  t	        d D                     y # 1 sw Y   +xY w)NTrZ   zhttp://www.crummyunicode.com/c              3   J   K   | ]  }d t        |j                        v   ywr   r   r   s     r$   r   zATestWarnings.test_url_warning_with_unicode_url.<locals>.<genexpr>	  r   r   r   r   s      r$   !test_url_warning_with_unicode_urlz.TestWarnings.test_url_warning_with_unicode_url  sZ    $$D1 	>\ 99<=D	> 	 #!# # 	$		> 	>r   c                     t        j                  d      5 }| j                  d      }d d d        | j                  t	        d D                     y # 1 sw Y   +xY w)NTrZ   s$   http://www.crummybytes.com/ is greatc              3   J   K   | ]  }d t        |j                        v   ywr   r   r   s     r$   r   zETestWarnings.test_url_warning_with_bytes_and_space.<locals>.<genexpr>  %      # 03qyy>A #r   ra   rb   r   assertFalser   r   s      r$   %test_url_warning_with_bytes_and_spacez2TestWarnings.test_url_warning_with_bytes_and_space  \    $$D1 	F\99DED	F #!# # 	$	F 	Fr   c                     t        j                  d      5 }| j                  d      }d d d        | j                  t	        d D                     y # 1 sw Y   +xY w)NTrZ   z%http://www.crummyuncode.com/ is greatc              3   J   K   | ]  }d t        |j                        v   ywr   r   r   s     r$   r   zGTestWarnings.test_url_warning_with_unicode_and_space.<locals>.<genexpr>  r   r   r   r   s      r$   'test_url_warning_with_unicode_and_spacez4TestWarnings.test_url_warning_with_unicode_and_space  r   r   N)rQ   rR   rS   r   r   r   r   r   r?   r&   r$   r   r      s    $ $$$$r&   c                       e Zd Zd Zy)TestSelectiveParsingc                     d}t        d      }| j                  ||      }| j                  |j                         d       y )Nz&No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>r   )r   s   <b>Yes</b><b>Yes <c>Yes</c></b>)r   r   r   r.   )r"   rE   strainerr   s       r$   test_parse_with_soupstrainerz1TestSelectiveParsing.test_parse_with_soupstrainer  s:    9$yyHy5(JKr&   N)rQ   rR   rS   r   r?   r&   r$   r   r     s    Lr&   r   c                   ^    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zy)TestEntitySubstitutionz1Standalone tests of the EntitySubstitution class.c                     t         | _        y r>   )r   subrH   s    r$   setUpzTestEntitySubstitution.setUp$  s	    %r&   c                 ^    d}| j                  | j                  j                  |      d       y )Nu   foo∀☃õbaru   foo&forall;☃&otilde;barr   r   substitute_htmlr"   r   s     r$   test_simple_html_substitutionz4TestEntitySubstitution.test_simple_html_substitution'  s+     ,11!4=	?r&   c                     d}t        |      }| j                  | j                  j                  |j                        d       y )Ns   fooz&lsquo;&rsquo;foo&ldquo;&rdquo;)r   r   r   r   rE   )r"   quotesdammits      r$   test_smart_quote_substitutionz4TestEntitySubstitution.test_smart_quote_substitution.  s9     (v&11&--@;	=r&   c                 `    d}| j                  | j                  j                  |d      |       y )NWelcome to "my bar"Fr   r   substitute_xmlr   s     r$   Itest_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_falsez`TestEntitySubstitution.test_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_false6  s(    !00E:A>r&   c                     | j                  | j                  j                  dd      d       | j                  | j                  j                  dd      d       y )NWelcomeTz	"Welcome"z	Bob's Barz"Bob's Bar"r   rH   s    r$   6test_xml_attribute_quoting_normally_uses_double_quoteszMTestEntitySubstitution.test_xml_attribute_quoting_normally_uses_double_quotes:  sJ    00DA%	'00dC(	*r&   c                 `    d}| j                  | j                  j                  |d      d       y )Nr   Tz'Welcome to "my bar"'r   r   s     r$   Otest_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quoteszfTestEntitySubstitution.test_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotes@  s+    !00D93	5r&   c                 `    d}| j                  | j                  j                  |d      d       y )NWelcome to "Bob's Bar"Tz""Welcome to &quot;Bob's Bar&quot;"r   r   s     r$   btest_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quoteszyTestEntitySubstitution.test_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotesE  s,    %HH##At,1	3r&   c                 ^    d}| j                  | j                  j                  |      |       y )Nr   r   )r"   quoteds     r$   <test_xml_quotes_arent_escaped_when_value_is_not_being_quotedzSTestEntitySubstitution.test_xml_quotes_arent_escaped_when_value_is_not_being_quotedK  s&    *008&Ar&   c                 Z    | j                  | j                  j                  d      d       y )Nzfoo<bar>zfoo&lt;bar&gt;r   rH   s    r$   'test_xml_quoting_handles_angle_bracketsz>TestEntitySubstitution.test_xml_quoting_handles_angle_bracketsO  s%    HH##J/	r&   c                 Z    | j                  | j                  j                  d      d       y )NzAT&TzAT&amp;Tr   rH   s    r$   #test_xml_quoting_handles_ampersandsz:TestEntitySubstitution.test_xml_quoting_handles_ampersandsT  s!    008*Er&   c                 Z    | j                  | j                  j                  d      d       y )N&Aacute;T&Tz&amp;Aacute;T&amp;Tr   rH   s    r$   Etest_xml_quoting_including_ampersands_when_they_are_part_of_an_entityz\TestEntitySubstitution.test_xml_quoting_including_ampersands_when_they_are_part_of_an_entityW  s%    HH##M2!	#r&   c                 Z    | j                  | j                  j                  d      d       y )Nr   z&Aacute;T&amp;T)r   r   "substitute_xml_containing_entitiesrH   s    r$   Dtest_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entityz[TestEntitySubstitution.test_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entity\  s%    HH77F	r&   c                 ^    d}| j                  | j                  j                  |      |       y)z:There's no need to do this except inside attribute values.zBob's "bar"Nr   )r"   texts     r$    test_quotes_not_html_substitutedz7TestEntitySubstitution.test_quotes_not_html_substituteda  s&    11$7>r&   N)rQ   rR   rS   __doc__r   r   r   r   r   r   r   r   r   r   r  r  r  r?   r&   r$   r   r   "  sH    ;&?=?*5
3B
F#

?r&   r   c                   T     e Zd Z fdZd Zd Zd Zd Z ee	d      d        Z
 xZS )TestEncodingConversionc                     t         t        |           d| _        | j                  j	                  d      | _        | j                  | j
                  d       y )NuU   <html><head><meta charset="utf-8"/></head><body><foo>Sacré bleu!</foo></body></html>r,   sU   <html><head><meta charset="utf-8"/></head><body><foo>Sacré bleu!</foo></body></html>)superr
  r   unicode_datar.   r0   r   )r"   	__class__s    r$   r   zTestEncodingConversion.setUpk  sM    $d13 U**11':NNj	lr&   c                    t         j                  j                  }t        j                  t        j
                         	 d }|t         j                  _        d}| j                  |      }|j                         }| j                  t        |t                     | j                  || j                  |j                                      | j                  |j                  j                         d       t        j                  t        j                         |t         j                  _        y # t        j                  t        j                         |t         j                  _        w xY w)Nc                      y r>   r?   rd   s    r$   noopz>TestEncodingConversion.test_ascii_in_unicode_out.<locals>.noopz      r&   s   <foo>a</foo>r,   )bs4r   chardet_dammitloggingdisableWARNINGr   decoder   rc   rd   r   document_forr/   lowerNOTSET)r"   chardetr  asciisoup_from_asciiunicode_outputs         r$   test_ascii_in_unicode_outz0TestEncodingConversion.test_ascii_in_unicode_outt  s     **++(	0 )-CJJ%#E"ii.O,335NOOJ~s;<^T->->u||~-NO_>>DDFPOOGNN+(/CJJ% OOGNN+(/CJJ%s   B3D+ +:E%c                    | j                  | j                        }| j                  |j                         | j                         | j                  |j                  j
                  d       | j                  |j                  d        y Nu   Sacré bleu!)r   r  r   r  foor    r/   r"   soup_from_unicodes     r$   test_unicode_in_unicode_outz2TestEncodingConversion.test_unicode_in_unicode_out  sn     !IId&7&78*113T5F5FG*..557GH*<<dCr&   c                     | j                  | j                        }| j                  |j                         | j                         | j                  |j
                  j                  d       y r#  )r   r0   r   r  r  r$  r    )r"   soup_from_utf8s     r$   test_utf8_in_unicode_outz/TestEncodingConversion.test_utf8_in_unicode_out  sR     4>>2..0$2C2CD++224DEr&   c                     | j                  | j                        }| j                  |j                  d      | j                         y )Nr,   )r   r  r   r.   r0   r%  s     r$   test_utf8_outz$TestEncodingConversion.test_utf8_out  s7     IId&7&78*11':DNNKr&   zQBad HTMLParser detected; skipping test of non-ASCII characters in attribute name.c                     d}| j                  | j                  |      j                  j                  d      |j                  d             y )Nu    <div><a ☃="snowman"></a></div>r   )r   r   divr.   rD   s     r$   1test_attribute_name_containing_unicode_characterszHTestEncodingConversion.test_attribute_name_containing_unicode_characters  s<     <6*..55f=v}}V?TUr&   )rQ   rR   rS   r   r!  r'  r*  r,  r   PYTHON_3_PRE_3_2r/  __classcell__)r  s   @r$   r
  r
  g  sC    l0(DFL
 []V]Vr&   r
  c                   |    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestUnicodeDammitz"Standalone tests of UnicodeDammit.c                 V    d}t        |      }| j                  |j                  |       y )Nu   I'm already Unicode! ☃r   r   unicode_markupr"   rE   r   s      r$   test_unicode_inputz$TestUnicodeDammit.test_unicode_input  s'    3v&..7r&   c                 V    d}t        |      }| j                  |j                  d       y )N   <foo></foo>u   <foo>‘’“”</foo>r5  r7  s      r$   test_smart_quotes_to_unicodez.TestUnicodeDammit.test_smart_quotes_to_unicode  s,    /v&!!#H	Jr&   c                 Z    d}t        |d      }| j                  |j                  d       y )Nr:  xmlsmart_quotes_toz+<foo>&#x2018;&#x2019;&#x201C;&#x201D;</foo>r5  r7  s      r$   !test_smart_quotes_to_xml_entitiesz3TestUnicodeDammit.test_smart_quotes_to_xml_entities  s.    /vu=!!#P	Rr&   c                 Z    d}t        |d      }| j                  |j                  d       y )Nr:  r   r>  z'<foo>&lsquo;&rsquo;&ldquo;&rdquo;</foo>r5  r7  s      r$   "test_smart_quotes_to_html_entitiesz4TestUnicodeDammit.test_smart_quotes_to_html_entities  s.    /vv>!!#L	Nr&   c                 Z    d}t        |d      }| j                  |j                  d       y )Nr:  r  r>  z<foo>''""</foo>r5  r7  s      r$   test_smart_quotes_to_asciiz,TestUnicodeDammit.test_smart_quotes_to_ascii  s-    /vw?!!#8	:r&   c                     d}t        |      }| j                  |j                  j                         d       | j                  |j                  d       y )Ns   Sacré bleu! ☃r,   u   Sacré bleu! ☃r   r   r/   r  r6  )r"   r   r   s      r$   test_detect_utf8z"TestUnicodeDammit.test_detect_utf8  sG    1t$117797C..0LMr&   c                     d}t        |dg      }| j                  |j                  j                         d       | j                  |j                  d       y )Ns   
iso-8859-8u   םולשrF  )r"   hebrewr   s      r$   test_convert_hebrewz%TestUnicodeDammit.test_convert_hebrew  sK    $v~611779<H..0JKr&   c                     d}t        |      }| j                  |j                  j                         d       | j                  |j                  j                  d      |       y )Ns   ケータイ Watchr,   )r   r   r/   r  r6  r.   )r"   utf_8r   s      r$   /test_dont_see_smart_quotes_where_there_are_nonezATestUnicodeDammit.test_dont_see_smart_quotes_where_there_are_none  sQ    Iu%117797C..55g>Fr&   c                     dj                  d      }t        |dg      }| j                  |j                  j	                         d       y )Nr+   r,   rI  r.   r   r   r/   r  r"   r0   r   s      r$    test_ignore_inappropriate_codecsz2TestUnicodeDammit.test_ignore_inappropriate_codecs  s?    #**73	y<.9117797Cr&   c                     dj                  d      }dD ]9  }t        ||g      }| j                  |j                  j	                         d       ; y )Nr+   r,   )z.utf8z...z
utF---16.!rP  )r"   r0   bad_encodingr   s       r$   test_ignore_invalid_codecsz,TestUnicodeDammit.test_ignore_invalid_codecs  sP    #**73	: 	HL"9|n=FV55;;=wG	Hr&   c                     dj                  d      }t        |dg      }| j                  |j                  j	                         d       t        |ddg      }| j                  |j                  d        y r*   rP  rQ  s      r$   r1   z(TestUnicodeDammit.test_exclude_encodings  sn    #**73	 yWIF11779>J '>)BD1148r&   c                 P    t        d      }t        |j                        }d|v sJ y )Ns'   <?xml version="1.0" encoding="UTF-" ?>u   utf-�)r   list	encodings)r"   detectedrY  s      r$   Ptest_encoding_detector_replaces_junk_in_encoding_name_with_replacement_characterzbTestUnicodeDammit.test_encoding_detector_replaces_junk_in_encoding_name_with_replacement_character  s-    #9;++,	.);;;r&   c                 d    dD ]+  }t        |d      }| j                  d|j                         - y )N)s&   <html><meta charset="euc-jp" /></html>s&   <html><meta charset='euc-jp' /></html>s$   <html><meta charset=euc-jp /></html>s#   <html><meta charset=euc-jp/></html>Tis_htmleuc-jp)r   r   r/   r"   r#   r   s      r$    test_detect_html5_style_meta_tagz2TestUnicodeDammit.test_detect_html5_style_meta_tag  s:    4 	4D
 #46F&224	4r&   c                 t   d}t         j                  j                  }t        j                  t        j
                         	 d }|t         j                  _        t        |      }| j                  d|j                         | j                  d|j                  v        t        |d      }| j                  |j                         t        j                  t        j                         |t         j                  _        y # t        j                  t        j                         |t         j                  _        w xY w)NsT   ﻿<?xml version="1.0" encoding="UTF-8"?>
<html><b>بتر</b>
<i>ѐ</i></html>c                      y r>   r?   r  s    r$   r  zBTestUnicodeDammit.test_last_ditch_entity_replacement.<locals>.noop  r  r&   Tu   �r   )r  r   r  r  r  r  r   r   contains_replacement_charactersr   r6  r   r  )r"   docr  r  r   r   s         r$   "test_last_ditch_entity_replacementz4TestUnicodeDammit.test_last_ditch_entity_replacement   s     2 **++(	0(,CJJ%"3'FT6#I#IJOOH(=(==> m4DOOD@@AOOGNN+(/CJJ% OOGNN+(/CJJ%s   BC= =:D7c                     d}t        |      }| j                  d|j                         | j                  d|j                         y )Ns   < a >   < / a > u   <a>áé</a>zutf-16le)r   r   r6  r/   r`  s      r$   test_byte_order_mark_removedz.TestUnicodeDammit.test_byte_order_mark_removed#  s=    Mt$(=(=>V%=%=>r&   c                    dj                  d      }dj                  d      }||z   |z   }| j                  t        |j                  d       t	        j
                  |      }| j                  d|j                  d             y )Nu	   ☃☃☃r   u   “Hi, I like Windows!”windows_1252u+   ☃☃☃“Hi, I like Windows!”☃☃☃)r.   r   UnicodeDecodeErrorr  r   	detwingler   )r"   r   rj  re  fixeds        r$   test_detwinglez TestUnicodeDammit.test_detwingle*  s    !))&1./5vn/E 	
 \!D( 	,cjj&A '',95<<;O	Qr&   c                     dD ]Z  }|j                  d      }| j                  |j                  d             t        j                  |      }| j                  ||       \ y )N)u   œu   ₓu   ðr      )r.   r   endswithr   rl  r   )r"   tricky_unicode_charinputoutputs       r$   +test_detwingle_ignores_multibyte_charactersz=TestUnicodeDammit.test_detwingle_ignores_multibyte_charactersB  s[    
$ 	,
 (..v6EOOENN734",,U3FVU+	,r&   c                    d}|j                  d      }d}|j                  d      }t        j                  }| j                  d  ||d             | j                  d ||d             | j                  d ||d             | j                  d ||             | j                  d ||             d	d
z  }| j                  d  |||z                | j                  d  |||z                | j                  d |||z   dd             | j                  d ||d             | j                  d  |d|z   d             y )Nz0<html><head><meta charset="utf-8"></head></html>r  z,<?xml version="1.0" encoding="ISO-8859-1" ?>Fr]  r,   Tz
iso-8859-1    i  )r^  search_entire_document)rx     a)r.   r   find_declared_encodingr   )r"   html_unicode
html_bytesxml_unicode	xml_bytesmspacers          r$   test_find_declared_encodingz-TestUnicodeDammit.test_find_declared_encodingQ  sH    J!((1
C&&w/	33qu=>!L$"?@!J"=>q~6q|4 q*!456q)!345 	fz!4M	
 	i5	
 	!D9$TB	
r&   N)rQ   rR   rS   r  r8  r;  r@  rB  rD  rG  rK  rN  rR  rU  r1   r[  ra  rf  rh  rn  ru  r  r?   r&   r$   r3  r3    si    ,8
JRN:NLGD
H9<	4!0F?Q0,,
r&   r3  c                       e Zd Zd Zd Zd Zy)TestNamedspacedAttributec                 z    t        dd       }| j                  |d       t        d      }| j                  |d       y )Nxmlnsr   r   r"   rt   s     r$    test_name_may_be_none_or_missingz9TestNamedspacedAttribute.test_name_may_be_none_or_missing  s8    .G$(G$r&   c                 @    t        dd      }| j                  d|       y )Nrt   r   za:br  r  s     r$   6test_attribute_is_equivalent_to_colon_separated_stringzOTestNamedspacedAttribute.test_attribute_is_equivalent_to_colon_separated_string  s    S)"r&   c                    t        ddd      }t        ddd      }| j                  ||       t        ddd       }| j                  ||       t        ddd      }| j                  ||       t        ddd      }| j                  ||       y )Nrt   r   cz)r   r   assertNotEqual)r"   rt   r   r  des         r$   ;test_attributes_are_equivalent_if_prefix_and_name_identicalzTTestNamedspacedAttribute.test_attributes_are_equivalent_if_prefix_and_name_identical  s    S#.S#.A  S$/A  S#.Aq!S#.Aq!r&   N)rQ   rR   rS   r  r  r  r?   r&   r$   r  r    s    %#"r&   r  c                       e Zd Zd Zd Zy))TestAttributeValueWithCharsetSubstitutionc                     t        d      }| j                  d|       | j                  d|j                         | j                  d|j                  d             y )Nr_  r   )r   r   original_valuer.   r"   rW   s     r$   !test_content_meta_attribute_valuezKTestAttributeValueWithCharsetSubstitution.test_content_meta_attribute_value  sK    )(35)5#7#78f!56r&   c                     t        d      }| j                  d|       | j                  d|j                         | j                  d|j                  d             y )Nztext/html; charset=euc-jpztext/html; charset=utf8r   )r
   r   r  r.   r  s     r$   r  zKTestAttributeValueWithCharsetSubstitution.test_content_meta_attribute_value  sO    )*EF4e<4e6J6JK2ELL4HIr&   N)rQ   rR   rS   r  r?   r&   r$   r  r    s    7Jr&   r  ).r  pdbr   r  unittestsysr   r  r   r   bs4.builderr   r   bs4.elementr   r	   r
   r   r   r   r   
bs4.dammitr   r   r   bs4.testingr   r   r   ra   r   r   LXML_PRESENTImportErrorr  version_infor0  r   r   r   TestCaser   r
  r3  r  r  r?   r&   r$   <module>r     s-   )    
     
 
 BL $$Q'1,I1A1AE1I K
h K
Z*@8 *@X,$8 ,$^L8 LB?X.. B?J:VX :VxZ
)) Z
x"x "<J0A0A Jc  Ls   
D DDD