HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_codeccallbacks.cpython-37.pyc
B

��g/��@s�ddlZddlZddlZddlZddlZddlZGdd�d�ZGdd�de	�Z
Gdd�de	�ZGdd	�d	e�Z
Gd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�dej�Zedkr�e��dS)�Nc@seZdZdd�Zdd�ZdS)�	PosReturncCs
d|_dS)Nr)�pos)�self�r�4/usr/local/lib/python3.7/test/test_codeccallbacks.py�__init__szPosReturn.__init__cCs>|j}|}|dkr t|j�|}||jkr6t|j�|_d|fS)Nrz<?>)r�len�object�start)r�excZoldposZrealposrrr�handles
zPosReturn.handleN)�__name__�
__module__�__qualname__rrrrrrrsrc@seZdZdd�ZdS)�BadStartUnicodeEncodeErrorcCst�|ddddd�g|_dS)N�ascii�r��bad)�UnicodeEncodeErrorrr
)rrrrrsz#BadStartUnicodeEncodeError.__init__N)r
rrrrrrrrsrc@seZdZdd�ZdS)�BadObjectUnicodeEncodeErrorcCst�|ddddd�g|_dS)Nrrrrr)rrr	)rrrrr!sz$BadObjectUnicodeEncodeError.__init__N)r
rrrrrrrr src@seZdZdd�ZdS)�NoEndUnicodeDecodeErrorcCs t�|dtd�ddd�|`dS)Nr�rrr)�UnicodeDecodeErrorr�	bytearray�end)rrrrr'sz NoEndUnicodeDecodeError.__init__N)r
rrrrrrrr&src@seZdZdd�ZdS)�BadObjectUnicodeDecodeErrorcCs"t�|dtd�ddd�g|_dS)Nrrrrr)rrrr	)rrrrr-sz$BadObjectUnicodeDecodeError.__init__N)r
rrrrrrrr,src@seZdZdd�ZdS)�NoStartUnicodeTranslateErrorcCst�|dddd�|`dS)Nrrrr)�UnicodeTranslateErrorrr
)rrrrr3sz%NoStartUnicodeTranslateError.__init__N)r
rrrrrrrr2src@seZdZdd�ZdS)�NoEndUnicodeTranslateErrorcCst�|dddd�|`dS)Nrrrr)rrr)rrrrr9sz#NoEndUnicodeTranslateError.__init__N)r
rrrrrrrr8src@seZdZdd�ZdS)�NoObjectUnicodeTranslateErrorcCst�|dddd�|`dS)Nrrrr)rrr	)rrrrr?sz&NoObjectUnicodeTranslateError.__init__N)r
rrrrrrrr >sr c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIS)J�CodecCallbackTestcCs0d}|�|�dd�d�|�|�dd�d�dS)Nuスパモ änd eggsr�xmlcharrefreplaces&&#12473;&#12497;&#12514; &#228;nd eggszlatin-1s!&#12473;&#12497;&#12514; �nd eggs)�assertEqual�encode)r�srrr�test_xmlcharrefreplaceEs

z(CodecCallbackTest.test_xmlcharrefreplacecCsddd�}t�d|�d}d}|�|�dd�|�d}|�|�dd�|�d	}|�|�d
d�|�dS)Nc	Ss�t|t�std|��g}x`|j|j|j�D]J}y|�dtjj	t
|��Wq.tk
rv|�dt
|��Yq.Xq.Wd�|�|jfS)Nzdon't know how to handle %rz&%s;z&#%d;r)
�
isinstancer�	TypeErrorr	r
r�append�htmlZentitiesZcodepoint2name�ord�KeyError�join)r�l�crrr�xmlcharnamereplaceWs
zECodecCallbackTest.test_xmlcharnamereplace.<locals>.xmlcharnamereplaceztest.xmlcharnamereplaceu«ℜ» = 〈ሴ€〉s0&laquo;&real;&raquo; = &lang;&#4660;&euro;&rang;rs$�&real;� = &lang;&#4660;&euro;&rang;zlatin-1s�&real;� = &lang;&#4660;�&rang;ziso-8859-15)�codecs�register_errorr#r$)rr0�sin�soutrrr�test_xmlcharnamereplaceSsz)CodecCallbackTest.test_xmlcharnamereplacecCsddd�}t�d|�d}d}|�|�dd�|�d}|�|�dd�|�d	}|�|�d
d�|�dS)Nc	Ssdt|t�std|��g}x4|j|j|j�D]}|�t�|dt	|���q.Wdd�
|�|jfS)Nzdon't know how to handle %rz0x%xz
%sz, )r'rr(r	r
rr)�unicodedata�namer+r-)rr.r/rrr�uninamereplacevs
z=CodecCallbackTest.test_uninamereplace.<locals>.uninamereplaceztest.uninamereplaceu¬ሴ€耀sNNOT SIGN, ETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000rsE�ETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000zlatin-1sA�ETHIOPIC SYLLABLE SEE�CJK UNIFIED IDEOGRAPH-8000ziso-8859-15)r1r2r#r$)rr8r3r4rrr�test_uninamereplacems	z%CodecCallbackTest.test_uninamereplacecCsPd}d}|�|�dd�|�d}|�|�dd�|�d}|�|�dd�|�dS)	Nua¬ሴ€耀􏿿s!a\xac\u1234\u20ac\u8000\U0010ffffr�backslashreplacesa�\u1234\u20ac\u8000\U0010ffffzlatin-1sa�\u1234�\u8000\U0010ffffziso-8859-15)r#r$)rr3r4rrr�test_backslashescape�sz&CodecCallbackTest.test_backslashescapecCsPd}d}|�|�dd�|�d}|�|�dd�|�d}|�|�dd�|�dS)	Nua¬ሴ€耀􏿿s[a\N{NOT SIGN}\N{ETHIOPIC SYLLABLE SEE}\N{EURO SIGN}\N{CJK UNIFIED IDEOGRAPH-8000}\U0010ffffr�namereplacesPa�\N{ETHIOPIC SYLLABLE SEE}\N{EURO SIGN}\N{CJK UNIFIED IDEOGRAPH-8000}\U0010ffffzlatin-1sDa�\N{ETHIOPIC SYLLABLE SEE}�\N{CJK UNIFIED IDEOGRAPH-8000}\U0010ffffziso-8859-15)r#r$)rr3r4rrr�test_nameescape�sz!CodecCallbackTest.test_nameescapecCsJdd�}t�d|�d}d}|�|�dd�|�d}|�t|jdd�dS)NcSsFt|t�std|��|j|j|jd�dkr>d|jdfS|�dS)Nzdon't know how to handle %r�s���)r'rr(r	r
)rrrr�relaxedutf8�s

z>CodecCallbackTest.test_decoding_callbacks.<locals>.relaxedutf8ztest.relaxedutf8sab��cü����u	abcüzutf-8s����)r1r2r#�decode�assertRaisesr)rr@r3r4rrr�test_decoding_callbacks�s
z)CodecCallbackTest.test_decoding_callbackscCs�tdd�dD��}d}d}|�t�|d|�d|�d}|�ttj|d|�d	|td
�<d}d}|�t�|d
|�d|�d|td
�<|�ttj|d
|�dS)Ncss(|] }t|�td|��d�fVqdS)r>rN)r+�bytes�upper)�.0r/rrr�	<genexpr>�sz7CodecCallbackTest.test_charmapencode.<locals>.<genexpr>Zabcdefgh�abcsAABBCC�strictrZabcAsXYZ�?ZabcDEFsAABBCCXYZXYZXYZ�replaceZXYZ)�dictr#r1�charmap_encoderB�UnicodeErrorr+r()r�charmapr3r4rrr�test_charmapencode�sz$CodecCallbackTest.test_charmapencodec	Cs�tj�dtf���|�tdjd�td�d��dkr�dd�}|�	d�dd�d�|�	d�dd	�d
�|�	d�dd�d�t
�d
|�|�	d�dd
�d�WdQRXdS)Nz*unicode_internal codec has been deprecatedszunicode-internalr?�cSst|t�std|��dS)Nzdon't know how to handle %r)�r)r'rr()rrrr�handler_unicodeinternal�s
zMCodecCallbackTest.test_decodeunicodeinternal.<locals>.handler_unicodeinternal�ignorerKu�r:z\x00ztest.huiz)�test�support�check_warnings�DeprecationWarningrBrrArr$r#r1r2)rrSrrr�test_decodeunicodeinternal�s*




z,CodecCallbackTest.test_decodeunicodeinternalcCs�dd�}t�d|�dd�}t�d|�d}|�|�dd�d	�|�|�dd�d
�|�d�dd�d
�|�d�dd�d�|�t�ddtd�di�dd�|�d�dd�d�|�d�dd�d�dS)Ncsjt�j�j�}t�t�r,�fdd�|D�}n*t�t�rJ�fdd�|D�}ntd���dd�|��jfS)Ncsg|]}dt�j|��qS)z<%d>)r+r	)rFr)rrr�
<listcomp>�szFCodecCallbackTest.test_callbacks.<locals>.handler1.<locals>.<listcomp>csg|]}d�j|�qS)z<%d>)r	)rFr)rrrrZszdon't know how to handle %rz[%s]r)�ranger
rr'rrr(r-)r�rr.r)rr�handler1�s

z2CodecCallbackTest.test_callbacks.<locals>.handler1z
test.handler1csJt�t�std����fdd�t�j�j�D�}dd�|��jdfS)Nzdon't know how to handle %rcsg|]}d�j|�qS)z<%d>)r	)rFr)rrrrZ
szFCodecCallbackTest.test_callbacks.<locals>.handler2.<locals>.<listcomp>z[%s]rr)r'rr(r[r
rr-)rr.r)rr�handler2s
z2CodecCallbackTest.test_callbacks.<locals>.handler2z
test.handler2s���rz[<129>][<128>][<255>]z[<129>][<128>]s\u3042\u3xxxzunicode-escapeuあ[<92><117><51>]xxxs\u3042\u3xxuあ[<92><117><51>]xxsabc�a�zrz
z[<98>][<99>]ugüßrksg[<252><223>]rkugüßs
g[<252><223>])r1r2r#rA�charmap_decoder+r$)rr]r^r%rrr�test_callbacks�s4






z CodecCallbackTest.test_callbackscs�ddddddg}x"|D]}t�d|t�|��qWd�|d	d
�|D�7}x\�fdd
�dD�D]F}x@d
D]8}x2|D]*}y|�||�Wqrtk
r�YqrXqrWqhWq^WdS)NrIrTrKr"r:r<ztest.i�cSsg|]}d|�qS)ztest.r)rF�errrrrrZ<sz6CodecCallbackTest.test_longstrings.<locals>.<listcomp>csg|]}|��qSrr)rFr%)r.rrrZ=s)�xuあuaä)rzlatin-1z
iso-8859-1ziso-8859-15zutf-8zutf-7zutf-16zutf-32)r1r2�lookup_errorr$rN)r�errorsrcZuni�encr)r.r�test_longstrings3s


z"CodecCallbackTest.test_longstringsc
Cs�|jt|f|dd���|jt|f|dg��ddddddg}x�tt|��D]v}xp|D]h}t|�t||�krtqZg}x6tt|��D]&}||kr�|�|�q�|�||�q�W|jt|f|��qZWqPW||�}	|�t|	�|�dS)N���ztoo muchZspamseggssspam�*g�?)rBr(r[r�typer)r#�str)
r�exctype�args�msgZ	wrongargs�iZwrongargZcallargs�jrrrr�check_exceptionobjectargsFs
z+CodecCallbackTest.check_exceptionobjectargscCs�|�tdddddgd�|�tdddddgd�|�tdd	d
ddgd�|�tddd
ddgd
�|�tddd
ddgd�|�tddd
ddgd�dS)Nrugürkrr>�ouchz?'ascii' codec can't encode character '\xfc' in position 1: ouchrQz;'ascii' codec can't encode characters in position 1-3: ouchuüxrz?'ascii' codec can't encode character '\xfc' in position 0: ouchuĀxzA'ascii' codec can't encode character '\u0100' in position 0: ouchu￿xzA'ascii' codec can't encode character '\uffff' in position 0: ouchu𐀀xzE'ascii' codec can't encode character '\U00010000' in position 0: ouch)rrr)rrrr�test_unicodeencodeerror_s0z)CodecCallbackTest.test_unicodeencodeerrorcCs<|�tdtd�dddgd�|�tdtd�dddgd�dS)	Nrsg�rkrr>rsz8'ascii' codec can't decode byte 0xfc in position 1: ouch�z6'ascii' codec can't decode bytes in position 1-2: ouch)rrrr)rrrr�test_unicodedecodeerrorsz)CodecCallbackTest.test_unicodedecodeerrorcCsr|�tddddgd�|�tddddgd�|�tddddgd	�|�td
dddgd�|�tddddgd
�dS)Nugürkrr>rsz4can't translate character '\xfc' in position 1: ouchugĀrkz6can't translate character '\u0100' in position 1: ouchug￿rkz6can't translate character '\uffff' in position 1: ouchug𐀀rkz:can't translate character '\U00010000' in position 1: ouchruz0can't translate characters in position 1-2: ouch)rrr)rrrr�test_unicodetranslateerror�s(




z,CodecCallbackTest.test_unicodetranslateerrorc
Cs~|�ttjd�|�ttjtd��|�ttjtddddd��|�ttjtdtd�ddd��|�ttjtdddd��dS)Nrjrsruあrr��)	rBr(r1�
strict_errors�	Exceptionrrrr)rrrr�test_badandgoodstrictexceptions�s(
z1CodecCallbackTest.test_badandgoodstrictexceptionsc
Cs�|�ttjd�|�ttjtd��|�t�tddddd��d�|�t�tdtd�ddd��d�|�t�t	dddd��d�dS)	Nrjrsruaあbrr>)rr>sa�b)
rBr(r1�
ignore_errorsrNr#rrrr)rrrr�test_badandgoodignoreexceptions�s(
z1CodecCallbackTest.test_badandgoodignoreexceptionsc
Cs�|�ttjd�|�ttjtd��|�ttjt��|�ttjt��|�t�tddddd��d�|�t�t	dt
d�ddd��d	�|�t�tdddd��d	�dS)
Nrjrsruaあbrr>)rJr>sa�b)u�r>)rBr(r1�replace_errorsrNrrr#rrrr)rrrr� test_badandgoodreplaceexceptions�s8
z2CodecCallbackTest.test_badandgoodreplaceexceptionscCs�|�ttjd�|�ttjtd��|�ttjtdtd�ddd��|�ttjtdddd��d}|d	7}d
�dd�|D��}|�	t�t
dd
|dddt|�d��d
�dd�|D��dt|�f�dS)Nrjrsrrxrruあ)rr�	�
�c�di�i�i'i'i��i��i?Bi@B)i�i��rcss|]}t|�VqdS)N)�chr)rFr/rrrrG'szOCodecCallbackTest.test_badandgoodxmlcharrefreplaceexceptions.<locals>.<genexpr>r_�bcss|]}d|VqdS)z&#%d;Nr)rFr/rrrrG-s)rBr(r1�xmlcharrefreplace_errorsrNrrrr-r#rr)r�csr%rrr�*test_badandgoodxmlcharrefreplaceexceptionss0
z<CodecCallbackTest.test_badandgoodxmlcharrefreplaceexceptionsc
CsD|�ttjd�|�ttjtd��ddddddd	d
ddd
dg}x�|D]�\}}|j|d��x|�t�tdd|dddt|�d��|dt|�f�|�t�t	d|dddt|�d��|dt|�f�WdQRXqFWddddg}xV|D]N\}}|j|d��4|�t�t
dtd|d�ddd��|df�WdQRXq�WdS)Nrjrs)uあz\u3042)�
z\x0a)r_z\x61)r?z\x00)�ÿz\xff)uĀz\u0100)u￿z\uffff)u𐀀z
\U00010000)u􏿿z
\U0010ffff)u�z\ud800)u�z\udfff)u��z\ud800\udfff)rlrr_r�r)�az\x61)�
z\x0a)�z\x00)rxz\xff)rDr��br>)rBr(r1�backslashreplace_errorsrN�subTestr#rrrrr)r�testsr%r\r�rrr�)test_badandgoodbackslashreplaceexceptions0sV
 
z;CodecCallbackTest.test_badandgoodbackslashreplaceexceptionsc
Cs�|�ttjd�|�ttjtd��|�ttjtdtd�ddd��|�ttjtdddd��dd	d
ddd
ddg}xb|D]Z\}}|j|d��@|�	t�t
dd|dddt|�d��|dt|�f�WdQRXqxWdS)Nrjrsrrxrruあ)uあz\N{HIRAGANA LETTER A})r?z\x00)uﯹzW\N{ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM})u󠁿z\N{CANCEL TAG})u􏿿z
\U0010ffff)u�z\ud800)u�z\udfff)u��z\ud800\udfff)rlr_r�)rBr(r1�namereplace_errorsrNrrrr�r#rr)rr�r%r\rrr�$test_badandgoodnamereplaceexceptionsjs>
z6CodecCallbackTest.test_badandgoodnamereplaceexceptionscCs�t�d�}|�t|d�|�t|td��|�t|tdddd��x>dD]6}|j|d�� |�t|td	|ddd��WdQRXqHW|�|td	d
ddd��d�|�t	|t	d	t
d
�ddd��|�|t	d	t
d�ddd��d�dS)N�surrogateescaperjrsu�rr)r_u�u�)rlrua�br>)��r>r�sa�b)u�r>)r1rerBr(rNrr�rr#rr)rZsurrogateescape_errorsr%rrr�(test_badandgoodsurrogateescapeexceptions�s>


 z:CodecCallbackTest.test_badandgoodsurrogateescapeexceptionscCs�t�d�}|�t|d�|�t|td��|�t|tdddd��x^dD]V}|j|d��@|�t|t|d	ddd��|�t|t|d	�	|�ddd��WdQRXqHWxBd
D]:}|j|d��$|�t|td|dt
|�d��WdQRXq�Wd
ddddddddddddddg}x�|D]�\}}}}|j|||d���|�|t|d	|dddt
|�d��|dt
|�f�|�|t|td|d|�d�dd|d��|dd�d|f�WdQRX�qWdS) N�
surrogatepassrjrsu�rr)zutf-8zutf-16lezutf-16bezutf-32lezutf-32be)�encodingr_)u�u�u��)rlr)zutf-8u�s�ru)zutf-16leu�s�r>)zutf-16beu�s�r>)zutf-32leu�s�rQ)zutf-32beu�s�rQ)zutf-8u�s�ru)zutf-16leu�s��r>)zutf-16beu�s�r>)zutf-32leu�s��rQ)zutf-32beu�s�rQ)zutf-8u��s��ru)zutf-16leu��s��r>)zutf-16beu��s��r>)zutf-32leu��s���rQ)zutf-32beu��s��rQ)r�rlrDr�r�r�)
r1rerBr(rNrr�rrr$rr#r)rZsurrogatepass_errorsrgr%r�r��nrrr�&test_badandgoodsurrogatepassexceptions�sp


&
$z8CodecCallbackTest.test_badandgoodsurrogatepassexceptionscs�d}d}xz|D]r�t�d�fdd��x|D]}|�tdj|d�q,Wx8dD]0\}}tj���|�t|j|d�WdQRXqLWqWdS)N)	rj�foo)rr>ru)r�rru)r�N)r�)r�rru)r�N)r�)rzlatin-1z
iso-8859-1ziso-8859-15ztest.badhandlercs�S)Nr)rd)�resrr�<lambda>rz:CodecCallbackTest.test_badhandlerresults.<locals>.<lambda>uあ))rrx)zutf-8rx)zutf-7s+x-)zunicode-internalr�)	r1r2rBr(r$rUrVrWrA)r�resultsZencsrgrDr)r�r�test_badhandlerresultss$


z(CodecCallbackTest.test_badhandlerresultscCs||�tjt�d��|�tjt�d��|�tjt�d��|�tjt�d��|�tjt�d��|�tjt�d��dS)NrIrTr"r:r<)r#r1ryrer|r�r�r�)rrrr�test_lookup(szCodecCallbackTest.test_lookupcCs8dd�}t�d|�xdD]}|�tdj|d�qWdS)NcSs$t|t�rd|jfStd|��dS)Nu䉂zdon't know how to handle %r)r'rrr()rrrr�	unencrepl:s

z@CodecCallbackTest.test_unencodablereplacement.<locals>.unencreplztest.unencreplhandler)rz
iso-8859-1ziso-8859-15u䉂)r1r2rBrr$)rr�rgrrr�test_unencodablereplacement9s
z-CodecCallbackTest.test_unencodablereplacementcCs&|�ttjd�|�ttjdd�dS)Nrjz
test.dummy)rBr(r1r2)rrrr�test_badregistercallHsz&CodecCallbackTest.test_badregistercallcCs|�ttj�dS)N)rBr(r1re)rrrr�test_badlookupcallOsz$CodecCallbackTest.test_badlookupcallcCs|�ttjd�dS)Nztest.unknown)rB�LookupErrorr1re)rrrr�test_unknownhandlerTsz%CodecCallbackTest.test_unknownhandlercCsRd}d�dd�|D��}t�dtj�x&dD]}xdD]}|�||�q6Wq,WdS)N)
r�r��2r�i�i�i�i'iP�i��i �i@BrcSsg|]}t|��qSr)r�)rFrdrrrrZ_sz;CodecCallbackTest.test_xmlcharrefvalues.<locals>.<listcomp>ztest.xmlcharrefreplace)rziso-8859-15)r"ztest.xmlcharrefreplace)r-r1r2r�r$)r�vr%rgrcrrr�test_xmlcharrefvaluesYs

z'CodecCallbackTest.test_xmlcharrefvaluesc	Cs�|�tdjdd�dd�}t�d|�|�tdjdd�|�tdjdd�|�td	jdd�|�td
jdd�|�tdjdd�|�tdjd
d�dd�}t�d|�|�tdjdd�t�}t�d|j�d|_|�	d�dd�d�d|_|�	d�dd�d�d|_|�t
djdd�d|_|�	d�dd�d�d|_|�	d�dd�d�d|_|�t
djdd�d|_|�	d�d
d�d�Gdd�dt�}|�ttj
dd d!di�|�ttj
dd |��|�ttj
dd d!tjdi�dS)"Nrxrztest.unknowncSsdS)Nrjr)rrrr�baddecodereturn1ksz=CodecCallbackTest.test_decodehelper.<locals>.baddecodereturn1ztest.baddecodereturn1�\zunicode-escapes\x0s\x0ys
\Uffffeeees\uyyyyzraw-unicode-escapecSsdS)N)rJNr)rrrr�baddecodereturn2usz=CodecCallbackTest.test_decodehelper.<locals>.baddecodereturn2ztest.baddecodereturn2ztest.posreturnris�0z<?>0���z<?><?>���rr>z<?>ru�s\uyyyy0c@seZdZdd�ZdS)z.CodecCallbackTest.test_decodehelper.<locals>.DcSst�dS)N)�
ValueError)r�keyrrr�__getitem__�sz:CodecCallbackTest.test_decodehelper.<locals>.D.__getitem__N)r
rrr�rrrr�D�sr�rI�)rBr�rAr1r2r(rrrr#�
IndexErrorrLrNrar��sys�
maxunicode)rr�r��handlerr�rrr�test_decodehelperes@z#CodecCallbackTest.test_decodehelperc	Csz|�tdjdd�dd�}t�d|�|�tdjdd�dd�}t�d	|�|�tdjdd	�t�}t�d
|j�d|_|�	d�dd
�d
�d|_|�	d�dd
�d�d|_|�t
djdd
�d|_|�	d�dd
�d
�d|_|�	d�dd
�d�d|_|�t
djdd
�d|_Gdd�dt�}xTdD]L}|�ttj
d|ddi�|�ttj
d||��|�ttj
d|ddi��q&WdS)Nr�rztest.unknowncSsdS)Nrjr)rrrr�badencodereturn1�sz=CodecCallbackTest.test_encodehelper.<locals>.badencodereturn1ztest.badencodereturn1cSsdS)N)rJNr)rrrr�badencodereturn2�sz=CodecCallbackTest.test_encodehelper.<locals>.badencodereturn2ztest.badencodereturn2ztest.posreturnriuÿ0s<?>0r�s<?><?>r�rr>s<?>rurc@seZdZdd�ZdS)z.CodecCallbackTest.test_encodehelper.<locals>.DcSst�dS)N)r�)rr�rrrr��sz:CodecCallbackTest.test_encodehelper.<locals>.D.__getitem__N)r
rrr�rrrrr��sr�)rIrKr"r:r<ztest.posreturnr�i,)rBr�r$r1r2r(rrrr#r�rLrNrMr�)rr�r�r�r�rcrrr�test_encodehelper�s6
z#CodecCallbackTest.test_encodehelpercCsBGdd�dt�}|�tdjdtjdi�|�tdjddi�dS)Nc@seZdZdd�ZdS)z1CodecCallbackTest.test_translatehelper.<locals>.DcSst�dS)N)r�)rr�rrrr��sz=CodecCallbackTest.test_translatehelper.<locals>.D.__getitem__N)r
rrr�rrrrr��sr�r�r�rr)rLrBr��	translater�r�r()rr�rrr�test_translatehelper�sz&CodecCallbackTest.test_translatehelpercCsHtd�dtd�dtd�dtd�di}xd	D]}d
|}|�|�q*WdS)N�&z&amp;�<z&lt;�>z&gt;�"z&quot;)rr�r�i�zabc<def>ghi)r+r�)rrOr��textrrr�test_bug828737�s
z CodecCallbackTest.test_bug828737cCs�ddddddddg}d	d
�}t�d|�tj���:x2|D]*\}}|�t��|�|d�WdQRXq:WWdQRXdd
�}t�d|�tj���,x$|D]\}}|�|�|d�d�q�WWdQRXdS)N)rrx)zutf-7s++)zutf-8rx)zutf-16rx)zutf-32rx)zunicode-escapes\u123g)zraw-unicode-escapes\u123g)zunicode-internalrxcSs$t|t�rd|_dStd|��dS)Nrj)u䉂rzdon't know how to handle %r)r'rr	r()rrrr�	replacing�s
z?CodecCallbackTest.test_mutatingdecodehandler.<locals>.replacingztest.replacingcSs$t|t�rd|_dStd|��dS)Nr)u䉂rzdon't know how to handle %r)r'rr	r()rrrr�mutating	s
z>CodecCallbackTest.test_mutatingdecodehandler.<locals>.mutatingz
test.mutatingu䉂)	r1r2rUrVrWrBr(rAr#)rZbaddatar�r��datar�rrr�test_mutatingdecodehandler�s&$z,CodecCallbackTest.test_mutatingdecodehandlercCs�dd�}t�d|�|�d�dd�d�|�d�dd�d�|�d	�d
d�d�|�d�d
d�d�dd�}t�d|�|�d�dd�d�|�d�dd�d�dS)NcSs(t|t�rd|jdfStd|��dS)Nu�rzdon't know how to handle %r)r'rr
r()rrrr�forward_shorter_than_ends
zPCodecCallbackTest.test_crashing_decode_handler.<locals>.forward_shorter_than_endztest.forward_shorter_than_ends�����z	utf-16-leu����Øs�����z	utf-16-besz	utf-32-leu
���ᄑsz	utf-32-becSs*t|t�rd|_d|jfStd|��dS)Nsu�zdon't know how to handle %r)r'rr	r
r()rrrr�replace_with_long9s

zICodecCallbackTest.test_crashing_decode_handler.<locals>.replace_with_longztest.replace_with_longr�zutf-16u�zutf-32u�)r1r2r#rA)rr�r�rrr�test_crashing_decode_handlers6

z.CodecCallbackTest.test_crashing_decode_handlercs�tjtjtjtjtjtjt�d�t�d�g}x�tt	t
fD]��G�fdd�dt�}x6|D].}|j|�d��|�
t||��WdQRXqVWG�fdd�dt�}xJ|D]B}|j|�d��*|�
t|f��||��WdQRXWdQRXq�Wq8WdS)Nr�r�cseZdZ�ZdS)zACodecCallbackTest.test_fake_error_class.<locals>.FakeUnicodeErrorN)r
rr�	__class__r)�clsrr�FakeUnicodeErrorWsr�)r�Zerror_classcseZdZ�ZdS)zACodecCallbackTest.test_fake_error_class.<locals>.FakeUnicodeErrorN)r
rrr�r)r�rrr�\s)r1ryr|r~r�r�r�rerrrrlr�rBr(rz)rZhandlersr�r�r)r�r�test_fake_error_classKs$

z'CodecCallbackTest.test_fake_error_classN)'r
rrr&r5r9r;r=rCrPrYrbrhrrrtrvrwr{r}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr!CsH
$9 (%:.,H;6
)3r!�__main__)r1Z
html.entitiesr*r�Ztest.supportrUr6Zunittestrrrrrrrrrrr ZTestCaser!r
�mainrrrr�<module>s0)