Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_unicode.cpython-35.pyc



��Yf���@s.dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZdd�Zej
e�dd�ZGdd	�d	e�ZGd
d�dejejejej�ZGdd
�d
ej�ZGdd�dej�Zedkr*ej�dS)z� Test script for the Unicode implementation.

Written by Marc-Andre Lemburg (mal@lemburg.com).

(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.

�N)�support�string_testscCs|ddd�}ddd�}ddd�}ddd	�}|d
krX||ddfS|dkrt||ddfSdSdS)N�strictcSsdS)N�*�)�input�errorsrr�6/opt/alt/python35/lib64/python3.5/test/test_unicode.py�decode1sz search_function.<locals>.decode1cSsdS)Nrr)rrrrr	�encode1sz search_function.<locals>.encode1cSsdS)Nr)rrr)rrrrr	�encode2sz search_function.<locals>.encode2cSsdS)Nr)rrr)rrrrr	�decode2sz search_function.<locals>.decode2z
test.unicode1z
test.unicode2r)�encodingr
rrr
rrr	�search_functionsrcCs|j�j�S)z�
    Try to get a fresh clone of the specified text:
    new object with a reference count of 1.

    This is a best-effort: latin1 single letters and the empty
    string ('') are singletons and cannot be cloned.
    )�encode�decode)�textrrr	�duplicate_string$src@seZdZdS)�StrSubclassN)�__name__�
__module__�__qualname__rrrr	r.srcs9eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zejejd!d"kd#�d$d%��Zd&d'�Zejd(d)��Zd*d+�Zd,d-�Z�fd.d/�Z �fd0d1�Z!�fd2d3�Z"�fd4d5�Z#�fd6d7�Z$�fd8d9�Z%d:d;�Z&�fd<d=�Z'd>d?�Z(d@dA�Z)dBdC�Z*dDdE�Z+dFdG�Z,dHdI�Z-dJdK�Z.dLdM�Z/�fdNdO�Z0dPdQ�Z1dRdS�Z2ej3ejd!dTdUkdV�ejdWdX���Z4dYdZ�Z5d[d\�Z6d]d^�Z7d_d`�Z8dadb�Z9dcdd�Z:dedf�Z;dgdh�Z<didj�Z=dkdl�Z>dmdn�Z?dodp�Z@ejdqdr��ZAdsdt�ZBdudv�ZCejDdwdxdy�dzd{��ZEd|d}�ZFd~d�ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^ejejdUd">kp�e_j`d��d�kd��d�d���Zaejd�d���Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zi�S)��UnicodeTestcGs�t||�}||�}|j||�|jt|�t|�k�||kr�Gdd�dt�}||�}t||�}||�}|j||�|j||k	�dS)Nc@seZdZdd�ZdS)z)UnicodeTest.checkequalnofix.<locals>.usubcSsdtj|�S)Nzusub(%r))�str�__repr__)�selfrrr	rBsz2UnicodeTest.checkequalnofix.<locals>.usub.__repr__N)rrrrrrrr	�usubAsr)�getattr�assertEqual�
assertTrue�typer)r�result�objectZ
methodname�args�methodZ
realresultrrrr	�checkequalnofix8szUnicodeTest.checkequalnofixcCsm|jdd�|jdd�|jttd�|jttd�|jttd	�|jdd�dS)
N�ÿu￿z'\Ufffffffe'z'\Uffffffff'z'\U%08x'iz\u0020� z'\U00110000')r�assertRaises�SyntaxError�eval�assertNotEqual)rrrr	�
test_literalsJszUnicodeTest.test_literalscCs�tjjd�s�|jtd�d�|jtd�d�|jtd�d�|jtd�d	�|jtd
�d�|jtd�d
�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�d}tdjtttd����}|j||�|jtdddd �tdddd ��Gd!d"�d"�}|j	t
t|��dS)#N�java�abcz'abc'zab\cz'ab\\c'zab\z'ab\\'z\cz'\\c'�\z'\\'�
z'\n'�
z'\r'�	z'\t'�z'\x08'z'"z'\'"'�'z"'"�"z'"'a�'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'��u𐀀�'u￿ic@seZdZdd�ZdS)z)UnicodeTest.test_ascii.<locals>.WrongReprcSsdS)Ns	byte-reprr)rrrr	rysz2UnicodeTest.test_ascii.<locals>.WrongRepr.__repr__N)rrrrrrrr	�	WrongReprxsr9)�sys�platform�
startswithr�ascii�join�map�chr�ranger(�	TypeError)r�
latin1repr�testreprr9rrr	�
test_asciiSs*$zUnicodeTest.test_asciicCs�tjjd�s�|jtd�d�|jtd�d�|jtd�d�|jtd�d	�|jtd
�d�|jtd�d
�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�|jtd�d�d}tdjtttd����}|j||�|jtdddd �tdddd ��Gd!d"�d"�}|j	t
t|��dS)#Nr-r.z'abc'zab\cz'ab\\c'zab\z'ab\\'z\cz'\\c'r/z'\\'r0z'\n'r1z'\r'r2z'\t'r3z'\x08'z'"z'\'"'r4z"'"r5z'"'u%'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'r6r7u𐀀r8u￿ic@seZdZdd�ZdS)z(UnicodeTest.test_repr.<locals>.WrongReprcSsdS)Ns	byte-reprr)rrrr	r�sz1UnicodeTest.test_repr.<locals>.WrongRepr.__repr__N)rrrrrrrr	r9�sr9)r:r;r<r�reprr>r?r@rAr(rB)rrCrDr9rrr	�	test_repr}s*$zUnicodeTest.test_reprcCsedj�}|jt|�d�|jt|�d�|jt|�d�|jtt|�dS)Nu	ᄑ∢㌳uᄑu∢u㌳)�__iter__r�nextr(�
StopIteration)r�itrrr	�test_iterators�s
zUnicodeTest.test_iteratorscCstjj|�|jdddd�|jdddd�|jdddd�|jdddd�|jdddd�|jddddd�|jddddd�|jd	ddddd�|jdddddd�|jdddd�|jdddd�|jdddd
�|jdddd
�|jdddd�|jdddd�|jdd
ddd�|jddddd�|jddd dd
�|jdd!dd�|jdd"dd�|jdd#dd�dS)$N�Zaaa�count�ar�b��
�uĂu􀌄�a_uĂ_uaĂua􀌄uĂ􀌄���i����rUi�����
aaaaaaaaaauĂaaaaaaaaaarVu􀌄aaaaaaaaaauĂĂĂĂĂĂĂĂĂĂu􀌄ĂĂĂĂĂĂĂĂĂĂrVrVuĂĂĂĂĂĂĂĂĂĂ�a_a_a_a_a_a_a_a_a_a_rWuĂ_Ă_Ă_Ă_Ă_Ă_Ă_Ă_Ă_Ă_rVrVuĂĂĂĂĂĂĂĂĂĂ)r�
CommonTest�
test_countr%�
checkequal)rrrr	rY�s,zUnicodeTest.test_countcCs�tjj|�|jdddddd�|jdddddd�|jdddddd�|jdddddd�|jdddd	dd	�|jdddd	dd
�|jdddd	dd�|jdd
dd�|jdd
ddd�|jdd
ddd�|jtdj�|jtdjd�|jdddddd�|jdd	dddd�|jdd	dddd�|jddddd�|jd dddd	�|jd!dddd	�|jdddddd�|jdd	dddd�|jdd	dddd�|jd"dddd�|jd#dddd�|jd$dddd�dS)%N�drOuĂ�findrQuȁuĠuȠu􀌄u􀈄u􂀄r�abcdefghiabcr.�	�def��hellorrTuĂ_uaĂua􀌄uĂ􀌄rUrUrUrUrUrUrUrUrUrUrUrU)rrX�	test_findrZr%r(rBr\)rrrr	rb�s2zUnicodeTest.test_findcCsxtjj|�|jdddddd�|jdddddd�|jdddddd�|jdddddd	�|jdd
dddd
�|jdd
dddd�|jdd
dddd�|jd
ddd�|jdddd�|jdddd�|jdddddd�|jddd
ddd�|jddd
ddd�|jddddd�|jddddd
�|jddddd
�|jdddddd�|jddd
ddd�|jddd
ddd�|jddddd�|jd dddd�|jd!dddd�dS)"NruĂrOr[�rfindrQuȁuĠuȠu􀌄u􀈄u􂀄r^r]r.�r6�_au_ĂuĂau􀌄au􀌄ĂrUrUrUrUrUrUrUrUrUrUrU)rrX�
test_rfindrZr%)rrrr	rf�s.zUnicodeTest.test_rfindcCs tjj|�|jdddd�|jdddd�|jdddd�|jddddd	�|jtdjd
�|jtdjdd	�|jtdjd
d�|jtdjd
d�|jdddddd�|jdddddd�|jdddddd�|jtddjd�|jtddjd�|jtddjd�|jdddddd�|jdddddd�|jdddddd�|jtddjd�|jtddjd�|jtddjd�dS)Nrr]�indexr6rMr_r.r^rQ�hibZabcdefghiab�	abcdefghi�ghi�r[uĂrOu􀌄rTuĂ_uaĂua􀌄uĂ􀌄rU)rrX�
test_indexr%r(�
ValueErrorrgrZ)rrrr	rls*zUnicodeTest.test_indexcCsEtjj|�|jdddd�|jdddd�|jdddd�|jd	dddd	d�|jtdjd�|jtdjdd
�|jtdjdd	d�|jtd
jdd	d�|jtd
jdd	d�|jd	ddddd�|jd	ddddd�|jd	ddddd�|jtddjd�|jtddjd�|jtddjd�|jd	ddddd�|jd	ddddd�|jd	ddddd�|jtddjd�|jtddjd�|jtddjd�dS)Nrdr]�rindexr6rMr_r^r.rrQrhZ	defghiabcrirjrkrOuĂr[u􀌄reu_ĂuĂau􀌄au􀌄ĂrUrUrU)rrX�test_rindexr%r(rmrnrZ)rrrr	ros,zUnicodeTest.test_rindexc
Cs�|jdddtd�di�|jdddtd�dtd�td�i�|jdddtd�dtd�td�td	�d
i�|jd	ddtd�dtd�di�|jdd
dtd�di�|jdddddi�|jjddddi�}|jddd|�|jjddd�}|jddd|�|jdjtjdd��d�|jdjtjddi��d�|jdjtjddi��d�|jdjtjddi��d�|jdjtjddi��d�|jdjtjdddd i��d!�|jdjtjddddi��d"�|jdjtjdd#i��d$�|jdjtjddi��d�|jdjtjddi��d�|jdjtjdd i��d%�|jd&jtjdd'i��d(�d2}xCd+D];}tj||i�}d,|}|jt|j|�qZW|jt	|jj�|jt|jjdd-�|jt	|jjd.d/�|jt	|jjdd.�|jt	|jjdd/d.�|jt|jjd0d.i�|jt	|jjd3d.i�|jt	d1j�|jt	djdd�dS)4NZbbbcZabababc�	translaterOZiiicrP�iZiiix�c�xr6ZxyyxZxzx�zZyyz<i>z
<i><i><i>cr.Zxyz�dZxyzzyZabdcdcbddddz[a]�Xz[X]z[]ZXXXz[XXX]�éu[é]Zaxb�123Zx123uxéu<é>u[<é>]z[123]u[aé]u<€>u	[<€>é]i��rQu
aé€􏿿z[%s]ZdefgrSr_Zxyrai)rQ)
r%�ord�	type2test�	maketransrrprr(rmrB)rZtblZinvalid_charZbefore�mappingrrrr	�test_maketrans_translate6sl%1
!!!!''!!!!!

z$UnicodeTest.test_maketrans_translatecCs�tjj|�x�d
D]�\}}|d9}|d9}x�dD]�}|j||g||d|�|j||g|||d|�|j||g||d|d	�|j||g||d	|d|d	�q>WqWdS)N�ba�āĀ�𐌁𐌀r^rr�Ă�𐌂�splitrS)r~rr�)rrr�r�)rrX�
test_splitrZ)r�left�right�delimrrr	r�|s


zUnicodeTest.test_splitcCs�tjj|�x�d
D]�\}}|d9}|d9}x�dD]�}|j||g||d|�|j||g|||d|�|j||g||d|d	�|j||g||d	|d|d	�q>WqWdS)Nr~�āĀ�𐌁𐌀r^rr�Ă�𐌂�rsplitrS)r~r�r�)rrr�r�)rrX�test_rsplitrZ)rr�r�r�rrr	r��s


zUnicodeTest.test_rsplitcCstjj|�|jd
ddd�x�dD]�\}}|d9}|d9}x�dD]�}|j||ddf||d|�|j|||f|||d|�|j||ddf||d|d�|j||d|f||d|d|d�qTWq-WdS)N�ABCDEFGHr6�	partitionu䈀r~�āĀ�𐌁𐌀r^rr�Ă�𐌂rS)r�r6r6)r~r�r�)rrr�r�)r�MixinStrUnicodeUserStringTest�test_partitionrZ)rr�r�r�rrr	r��s


zUnicodeTest.test_partitioncCstjj|�|jd
ddd�x�dD]�\}}|d9}|d9}x�dD]�}|jdd||f||d|�|j|||f|||d|�|jdd||f||d|d�|j||d|f||d|d|d�qTWq-WdS)Nr6r��
rpartitionu䈀r~�āĀ�𐌁𐌀r^rr�Ă�𐌂rS)r6r6r�)r~r�r�)rrr�r�)rr��test_rpartitionrZ)rr�r�r�rrr	r��s


zUnicodeTest.test_rpartitioncCstjj|�Gdd�d�}|jddddddd	g�|jd
ddd�|jdddtjd
��|jddddddd	g�|jddddddd	g�|jd
ddd�|jdddtjd
��|jtdddd|d�g�|jtdddddt�g�|jtdddddg�|jtdddddg�dS)Nc@s(eZdZdd�Zdd�ZdS)z(UnicodeTest.test_join.<locals>.MyWrappercSs
||_dS)N)�sval)rr�rrr	�__init__�sz1UnicodeTest.test_join.<locals>.MyWrapper.__init__cSs|jS)N)r�)rrrr	�__str__�sz0UnicodeTest.test_join.<locals>.MyWrapper.__str__N)rrrr�r�rrrr	�	MyWrapper�sr�za b c dr'r>rOrPrrru�abcdr6zw x y zZwxyz�1�2�foo�3rQrSrM)rOrPrrru)rOrPrrru)rr��	test_joinr%�Sequence�checkraisesrB�bytes)rr�rrr	r��s"""%%zUnicodeTest.test_joinrS� z*needs too much memory on a 64-bit platformcCsBttjd�d}d|f|}|jtdj|�dS)Ng�?rQ�Ar6)�intr:�maxsizer(�
OverflowErrorr>)r�size�seqrrr	�test_join_overflow�szUnicodeTest.test_join_overflowc	Cs6tjj|�|jdddddd�|jtdjdd�x�dD]�\}}|d9}|d9}x�dD]�}x�dD]�}|j||||d||�|j||||||d||�|j||||d|d|�|j|||||d|d|d|�q�WqsWqLWdS)Nzone@two!three!zone!two!three!�replace�!�@rQ�rrr~�āĀ�𐌁𐌀r^rr�Ă�𐌂ru�ă�𐌃rS)r~r�r�)rrr�r�)rur�r�)rrX�test_replacer%r(rBr�rZ)rr�r�r��replrrr	r��s$






zUnicodeTest.test_replacecCs,d}d}|j|j||�|�dS)Nr.zabc def)�assertIsr�)r�patternrrrr	�test_replace_id�szUnicodeTest.test_replace_idcCs�tj��ytjdt�|jddkd�|jddkd�|jdtd�kd�|jdtd�kd�WdQRXdS)N�ignorer.sabcFT)r�check_warnings�warnings�simplefilter�BytesWarningr�	bytearray)rrrr	�test_bytes_comparison�s
z!UnicodeTest.test_bytes_comparisoncsM�jdd��jddk��jddk��jddk�dS)Nr.r�u��u��)rr)rr)rZ
test_fixupZ
test_lecmpr	�test_comparison�s5zUnicodeTest.test_comparisoncs�t�j�|jddd�|jdj��|jdj��|jdj��|jdj��|jdj��|jd	j��|jd
j��|jdj��dS)NFuῼ�isloweruⅧuⅷu𐐁u𐐧u𐐩u𐑎u🐍u👯)�super�test_islowerr%�assertFalser�r)r)�	__class__rr	r�:s
zUnicodeTest.test_islowercs�t�j�tjjd�s2|jddd�|jdj��|jdj��|jdj��|jdj��|jd	j��|jd
j��|jdj��|jdj��dS)
Nr-Fuῼ�isupperuⅧuⅷu𐐁u𐐧u𐐩u𐑎u🐍u👯)	r��test_isupperr:r;r<r%rr�r�)r)r�rr	r�Is
zUnicodeTest.test_isuppercs�t�j�|jddd�|jddd�|jdj��|jdj��x9ddd	d
gD]%}|j|j�dj|��qlWdS)NTuῼ�istitleuGreek ῼitlecases ...u𐐁𐐩u𐐧𐑎u𐐩u𐑎u🐍u👯z{!a} is not title)r��test_istitler%rr�r��format)r�ch)r�rr	r�Ys
zUnicodeTest.test_istitlecs�t�j�|jddd�|jddd�|jddd�x?ddd	d
ddgD]%}|j|j�d
j|��q_WdS)NTu �isspaceu Fu—u𐐁u𐐧u𐐩u𐑎u🐍u👯z{!a} is not space.)r��test_isspacer%r�r�r�)rr�)r�rr	r�es
zUnicodeTest.test_isspacecsYt�j�xEddddddddgD]%}|j|j�d	j|��q,WdS)
Nu𐐁u𐐧u𐐩u𐑎u𝟶u𑁦u𐒠u🄇z{!a} is alnum.)r��test_isalnumr�isalnumr�)rr�)r�rr	r�os
zUnicodeTest.test_isalnumcs�t�j�|jddd�|jdj��|jdj��|jdj��|jdj��|jdj��|jd	j��dS)
NTuῼ�isalphau𐐁u𐐧u𐐩u𐑎u🐍u👯)r��test_isalphar%rr�r�)r)r�rr	r�us
zUnicodeTest.test_isalphacCs3|jddd�|jddd�|jddd�|jddd�|jddd�|jdd	d�|jdd
d�|jddd�|jtddd
�xEddddddddgD]%}|j|j�dj|��q�Wx6dddgD]%}|j|j�dj|��qWdS)NFr6�	isdecimalrOT�0u①�¼u٠�
0123456789�0123456789ar.ru𐐁u𐐧u𐐩u𐑎u🐍u👯u𑁥u🄇z{!a} is not decimal.u𝟶u𑁦u𐒠z{!a} is decimal.)r%r�rBr�r�r�r)rr�rrr	�test_isdecimal�s#zUnicodeTest.test_isdecimalcs�t�j�|jddd�|jddd�|jddd�xBddd	d
ddd
gD]%}|j|j�dj|��qbWx9ddddgD]%}|j|j�dj|��q�WdS)NTu①�isdigitFr�u٠u𐐁u𐐧u𐐩u𐑎u🐍u👯u𑁥z{!a} is not a digit.u𝟶u𑁦u𐒠u🄇z{!a} is a digit.)r��test_isdigitr%r�r�r�r)rr�)r�rr	r��s
#zUnicodeTest.test_isdigitcCs3|jddd�|jddd�|jddd�|jddd�|jddd�|jdd	d�|jdd
d�|jddd�|jtdjd
�x?ddddddgD]%}|j|j�dj|��q�Wx<dddddgD]%}|j|j�dj|��qWdS)NFr6�	isnumericrOTr�u①r�u٠r�r�r.ru𐐁u𐐧u𐐩u𐑎u🐍u👯z{!a} is not numeric.u𑁥u𝟶u𑁦u𐒠u🄇z{!a} is numeric.)r%r(rBr�r�r�r)rr�rrr	�test_isnumeric�s#zUnicodeTest.test_isnumericcCs�|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jd	j��|jd
j��|jdj��|jdj��dS)
NrO�Z�_Zb0ZbcZb_�µu𝔘𝔫𝔦𝔠𝔬𝔡𝔢r'�[�©r�)r�isidentifierr�)rrrr	�test_isidentifier�szUnicodeTest.test_isidentifiercCs�|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jdj��|jd	j��dS)
Nr6r'�abcdefgzabcdefg
uʹu͸u�u👯u󠀠)r�isprintabler�)rrrr	�test_isprintable�szUnicodeTest.test_isprintablec	Cs:xGdD]?}|j|j��|j|j��|j|j��qWxGdD]?}|j|j��|j|j��|j|j��qQWxNdD]F}tt|�}x.dD]&}|j||�d||f�q�Wq�WxNdD]F}tt|�}x.dD]&}|j||�d||f�qWq�WdS)N�a�b��a�b��	a�b�a�	a�b�a�A�B��A�B��	A�B�A�	A�B�Ar�r�r�����������z%a.%s() is Falser�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�r�r�r�r�)r�r�r�r�r�r�r�r�)rr�r�r�r�rr)r�sZ	meth_name�methrrr	�test_surrogates�s,



(

zUnicodeTest.test_surrogatescCs^tjj|�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jd	j�d
�|jdj�d�|jd
j�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�dS)Nu𐐧u𐑏u𐐧𐐧u𐑏𐑏u𐐧𐑏u
X𐐧x𐑏u
x𐑏x𐑏ufiuİui̇uΣuσuͅΣuͅσuAͅΣuaͅςuAͅΣauaͅσauAΣͅuaςͅuΣͅ uσͅ u򏿾uⅷ)rrX�
test_lowerr�lower)rrrr	r��s&zUnicodeTest.test_lowercCs�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jd	j�d
�|jdj�d�dS)
NraZhELlo�ßZssufiZfiuΣuσuAͅΣuaισr�uμ)r�casefold)rrrr	�
test_casefoldszUnicodeTest.test_casefoldcCstjj|�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d	�|jd
j�d
�|jdj�d�|jdj�d
�|jdj�d�|jdj�d�|jdj�d�dS)Nu𐑏u𐐧u𐑏𐑏u𐐧𐐧u𐐧𐑏u
X𐐧x𐑏u
X𐐧X𐐧ufi�FIuİuΣr��SSuῒuΪ̀u򏿾uⅷuⅧ)rrX�
test_upperr�upper)rrrr	r
szUnicodeTest.test_uppercCs�tjj|�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d	�d
}|jdj�|�|jdj�d
�|jdj�d�dS)Nu𐑏u𐐧u𐑏𐑏u𐐧𐑏u𐑏𐐧u
X𐐧x𐑏u
X𐑏x𐑏uhİuHi̇u	Ϊ̀i̇uῒİufinnishZFInnishuAͅΣuAͅς)rrX�test_capitalizer�
capitalize)rZexprrr	rszUnicodeTest.test_capitalizecs�t�j�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d	�|jd
j�d�|jdj�d
�|jdj�d�dS)Nu𐑏u𐐧u𐑏𐑏u𐐧𐑏u𐑏𐑏 𐑏𐑏u𐐧𐑏 𐐧𐑏u𐑏𐐧 𐑏𐐧uX𐐧x𐑏 X𐐧x𐑏uX𐑏x𐑏 X𐑏x𐑏ufiNNISHZFinnishu	AΣ ᾡxyu	Aς ᾩxyuAΣAuAσa)r��
test_titler�title)r)r�rr	r,s
zUnicodeTest.test_titlecCs�tjj|�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jd	j�d
�|jdj�d�|jd
j�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jd
j�d�|jdj�d�|jdj�d�dS)Nu𐑏u𐐧u𐑏𐑏u𐐧𐐧u𐐧𐑏u𐑏𐐧u
X𐐧x𐑏u
x𐑏X𐐧ufiruİui̇uΣuσuͅΣuΙσuAͅΣuaΙςuAͅΣauaΙσAuAΣͅuaςΙuΣͅ uσΙ r�ruῒuΪ̀)rrX�
test_swapcaser�swapcase)rrrr	r	=s.zUnicodeTest.test_swapcasecCshtjj|�|jdjdd�d�|jdjdd�d�|jdjdd�d�dS)	NrsrSu􏿿ux􏿿rMu	􏿿x􏿿r`u
􏿿x􏿿􏿿)rrX�test_centerr�center)rrrr	rWszUnicodeTest.test_center�rQzrequires 32-bit systemcCs`d
}yd|}Wn'tk
r=|jd|d�YnXz|jt|j�Wd~XdS)NrSr�rdrQ�üz$no enough memory (%.0f MiB required)�liUUUiVUUi)�MemoryErrorZskipTestr(r�r)rr�r�rrr	�test_case_operation_overflow`s
z(UnicodeTest.test_case_operation_overflowcCs7|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd �|jd
d�|jdd
�|jdd
�|jdd!�|jdd
�|jdd�|jdd
�|jdd
�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jtd
j�x}d"D]u}|d9}xbd#D]Z}|j||�|j|||�|j|d|�|j|d||d�q�Wq�WdS)$NrOZabdbZbdabZbdabaZbdbaZbdbrQrs�yr�Zabcxxxx�abr.r6�zabczabcZasdfZasd�Ā�𐌀r^rr�Ă�𐌂rS)rOrQN)rQNrO)rOrQN)rQNrO)rsrQr)rsrQN)rQNr)rOrr)rrrr)�assertInZassertNotInr(rB�__contains__)rZfillr�rrr	�
test_containsnsD


zUnicodeTest.test_containscCspdj�dj�dj�dj�dj�dj�djdd�djdd�djdd�dS)Nu𐀀􀀀u􀀀rMu𐀀)	r�r�rrrr
r�ljust�rjust)rrrr	�test_issue18183�s





zUnicodeTest.test_issue18183cCs�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d�|jdj�d	�|jd
j�d�|jdj�d
�ddl}|jdjd�d�|jdjtdd��d�|jdjd�d�|jddd�}|jdj|�d�Gdd�d�}Gdd�d�}Gdd �d �}Gd!d"�d"�}Gd#d$�d$�}Gd%d&�d&|j�}Gd'd(�d(t�}	|jdj�d�|jd)j�d)�|jd*jd)�d)�|jd+jd)�d)�|jd,jd)�d-�|jd.jd)�d/�|jd0jd)�d1�|jd2jd3d)�d)�|jd4jd3d)�d-�|jd5jd3d)�d/�|jd6jd3d)�d1�|jd*jd�d8�|jd9jdd)�d:�|jd;jdd)�d<�|jd=j�d>�|jd?j�d@�|jdAj�dB�|jdCj�dD�|jdEjdF�dG�|jdHj�dI�|jdJj�dK�|jdLj�dM�|jdNjdOdPi�dP�|jdQjdRdPi�dP�|jdSjdTdUi�dV�|jdWjdX|dY��dZ�|jd[j|d\�|dY��d]�|jd^j||d)���d)�|jd_jd)d`g�d)�|jdajd)d`g�d`�|jdbjd)d`gg�d`�|jdcjd)|d`�gg�d`�|jddjd)�d)�|jddjd�d�|jddjde�d)�|jdfjde�d�|jdgjd)�d)�|jdhjd)�d)�|jdijd)�d�|jdjjd)�dk�|jdljdm�dm�|jdnjdm�dm�|jdojdm�dm�|jdpjdm�dq�|jdrjdm�ds�|jdtjdm�du�|jdvjdm�du�|jdwjdm�dx�|jdyjdm�dz�|jd{jdm�d|�|jd}jdm�d~�|jdjdm�d��|jd�jd�ddTd��|jd�jd�dTd��|jd�jd�dTd��|jd�jdX�d��|jd�jdX�d��|jd�jdX�d��|jd�jdX�d��|jd�jdU�d��|jd�jdU�d��|jd�jdU�d��|jd�jdU�d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd�d��|jd�jd�d��|jd�jd�d��|jd�jd�d��|jd�j|��d)�|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�j|d���d��|jd�jd��d��|jd�jd��d��|jd�j|d���d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�jd��d��|jd�j|d���d��|jd�j|d���d��|jd*ji�dB�|jd*jg�d��|jd*jd3g�d��|jd�j|d���d��|jd�j|d���d��|jtd�j|d���|jtdj|d���|jtd�j|d���|jd�j|d�dd�dd�d���d��|jd*j|	d\��dZ�|jd+jd�d�|jd�jd�d��d��|jd�jd�d��d��|jd�jd�d�d��d��|jd�jd�d�d\d�d��d��|jd�jd�d�d�d�d��d��|jtd>j�|jtd@j�|jtdj�|jtdj�|jtd�j�|jtd�j�|jt	d*j�|jt	d2jd)�|jt
dDj�|jtdKj�|jtd�j�|jtd�j�|jt	d�j�|jtd�jd�|jtd�j�|jtd�jg�|jt
d�j�|jtd�jd�|jtd�jd�|jtd�jd�|jtd�jd�|jt
d�j�|jtd�jd�|jtd�jd�|jt
d�jd�dU�|jtd�jdU�|jtd�jd�|jtd�jd�|jtd�j�|jt	d�j�|jt	d�j�|jt	dBj�d�}
|jtd>|
d@j�|jtd�|
d�jdg�|jtd�jdg�|jtd�jdg�|jtd�jd�d��|jtd�jd)d�d�|jtd�jdd3d�dUd�d�d�d��
|jtd�jd�|jttdd��|jtd�jd�|jttdd��|jttdd��|jd�jd�d��d��|jddjd��d��|jdfjd��d�|jdjdBd�i�d��|jdjdBdi�d�|jdjd>di�d�|jdjd@di�d�|jdjddi�d�|jdjddi�d�|jtdjd�|jtd	jd�|jtd
jd�|jdjdd�d
�dS(Nr6rOrza{{za{za}}za}z{{bz{bz}}bz}bza{{bza{brzMy name is {0}ZFredzMy name is FredzMy name is {0[name]}�namezMy name is {0} :-{{}}zMy name is Fred :-{}i�rk�zThe year is {0.year}zThe year is 2007c@s+eZdZddd�Zdd�ZdS)z"UnicodeTest.test_format.<locals>.Cr[cSs
||_dS)N)�_x)rrsrrr	r��sz+UnicodeTest.test_format.<locals>.C.__init__cSs|S)Nr)r�specrrr	�
__format__�sz-UnicodeTest.test_format.<locals>.C.__format__N)rrrr�r#rrrr	�C�sr$c@s(eZdZdd�Zdd�ZdS)z"UnicodeTest.test_format.<locals>.DcSs
||_dS)N)rs)rrsrrr	r��sz+UnicodeTest.test_format.<locals>.D.__init__cSs
t|j�S)N)rrs)rr"rrr	r#�sz-UnicodeTest.test_format.<locals>.D.__format__N)rrrr�r#rrrr	�D�sr%c@s(eZdZdd�Zdd�ZdS)z"UnicodeTest.test_format.<locals>.EcSs
||_dS)N)rs)rrsrrr	r��sz+UnicodeTest.test_format.<locals>.E.__init__cSsd|jdS)NzE(�))rs)rrrr	r��sz*UnicodeTest.test_format.<locals>.E.__str__N)rrrr�r�rrrr	�E�sr'c@s(eZdZdd�Zdd�ZdS)z"UnicodeTest.test_format.<locals>.FcSs
||_dS)N)rs)rrsrrr	r��sz+UnicodeTest.test_format.<locals>.F.__init__cSsd|jdS)NzF(r&)rs)rrrr	r�sz+UnicodeTest.test_format.<locals>.F.__repr__N)rrrr�rrrrr	�F�sr(c@s4eZdZdd�Zdd�Zdd�ZdS)z"UnicodeTest.test_format.<locals>.GcSs
||_dS)N)rs)rrsrrr	r��sz+UnicodeTest.test_format.<locals>.G.__init__cSsd|jS)Nz
string is )rs)rrrr	r��sz*UnicodeTest.test_format.<locals>.G.__str__cSs+|dkrd|jdStj||�S)NruzG(r&)rsr"r#)r�format_specrrr	r#�sz-UnicodeTest.test_format.<locals>.G.__format__N)rrrr�r�r#rrrr	�G�sr*c@seZdZdd�ZdS)z"UnicodeTest.test_format.<locals>.IcSs
|j|�S)N)Zstrftime)rr)rrr	r#�sz-UnicodeTest.test_format.<locals>.I.__format__N)rrrr#rrrr	�I�sr+c@seZdZdd�ZdS)z"UnicodeTest.test_format.<locals>.JcSstj|d|�S)NrS)r�r#)rr)rrr	r#�sz-UnicodeTest.test_format.<locals>.J.__format__N)rrrr#rrrr	�J�sr,r.z{0}z{0:}zX{0}ZXabcz{0}XZabcXzX{0}YZXabcYz{1}rQzX{1}z{1}XzX{1}Y�z-15z{0}{1}z-15abcz{0}X{1}z-15Xabcz{{�{z}}�}z{{}}z{}z{{x}}z{x}z{{{0}}}�{z{123}z	{{{{0}}}}z{{0}}z}}{{z}{z}}x{{z}x{z{0[foo-bar]}zfoo-barZbazz{0[foo bar]}zfoo barz{0[ ]}r'rMr�z{foo._x}r�r�20z{1}{0}rRZ2010z{0._x.x}z{0[0]}r_z{0[1]}z	{0[1][0]}z{0[1][0].x}z{0:.3s}�abcdefz{0:.0s}z{0:3.3s}z{0:2.3s}z{0:2.2s}z{0:3.2s}zab z{0:x<0s}r!z{0:x<5s}z{0:x<6s}z{0:x<7s}Zresultxz{0:x<8s}Zresultxxz{0: <7s}zresult z{0:<7s}z{0:>7s}z resultz{0:>8s}z  resultz{0:^8s}z result z{0:^9s}z	 result  z{0:^10s}z
  result  z	{0:10000}i'i'z{0:10000000}i���z{0:<6s}zfooz{0:<6s}zfooz{0:^6s}zfooz{0:^6s}z foo  z{0:<6}z3z{0:<6}z3z{0:^6}z3z{0:<6}z3     g��Q�	@z3.14z3.14z3.14z{0:^6}z 3.14 z{0:<12}y@z(3+2j)z{0:<12}z(3+2j)z{0:^12}z(3+2j)z{0:^12}z   (3+2j)   z{0:abc}z{0!s}ZHelloz{0!s:}z{0!s:15}zHello          z	{0!s:15s}z{0!r}z'Hello'z{0!r:}zF(Hello)u͸z'\u0378'uʹu'ʹ'uF(ʹ)z{0!a}z'\u0374'z{0!a:}z	F(\u0374)z[]z[1]z{0:d}�datazG(data)zstring is dataz{0:^10}z{0:>15s}z{0:date: %Y-%m-%d}ZyearZmonthZday�zdate: 2007-08-27z{0:.{1}}zhello world�raz	{0:.{1}s}z{0:.{precision}s}Z	precisionz{0:{width}.{precision}s}�widthz
hello     �10�5z{az}azabc{0:{}z{0z{0.}z{0[}z{0]}z{0.[]}z{0..foo}z{0[0}z	{0[0:foo}z{c]}z	{{ {{{0}}z{0}}z{foo}�barz{0!x}z{0!}z{0!rs}z{!}z{:}z{:s}Z,23098475029384702983476098230754973209482573z{[z]}z{0[0]x}z
{0[0](10)}z{0[{1}]}r�r`z{0:{1:{2}}}r�z{0:{1:{2:{3:{4:{5:{6}}}}}}}rS��z{0:-s}�-z{0:=s}�#z#20z
{0:s}{1:s}�ABCuАБВu	ABCАБВz{[{}]}z{[{]}z{[}]}z{[[]}r�z{[!]}r�z{a{}b}rz{a{b}z{[}z0x{:0{:d}X}�Z0x0000000000000000i�i�i�y@@y@@y@@y@@)rr��datetime�dictZdater�r(rBrm�
IndexError�KeyError)rr@rur$r%r'r(r*r+r,Zbigrrr	�test_format�s�
"(%"(!	%%!zUnicodeTest.test_formatcCs�|jdji�d�|jdji�d�|jdji�d�|jdji�d�|jdji�d�|jdji�d	�|jd
ji�d�|jdji�d
�Gdd�dt�}|jdj|��d�|jdj|dd��d�Gdd�d�}|jdj|��d�Gdd�d�}|jdjd|d�i�d�|jtdj�|jtdj�|jtdji�|jtdji�|jtdji�|jtdji�|jtdji�|jtd ji�|jtd!jdd"i�|jtd!jd�|jtd#jdd"d$d%i�dS)&Nr6rOrza{{za{za}}za}z{{bz{bz}}bz}bza{{bza{bc@seZdZdd�ZdS)z,UnicodeTest.test_format_map.<locals>.MappingcSs|S)Nr)r�keyrrr	�__missing__�sz8UnicodeTest.test_format_map.<locals>.Mapping.__missing__N)rrrrFrrrr	�Mapping�srGz{hello}raz{a} {world}zhello worldc@s(eZdZdd�Zdd�ZdS)z4UnicodeTest.test_format_map.<locals>.InternalMappingcSsddi|_dS)NrOra)r|)rrrr	r��sz=UnicodeTest.test_format_map.<locals>.InternalMapping.__init__cSs|j|S)N)r|)rrErrr	�__getitem__�sz@UnicodeTest.test_format_map.<locals>.InternalMapping.__getitem__N)rrrr�rHrrrr	�InternalMapping�srIz{a}c@s+eZdZddd�Zdd�ZdS)z&UnicodeTest.test_format_map.<locals>.Cr[cSs
||_dS)N)r!)rrsrrr	r��sz/UnicodeTest.test_format_map.<locals>.C.__init__cSs|S)Nr)rr"rrr	r#�sz1UnicodeTest.test_format_map.<locals>.C.__format__N)rrrr�r#rrrr	r$�sr$z{foo._x}r�rr1r.r/z{az}az{}rSz{a} {}rPrQ)r�
format_maprAr(rBrm)rrGrIr$rrr	�test_format_map�s4"%zUnicodeTest.test_format_mapc
Cs@djtjd�}|jt��td|�}WdQRXdS)Nz.{}frQg���Q�@)r�r:r�r(rm)r�
format_stringr!rrr	�test_format_huge_precision�sz&UnicodeTest.test_format_huge_precisionc
Cs@djtjd�}|jt��td|�}WdQRXdS)Nz{}frQg���Q�@)r�r:r�r(rm)rrLr!rrr	�test_format_huge_width�sz"UnicodeTest.test_format_huge_widthc	Cs@djtjd�}|jt��|jd�}WdQRXdS)Nz
{{{}:.6f}}rQg���Q�@)r�r:r�r(rm)rrLr!rrr	�test_format_huge_item_number�sz(UnicodeTest.test_format_huge_item_numbercCsGdd�d�}|jdjd�d�|jdjd�d�|jd	jd�d
�|jdj|d��d�|jdjd
dg�d�|jdjddddi�d�|jdjdd
�d�|jdjdd�d�|jdjdd�d�|jtd jd
d�|jtd!jd
d�|jtd"jd
d�|jtd#jd
d�|jd$jdd%d&�d'�|jd(jdd%d&�d)�|jd*jd
d+d,d,d%d�d-�|jd.jddd%d
d,d,�d/�dS)0Nc@s+eZdZddd�Zdd�ZdS)z1UnicodeTest.test_format_auto_numbering.<locals>.Cr[cSs
||_dS)N)r!)rrsrrr	r��sz:UnicodeTest.test_format_auto_numbering.<locals>.C.__init__cSs|S)Nr)rr"rrr	r#�sz<UnicodeTest.test_format_auto_numbering.<locals>.C.__format__N)rrrr�r#rrrr	r$�sr$z{}rRr7z{:5}r�zs    z{!r}z's'z{._x}z{[1]}rQrSr�z{[a]}rOr`rP�4za{}b{}crZa0b1cza{:{}}brsz^10za    x     bza{:{}x}brr=Za0x14bz{}{1}z{1}{}z{:{1}}z{0:{}}z{f}{}�f�testZtest4z{}{f}Z4testz{:{f}}{g}{}rM�gz 1g3z{f:{}}{}{g}z 14g)rr�r(rm)rr$rrr	�test_format_auto_numbering�s$%(z&UnicodeTest.test_format_auto_numberingcCs�tjj|�|jdfd�|jddgd�|jddid	�|jddld�|jddod
�|jddrd�tjjd�s�|jdtd�|jdvd�|jdxd�|jdddddid�|jdddddid�|jdyd�|jdzd#�|jtd j	d{�|jd|d#�|jt
d j	d%�|jtd&j	d}�|jt
d(j	d%�|jd)d*did+�|jd)d*did+�|jd)d*did+�|jd)d*did+�|jd)d*ddd,id+�|jd)d*ddd,id+�|jd-d~d.�|jd/dd0�|jd�d+�|jd�d4�|jd�d5�|jd�d7�|jd�d4�|jd�d:�|jd�d<�|jd�d=�Gd>d?�d?�}|jd@|�d�tdA�}tdB�}|jdC|dA�|jdD|dE�|jdC|dB�|jdD|dF�|jd�d=�|jd�dJ�GdKdL�dL�}GdMdN�dN�}|dO�}|dP�}|jd�dS�|jd�dV�|jd�dY�|jd�dZ�|jdQ|d[�|jdT|d\�|jdW|d]�|jd |dZ�|j
t
d^tjdQd_�f|j
t
d`tjdTda�f|j
t
dbtjdWdc�f|j
t
ddtjdQ|�f|jt
tjd |�fdS)�Nz%s, %sr.zabc, abcz%s, %s, %i, %f, %5.2frQrSrMzabc, abc, 1, 2.000000,  3.00zabc, abc, 1, -2.000000,  3.00�@zabc, abc, -1, -2.000000,  3.50��(\�@zabc, abc, -1, -2.000000,  3.57��(\�\�@z abc, abc, -1, -2.000000, 1003.57r-z%r, %r�abcz
b'abc', 'abc'z%r�ሴu'ሴ'z%az'\u1234'z%(x)s, %(y)srsrr_zabc, defu
%(x)s, %(ü)srz%ci4i�u𡒃�Zaau%.1ဲfg�?z%iz
...%(foo)s...r�z	...abc...r0z...%s...%s...%s...%s...z...1...2...3...abc...z"...%%...%%s...%s...%s...%s...%s...z...%...%s...1...2...3...abc...z...%s...z%*sr5z  abczabc  z%*.*sz   abz%i %*.*srRz10   abcz
%i%s %*.*sz	103   abcrOc@seZdZdd�ZdS)z,UnicodeTest.test_formatting.<locals>.WrappercSsdS)Nuሴr)rrrr	r�Asz4UnicodeTest.test_formatting.<locals>.Wrapper.__str__N)rrrr�rrrr	�Wrapper@sr[z%s�nan�infz%fz%F�NAN�INFz%.1suaé€z%.2suaéc@s4eZdZdd�Zdd�Zdd�ZdS)z.UnicodeTest.test_formatting.<locals>.PseudoIntcSst|�|_dS)N)r��value)rr`rrr	r�Ssz7UnicodeTest.test_formatting.<locals>.PseudoInt.__init__cSs|jS)N)r`)rrrr	�__int__Usz6UnicodeTest.test_formatting.<locals>.PseudoInt.__int__cSs|jS)N)r`)rrrr	�	__index__Wsz8UnicodeTest.test_formatting.<locals>.PseudoInt.__index__N)rrrr�rarbrrrr	�	PseudoIntRsrcc@s(eZdZdd�Zdd�ZdS)z0UnicodeTest.test_formatting.<locals>.PseudoFloatcSst|�|_dS)N)�floatr`)rr`rrr	r�Zsz9UnicodeTest.test_formatting.<locals>.PseudoFloat.__init__cSs
t|j�S)N)r�r`)rrrr	ra\sz8UnicodeTest.test_formatting.<locals>.PseudoFloat.__int__N)rrrr�rarrrr	�PseudoFloatYsrego���!	@�mz%xr�2az%Xr-r(z%or^�11�mZ6dZ6DZ155z,%x format: an integer is required, not floatg��Q�	@z,%X format: an integer is required, not floatg�z�G�@z,%o format: an integer is required, not floatg�p=
ף�?z2%x format: an integer is required, not PseudoFloat)r.r.zabc, abc)r.r.rQrSrM���)r.r.rQrjrMrUrj)r.r.rUrjrUrUrj)r.r.rUrjrVrUrj)r.r.rUrjrW)rXr.z
b'abc', 'abc')rYu'ሴ')rYz'\u1234'uሴu𡒃)rZu𡒃gUUUUUU�?)rQrSrMr.)rQrSrMr.z	...abc...)r5r.z  abc���)rkr.zabc  )r5rSr.z   ab)r5rMr.z  abc)rRr5rMr.z10   abc)rRrMr5rMr.z	103   abcrOrOuaérgr(rhri)rr��test_formattingrr:r;r<r(r��__mod__rBrmrd�assertRaisesRegex�operator�mod)rr[r^r_rcreZpiZletter_mrrr	rls~    zUnicodeTest.test_formattingc	Cs|ddl}Gdd�dt|j�}Gdd�d|j�}Gdd�dt|j�}|jd|j|jfd	�|jd
|j|j|j|j|j|j|jfd�|jdd
|jid�|jdd
|jid�|jdd
|jid�|jdd
|jid�|jdd
|jd|jid�|jdd
|jddid�dS)Nrc@seZdZdZdS)z4UnicodeTest.test_formatting_with_enum.<locals>.FloatgJ�M�!	@N)rrr�PIrrrr	�Floatqsrrc@seZdZdZdS)z2UnicodeTest.test_formatting_with_enum.<locals>.Intr-N)rrr�IDESrrrr	�Intssrtc@seZdZdZdS)z2UnicodeTest.test_formatting_with_enum.<locals>.Strr.N)rrrr>rrrr	�Strusruz%s, %szStr.ABC, Str.ABCz%s, %s, %d, %i, %u, %f, %5.2fz-Str.ABC, Str.ABC, 15, 15, 15, 3.141593,  3.14z
...%(foo)s...r�z
...Str.ABC...z...Int.IDES...z
...%(foo)i...z...15...z
...%(foo)d...z
...%(foo)u...r_z
...%(foo)f...r0z...3.141593...)	�enumrdZEnumZIntEnumrrr>rsrq)rrvrrrtrurrr	�test_formatting_with_enumns.	z%UnicodeTest.test_formatting_with_enumc	Cs;djtjd�}|jt��|d}WdQRXdS)Nz%.{}frQg���Q�@)r�r:r�r(rm)rrLr!rrr	�test_formatting_huge_precision�sz*UnicodeTest.test_formatting_huge_precisioncCs4Gdd�dt�}|jd|d�d�dS)Nc@seZdZdd�ZdS)zBUnicodeTest.test_issue28598_strsubclass_rhs.<locals>.SubclassedStrcSs
dj|�S)Nz'Success, self.__rmod__({!r}) was called)r�)r�otherrrr	�__rmod__�szKUnicodeTest.test_issue28598_strsubclass_rhs.<locals>.SubclassedStr.__rmod__N)rrrrzrrrr	�
SubclassedStr�sr{z	lhs %% %rZrhsz.Success, self.__rmod__('lhs %% %r') was called)rr)rr{rrr	�test_issue28598_strsubclass_rhs�sz+UnicodeTest.test_issue28598_strsubclass_rhsc	CsHddlm}dj|d�}|jt��|d}WdQRXdS)Nr)�INT_MAXz%.{}frQg���Q�@)�	_testcapir}r�r(rm)rr}rLr!rrr	�'test_formatting_huge_precision_c_limits�sz3UnicodeTest.test_formatting_huge_precision_c_limitsc	Cs;djtjd�}|jt��|d}WdQRXdS)Nz%{}frQg���Q�@)r�r:r�r(rm)rrLr!rrr	�test_formatting_huge_width�sz&UnicodeTest.test_formatting_huge_widthcCsvxodjdjfD][}|jt��}|dg�WdQRXt|j�}|jd|�|jd|�qWdS)Nr�rQr�tuple)r<�endswithr(rBr�	exceptionr)rr��cm�excrrr	�test_startswith_endswith_errors�sz+UnicodeTest.test_startswith_endswith_errors�LC_ALLZde_DEZfr_FRcCs|jdd�dS)Nz1.0z%.1fg�?z1.0)r)rrrr	�test_format_float�szUnicodeTest.test_format_floatcCs�|jtd�d�x�dD]�}t|�}|jt|�|�|jt|�t|��|dkr|j|jd�d�|j|jd�d�qW|jtd�d�Gd	d
�d
�}|jt|d��d�|d�}|jt|�d�|jt|�d�x0dD](}|jt|�tt|���q'Wtjjd�s~|jt	tddd�|jtddd�d�tjjd�s�|jtt
d�dd�d�|jt	tddd�dS)Nzunicode remains unicoder=rw�€�􏿿sasciizutf-8z strings are converted to unicodec@s(eZdZdd�Zdd�ZdS)z2UnicodeTest.test_constructor.<locals>.StringCompatcSs
||_dS)N)rs)rrsrrr	r��sz;UnicodeTest.test_constructor.<locals>.StringCompat.__init__cSs|jS)N)rs)rrrr	r��sz:UnicodeTest.test_constructor.<locals>.StringCompat.__str__N)rrrr�r�rrrr	�StringCompat�sr�z)__str__ compatible objects are recognizedz#unicode(obj) is compatible to str()r0�������^@r-z!decoding unicode is not supportedrsstrings are decoded to unicodezstrings are decoded to unicodes(character buffers are decoded to unicodez(character buffers are decoded to unicoder)r=rwr�r�)r0r�r0)rrr�lenrr:r;r<r(rB�
memoryview)rr�subclassr��o�objrrr	�test_constructor�sP	
	
&	zUnicodeTest.test_constructorcCsw|jtdd�d�|jtdddd�d�|jtddd�d�|jtdddd�d�dS)	z>Pass various keyword argument combinations to the constructor.r"r�sfoorzutf-8rrN)rr)rrrr	�test_constructor_keyword_args�sz)UnicodeTest.test_constructor_keyword_argscCst|jt�d�|jtdd�d�djd�}|jt|dd�d�|jtt|dd�dS)	z(Check the constructor argument defaults.r6rr�¢zutf-8rr=N)rrrr(�UnicodeDecodeError)rZ	utf8_centrrr	�test_constructor_defaultss
z%UnicodeTest.test_constructor_defaultscCsd-d.d/d0d1d2d3d4d5d6d7d8d9d:g}x-|D]%\}}|j|jd�|�q7W|jdjd�d�|jdjd�d�|jd jd�d!�|jd"jd�d#�|jdjd�d�|jdjd�d�|jd!jd�d �|jd#jd�d"�|jd$jd�d%�|jd%jd�d$�|jd&jdd'�d(�d)}d*}xR|D]J}|j|jd+�|jd,��|j|jd,�jd+�|�q�Wx0|D](}|j|jd,�jd+�|�q�WdS);N�A≢Α.�	A+ImIDkQ.�
Hi Mom -☺-!�Hi Mom -+Jjo--!�	日本語�
+ZeVnLIqe-�Item 3 is £1.�Item 3 is +AKM-1.�+�+-�+-�+--�+?�+-?�\?�+AFw?�\\?�+AFwAXA?�\\\?�
+AFwAXABc?�++--�+-+---�򫳞�+2m/c3g-�/�/zutf-7u�s+2AE-u�xs+2AE-xu�s+3AE-u�xs+3AE-xu�򫳞s
+2AHab9ze-s+�r�r6zGABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?z!"#$%&*;<=>@[]^_`{|}�utf7r=)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�)r�r�)rrr)rZutfTestsrsrZset_dZset_orrrrr	�test_codecs_utf7sD	
"&
zUnicodeTest.test_codecs_utf7cCs!|jdjd�d�|jdjd�d�|jdjd�d�|jdjd�d	�|jd
jdd�d�|jd
jdd�d�|jdjd�dd�|jdjd�d�|jtd	d�d�|jtdd�d�|jtdd�d�dS)Nr6zutf-8�u€s€u𐀂s𐀂u𣑖s𣑖u��
surrogatepasss�u�s�rRu�正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git unds�正確に言うと翻訳はされていません。一部はドイツ語ですが、あとはでたらめです。実際には「Wenn ist das Nunstuck git undu(𐀂𐀂𐀂𐀂𐀂𐀂𐀂𐀂𐀂𐀂)rrr)rrrr	�test_codecs_utf8>s
zUnicodeTest.test_codecs_utf8cCs[ddddddddd d!d"g}x-|D]%\}}|j|jd�|�q.WdS)#N�r�arO���€�€�߿�߿�ࠀ�ࠀ�퟿�퟿���￿�￿�𐀀�𐀀�􏿿�􏿿zutf-8)r�r)r�rO)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)rr)r�	sequencesr��resrrr	� test_utf8_decode_valid_sequencescs		z,UnicodeTest.test_utf8_decode_valid_sequencesc
Cs�dd�tdd�D�}dd�tdd�D�}dd�tdd	�D�}|||d
d�tdd�D�}x$|D]}|jt|jd
�q�Wx9|D]1}x(|D] }|jt||jd
�q�Wq�Wxf|D]^}xU|dd�D]C}x:|dd�D](}	|jt||d|	jd
�qWq�Wq�Wx`dd�tdd�D�D]B}|jtd|djd
�|jtd|djd
�qeWx`dd�tdd�D�D]B}|jtd|djd
�|jtd|djd
�q�Wx`dd�tdd�D�D]B}|jtd|djd
�|jtd|djd
�q+Wx`dd�tdd�D�D]B}|jtd|djd
�|jtd|djd
�q�WdS)NcSsg|]}t|g��qSr)r�)�.0rsrrr	�
<listcomp>vs	zBUnicodeTest.test_utf8_decode_invalid_sequences.<locals>.<listcomp>��cSsg|]}t|g��qSr)r�)r�rsrrr	r�xs	��cSsg|]}t|g��qSr)r�)r�rsrrr	r�zs	��cSsg|]}t|g��qSr)r�)r�rsrrr	r�}s	�r7zutf-8rMs�cSsg|]}t|g��qSr)r�)r�rsrrr	r��s	�s�s�cSsg|]}t|g��qSr)r�)r�rsrrr	r��s	s�cSsg|]}t|g��qSr)r�)r�rsrrr	r��s	�s�s��s��cSsg|]}t|g��qSr)r�)r�rsrrr	r��s	s�)rAr(r�r)
rZcontinuation_bytesZinvalid_2B_seq_start_bytesZinvalid_4B_seq_start_bytesZinvalid_start_bytes�byteZsb�cbZcb1Zcb3rrr	�"test_utf8_decode_invalid_sequencestsD(


"
	%#		#		#		#		z.UnicodeTest.test_utf8_decode_invalid_sequencesc@Cs�d}d|fd|dfd|fd|dfd|fd|dfd	|dfd
|fd|dfd|d
fd|dfd|fd|dfd|d
fd|dfd|fd|dfd|d|fd|dfd|dfd|ddfd|d|fd|fd|dfd|d
fd |dfd!|d"fd#|fd$|fd%|dfd&|dfd'|dfd(|d|fd)|d|dfd*|d|dfd+|d|fd,|d|fd-|d|dfd.|ddfd/|d|dfd0|fd1|dfd2|dfd3|d
fd4|dfd5|ddfd6|dd|fd7|d|ddfd8|fd9|dfd:|dfd;|ddfd<|d"fd=|fd>|dfd?|d
fd@|dAfdB|fdC|d
fdSdTdUdVg?}x�t|�D]�\}\}}|jt|jdLdM�|j|jdLdN�|�|j|dOjdLdN�|dP�|j|jdLdQ�|jddR��qHWdS)WNu�s�s��rSs�s��s�s��s��s�s��s���rMs�Ar�s�s��s���s����r`s�s�As�A�s�AAZAAs�As��As�A�s�s��s���s����s�����r5s�s�s�As�AAs�As�A�s�A��s�A�As�AA�s�A�s�A��s��As�A��s�s��s��s���s����s��As��A�s�A��As�s��s��s��As�����s�s��s���s������r:s�s�����ABC��ABC��BC���BC��C��C�
a���b�c��d�a���b�c��dzutf-8rr��brPr�r6)r�r�)r�r�)r�r�)r�r�)�	enumerater(r�rrr�)r�FFFDr��nr�r�rrr	�test_issue8271�s�	
	
	

	


	


	


	



		


	



	


	


	
	$zUnicodeTest.test_issue8271cCstdd�|j�D��S)Ncss|]}t|d�VqdS)r?N)r�)r�rrrrr	�	<genexpr>�sz,UnicodeTest.to_bytestring.<locals>.<genexpr>)r�r�)rr�rrr	�
to_bytestring�szUnicodeTest.to_bytestringcCs�|jt��}|jd�WdQRX|j}|j|t|��|j|jdd�|�|jd|djdd�d|d�|jdd	�}|j|jdd
�|�|jd|djdd
�d|d�dS)z�
        Check that an invalid UTF-8 sequence raises a UnicodeDecodeError when
        'strict' is used, returns res when 'replace' is used, and that doesn't
        return anything when 'ignore' is used.
        zutf-8Nr�saaaasbbbbZaaaaZbbbbu�r6r�)r(r�rr�rrrr�)rr�r��errr�r�rrr	�assertCorrectUTF8Decoding�s	z%UnicodeTest.assertCorrectUTF8DecodingcCs7d}x*dD]"}|jt|g�dd�q
WdS)ah
        Test that an 'invalid start byte' error is raised when the first byte
        is not in the ASCII range or is not a valid start byte of a 2-, 3-, or
        4-bytes sequence. The invalid start byte is replaced with a single
        U+FFFD when errors='replace'.
        E.g. <80> is a continuation byte and can appear only after a start byte.
        u�s��������zinvalid start byteN)r�r�)rr�r�rrr	�test_invalid_start_bytes
z#UnicodeTest.test_invalid_start_bytec&Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&g&}d'}x*|D]"}|j|j|�d'd(�q�Wd)S)*aa
        Test that an 'unexpected end of data' error is raised when the string
        ends after a start byte of a 2-, 3-, or 4-bytes sequence without having
        enough continuation bytes.  The incomplete sequence is replaced with a
        single U+FFFD when errors='replace'.
        E.g. in the sequence <F3 80 80>, F3 is the start byte of a 4-bytes
        sequence, but it's followed by only 2 valid continuation bytes and the
        last continuation bytes is missing.
        Note: the continuation bytes must be all valid, if one of them is
        invalid another error will be raised.
        ZC2ZDFzE0 A0zE0 BFzE1 80zE1 BFzEC 80zEC BFzED 80zED 9FzEE 80zEE BFzEF 80zEF BFzF0 90zF0 BFzF0 90 80zF0 90 BFzF0 BF 80zF0 BF BFzF1 80zF1 BFzF1 80 80zF1 80 BFzF1 BF 80zF1 BF BFzF3 80zF3 BFzF3 80 80zF3 80 BFzF3 BF 80zF3 BF BFzF4 80zF4 8FzF4 80 80zF4 80 BFzF4 8F 80zF4 8F BFu�zunexpected end of dataN)r�r�)rr�r�r�rrr	�test_unexpected_end_of_datas

z'UnicodeTest.test_unexpected_end_of_datac	Cs�d}|d}d|dfd|dfd|fd|fd	|dfd
|dfd|fd|fg}x0|D](\}}|j|j|�|d
�quWdS)a�
        Test that an 'invalid continuation byte' error is raised when the
        continuation byte of a 2-bytes sequence is invalid.  The start byte
        is replaced by a single U+FFFD and the second byte is handled
        separately when errors='replace'.
        E.g. in the sequence <C2 41>, C2 is the start byte of a 2-bytes
        sequence, but 41 is not a valid continuation byte because it's the
        ASCII letter 'A'.
        u�rSzC2 00rzC2 7Fr�zC2 C0zC2 FFzDF 00zDF 7FzDF C0zDF FFzinvalid continuation byteN)r�r�)rr��FFFDx2r�r�r�rrr	�test_invalid_cb_for_2bytes_seq9s

z*UnicodeTest.test_invalid_cb_for_2bytes_seqcMCs�d}|d}d|dfd|dfd|fd|fd	|fd
|fd|dfd|dfd
|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd |dfd!|fd"|fd#|dfd$|dfd%|fd&|fd'|dfd(|dfd)|fd*|fd+|dfd,|dfd-|fd.|fd/|fd0|fd1|dfd2|dfd3|fd4|fd5|dfd6|dfd7|fd8|fd9|dfd:|dfd;|fd<|fd=|dfd>|dfd?|fd@|fdA|dfdB|dfdC|fdD|fdE|dfdF|dfdG|fdH|fdI|dfdJ|dfdK|fdL|fdM|dfdN|dfdO|fdP|fgL}x0|D](\}}|j|j|�|dQ�qYWdRS)Sa�
        Test that an 'invalid continuation byte' error is raised when the
        continuation byte(s) of a 3-bytes sequence are invalid.  When
        errors='replace', if the first continuation byte is valid, the first
        two bytes (start byte + 1st cb) are replaced by a single U+FFFD and the
        third byte is handled separately, otherwise only the start byte is
        replaced with a U+FFFD and the other continuation bytes are handled
        separately.
        E.g. in the sequence <E1 80 41>, E1 is the start byte of a 3-bytes
        sequence, 80 is a valid continuation byte, but 41 is not a valid cb
        because it's the ASCII letter 'A'.
        Note: when the start byte is E0 or ED, the valid ranges for the first
        continuation byte are limited to A0..BF and 80..9F respectively.
        Python 2 used to consider all the bytes in range 80..BF valid when the
        start byte was ED.  This is fixed in Python 3.
        u�rSzE0 00rzE0 7Fr�zE0 80zE0 9FzE0 C0zE0 FFzE0 A0 00zE0 A0 7FzE0 A0 C0zE0 A0 FFzE0 BF 00zE0 BF 7FzE0 BF C0zE0 BF FFzE1 00zE1 7FzE1 C0zE1 FFzE1 80 00zE1 80 7FzE1 80 C0zE1 80 FFzE1 BF 00zE1 BF 7FzE1 BF C0zE1 BF FFzEC 00zEC 7FzEC C0zEC FFzEC 80 00zEC 80 7FzEC 80 C0zEC 80 FFzEC BF 00zEC BF 7FzEC BF C0zEC BF FFzED 00zED 7FzED A0zED BFzED C0zED FFzED 80 00zED 80 7FzED 80 C0zED 80 FFzED 9F 00zED 9F 7FzED 9F C0zED 9F FFzEE 00zEE 7FzEE C0zEE FFzEE 80 00zEE 80 7FzEE 80 C0zEE 80 FFzEE BF 00zEE BF 7FzEE BF C0zEE BF FFzEF 00zEF 7FzEF C0zEF FFzEF 80 00zEF 80 7FzEF 80 C0zEF 80 FFzEF BF 00zEF BF 7FzEF BF C0zEF BF FFzinvalid continuation byteN)r�r�)rr�r�r�r�r�rrr	�test_invalid_cb_for_3bytes_seqOsL
#
z*UnicodeTest.test_invalid_cb_for_3bytes_seqcuCsAd}|d}d|dfd|dfd|fd|fd	|fd
|fd|dfd|dfd
|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd|dfd|fd|fd|dfd |dfd!|fd"|fd#|dfd$|dfd%|fd&|fd'|dfd(|dfd)|fd*|fd+|dfd,|dfd-|fd.|fd/|dfd0|dfd1|fd2|fd3|dfd4|dfd5|fd6|fd7|dfd8|dfd9|fd:|fd;|dfd<|dfd=|fd>|fd?|dfd@|dfdA|fdB|fdC|dfdD|dfdE|fdF|fdG|dfdH|dfdI|fdJ|fdK|dfdL|dfdM|fdN|fdO|dfdP|dfdQ|fdR|fdS|dfdT|dfdU|fdV|fdW|dfdX|dfdY|fdZ|fd[|dfd\|dfd]|fd^|fd_|fd`|fda|dfdb|dfdc|fdd|fde|dfdf|dfdg|fdh|fdi|dfdj|dfdk|fdl|fdm|dfdn|dfdo|fdp|fdq|dfdr|dfds|fdt|fdu|dfdv|dfdw|fdx|fgt}x0|D](\}}|j|j|�|dy�qWdzS){at
        Test that an 'invalid continuation byte' error is raised when the
        continuation byte(s) of a 4-bytes sequence are invalid.  When
        errors='replace',the start byte and all the following valid
        continuation bytes are replaced with a single U+FFFD, and all the bytes
        starting from the first invalid continuation bytes (included) are
        handled separately.
        E.g. in the sequence <E1 80 41>, E1 is the start byte of a 3-bytes
        sequence, 80 is a valid continuation byte, but 41 is not a valid cb
        because it's the ASCII letter 'A'.
        Note: when the start byte is E0 or ED, the valid ranges for the first
        continuation byte are limited to A0..BF and 80..9F respectively.
        However, when the start byte is ED, Python 2 considers all the bytes
        in range 80..BF valid.  This is fixed in Python 3.
        u�rSzF0 00rzF0 7Fr�zF0 80zF0 8FzF0 C0zF0 FFzF0 90 00zF0 90 7FzF0 90 C0zF0 90 FFzF0 BF 00zF0 BF 7FzF0 BF C0zF0 BF FFzF0 90 80 00zF0 90 80 7FzF0 90 80 C0zF0 90 80 FFzF0 90 BF 00zF0 90 BF 7FzF0 90 BF C0zF0 90 BF FFzF0 BF 80 00zF0 BF 80 7FzF0 BF 80 C0zF0 BF 80 FFzF0 BF BF 00zF0 BF BF 7FzF0 BF BF C0zF0 BF BF FFzF1 00zF1 7FzF1 C0zF1 FFzF1 80 00zF1 80 7FzF1 80 C0zF1 80 FFzF1 BF 00zF1 BF 7FzF1 BF C0zF1 BF FFzF1 80 80 00zF1 80 80 7FzF1 80 80 C0zF1 80 80 FFzF1 80 BF 00zF1 80 BF 7FzF1 80 BF C0zF1 80 BF FFzF1 BF 80 00zF1 BF 80 7FzF1 BF 80 C0zF1 BF 80 FFzF1 BF BF 00zF1 BF BF 7FzF1 BF BF C0zF1 BF BF FFzF3 00zF3 7FzF3 C0zF3 FFzF3 80 00zF3 80 7FzF3 80 C0zF3 80 FFzF3 BF 00zF3 BF 7FzF3 BF C0zF3 BF FFzF3 80 80 00zF3 80 80 7FzF3 80 80 C0zF3 80 80 FFzF3 80 BF 00zF3 80 BF 7FzF3 80 BF C0zF3 80 BF FFzF3 BF 80 00zF3 BF 80 7FzF3 BF 80 C0zF3 BF 80 FFzF3 BF BF 00zF3 BF BF 7FzF3 BF BF C0zF3 BF BF FFzF4 00zF4 7FzF4 90zF4 BFzF4 C0zF4 FFzF4 80 00zF4 80 7FzF4 80 C0zF4 80 FFzF4 8F 00zF4 8F 7FzF4 8F C0zF4 8F FFzF4 80 80 00zF4 80 80 7FzF4 80 80 C0zF4 80 80 FFzF4 80 BF 00zF4 80 BF 7FzF4 80 BF C0zF4 80 BF FFzF4 8F 80 00zF4 8F 80 7FzF4 8F 80 C0zF4 8F 80 FFzF4 8F BF 00zF4 8F BF 7FzF4 8F BF C0zF4 8F BF FFzinvalid continuation byteN)r�r�)rr�r�r�r�r�rrr	�test_invalid_cb_for_4bytes_seq�sx
###z*UnicodeTest.test_invalid_cb_for_4bytes_seqcCs|jdjd�d�dS)Nzwww.python.org.Zidnaswww.python.org.)rr)rrrr	�test_codecs_idna�szUnicodeTest.test_codecs_idnacCs9|jtdjd�|jtdjdd�|jdjdd�d�|jdjdd�d�|jdjdd�djddd��|jdjdd�djd	ddd��|jttd
d�|jttd
dd�|jtd
dd�d�|jtd
dd�d�|jtd
dd�d�|jdjdd�d�|jtdjd�|jtdjd�|jttdd�|jtdjd�|jtdjd�|jtdjddd�|jttd�|jttd�|jttd�|jttd�dS)NuAndr‚ xr=rr�sAndr xr�sAndr? xrrsAndr� xzAndr xu	Andr� xs� xu� xs	\N{foo}xxzunicode-escapeZxxs\shelloz
test.unicode1z
test.unicode2raru�u�)	r(�UnicodeErrorrrrrrBrd�complex)rrrr	�test_codecs_errors�s0zUnicodeTest.test_codecs_errorscCs�|jdjd�d�|jdjd�d�|jdjd�d�|jdjd�d�|jdjd�d�|jdjd�d	�|jdjd
�d�|jdj�d�xwtd
�D]i}t|�}xTdD]L}tj��7tjdt�|jt|j|�|�|�WdQRXq�Wq�WxStd�D]E}t|�}x0dD](}|jt|j|�|�|�qeWqLWxStd�D]E}t|�}x0dD](}|jt|j|�|�|�q�Wq�Wtj��Ntjdt�d}x0dD](}|jt|j|�|�|�qWWdQRXdj	t
tttdd��ttdd����}x0dD](}|jt|j|�|�|�q�WdS) Nrar=shello�utf-7�utf-8�	utf-16-les
hello�	utf-16-bes
hello�latin-1u☃s☃i�utf-16�raw_unicode_escape�unicode_escape�unicode_internalr�r7r�u𐀁𠀂𰀃񀀄񐀅r6ri�i�i)r�r�r�r�r�r�r�r�)r�)r=)r�r�r�r�r�r�r�)r�)rrrAr@r��catch_warningsr��DeprecationWarningrr>r?�list)rrr�urrrr	�test_codecssF

1
*
*

-
zUnicodeTest.test_codecsc9Cs�ttd��}x0d<D](}|jt||�j|�|�qWttdd;��}x0d=D](}|jt||�j|�|�qaWdS)>Nr��cp037�cp1026�cp273�cp437�cp500�cp720�cp737�cp775�cp850�cp852�cp855�cp858�cp860�cp861�cp862�cp863�cp865�cp866�cp1125�
iso8859_10�
iso8859_13�
iso8859_14�
iso8859_15�	iso8859_2�	iso8859_3�	iso8859_4�	iso8859_5�	iso8859_6�	iso8859_7�	iso8859_9�koi8_r�koi8_t�koi8_u�kz1048�latin_1�mac_cyrillic�
mac_latin2�cp1250�cp1251�cp1252�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�cp856�cp857�cp864�cp869�cp874�	mac_greek�mac_iceland�	mac_roman�mac_turkish�cp1006�	iso8859_8r7)9rrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;) rrrrrrr	r
rrr
rrrrrrrrrrrrrrrr r!r#r%r&r')r�rArrr)rr�rrrr	�test_codecs_charmap9s8
	&

zUnicodeTest.test_codecs_charmapcCsT|jdd�|jdd�|jdd�|jdd�|jdd�dS)Nr2ri)r)rrrr	�test_concatenationps
zUnicodeTest.test_concatenationcCs�Gdd�d�}|�}tdd|�tddd|�tddd|�tddd|�tdd|�tdddd|�tdddd|�td	d|�td	d|�dS)
Nc@seZdZdd�ZdS)z,UnicodeTest.test_printing.<locals>.BitBucketcSsdS)Nr)rrrrr	�writeysz2UnicodeTest.test_printing.<locals>.BitBucket.writeN)rrrr>rrrr	�	BitBucketxsr?r.�filer_zabc
�endr'zdef
)�print)rr?�outrrr	�
test_printingws	zUnicodeTest.test_printingcCs�d}|jd�jd�}|j||�d}|jd�jd�}|j||�d}|jd�jd�}|j||�ydjd�WnKtk
r�}z+|j|jd�|j|jd�WYdd}~XnX|jd�dS)	Nu􀀀zraw-unicode-escapes
\U00100000s
\U00010000s
\U11111111rrRz%Should have raised UnicodeDecodeError)rrrr��startrAZfail)rrsr�errr	�	test_ucs4�s&zUnicodeTest.test_ucs4cCs�Gdd�d�}Gdd�dt�}Gdd�dt�}|jt|��d�|jt|d��d�t|d��}|j|d	�|jt|�|�t|d��}|j|d	�|jt|�t�dS)
Nc@seZdZdd�ZdS)z0UnicodeTest.test_conversion.<locals>.ObjectToStrcSsdS)Nr�r)rrrr	r��sz8UnicodeTest.test_conversion.<locals>.ObjectToStr.__str__N)rrrr�rrrr	�ObjectToStr�srHc@seZdZdd�ZdS)z5UnicodeTest.test_conversion.<locals>.StrSubclassToStrcSsdS)Nr�r)rrrr	r��sz=UnicodeTest.test_conversion.<locals>.StrSubclassToStr.__str__N)rrrr�rrrr	�StrSubclassToStr�srIc@s+eZdZddd�Zdd�ZdS)z=UnicodeTest.test_conversion.<locals>.StrSubclassToStrSubclassr6cSstj|d|�S)NrS)r�__new__)�clsZcontentrrr	rJ�szEUnicodeTest.test_conversion.<locals>.StrSubclassToStrSubclass.__new__cSs|S)Nr)rrrr	r��szEUnicodeTest.test_conversion.<locals>.StrSubclassToStrSubclass.__str__N)rrrrJr�rrrr	�StrSubclassToStrSubclass�srLr�r9Zfoofoo)rrr�r r)rrHrIrLr�rrr	�test_conversion�szUnicodeTest.test_conversioncCs\Gdd�d�}Gdd�d�}|jt|��d�|jt|��d�dS)Nc@seZdZdd�ZdS)z)UnicodeTest.test_unicode_repr.<locals>.s1cSsdS)Nz\nr)rrrr	r�sz2UnicodeTest.test_unicode_repr.<locals>.s1.__repr__N)rrrrrrrr	�s1�srNc@seZdZdd�ZdS)z)UnicodeTest.test_unicode_repr.<locals>.s2cSsdS)Nz\nr)rrrr	r�sz2UnicodeTest.test_unicode_repr.<locals>.s2.__repr__N)rrrrrrrr	�s2�srOz\n)rrF)rrNrOrrr	�test_unicode_repr�szUnicodeTest.test_unicode_reprcCs0|jtd�d�|jtd�d�dS)Nu𐀀z'%c'�u𔀀z'\U00014000')rQu'𐀀')rrF)rrrr	�test_printable_repr�szUnicodeTest.test_printable_repr�Pr`z only applies to 32-bit platformscCs|jtdjtj�dS)Nzt	t	)r(r��
expandtabsr:r�)rrrr	�$test_expandtabs_overflows_gracefully�sz0UnicodeTest.test_expandtabs_overflows_gracefullycCs d}|j|j�|�dS)Nr.)r�rT)rr�rrr	�test_expandtabs_optimization�sz(UnicodeTest.test_expandtabs_optimizationcs�tjd�dkr$d}d}nd}d}x�dD]��t��}|dkrdd}|}n'|d
krd}|}nd}|}tj||���fdd�}|jt|�|jt|�q7WdS)NrSrk�0�H��$rOrw�€�􏿿r7rQirSr`cs��S)Nrr)�char�maxlenrr	�<lambda>�sz0UnicodeTest.test_raiseMemError.<locals>.<lambda>)rOrwr[r\)�struct�calcsizeryr:r�r(r)rZascii_struct_sizeZcompact_struct_size�codeZ	char_sizeZstruct_sizeZallocr)r]r^r	�test_raiseMemError�s&	
		zUnicodeTest.test_raiseMemErrorcCsSGdd�dt�}|d�}|jd|d�|jdj|�d�dS)Nc@seZdZdd�ZdS)z+UnicodeTest.test_format_subclass.<locals>.ScSsdS)Nz__str__ overriddenr)rrrr	r��sz3UnicodeTest.test_format_subclass.<locals>.S.__str__N)rrrr�rrrr	�S�srd�xxxz%sz__str__ overriddenz{})rrr�)rrdr�rrr	�test_format_subclass�sz UnicodeTest.test_format_subclasscCsvGdd�dt�}|j|d�|d�d�Gdd�dt�}|d�}|d7}|j|d�dS)Nc@seZdZdd�ZdS)z(UnicodeTest.test_subclass_add.<locals>.ScSsdS)Nr�r)rr�rrr	�__add__�sz0UnicodeTest.test_subclass_add.<locals>.S.__add__N)rrrrgrrrr	rd�srdrPr8r�c@seZdZdd�ZdS)z(UnicodeTest.test_subclass_add.<locals>.ScSsdS)Nr�r)rr�rrr	�__iadd__�sz1UnicodeTest.test_subclass_add.<locals>.S.__iadd__N)rrrrhrrrr	rd�sr�)rr)rrdr�rrr	�test_subclass_add�s 
zUnicodeTest.test_subclass_addcCsTd}|j�}|j|d|�|j|d|�|jt|�d�dS)Nr.rrQ)�__getnewargs__�assertIsNotrr�)rrr#rrr	�test_getnewargs	s
zUnicodeTest.test_getnewargscCs�x�tddd�D]�}d|d}tjdtf��o|jd�}|j|jd�|�|d7}|jd�}|j||�|j|jd�|�WdQRXqWdS)	NrQr[r;rOrPz*unicode_internal codec has been deprecatedr�rr)rArr�r�rrrr+)rZlengthrr.r2rrr	�test_resize		s	

zUnicodeTest.test_resizecCs�d}d|}d|}d|}d|}d|}d|}d|}d	|}	||||||||	f}
x�tj|
d
�D]�\}}||k}
|j||k|
�|j||k|
�|
r�|j||k�|j||k�t|�}t|�}|j||�|j||k�|j||k�|j||k�|j||k�q�W|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||	k�|j||k�|j||k�|j||k�|j||	k�dS)NrRrOrtr�r&uĀu￿u􀀀u􏿿rS)�	itertools�combinationsrrrrkr�)r�Nr=Zascii2�latin�latin2ZbmpZbmp2ZastralZastral2�stringsZtext1Ztext2ZequalZcopy1Zcopy2rrr	�test_compare	sv







zUnicodeTest.test_comparecCs*tj|tt�tj|tt�dS)N)rZcheck_free_after_iterating�iterr�reversed)rrrr	�test_free_after_iteratingd	sz%UnicodeTest.test_free_after_iterating)jrrrrrzr%r,rErGrLrYrbrfrlror}r�r�r�r�r��unittestZskipIfr:r�r�r�r�cpython_onlyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr	rZ
skipUnlessrrrrDrKrMrNrOrTrlrwrxr|rr�r�Zrun_with_localer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr<r=rDrGrMrPrRr`rarUrVrcrfrirlrmrtrwrr)r�r	r1s�	**F;
		 
'�0W 	!F	/%/Y
:O&77+Jrc@s�eZdZdd�Zejdd��Zejdd��Zejdd��Zejd	d
��Z	ejdd��Z
ejd
d��Zejdd��ZdS)�CAPITestc
s�tjd�ddlm}m�m}m}m}m}m	}m
}m}m}	m
}
m}d}t||����_��fdd����fdd�}
|
d	d
d��jtd�d
d�|
dd|d��|
dd|d���jt���d|d��WdQRX|
dd|d�|d��|
dd�|
dd�|
dd�|
dd�|
d d!d"�|
d#d$d%�|
d&d'd(jd)��|
d*d+d,�|
d-d.d/�|
d0d1d,�|
d2d3d/�|
d4d5d/�|
d4d6d/�|
d4d7d/d�|
d&d8dd(jd)��|
d9d:d#�|
d;d<d#�|
d=d>d#�|
d?d@d#�|
dAdBd#�|
dCdDd#�|
d?dEd#�|
dAdFd#�|
dCdGd#�|
d9dHd"�|
d;dId"�|
d=dJd"�|
d9dKd#�|
d;dLd#�|
d=dMd#�|
d9dNd#dO�|
d;dPd#dO�|
d=dQd#dO�|
dRdNddO�|
dSdPddO�|
dTdQddO�|
dUdV|dW��|
dXdY|dW��|
dZd[|d���|
dZd]|d���|
dZd^|d���|
dZd_|d���|
dZd`|d���|
dZda|d���|
dZdb|d���|
dZdc|d���|
ddde|d\��|
dddf|d\��|
dddg|	d\��|
dddh|
d\��didj||�dk}|dk}|
t|�db||��|
t|�db||��didj||	�dk}|
t|�dg|	|���dl|d���|
ddjdWdm�dn|d\��|
ddjdo�dp|d\��|
ddjdodm�dq|d\��|
ddjdrdm�jdo�ds|d\��|
ddjdWdm�dt|d\��|
ddjdo�du|d\��|
ddjdodm�dv|d\��|
ddjdrdm�jdo�dw|d\��|
ddjdWdm�dx|dy��|
ddjdo�dz|dy��|
ddjdodm�d{|dy��|
ddjdrdm�jdo�d||dy��|
d}d~d�|
d�d�d#d��|
d�d�dd��|
d�d�dd��|
dd�d"�|
d�d��|
d�d�|dW��|
d�d�d"�dS)�N�ctypesr)�	pythonapi�	py_object�sizeof�c_int�c_long�
c_longlong�	c_ssize_t�c_uint�c_ulong�c_ulonglong�c_size_t�c_void_p�PyUnicode_FromFormatcs,t�fdd�|D��}�||�S)Nc3s0|]&}t|t�r$�|�n|VqdS)N)�
isinstancer)r��arg)r}rr	r�x	szJCAPITest.test_from_format.<locals>.PyUnicode_FromFormat.<locals>.<genexpr>)r�)r�r#Zcargs)�_PyUnicode_FromFormatr}rr	r�v	s
z7CAPITest.test_from_format.<locals>.PyUnicode_FromFormatcs#�||�}�j||�dS)N)r)Zexpectedr�r#r)r�rrr	�check_format|	sz/CAPITest.test_from_format.<locals>.check_formatuascii=unicodeés	ascii=%Uu	unicodeéz^^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format string, got a non-ASCII byte: 0xe9$sunicode�=%sr=uꯍs%ciͫu􏿿i��iu𐀀􀀀s%c%cii�%�%s%%z%ss%%sz[%]s[%%]z%abcs%%%ssabcr.s%.3ssabcdefuabc[�s%.5suabc[€]�utf8z'\u20acABC's%Au€ABCz'\u20s%.5Au	€ABCDEFu'€ABC's%Ru'€As%.3Ru€ABs%.3Ss%.3Us%.3Vs%.5Vz
repr=  abcsrepr=%5Szrepr=abs	repr=%.2Sz
repr=   abs
repr=%5.2Sz
repr=   'abc'srepr=%8Rzrepr='abs	repr=%.3Rz
repr=  'abs
repr=%5.3Rsrepr=%8As	repr=%.3As
repr=%5.3Asrepr=%5ss	repr=%.2ss
repr=%5.2ssrepr=%5Us	repr=%.2Us
repr=%5.2Usrepr=%5Vs123s	repr=%.2Vs
repr=%5.2Vz
repr=  123zrepr=12z
repr=   12Z010s%03irRZ0010s%0.4iz-123s%ir0s%lis%llis%zis%ds%lds%llds%zdrxs%us%lus%llus%zurSrkrQs%pr�s%010ir[s%100is%.100i�Ps%100.80is%010us%100us%.100us%100.80us%010xi#s%100xs%.100xs%100.80xz%A:'abc\xe9\uabcd\U0010ffff's%%A:%Auabcéꯍ􏿿zrepr=abcsrepr=%Vsxyzurepr=人民s人民urepr=abc�sabc�s%1%sz%1abcs%1abcz%+is%+iz%.%ss%.%si����i����i����i����i����i����i����i����rU)r�
import_moduler{r|r}r~rr�r�r�r�r�r�r�r�rZrestypernrmr(r�rrr)rr|r~rr�r�r�r�r�r�r�r�rr�Zmin_longlongZmax_longlongZ
max_ulonglongr)r�r�r}rr	�test_from_formatl	sT
R	
	



































zCAPITest.test_from_formatc	Cs�ddlm}tjd�ddlm}m}|dd�\}}|j|d�|j|d�|dd	�\}}|j|d	�|j|d�|dd
�\}}|j|d	�|j|d�|dd�\}}|j|d	�|j|d�|d
d�\}}|j|d�|j|d�td�}||�dkrid	}d}nd}d}|||�\}}|j||�|j||d�dS)Nr)�unicode_aswidecharr{)�c_wcharr~r2rSrr.rMr`zabcrRzabcdefrr;zabcdefi��rQr)	r~r�rr�r{r�r~rr@)	rr�r�r~�wcharr��nonbmpZbuflen�ncharrrr	�test_aswidecharU
s6
	zCAPITest.test_aswidecharcCs�ddlm}tjd�ddlm}m}|d�\}}|j|d�|j|d�|d�\}}|j|d	�|j|d
�td�}||�dkr�d}nd
}||�\}}|j||�|j||d�dS)Nr)�unicode_aswidecharstringr{)r�r~r.rMzabczabcdefr;zabcdefi��rSrQr)	r~r�rr�r{r�r~rr@)rr�r�r~r�r�r�r�rrr	�test_aswidecharstring{
s 
	zCAPITest.test_aswidecharstringcCsfddlm}xOddddddgD]5}t|�}|j|||d	�|d
�|j|||d�|d�|j|||d	d	�|d�|j|||d	d�|d�|jt|||d	d	�|jt|||d
d�d
j||g�}|j||t|�d	�|d
�|j||t|�d�|d�q)WdS)Nr)�unicode_asucs4r.u¡¢u你好ua😀u	a�b�cu��rQru￿u￿rS)r~r�r�rr(�SystemErrorr>)rr�r��lrrr	�test_asucs4�
s  $$&zCAPITest.test_asucs4c	
Csddlm}ddddg}xt|�D]\}}x7|d|�D]%}|jt||d|dd�qLWxZtd�D]L}|j||d||d�|||d�jdd�d|f�q�WxZtd�D]L}|j|||||d�|||d�jdd�d|f�q�Wq/W|d}|jt	||d	|dd�|jt	||d|dd�|jt	||d|d	d�|jt	||d|d
d�|jt||d
|dd�|jt||d|dd�|jt||dddd�dS)Nr)�unicode_copycharactersZabcdeu
¡¢£¤¥u你好世界!u😀😁😂😃😄r5rr:rQr�rUrUrU)
r~r�r�r(r�rArrrrB)	rr�rs�idxZfrom_ZtoZ
from_startZto_startr�rrr	�test_copycharacters�
s6	
zCAPITest.test_copycharacterscCs�ddlm}|j|d�d�|j|d�d�|j|d�d�|jt|d	d
�|jtd|d	d�dS)
Nr)�unicode_encodedecimalrxs123u٣.١٤s3.14u
 3.14 s 3.14 u123€rz'^'decimal' codec can't encode characterr�)r~r�rr(�UnicodeEncodeErrorrnrm)rr�rrr	�test_encode_decimal�
s	
zCAPITest.test_encode_decimalcCslddlm}|j|d�d�|j|d�d�|j|d�d�|j|d�d�dS)Nr)�unicode_transformdecimaltoasciirxu٣.١٤z3.14u
 3.14 u123€)r~r�r)rZtransform_decimalrrr	�test_transform_decimal�
szCAPITest.test_transform_decimalcCs�ddlm}x�d
D]�}d}xxtd�D]j}|t|�7}|j||�t|�j�|d	�|j||�t|�j�|d	�q0WqWdS)Nr)�getargs_s_hashrZ�� �
�r6r5rQ)rZr�r�r�)r~r�rAr@rr)rr��kr�rqrrr	�test_pep393_utf8_caching_bug�
s
*z%CAPITest.test_pep393_utf8_caching_bugN)
rrrr�rryr�r�r�r�r�r�r�rrrr	rzi	s�&*rzc@s(eZdZdd�Zdd�ZdS)�StringModuleTestc	Cs�dd�}|d�}|j|ddddg�|d�}|j|ddg�|d�}|j|dg�|d�}|j|g�|d�}|j|dg�|jttjd�dS)NcSsttj|��S)N)r�_string�formatter_parser)r�rrr	�parse�
sz5StringModuleTest.test_formatter_parser.<locals>.parsez2prefix {2!s}xxx{0:^+10.3f}{obj.attr!s} {z[0]!s:10}�prefix r�r6r�rer��^+10.3f�obj.attrr'�z[0]r7zprefix {} suffix� suffixrz{0}rQ)r�r�r6r�)rer�r�N)r6r�r6r�)r'r�r7r�)r�r6r6N)r�NNN)rNNN)r6r�r6N)rr(rBr�r�)rr�Z	formatterrrr	�test_formatter_parser�
s(	
	
	
	
z&StringModuleTest.test_formatter_parsercCs�dd�}|j|d�dgg�|j|d�ddgg�|j|d�ddgg�|j|d
�ddddgg�|jttjd
�dS)NcSs-ttj|��}t|d�|d<|S)NrQ)rr��formatter_field_name_split)r�itemsrrr	r�sz?StringModuleTest.test_formatter_field_name_split.<locals>.splitr�zobj.argTr�zobj[key]FrEzobj.arg[key1][key2]�key1�key2rQ)Tr�)FrE)Tr�)Fr�)Fr�)rr(rBr�r�)rr�rrr	�test_formatter_field_name_splits
z0StringModuleTest.test_formatter_field_name_splitN)rrrr�r�rrrr	r��
s!r��__main__)�__doc__r��codecsrnror`r:rxr�rRrrr�registerrrrrXr�ZMixinStrUnicodeTestZTestCaserrzr�r�mainrrrr	�<module>s>

���������>��3