o
    ek                  
   @   s  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zdd	l
mZmZ d
Z W n e!yv Z" zdZ W Y dZ"["ndZ"["ww ej#d dkoej#dk Z$G dd deZ%G dd deZ&G dd deZ&G dd deZ'G dd dej(Z)G dd deZ*G dd dej(Z+G dd deZ,G dd dej(Z-dS )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                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )TestConstructorc                 C   "   d}|  |}| d|jj d S )Nu   <h1>éé</h1>u   éésoupassertEqualh1stringselfdatar    r"   CD:\Projects\ConvertPro\env\Lib\site-packages\bs4/tests/test_soup.pytest_short_unicode_input3      
z(TestConstructor.test_short_unicode_inputc                 C   r   )Nz<h1>foo bar</h1>zfoo barr   r   r"   r"   r#   test_embedded_null8   r%   z"TestConstructor.test_embedded_nullc                 C   s,   d d}| j|dgd}| d|j d S N   Räksmörgåsutf-8)Zexclude_encodingszwindows-1252)encoder   r   original_encoding)r    	utf8_datar   r"   r"   r#   test_exclude_encodings=   s   
z&TestConstructor.test_exclude_encodingsc                 C   s  G dd dt }tddd}tjdd tdd|i|}W d    n1 s(w   Y  t|j|s5J | tdd	|jj | d
|jj	 |di |}tjdd}td|dd}W d    n1 sgw   Y  t
|d j}|dszJ | ||j | ||j d S )Nc                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Ze ZZ	dd Z
dS )z7TestConstructor.test_custom_builder_class.<locals>.Mockc                 [   s"   || _ d| _d| _g | _g | _d S )NTF)called_withZis_xmlZstore_line_numbersZcdata_list_attributesZpreserve_whitespace_tags)r    kwargsr"   r"   r#   __init__F   s
   
z@TestConstructor.test_custom_builder_class.<locals>.Mock.__init__c                 S      d S Nr"   r    r   r"   r"   r#   initialize_soupL      zGTestConstructor.test_custom_builder_class.<locals>.Mock.initialize_soupc                 S   s
   || _ d S r2   )fedr    markupr"   r"   r#   feedN      
z<TestConstructor.test_custom_builder_class.<locals>.Mock.feedc                 S   r1   r2   r"   r    r"   r"   r#   resetP   r5   z=TestConstructor.test_custom_builder_class.<locals>.Mock.resetc                 S   r1   r2   r"   )r    ignorer"   r"   r#   r=   R   r5   z>TestConstructor.test_custom_builder_class.<locals>.Mock.ignorec                    s    dV  d S )N)prepared markupzoriginal encodingzdeclared encodingzcontains replacement charactersr"   r    argsr/   r"   r"   r#   prepare_markupU   s   
zFTestConstructor.test_custom_builder_class.<locals>.Mock.prepare_markupN)__name__
__module____qualname__r0   r4   r9   r<   r=   Zset_up_substitutionsZcan_be_empty_elementrA   r"   r"   r"   r#   MockE   s    rE   valueT)varZconvertEntitiesrecord builder)rG   r>   )rK   Zignored_valuer   zCKeyword arguments to the BeautifulSoup constructor will be ignored.)rJ   r"   )objectdictwarningscatch_warningsr   
isinstancerK   r   r.   r6   strmessage
startswith)r    rE   r/   r   rK   wmsgr"   r"   r#   test_custom_builder_classB   s*   z)TestConstructor.test_custom_builder_classc                 C   s8   G dd dt }dd }dd l}| jtdtd|d d S )	Nc                   @      e Zd Zdd ZdS )z:TestConstructor.test_parser_markup_rejection.<locals>.Mockc                 _   s   t d)NzNope.)r   r?   r"   r"   r#   r9   u   s   z?TestConstructor.test_parser_markup_rejection.<locals>.Mock.feedN)rB   rC   rD   r9   r"   r"   r"   r#   rE   t   s    rE   c                    s"    t d d dfV  t d d dfV  d S )NF)r8   r?   r"   r"   r#   rA   x   s   zDTestConstructor.test_parser_markup_rejection.<locals>.prepare_markupr   zoThe markup you provided was rejected by the parser. Trying a different parser or a different encoding may help.rJ   )rK   )r   reassertRaisesRegexr   r   )r    rE   rA   rX   r"   r"   r#   test_parser_markup_rejectionq   s   
z,TestConstructor.test_parser_markup_rejectionc              	   C   s   d}|  |}|j}| d|d  | ddg|d  | j |td d}| d|jd  ddiddifD ]5}tjd	d
}| j |d |d}W d    n1 sPw   Y  |j}| ddg|d  | d|d  q5d S )Nz&<a id=" an id " class=" a class "></a>z an id idaclass)rK   Zmulti_valued_attributesz	 a class *TrH   Zan)r   r\   r   r   rN   rO   )r    r8   r   r\   Z
switcheroorT   r"   r"   r#   test_cdata_list_attributes   s   
z*TestConstructor.test_cdata_list_attributesc                    sp   G dd dt G dd dtG dd dt | jdt tt id}t fd	d
| D s6J d S )Nc                   @      e Zd ZdS )z9TestConstructor.test_replacement_classes.<locals>.TagPlusNrB   rC   rD   r"   r"   r"   r#   TagPlus       rb   c                   @   r`   )z<TestConstructor.test_replacement_classes.<locals>.StringPlusNra   r"   r"   r"   r#   
StringPlus   rc   rd   c                   @   r`   )z=TestConstructor.test_replacement_classes.<locals>.CommentPlusNra   r"   r"   r"   r#   CommentPlus   rc   re   z<a><b>foo</b>bar</a><!--whee-->)Zelement_classesc                 3   s     | ]}t | fV  qd S r2   )rP   ).0xre   rd   rb   r"   r#   	<genexpr>   s
    
z;TestConstructor.test_replacement_classes.<locals>.<genexpr>)r   r   r   r   allZrecursiveChildGeneratorr3   r"   rh   r#   test_replacement_classes   s   z(TestConstructor.test_replacement_classesN)
rB   rC   rD   r$   r&   r-   rV   rZ   r_   rk   r"   r"   r"   r#   r   1   s    /r   c                   @   sF   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dS )TestWarningsTc                 C   s"   | tjd d }| | d S )NP   )rS   r   ZNO_PARSER_SPECIFIED_WARNING
assertTrue)r    sZis_therevr"   r"   r#   _no_parser_specified   s   z!TestWarnings._no_parser_specifiedc                 C   sR   t jdd}| d}W d    n1 sw   Y  t|d j}| | d S )NTrH   <a><b></b></a>r   rN   rO   r   rQ   rR   Z_assert_no_parser_specifiedr    rT   r   rU   r"   r"   r#   #test_warning_if_no_parser_specified   s
   z0TestWarnings.test_warning_if_no_parser_specifiedc                 C   sT   t jdd}| dd}W d    n1 sw   Y  t|d j}| | d S )NTrH   rr   htmlr   rs   rt   r"   r"   r#   *test_warning_if_parser_specified_too_vague   s
   z7TestWarnings.test_warning_if_parser_specified_too_vaguec                 C   sH   t jdd}| dd}W d    n1 sw   Y  | g | d S )NTrH   rr   html.parser)rN   rO   r   r   )r    rT   r   r"   r"   r#   ,test_no_warning_if_explicit_parser_specified   s   z9TestWarnings.test_no_warning_if_explicit_parser_specifiedc                 C   s|   t jdd}| jdtdd}W d    n1 sw   Y  t|d j}| d|v  | d|v  | d	|  d S )
NTrH   rr   b)parseOnlyTheser   r{   
parse_onlys   <b></b>)	rN   rO   r   r
   rQ   rR   rn   r   r*   rt   r"   r"   r#   )test_parseOnlyThese_renamed_to_parse_only   s   z6TestWarnings.test_parseOnlyThese_renamed_to_parse_onlyc                 C   sz   t jdd}d}| j|dd}W d    n1 sw   Y  t|d j}| d|v  | d|v  | d|j d S )	NTrH   s   éutf8)fromEncodingr   r   Zfrom_encoding)rN   rO   r   rQ   rR   rn   r   r+   )r    rT   r~   r   rU   r"   r"   r#   *test_fromEncoding_renamed_to_from_encoding   s   z7TestWarnings.test_fromEncoding_renamed_to_from_encodingc                 C   s   | j t| jddd d S )Nz<a>T)Zno_such_argument)assertRaises	TypeErrorr   r;   r"   r"   r#   "test_unrecognized_keyword_argument   s   

z/TestWarnings.test_unrecognized_keyword_argumentN)T)
rB   rC   rD   rq   ru   rw   ry   r}   r   r   r"   r"   r"   r#   rl      s    
	rl   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )rl   c                 C   s   t  }|j}z/tjdd}| |}W d    n1 sw   Y  t|d j}| d|v  W |	  n|	  w tjdd}| |}W d    n1 sRw   Y  | 
dt| d S )NTrH   r   zlooks like a filename)tempfileNamedTemporaryFilenamerN   rO   r   rQ   rR   rn   closer   len)r    Z
filehandlefilenamerT   r   rU   r"   r"   r#   test_disk_file_warning   s   z#TestWarnings.test_disk_file_warningc                 C   R   t jdd}| d}W d    n1 sw   Y  | tdd |D  d S )NTrH   s   http://www.crummybytes.com/c                 s       | ]
}d t |jv V  qdS zlooks like a URLNrQ   rR   rf   rT   r"   r"   r#   ri         z?TestWarnings.test_url_warning_with_bytes_url.<locals>.<genexpr>rN   rO   r   rn   anyr    Zwarning_listr   r"   r"   r#   test_url_warning_with_bytes_url   s   z,TestWarnings.test_url_warning_with_bytes_urlc                 C   r   )NTrH   zhttp://www.crummyunicode.com/c                 s   r   r   r   r   r"   r"   r#   ri   	  r   zATestWarnings.test_url_warning_with_unicode_url.<locals>.<genexpr>r   r   r"   r"   r#   !test_url_warning_with_unicode_url  s   z.TestWarnings.test_url_warning_with_unicode_urlc                 C   r   )NTrH   s$   http://www.crummybytes.com/ is greatc                 s   r   r   r   r   r"   r"   r#   ri     r   zETestWarnings.test_url_warning_with_bytes_and_space.<locals>.<genexpr>rN   rO   r   ZassertFalser   r   r"   r"   r#   %test_url_warning_with_bytes_and_space     z2TestWarnings.test_url_warning_with_bytes_and_spacec                 C   r   )NTrH   z%http://www.crummyuncode.com/ is greatc                 s   r   r   r   r   r"   r"   r#   ri     r   zGTestWarnings.test_url_warning_with_unicode_and_space.<locals>.<genexpr>r   r   r"   r"   r#   'test_url_warning_with_unicode_and_space  r   z4TestWarnings.test_url_warning_with_unicode_and_spaceN)rB   rC   rD   r   r   r   r   r   r"   r"   r"   r#   rl      s    c                   @   rW   )TestSelectiveParsingc                 C   s.   d}t d}| j||d}| | d d S )Nz&No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>rz   )r|   s   <b>Yes</b><b>Yes <c>Yes</c></b>)r
   r   r   r*   )r    r8   Zstrainerr   r"   r"   r#   test_parse_with_soupstrainer  s   z1TestSelectiveParsing.test_parse_with_soupstrainerN)rB   rC   rD   r   r"   r"   r"   r#   r     s    r   c                   @   sx   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )TestEntitySubstitutionz1Standalone tests of the EntitySubstitution class.c                 C   s
   t | _d S r2   )r   subr;   r"   r"   r#   setUp$  r:   zTestEntitySubstitution.setUpc                 C   s   d}|  | j|d d S )Nu   foo∀☃õbaru   foo&forall;☃&otilde;barr   r   substitute_htmlr    ro   r"   r"   r#   test_simple_html_substitution'  s   z4TestEntitySubstitution.test_simple_html_substitutionc                 C   s&   d}t |}| | j|jd d S )Ns   fooz&lsquo;&rsquo;foo&ldquo;&rdquo;)r   r   r   r   r8   )r    quotesdammitr"   r"   r#   test_smart_quote_substitution.  s
   z4TestEntitySubstitution.test_smart_quote_substitutionc                 C   s   d}|  | j|d| d S )NWelcome to "my bar"Fr   r   Zsubstitute_xmlr   r"   r"   r#   Itest_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_false6  s   z`TestEntitySubstitution.test_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_falsec                 C   s0   |  | jddd |  | jddd d S )NZWelcomeTz	"Welcome"z	Bob's Barz"Bob's Bar"r   r;   r"   r"   r#   6test_xml_attribute_quoting_normally_uses_double_quotes:  s   zMTestEntitySubstitution.test_xml_attribute_quoting_normally_uses_double_quotesc                 C      d}|  | j|dd d S )Nr   Tz'Welcome to "my bar"'r   r   r"   r"   r#   Otest_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotes@  s   zfTestEntitySubstitution.test_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotesc                 C   r   )NWelcome to "Bob's Bar"Tz""Welcome to &quot;Bob's Bar&quot;"r   r   r"   r"   r#   btest_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotesE  s
   zyTestEntitySubstitution.test_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotesc                 C   s   d}|  | j|| d S )Nr   r   )r    quotedr"   r"   r#   <test_xml_quotes_arent_escaped_when_value_is_not_being_quotedK  s   zSTestEntitySubstitution.test_xml_quotes_arent_escaped_when_value_is_not_being_quotedc                 C      |  | jdd d S )Nzfoo<bar>zfoo&lt;bar&gt;r   r;   r"   r"   r#   'test_xml_quoting_handles_angle_bracketsO     
z>TestEntitySubstitution.test_xml_quoting_handles_angle_bracketsc                 C   r   )NzAT&TzAT&amp;Tr   r;   r"   r"   r#   #test_xml_quoting_handles_ampersandsT  s   z:TestEntitySubstitution.test_xml_quoting_handles_ampersandsc                 C   r   )N&Aacute;T&Tz&amp;Aacute;T&amp;Tr   r;   r"   r"   r#   Etest_xml_quoting_including_ampersands_when_they_are_part_of_an_entityW  r   z\TestEntitySubstitution.test_xml_quoting_including_ampersands_when_they_are_part_of_an_entityc                 C   r   )Nr   z&Aacute;T&amp;T)r   r   Z"substitute_xml_containing_entitiesr;   r"   r"   r#   Dtest_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entity\  r   z[TestEntitySubstitution.test_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entityc                 C   s   d}|  | j|| dS )z:There's no need to do this except inside attribute values.zBob's "bar"Nr   )r    textr"   r"   r#    test_quotes_not_html_substituteda  s   z7TestEntitySubstitution.test_quotes_not_html_substitutedN)rB   rC   rD   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r"   r"   r#   r   "  s    r   c                       sN   e Zd Z fddZdd Zdd Zdd Zd	d
 Zee	ddd Z
  ZS )TestEncodingConversionc                    s4   t t|   d| _| jd| _| | jd d S )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*   r,   r   r;   	__class__r"   r#   r   k  s   zTestEncodingConversion.setUpc              	   C   s   t jj}ttj z<dd }|t j_d}| |}| }| t	|t
 | || |  | |j d W ttj |t j_d S ttj |t j_w )Nc                 S   r1   r2   r"   rQ   r"   r"   r#   noopz  r5   z>TestEncodingConversion.test_ascii_in_unicode_out.<locals>.noops   <foo>a</foo>r)   )bs4r   chardet_dammitloggingdisableWARNINGr   decodern   rP   rQ   r   Zdocument_forr+   lowerNOTSET)r    chardetr   asciiZsoup_from_asciiZunicode_outputr"   r"   r#   test_ascii_in_unicode_outt  s   

z0TestEncodingConversion.test_ascii_in_unicode_outc                 C   s@   |  | j}| | | j | |jjd | |jd  d S Nu   Sacré bleu!)r   r   r   r   foor   r+   r    Zsoup_from_unicoder"   r"   r#   test_unicode_in_unicode_out  s   z2TestEncodingConversion.test_unicode_in_unicode_outc                 C   s2   |  | j}| | | j | |jjd d S r   )r   r,   r   r   r   r   r   )r    Zsoup_from_utf8r"   r"   r#   test_utf8_in_unicode_out  s   z/TestEncodingConversion.test_utf8_in_unicode_outc                 C   s$   |  | j}| |d| j d S )Nr)   )r   r   r   r*   r,   r   r"   r"   r#   test_utf8_out  s   z$TestEncodingConversion.test_utf8_outzQBad HTMLParser detected; skipping test of non-ASCII characters in attribute name.c                 C   s(   d}|  | |jd|d d S )Nu    <div><a ☃="snowman"></a></div>r~   )r   r   divr*   r7   r"   r"   r#   1test_attribute_name_containing_unicode_characters  s   $zHTestEncodingConversion.test_attribute_name_containing_unicode_characters)rB   rC   rD   r   r   r   r   r   r   PYTHON_3_PRE_3_2r   __classcell__r"   r"   r   r#   r   g  s    	r   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&S )'TestUnicodeDammitz"Standalone tests of UnicodeDammit.c                 C   s   d}t |}| |j| d S )Nu   I'm already Unicode! ☃r   r   unicode_markupr    r8   r   r"   r"   r#   test_unicode_input  s   z$TestUnicodeDammit.test_unicode_inputc                 C   s   d}t |}| |jd d S )N   <foo></foo>u   <foo>‘’“”</foo>r   r   r"   r"   r#   test_smart_quotes_to_unicode  s
   z.TestUnicodeDammit.test_smart_quotes_to_unicodec                 C   "   d}t |dd}| |jd d S )Nr   xmlZsmart_quotes_toz+<foo>&#x2018;&#x2019;&#x201C;&#x201D;</foo>r   r   r"   r"   r#   !test_smart_quotes_to_xml_entities  
   z3TestUnicodeDammit.test_smart_quotes_to_xml_entitiesc                 C   r   )Nr   rv   r   z'<foo>&lsquo;&rsquo;&ldquo;&rdquo;</foo>r   r   r"   r"   r#   "test_smart_quotes_to_html_entities  r   z4TestUnicodeDammit.test_smart_quotes_to_html_entitiesc                 C   r   )Nr   r   r   z<foo>''""</foo>r   r   r"   r"   r#   test_smart_quotes_to_ascii  r   z,TestUnicodeDammit.test_smart_quotes_to_asciic                 C   s0   d}t |}| |j d | |jd d S )Ns   Sacré bleu! ☃r)   u   Sacré bleu! ☃r   r   r+   r   r   )r    r~   r   r"   r"   r#   test_detect_utf8  s   z"TestUnicodeDammit.test_detect_utf8c                 C   s4   d}t |dg}| |j d | |jd d S )Ns   
iso-8859-8u   םולשr   )r    hebrewr   r"   r"   r#   test_convert_hebrew  s   z%TestUnicodeDammit.test_convert_hebrewc                 C   s6   d}t |}| |j d | |jd| d S )Ns   ケータイ Watchr)   )r   r   r+   r   r   r*   )r    utf_8r   r"   r"   r#   /test_dont_see_smart_quotes_where_there_are_none  s   zATestUnicodeDammit.test_dont_see_smart_quotes_where_there_are_nonec                 C   s,   d d}t|dg}| |j d d S )Nr(   r)   r   r*   r   r   r+   r   r    r,   r   r"   r"   r#    test_ignore_inappropriate_codecs  s   
z2TestUnicodeDammit.test_ignore_inappropriate_codecsc                 C   s6   d d}dD ]}t||g}| |j d qd S )Nr(   r)   )z.utf8z...z
utF---16.!r   )r    r,   Zbad_encodingr   r"   r"   r#   test_ignore_invalid_codecs  s
   
z,TestUnicodeDammit.test_ignore_invalid_codecsc                 C   sL   d d}t|dgd}| |j d t|ddgd}| |jd  d S r'   r   r   r"   r"   r#   r-     s   
z(TestUnicodeDammit.test_exclude_encodingsc                 C   s"   t d}t|j}d|v sJ d S )Ns'   <?xml version="1.0" encoding="UTF-" ?>u   utf-�)r   list	encodings)r    Zdetectedr   r"   r"   r#   Ptest_encoding_detector_replaces_junk_in_encoding_name_with_replacement_character  s
   
zbTestUnicodeDammit.test_encoding_detector_replaces_junk_in_encoding_name_with_replacement_characterc                 C   s(   dD ]}t |dd}| d|j qd S )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   r"   r"   r#    test_detect_html5_style_meta_tag  s   z2TestUnicodeDammit.test_detect_html5_style_meta_tagc              	   C   s   d}t jj}ttj z3dd }|t j_t|}| d|j | 	d|j
v  t|d}| 	|j W ttj |t j_d S ttj |t j_w )NsT   ﻿<?xml version="1.0" encoding="UTF-8"?>
<html><b>بتر</b>
<i>ѐ</i></html>c                 S   r1   r2   r"   r   r"   r"   r#   r     r5   zBTestUnicodeDammit.test_last_ditch_entity_replacement.<locals>.noopTu   �rx   )r   r   r   r   r   r   r   r   Zcontains_replacement_charactersrn   r   r   r   )r    docr   r   r   r   r"   r"   r#   "test_last_ditch_entity_replacement   s   

z4TestUnicodeDammit.test_last_ditch_entity_replacementc                 C   s,   d}t |}| d|j | d|j d S )Ns   < a >   < / a > u   <a>áé</a>zutf-16le)r   r   r   r+   r   r"   r"   r#   test_byte_order_mark_removed#  s   z.TestUnicodeDammit.test_byte_order_mark_removedc                 C   sP   d d}d d}|| | }| t|jd t|}| d|d d S )Nu	   ☃☃☃r~   u   “Hi, I like Windows!”windows_1252u+   ☃☃☃“Hi, I like Windows!”☃☃☃)r*   r   UnicodeDecodeErrorr   r   	detwingler   )r    r~   r   r   fixedr"   r"   r#   test_detwingle*  s   


z TestUnicodeDammit.test_detwinglec                 C   s>   dD ]}| d}| |d t|}| || qd S )N)u   œu   ₓu   ðr~      )r*   rn   endswithr   r   r   )r    Ztricky_unicode_charinputoutputr"   r"   r#   +test_detwingle_ignores_multibyte_charactersB  s   

z=TestUnicodeDammit.test_detwingle_ignores_multibyte_charactersc                 C   s   d}| d}d}| d}tj}| d ||dd | d||dd | d||dd | d|| | d|| d	d
 }| d |||  | d |||  | d||| ddd | d||dd | d |d| dd d S )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)r     a)r*   r   Zfind_declared_encodingr   )r    Zhtml_unicodeZ
html_bytesZxml_unicodeZ	xml_bytesmZspacerr"   r"   r#   test_find_declared_encodingQ  s0   


z-TestUnicodeDammit.test_find_declared_encodingN)rB   rC   rD   r   r   r   r   r   r   r   r   r   r   r   r-   r   r   r   r   r   r  r  r"   r"   r"   r#   r     s(    #r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestNamedspacedAttributec                 C   s.   t dd }| |d t d}| |d d S )NZxmlnsr   r   r    r\   r"   r"   r#    test_name_may_be_none_or_missing  s   
z9TestNamedspacedAttribute.test_name_may_be_none_or_missingc                 C   s   t dd}| d| d S )Nr\   rz   za:br
  r  r"   r"   r#   6test_attribute_is_equivalent_to_colon_separated_string  s   
zOTestNamedspacedAttribute.test_attribute_is_equivalent_to_colon_separated_stringc                 C   sp   t ddd}t ddd}| || t ddd }| || t ddd}| || t ddd}| || d S )Nr\   rz   cz)r   r   ZassertNotEqual)r    r\   rz   r  der"   r"   r#   ;test_attributes_are_equivalent_if_prefix_and_name_identical  s   zTTestNamedspacedAttribute.test_attributes_are_equivalent_if_prefix_and_name_identicalN)rB   rC   rD   r  r  r  r"   r"   r"   r#   r	    s    r	  c                   @   s   e Zd Zdd Zdd ZdS ))TestAttributeValueWithCharsetSubstitutionc                 C   s8   t d}| d| | d|j | d|d d S )Nr   r~   )r   r   original_valuer*   r    rF   r"   r"   r#   !test_content_meta_attribute_value     zKTestAttributeValueWithCharsetSubstitution.test_content_meta_attribute_valuec                 C   s8   t d}| d| | d|j | d|d d S )Nztext/html; charset=euc-jpztext/html; charset=utf8r~   )r	   r   r  r*   r  r"   r"   r#   r    r  N)rB   rC   rD   r  r"   r"   r"   r#   r    s    r  ).r   pdbr   r   Zunittestsysr   r   r   r   Zbs4.builderr   r   Zbs4.elementr   r   r	   r
   r   r   r   Z
bs4.dammitr   r   r   Zbs4.testingr   r   r   rN   r   r   ZLXML_PRESENTImportErrorr  version_infor   r   rl   r   ZTestCaser   r   r   r	  r  r"   r"   r"   r#   <module>   s@   $
 ,/	E< ]