HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/bs4/tests/__pycache__/test_dammit.cpython-310.pyc
o

�h[<�@slddlZddlZddlZddlmZddlmZmZmZGdd�de�Z	Gdd�de�Z
Gdd	�d	e�ZdS)
�N)�
BeautifulSoup)�EntitySubstitution�EncodingDetector�
UnicodeDammitc@sbeZdZdZdd�Zej�dgd��dd��Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�TestUnicodeDammitz"Standalone tests of UnicodeDammit.cCsd}t|�}|j|ks
J�dS)NuI'm already Unicode! ☃)r�unicode_markup)�self�markup�dammit�r�H/usr/local/CyberCP/lib/python3.10/site-packages/bs4/tests/test_dammit.py�test_unicode_inputsz$TestUnicodeDammit.test_unicode_inputz smart_quotes_to,expect_converted))Nu‘’“”)�xmlz &#x2018;&#x2019;&#x201C;&#x201D;)�htmlz&lsquo;&rsquo;&ldquo;&rdquo;)�asciiz''""cCs,d}t|dg|d�j}|d�|�ksJ�dS)zbVerify the functionality of the smart_quotes_to argument
        to the UnicodeDammit constructor.s<foo>����</foo>�windows-1252)�known_definite_encodings�smart_quotes_toz
<foo>{}</foo>N)rr�format)rr�expect_convertedr	�	convertedrrr�test_smart_quotes_tos��z&TestUnicodeDammit.test_smart_quotes_tocCs0d}t|�}|j��dksJ�|jdksJ�dS)NsSacré bleu! ☃�utf-8uSacré bleu! ☃�r�original_encoding�lowerr)r�utf8r
rrr�test_detect_utf8&sz"TestUnicodeDammit.test_detect_utf8cCs4d}t|dg�}|j��dksJ�|jdksJ�dS)N����
iso-8859-8uםולשr�r�hebrewr
rrr�test_convert_hebrew,sz%TestUnicodeDammit.test_convert_hebrewcCs6d}t|�}|j��dksJ�|j�d�|ksJ�dS)Nsケータイ Watchr)rrrr�encode)r�utf_8r
rrr�/test_dont_see_smart_quotes_where_there_are_none2szATestUnicodeDammit.test_dont_see_smart_quotes_where_there_are_nonecCs,d�d�}t|dg�}|j��dksJ�dS)N�
Räksmörgåsrr�r#rrr�r�	utf8_datar
rrr� test_ignore_inappropriate_codecs8s
z2TestUnicodeDammit.test_ignore_inappropriate_codecscCs6d�d�}dD]}t||g�}|j��dksJ�qdS)Nr&r)z.utf8z...z
utF---16.!r')rr)�bad_encodingr
rrr�test_ignore_invalid_codecs=s

�z,TestUnicodeDammit.test_ignore_invalid_codecscCsLd�d�}t|dgd�}|j��dksJ�t|ddgd�}|jdks$J�dS)Nr&r)�exclude_encodingsrr'r(rrr�test_exclude_encodingsCs
�z(TestUnicodeDammit.test_exclude_encodingsN)�__name__�
__module__�__qualname__�__doc__r
�pytest�mark�parametrizerrr"r%r*r,r.rrrrrs�

rc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestEncodingDetectorcCs"td�}t|j�}d|vsJ�dS)Ns'<?xml version="1.0" encoding="UTF-�" ?>uutf-�)r�list�	encodings)r�detectedr8rrr�Ptest_encoding_detector_replaces_junk_in_encoding_name_with_replacement_characterSs
�
zeTestEncodingDetector.test_encoding_detector_replaces_junk_in_encoding_name_with_replacement_charactercCs(dD]}t|dd�}d|jksJ�qdS)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_htmlzeuc-jp)rr�r�datar
rrr� test_detect_html5_style_meta_tagYs�z5TestEncodingDetector.test_detect_html5_style_meta_tagc	Cs�d}tjj}t�tj�z1dd�}|tj_t|�}d|jks J�d|jvs'J�t	|d�}|js1J�Wt�tj
�|tj_dSt�tj
�|tj_w)NsT<?xml version="1.0" encoding="UTF-8"?>
<html><b>بتر</b>
<i>��ѐ����</i></html>cSsdS�Nr)�strrrr�noopyszETestEncodingDetector.test_last_ditch_entity_replacement.<locals>.noopTu�zhtml.parser)�bs4r
�chardet_dammit�logging�disable�WARNINGr�contains_replacement_charactersrr�NOTSET)r�doc�chardetrBr
�souprrr�"test_last_ditch_entity_replacementcs
�
z7TestEncodingDetector.test_last_ditch_entity_replacementcCs,d}t|�}d|jks
J�d|jksJ�dS)N���<a>��</a>u<a>áé</a>�utf-16le)rrrr=rrr�test_byte_order_mark_removed�sz1TestEncodingDetector.test_byte_order_mark_removedcCs�d}t|�}t|dgd�}d|jksJ�t|dgd�}d|jks"J�dgdd�|jD�ks/J�d	}t|dgd
gd�}d
|jksAJ�dd
gdd�|jD�ksOJ�dS)
NrNzutf-16)rr)�user_encodingsrOcS�g|]}|d�qS�rr��.0�xrrr�
<listcomp>��zRTestEncodingDetector.test_known_definite_versus_user_encodings.<locals>.<listcomp>rr)rrQcSrRrSrrTrrrrW�rX�rr�tried_encodings)rr>r
�before�afterr!rrr�)test_known_definite_versus_user_encodings�s� z>TestEncodingDetector.test_known_definite_versus_user_encodingscCsHd}t|dgdgdgd�}d|jksJ�gd�dd�|jD�ks"J�dS)	Nr�	shift-jisrr)r�override_encodingsrQ)r^rrcSrRrSrrTrrrrW�rXzKTestEncodingDetector.test_deprecated_override_encodings.<locals>.<listcomp>rYr rrr�"test_deprecated_override_encodings�s��z7TestEncodingDetector.test_deprecated_override_encodingscCstd�d�}d�d�}|||}t�t��
|�d�Wd�n1s%wYt�|�}d|�d�ks8J�dS)Nu	☃☃☃ru“Hi, I like Windows!”�windows_1252u+☃☃☃“Hi, I like Windows!”☃☃☃)r#r3�raises�UnicodeDecodeError�decoder�	detwingle)rrrarJ�fixedrrr�test_detwingle�s
��
z#TestEncodingDetector.test_detwinglecCs<dD]}|�d�}|�d�sJ�t�|�}||ksJ�qdS)N)uœuₓu𐐓r��)r#�endswithrre)r�tricky_unicode_char�input�outputrrr�+test_detwingle_ignores_multibyte_characters�s

�z@TestEncodingDetector.test_detwingle_ignores_multibyte_characterscCsd}|�d�}d}|�d�}tj}||dd�dusJ�d||dd�ks%J�d||dd�ks/J�d||�ks7J�d||�ks?J�d	d
}|||�dusMJ�|||�dusWJ�|||ddd�dksdJ�||dd�dksnJ�|d	|dd�dkszJ�|d
|dd�dus�J�dS)Nz0<html><head><meta charset="utf-8"></head></html>rz,<?xml version="1.0" encoding="ISO-8859-1" ?>Fr;rTz
iso-8859-1� i�)r<�search_entire_document)ro�a)r#r�find_declared_encoding)r�html_unicode�
html_bytes�xml_unicode�	xml_bytes�m�spacerrrr�test_find_declared_encoding�s&

�z0TestEncodingDetector.test_find_declared_encodingN)r/r0r1r:r?rMrPr]r`rgrmrxrrrrr6Qs
#r6c@s�eZdZdZdd�Zej�dddg�dd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TestEntitySubstitutionz1Standalone tests of the EntitySubstitution class.cCs
t|_dSr@)r�sub�rrrr�setup_methods
z#TestEntitySubstitution.setup_methodzoriginal,substituted)ufoo∀☃õbarufoo&forall;☃&otilde;bar)u‘’foo“”z&lsquo;&rsquo;foo&ldquo;&rdquo;cCs|j�|�|ks
J�dSr@�rz�substitute_html)r�original�substitutedrrr�test_substitute_htmlsz+TestEntitySubstitution.test_substitute_htmlcCs:dD]\}}d}||}||}|j�|�|ksJ�qdS)N)
)z&models;u⊧)z&Nfr;u𝔑)z&ngeqq;u≧̸)z&not;�¬)z&Not;u⫬z||)�fjr�)z&gt;�>)z&lt;�<)z&amp;�&z3 %s 4r})r�entity�u�template�raw�
with_entitiesrrr�test_html5_entity%s�z(TestEntitySubstitution.test_html5_entitycCs<d}d}|j�|�|ksJ�d}d}|j�|�|ksJ�dS)Nufjords ⊔ penguinszfjords &sqcup; penguinsufjords ⊔︀ penguinszfjords &sqcups; penguinsr})rr>r	rrr�)test_html5_entity_with_variation_selectorCsz@TestEntitySubstitution.test_html5_entity_with_variation_selectorcCsd}|j�|d�|ks
J�dS)N�Welcome to "my bar"F�rz�substitute_xml�r�srrr�Itest_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_falseO�z`TestEntitySubstitution.test_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_falsecCs0|j�dd�dksJ�|j�dd�dksJ�dS)N�WelcomeTz	"Welcome"z	Bob's Barz"Bob's Bar"r�r{rrr�6test_xml_attribute_quoting_normally_uses_double_quotesSszMTestEntitySubstitution.test_xml_attribute_quoting_normally_uses_double_quotescC�d}|j�|d�dks
J�dS)Nr�Tz'Welcome to "my bar"'r�r�rrr�Otest_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotesWr�zfTestEntitySubstitution.test_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotescCr�)N�Welcome to "Bob's Bar"Tz""Welcome to &quot;Bob's Bar&quot;"r�r�rrr�btest_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotes[r�zyTestEntitySubstitution.test_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotescCsd}|j�|�|ksJ�dS)Nr�r�)r�quotedrrr�<test_xml_quotes_arent_escaped_when_value_is_not_being_quoted_szSTestEntitySubstitution.test_xml_quotes_arent_escaped_when_value_is_not_being_quotedcC�|j�d�dks
J�dS)Nzfoo<bar>zfoo&lt;bar&gt;r�r{rrr�'test_xml_quoting_handles_angle_bracketsc�z>TestEntitySubstitution.test_xml_quoting_handles_angle_bracketscCr�)NzAT&TzAT&amp;Tr�r{rrr�#test_xml_quoting_handles_ampersandsfr�z:TestEntitySubstitution.test_xml_quoting_handles_ampersandscCr�)N�&Aacute;T&Tz&amp;Aacute;T&amp;Tr�r{rrr�Etest_xml_quoting_including_ampersands_when_they_are_part_of_an_entityir�z\TestEntitySubstitution.test_xml_quoting_including_ampersands_when_they_are_part_of_an_entitycCr�)Nr�z&Aacute;T&amp;T)rz�"substitute_xml_containing_entitiesr{rrr�Dtest_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entitylr�z[TestEntitySubstitution.test_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entitycCsd}|j�|�|ksJ�dS)z:There's no need to do this except inside attribute values.zBob's "bar"Nr})r�textrrr� test_quotes_not_html_substitutedosz7TestEntitySubstitution.test_quotes_not_html_substitutedN)r/r0r1r2r|r3r4r5r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrys,��

ry)r3rErCr�
bs4.dammitrrr�objectrr6ryrrrr�<module>sE?