Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_codeccallbacks.cpython-34.pyc

�
f f���@s7ddlZddlZddlZddlZddlZddlZddlZGdd�d�Z	Gdd�de
�ZGdd�de
�ZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�dej�Zedkr3ej�ndS)�Nc@s(eZdZdd�Zdd�ZdS)�	PosReturncCs
d|_dS)Nr)�pos)�self�r�=/opt/alt/python34/lib64/python3.4/test/test_codeccallbacks.py�__init__szPosReturn.__init__cCs_|j}|}|dkr1t|j�|}n||jkrUt|j�|_nd|fS)Nrz<?>)r�len�object�start)r�excZoldposZrealposrrr�handles	zPosReturn.handleN)�__name__�
__module__�__qualname__rrrrrrr	src@seZdZdd�ZdS)�BadStartUnicodeEncodeErrorcCs)tj|ddddd�g|_dS)N�ascii�r��bad)�UnicodeEncodeErrorrr
)rrrrrsz#BadStartUnicodeEncodeError.__init__N)r
rrrrrrrrsrc@seZdZdd�ZdS)�BadObjectUnicodeEncodeErrorcCs)tj|ddddd�g|_dS)Nrrrrr)rrr	)rrrrr"sz$BadObjectUnicodeEncodeError.__init__N)r
rrrrrrrr!src@seZdZdd�ZdS)�NoEndUnicodeDecodeErrorcCs,tj|dtd�ddd�|`dS)Nr�rrr)�UnicodeDecodeErrorr�	bytearray�end)rrrrr(s"z NoEndUnicodeDecodeError.__init__N)r
rrrrrrrr'src@seZdZdd�ZdS)�BadObjectUnicodeDecodeErrorcCs/tj|dtd�ddd�g|_dS)Nrrrrr)rrrr	)rrrrr.s"z$BadObjectUnicodeDecodeError.__init__N)r
rrrrrrrr-src@seZdZdd�ZdS)�NoStartUnicodeTranslateErrorcCs#tj|dddd�|`dS)Nrrrr)�UnicodeTranslateErrorrr
)rrrrr4sz%NoStartUnicodeTranslateError.__init__N)r
rrrrrrrr3src@seZdZdd�ZdS)�NoEndUnicodeTranslateErrorcCs#tj|dddd�|`dS)Nrrrr)rrr)rrrrr:sz#NoEndUnicodeTranslateError.__init__N)r
rrrrrrrr9src@seZdZdd�ZdS)�NoObjectUnicodeTranslateErrorcCs#tj|dddd�|`dS)Nrrrr)rrr	)rrrrr@sz&NoObjectUnicodeTranslateError.__init__N)r
rrrrrrrr ?sr 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#dCS)D�CodecCallbackTestcCsBd}|j|jdd�d�|j|jdd�d�dS)Nuスパモ änd eggsr�xmlcharrefreplaces&&#12473;&#12497;&#12514; &#228;nd eggszlatin-1s!&#12473;&#12497;&#12514; �nd eggs)�assertEqual�encode)r�srrr�test_xmlcharrefreplaceFsz(CodecCallbackTest.test_xmlcharrefreplacecCs�dd�}tjd|�d}d}|j|jdd�|�d}|j|jdd�|�d	}|j|jd
d�|�dS)NcSs�t|t�s"td|��ng}xr|j|j|j�D]W}y%|jdtjj	t
|��WqBtk
r�|jdt
|��YqBXqBWdj|�|jfS)Nzdon't know how to handle %rz&%s;z&#%d;r)
�
isinstancer�	TypeErrorr	r
r�append�htmlZentitiesZcodepoint2name�ord�KeyError�join)r�l�crrr�xmlcharnamereplaceXs %
 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_xmlcharnamereplaceTs
z)CodecCallbackTest.test_xmlcharnamereplacecCs�dd�}tjd|�d}d}|j|jdd�|�d}|j|jdd�|�d	}|j|jd
d�|�dS)NcSs�t|t�s"td|��ng}xD|j|j|j�D])}|jtj|dt	|���qBWddj
|�|jfS)Nzdon't know how to handle %rz0x%xz
%sz, )r'rr(r	r
rr)�unicodedata�namer+r-)rr.r/rrr�uninamereplacews '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_uninamereplacens	
z%CodecCallbackTest.test_uninamereplacecCspd}d}|j|jdd�|�d}|j|jdd�|�d}|j|jdd�|�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_backslashescapecCsgdd�}tjd|�d}d}|j|jdd�|�d}|jt|jdd�dS)NcSs`t|t�s"td|��n|j|j|jd�dkrVd|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}|jtj|d|�d|�d}|jttj|d|�d	|td
�<d}d}|jtj|d
|�d|�d|td
�<|jttj|d
|�dS)Ncss4|]*}t|�td|j�d�fVqdS)r<rN)r+�bytes�upper)�.0r/rrr�	<genexpr>�sz7CodecCallbackTest.test_charmapencode.<locals>.<genexpr>Zabcdefgh�abcsAABBCC�strictrZabcAsXYZ�?ZabcDEFsAABBCCXYZXYZXYZ�replaceZXYZ)�dictr#r1�charmap_encoder@�UnicodeErrorr+r()r�charmapr3r4rrr�test_charmapencode�s##z$CodecCallbackTest.test_charmapencodecCs�tjjdtf���|jtdjd�tdjd��dkr�dd�}|j	djdd�d�|j	djdd	�d
�t
jd|�|j	djdd�d�nWdQXdS)
Nz*unicode_internal codec has been deprecatedszunicode-internalr=�cSs&t|t�s"td|��ndS)Nzdon't know how to handle %r�r)rPr)r'rr()rrrr�handler_unicodeinternal�szMCodecCallbackTest.test_decodeunicodeinternal.<locals>.handler_unicodeinternal�ignorerIu�ztest.huiZ)�test�support�check_warnings�DeprecationWarningr@rr?rr$r#r1r2)rrQrrr�test_decodeunicodeinternal�s$
z,CodecCallbackTest.test_decodeunicodeinternalcCsdd�}tjd|�dd�}tjd|�d}|j|jdd�d	�|j|jdd�d
�|jdjdd�d
�|jdjdd�d�|jtjddidtd�6�dd�|jdjdd�d�|jdjdd�d�dS)Ncs�t�j�j�}t�t�r@�fdd�|D�}n;t�t�rk�fdd�|D�}ntd���ddj|��jfS)Ncs'g|]}dt�j|��qS)z<%d>)r+r	)rDr)rrr�
<listcomp>�s	zFCodecCallbackTest.test_callbacks.<locals>.handler1.<locals>.<listcomp>cs!g|]}d�j|�qS)z<%d>)r	)rDr)rrrrX�s	zdon't know how to handle %rz[%s]r)�ranger
rr'rrr(r-)r�rr.r)rr�handler1�sz2CodecCallbackTest.test_callbacks.<locals>.handler1z
test.handler1csht�t�s"td���n�fdd�t�j�j�D�}ddj|��jdfS)Nzdon't know how to handle %rcs!g|]}d�j|�qS)z<%d>)r	)rDr)rrrrX�s	zFCodecCallbackTest.test_callbacks.<locals>.handler2.<locals>.<listcomp>z[%s]rr)r'rr(rYr
rr-)rr.r)rr�handler2�s(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�z�arz
z[<98>][<99>]ugüßrksg[<252><223>]rkugüßs
g[<252><223>])r1r2r#r?�charmap_decoder+r$)rr[r\r%rrr�test_callbacks�s4
#z CodecCallbackTest.test_callbackscs�dddddg}x+|D]#}tjd|tj|��qWd�|dd	�|D�7}xl�fd
d	�dD�D]Q}xHdD]@}x7|D]/}y|j||�Wq�tk
r�Yq�Xq�Wq�WqzWdS)NrGrRrIr"r:ztest.i�cSsg|]}d|�qS)ztest.r)rD�errrrrrX(s	z6CodecCallbackTest.test_longstrings.<locals>.<listcomp>csg|]}|��qSrr)rDr%)r.rrrX)s	�x�あ�aär�latin-1�
iso-8859-1�iso-8859-15�utf-8�utf-7�utf-16�utf-32)rbrcrd)zasciirerfrgrhrirjrk)r1r2�lookup_errorr$rL)r�errorsraZuni�encr)r.r�test_longstringss	
! 


z"CodecCallbackTest.test_longstringsc
Cs(|jt||dd��|jt||dg�ddddddg}x�tt|��D]�}x�|D]�}t|�t||�kr�qong}xGtt|��D]3}||kr�|j|�q�|j||�q�W|jt||�qoWqbW||�}	|jt|	�|�dS)	Nrztoo muchZspamseggssspam�*g�?���)r@r(rYr�typer)r#�str)
r�exctype�args�msgZ	wrongargs�iZwrongargZcallargs�jrrrr�check_exceptionobjectargs2s
z+CodecCallbackTest.check_exceptionobjectargscCs�|jtdddddgd�|jtdddddgd�|jtdd	d
ddgd�|jtddd
ddgd
�|jtddd
ddgd�|jtddd
ddgd�dS)Nrugürkrr<�ouchz?'ascii' codec can't encode character '\xfc' in position 1: ouchrOz;'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)ryr)rrrr�test_unicodeencodeerrorKs0z)CodecCallbackTest.test_unicodeencodeerrorcCsT|jtdtd�dddgd�|jtdtd�dddgd�dS)	Nrsg�rkrr<rzz8'ascii' codec can't decode byte 0xfc in position 1: ouch�z6'ascii' codec can't decode bytes in position 1-2: ouch)ryrr)rrrr�test_unicodedecodeerrorksz)CodecCallbackTest.test_unicodedecodeerrorcCs�|jtddddgd�|jtddddgd�|jtddddgd	�|jtd
dddgd�|jtddddgd
�dS)Nugürkrr<rzz4can'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: ouchr|z0can't translate characters in position 1-2: ouch)ryr)rrrr�test_unicodetranslateerrorws(z,CodecCallbackTest.test_unicodetranslateerrorc	Cs�|jttjd�|jttjtd��|jttjtddddd��|jttjtdtd�ddd��|jttjtdddd��dS)Nrprzruあrrs�)	r@r(r1�
strict_errors�	Exceptionrrrr)rrrr�test_badandgoodstrictexceptions�s(
z1CodecCallbackTest.test_badandgoodstrictexceptionscCs�|jttjd�|jttjtd��|jtjtddddd��d	�|jtjtdtd�ddd��d
�|jtjt	dddd��d�dS)Nrprzruaあbrr<rsa�b)rr<)rr<)rr<)
r@r(r1�
ignore_errorsrLr#rrrr)rrrr�test_badandgoodignoreexceptions�s(
z1CodecCallbackTest.test_badandgoodignoreexceptionscCs�|jttjd�|jttjtd��|jttjt��|jttjt��|jtjtddddd��d
�|jtjt	dt
d�ddd��d�|jtjtdddd��d�dS)
Nrprzruaあbrr<rHsa�b��)rHr<)r�r<)r�r<)r@r(r1�replace_errorsrLrrr#rrrr)rrrr� test_badandgoodreplaceexceptions�s8


z2CodecCallbackTest.test_badandgoodreplaceexceptionscCs|jttjd�|jttjtd��|jttjtdtd�ddd��|jttjtdddd��d}|d7}djdd�|D��}|j	tjt
dd|dddt|�d��djdd�|D��dt|�f�dS)Nrprzrs�rruあ�	�
�c�d�����'�'韆順�?B�@B����rcss|]}t|�VqdS)N)�chr)rDr/rrrrEszOCodecCallbackTest.test_badandgoodxmlcharrefreplaceexceptions.<locals>.<genexpr>r^�bcss|]}d|VqdS)z&#%d;Nr)rDr/rrrrEs)rrr�r�r�r�r�r�r�r�r�r�r�r�)r�r�)r@r(r1�xmlcharrefreplace_errorsrLrrrr-r#rr)rZcsr%rrr�*test_badandgoodxmlcharrefreplaceexceptions�s2

z<CodecCallbackTest.test_badandgoodxmlcharrefreplaceexceptionscCs0|jttjd�|jttjtd��|jttjtdtd�ddd��|jttjtdddd��d!d"d#d$d%d&d'd(d)d*d+d,g}xz|D]r\}}|jd|��R|j	tjt
dd|d ddt|�d��|dt|�f�WdQXq�WdS)-Nrprzrs�rr�あ�\u3042�
�\x0ar^�\x61r=�\x00�ÿ�\xff�Ā�\u0100�￿�\uffff�𐀀�
\U00010000�􏿿�
\U0010ffff���\ud800���\udfff����\ud800\udfffrsr�)r�r�)r�r�)r^r�)r=r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r@r(r1�backslashreplace_errorsrLrrr�subTestr#rr)r�testsr%rZrrr�)test_badandgoodbackslashreplaceexceptionssF
	z;CodecCallbackTest.test_badandgoodbackslashreplaceexceptionscCs1tjd�}|jt|d�|jt|td��|jt|tdddd��xLdD]D}|jd
|��*|jt|td|ddd��WdQXqdW|j|tdddd
d��d�|jt	|t	dt
d�ddd��|j|t	dt
d�dd
d��d�dS)N�surrogateescaperprz��rrr^����rsrua�br<���asa�b)r^r�r�)r�r<)r�r<)r1rlr@r(rLrr�rr#rr)rZsurrogateescape_errorsr%rrr�(test_badandgoodsurrogateescapeexceptionsMs>

#z:CodecCallbackTest.test_badandgoodsurrogateescapeexceptionscCs�tjd�}|jt|d�|jt|td��|jt|tdddd��xzd(D]r}|jd|��X|jt|t|d
ddd��|jt|t|d
j	|�ddd��WdQXqdWd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:g}x�|D]�\}}}}|jd|d#|d$|���|j
|t|d
|d%ddt|�d��|dt|�f�|j
|t|td&|d|�d'�d|d��|dd�d|f�WdQXqWdS);N�
surrogatepassrprz��rr�utf-8�utf-16le�utf-16be�utf-32le�utf-32be�encodingr^r��r|��r<����rO�����������������������������������rsrBr�r��b)r�r�r�r�r�)�asciir�r�r|)r�r�r�r|)r�r�r�r<)r�r�r�r<)r�r�r�rO)r�r�r�rO)r�r�r�r|)r�r�r�r|)r�r�r�r<)r�r�r�r<)r�r�r�rO)r�r�r�rO)r�r�r�r|)r�r�r�r|)r�r�r�r<)r�r�r�r<)r�r�r�rO)r�r�r�rO)
r1rlr@r(rLrr�rrr$r#rr)rZsurrogatepass_errorsrnr�r%r��nrrr�&test_badandgoodsurrogatepassexceptionsysj

,	!z8CodecCallbackTest.test_badandgoodsurrogatepassexceptionscs�d}d}x�|D]��tjd
�fdd��x'|D]}|jtd
j|d
�q<WxCd!D];\}}tjj��|jt|j|d
�WdQXqfWqWdS)"Nrp�foorr<r|r�latin-1�
iso-8859-1�iso-8859-15ztest.badhandlercs�S)Nr)rb)�resrr�<lambda>�sz:CodecCallbackTest.test_badhandlerresults.<locals>.<lambda>uあ���utf-8�utf-7�+x-�unicode-internal��rr<r|�r�rr|�r�N�r��r�rr|�r�N�r�)	rpr�r�r�r�r�r�r�r�)�asciir�r�r��r�r��r�r��r�r��r�r�)r�r�r�r�)	r1r2r@r(r$rSrTrUr?)rZresultsZencsrnrBr)r�r�test_badhandlerresults�s*

z(CodecCallbackTest.test_badhandlerresultscCs�|jtjtjd��|jtjtjd��|jtjtjd��|jtjtjd��|jtjtjd��dS)NrGrRr"r:)r#r1rrlr�r�r�)rrrr�test_lookup�szCodecCallbackTest.test_lookupcCsJdd�}tjd|�x'dD]}|jtdj|d�q#WdS)	NcSs0t|t�rd|jfStd|��dS)Nu䉂zdon't know how to handle %r)r'rrr()rrrr�	unencrepl�s
z@CodecCallbackTest.test_unencodablereplacement.<locals>.unencreplztest.unencreplhandlerr�
iso-8859-1�iso-8859-15u䉂)zasciir�r�)r1r2r@rr$)rr�rnrrr�test_unencodablereplacement�s
z-CodecCallbackTest.test_unencodablereplacementcCs3|jttjd�|jttjdd�dS)Nrpz
test.dummy)r@r(r1r2)rrrr�test_badregistercall�sz&CodecCallbackTest.test_badregistercallcCs|jttj�dS)N)r@r(r1rl)rrrr�test_badlookupcall�sz$CodecCallbackTest.test_badlookupcallcCs|jttjd�dS)Nztest.unknown)r@�LookupErrorr1rl)rrrr�test_unknownhandlersz%CodecCallbackTest.test_unknownhandlerc
Cskd}djdd�|D��}tjdtj�x/dD]'}xdD]}|j||�qIWq<WdS)Nr�r��2r�������'�P�順� ��@BrcSsg|]}t|��qSr)r�)rDrbrrrrXs	z;CodecCallbackTest.test_xmlcharrefvalues.<locals>.<listcomp>�test.xmlcharrefreplacer�iso-8859-15r")
rr�r�r�r�r�r�r�r�r�rrr)zasciir)zxmlcharrefreplacer)r-r1r2r�r$)r�vr%rnrarrr�test_xmlcharrefvaluess

z'CodecCallbackTest.test_xmlcharrefvaluescCs�|jtdjdd�dd�}tjd|�|jtdjdd�|jtdjdd�|jtd	jdd�|jtd
jdd�|jtdjdd�|jtdjd
d�dd�}tjd|�|jtdjdd�t�}tjd|j�d|_|j	djdd�d�d |_|j	djdd�d�d!|_|jt
djdd�d|_|j	djdd�d�d|_|j	djdd�d�d|_|jt
djdd�d|_|j	djd
d�d�Gdd�dt�}|jttj
ddidd6�|jttj
dd|��|jttj
dditjdd6�dS)"Ns�rztest.unknowncSsdS)Nrpr)rrrr�baddecodereturn1sz=CodecCallbackTest.test_decodehelper.<locals>.baddecodereturn1ztest.baddecodereturn1s\zunicode-escapes\x0s\x0ys
\Uffffeeees\uyyyyzraw-unicode-escapecSsdS)NrH)rHNr)rrrr�baddecodereturn2"sz=CodecCallbackTest.test_decodehelper.<locals>.baddecodereturn2ztest.baddecodereturn2ztest.posreturnrs�0z<?>0r<z<?><?>r|z<?>�s\uyyyy0c@seZdZdd�ZdS)z.CodecCallbackTest.test_decodehelper.<locals>.DcSs
t�dS)N)�
ValueError)r�keyrrr�__getitem__Gsz:CodecCallbackTest.test_decodehelper.<locals>.D.__getitem__N)r
rrrrrrr�DFsr
rG�rq������)r@r�r?r1r2r(rrrr#�
IndexErrorrJrLr_r
�sys�
maxunicode)rrr�handlerr
rrr�test_decodehelpers@								#z#CodecCallbackTest.test_decodehelperc	Cs|jtdjdd�dd�}tjd|�|jtdjdd�dd�}tjd	|�|jtdjdd	�t�}tjd
|j�d|_|j	djdd
�d
�d|_|j	djdd
�d�d|_|jt
djdd
�d|_|j	djdd
�d
�d|_|j	djdd
�d�d|_|jt
djdd
�d|_Gdd�dt�}xsdD]k}|jttj
d|idd6�|jttj
d||��|jttj
d|idd6�q�WdS)Nr�rztest.unknowncSsdS)Nrpr)rrrr�badencodereturn1Ssz=CodecCallbackTest.test_encodehelper.<locals>.badencodereturn1ztest.badencodereturn1cSsdS)NrH)rHNr)rrrr�badencodereturn2Xsz=CodecCallbackTest.test_encodehelper.<locals>.badencodereturn2ztest.badencodereturn2�test.posreturnruÿ0s<?>0r<s<?><?>r|s<?>rc@seZdZdd�ZdS)z.CodecCallbackTest.test_encodehelper.<locals>.DcSs
t�dS)N)r
)rrrrrr{sz:CodecCallbackTest.test_encodehelper.<locals>.D.__getitem__N)r
rrrrrrrr
zsr
rGrIr"r:ri,rqrr)zstrictzreplacezxmlcharrefreplacezbackslashreplacer)r@r�r$r1r2r(rrrr#rrJrLrKr
)rrrrr
rarrr�test_encodehelperMs6								
#z#CodecCallbackTest.test_encodehelpercCs[Gdd�dt�}|jtdjitjdd6�|jtdjifd6�dS)Nc@seZdZdd�ZdS)z1CodecCallbackTest.test_translatehelper.<locals>.DcSs
t�dS)N)r
)rrrrrr�sz=CodecCallbackTest.test_translatehelper.<locals>.D.__getitem__N)r
rrrrrrrr
�sr
r�rr)rJr@r(�	translaterr)rr
rrr�test_translatehelper�s$z&CodecCallbackTest.test_translatehelpercCsfidtd�6dtd�6dtd�6dtd�6}x%dD]}d
|}|j|�qAWdS)Nz&amp;�&z&lt;�<z&gt;�>z&quot;�"rr�r���zabc<def>ghi)rr�r�r )r+r)rrMr��textrrr�test_bug828737�s




z CodecCallbackTest.test_bug828737cCsddddddddg}dd
�}tjd|�tjj��Bx:|D]2\}}|jt��|j|d�WdQXqQWWdQXdd�}tjd|�tjj��Bx:|D]2\}}|jt��|j|d�WdQXq�WWdQXdS)Nr���utf-7�++�utf-8�utf-16�utf-32�unicode-escape�\u123g�raw-unicode-escape�unicode-internalcSs0t|t�rd|_dStd|��dS)Nrp�䉂rzdon't know how to handle %r)r-r)r'rr	r()rrrr�	replacing�s	z?CodecCallbackTest.test_mutatingdecodehandler.<locals>.replacingztest.replacingcSs:t|t�r&d|jdd�<dStd|��dS)Nr�䉂rzdon't know how to handle %r)r/r)r'rr	r()rrrr�mutating�sz>CodecCallbackTest.test_mutatingdecodehandler.<locals>.mutatingz
test.mutating)zasciir#)r$r%)r&r#)r'r#)r(r#)r)r*)r+r*)r,r#)r1r2rSrTrUr@r(r?)rZbaddatar.r��datar0rrr�test_mutatingdecodehandler�s(	 z,CodecCallbackTest.test_mutatingdecodehandlercs1tjtjtjtjtjtjd�tjd�g}x�ttt	fD]��G�fdd�dt
�}xC|D];}|jd|d���|jt
||��WdQXquWG�fdd�dt�}xV|D]N}|jd|d���.|jt
|f��||��WdQXWdQXq�WqLWdS)Nr�r�cseZdZ�ZdS)zACodecCallbackTest.test_fake_error_class.<locals>.FakeUnicodeErrorN)r
rr�	__class__r)�clsrr�FakeUnicodeError�sr5rZerror_classcseZdZ�ZdS)zACodecCallbackTest.test_fake_error_class.<locals>.FakeUnicodeErrorN)r
rrr3r)r4rrr5�s)r1rr�r�r�r�rlrrrrsr�r@r(r�)rZhandlersr5rr)r4r�test_fake_error_class�s"
 
z'CodecCallbackTest.test_fake_error_classN)$r
rrr&r5r9r;rArNrWr`roryr{r}r~r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr"r2r6rrrrr!DsB
9 (%1,D
;5
)r!�__main__)r1Z
html.entitiesr*rZtest.supportrSr6Zunittest�warningsrrrrrrrrrrr ZTestCaser!r
�mainrrrr�<module>s(����