Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_bytes.cpython-38.opt-2.pyc
U

>��g� �@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl	m
Z
mZejjr�dd�Zndd�ZGdd�d�ZGdd	�d	�ZGd
d�deej�ZGdd
�d
eej�ZGdd�dej�ZGdd�dej�ZGdd�de
jj�ZGdd�deej�ZGdd�deej�ZGdd�d�ZGdd�de�Z Gdd�de!�Z"Gdd�de!�Z#Gd d!�d!eej�Z$Gd"d#�d#eej�Z%e&d$k�r�e�'�dS)%�N)�bigaddrspacetest�MAX_Py_ssize_tcst����fdd��}|S)Nc
s2tj�dtf���||�W5QR�SQRXdS�N���test�supportZcheck_warnings�BytesWarning)�args�kw��func��./opt/cppython/lib/python3.8/test/test_bytes.py�wrappersz%check_bytes_warnings.<locals>.wrapper)�	functools�wraps)r
rrrr�check_bytes_warningssrcCs|S�Nrrrrrr sc@seZdZddd�Zdd�ZdS)�	IndexablercCs
||_dSr��value)�selfrrrr�__init__%szIndexable.__init__cCs|jSrr�rrrr�	__index__'szIndexable.__index__N)r)�__name__�
__module__�__qualname__rrrrrrr$s
rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zdd�Zdd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dCdD�Z&dEdF�Z'dGdH�Z(dIdJ�Z)dKdL�Z*dMdN�Z+dOdP�Z,dQdR�Z-dSdT�Z.dUdV�Z/dWdX�Z0dYdZ�Z1d[d\�Z2d]d^�Z3d_d`�Z4dadb�Z5dcdd�Z6dedf�Z7dgdh�Z8didj�Z9dkdl�Z:dmdn�Z;dodp�Z<dqdr�Z=dsdt�Z>dudv�Z?dwdx�Z@dydz�ZAd{d|�ZBd}d~�ZCdd��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�S)��
BaseBytesTestcCs.|��}|�t|�|j�|�|j|j�dSr)�	type2test�assertEqual�type�	__class__�r�brrr�test_basics-szBaseBytesTest.test_basicscCsH|�d�}tjtjfD],}||�}|�||�|�t|�t|��qdS�N�abcd)r �copy�deepcopyr!r"�r�aZcopy_methodr%rrr�	test_copy2s

zBaseBytesTest.test_copycs�|���|�t��d�|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fd	d��|�t�fd
d��|�t�fdd��|�t�fdd��|�t�fd
d��dS)Nrcs�dS)Nrrr�r%rr�<lambda><�z3BaseBytesTest.test_empty_sequence.<locals>.<lambda>cs�dS�N�rrr.rrr/=r0cs
�tjSr��sys�maxsizerr.rrr/>r0cs�tjdSr1r3rr.rrr/?r0cs�ddS�N�
�drrr.rrr/@r0cs�dS�N���rrr.rrr/Ar0cs�dS)N���rrr.rrr/Br0cs�tjSrr3rr.rrr/Cr0cs�tjdSr1r3rr.rrr/Dr0cs�tjdS)N�r3rr.rrr/Er0cs�ddSr6rrr.rrr/Fr0)r r!�len�assertRaises�
IndexErrorrrr.r�test_empty_sequence9sz!BaseBytesTest.test_empty_sequencecCs|�td��}|�t|�d�|�t|�ttd���|�dh�}|�|d�|�ddh�}|�t|�ddh�|�ttd���}|�t|�d�|�t|�ttd���|�dd	�td�D��}|�t|�d
�|�t|�ttd��ddd��Gd
d�d�}|�|��}|�|d�dS)N��*�*�+�-)rDrE)rErDcss|]}|dr|VqdS)r<Nr��.0�irrr�	<genexpr>Ysz3BaseBytesTest.test_from_iterable.<locals>.<genexpr>�r2r<c@seZdZdd�ZdS)z+BaseBytesTest.test_from_iterable.<locals>.ScSsd|S)N�r2r<�r)rrHrrr�__getitem___sz7BaseBytesTest.test_from_iterable.<locals>.S.__getitem__N)rrrrMrrrr�S^srN�)r �ranger!r=�list�assertIn�tuple�iter)rr%rNrrr�test_from_iterableHs "z BaseBytesTest.test_from_iterablecCsT|�ttd���}|�t|�d�|�t|�ttd���|�d�}|�|d�dS)NrArKrO)r rSrPr!r=rQr$rrr�test_from_tupleds

zBaseBytesTest.test_from_tuplecCsZ|�ttd���}|�t|�d�|�t|�ttd���|�dddg�}|�|d�dS)NrAr2r<rLrO)r rQrPr!r=r$rrr�test_from_listls
zBaseBytesTest.test_from_listcs\G�fdd�d�}|�|�g�|�t��d�G�fdd�d�}|�g�|�t��d�dS)NcseZdZ�fdd�ZdS)z0BaseBytesTest.test_from_mutating_list.<locals>.Xcs���dS�NrB)�clearr�r,rrrwsz:BaseBytesTest.test_from_mutating_list.<locals>.X.__index__N�rrrrrrZrr�Xvsr\rCcseZdZ�fdd�ZdS)z0BaseBytesTest.test_from_mutating_list.<locals>.Ycst��dkr��|�dS)N��rB)r=�appendrrZrrr~s
z:BaseBytesTest.test_from_mutating_list.<locals>.Y.__index__Nr[rrZrr�Y}sr_s�****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************�r!�bytes)rr\r_rrZr�test_from_mutating_listtsz%BaseBytesTest.test_from_mutating_listcCsh|�t�td�td�td�g�}|�t|�ddddg�|�t|jtd�g�|�t|jtd�g�dS)Nr2��rr:rA)r rr!rQr>�
ValueErrorr$rrr�test_from_index�s�zBaseBytesTest.test_from_indexcCsd|�t�ddddg��}|�|d�|�d�}|�|d�Gdd�dt�}|�|�|d��d�dS)N�Br2r<rLrOc@seZdZdd�ZdS)z)BaseBytesTest.test_from_buffer.<locals>.BcSst�dSr)�	TypeErrorrrrrr�sz3BaseBytesTest.test_from_buffer.<locals>.B.__index__Nr[rrrrrg�ssfoobar)r �arrayr!ra)rr,rgrrr�test_from_buffer�s
zBaseBytesTest.test_from_buffercCs�|�|�d�d�|�|�d�d�|�|�d�d�|�t|jd�|�|�dd	�d
�|�|�d
�d
�|�t|jtjd�dS)Nrr0r2��sr:�0�ascii�0)r!r r>re�
OverflowErrorr4r5rrrr�test_from_ssize�szBaseBytesTest.test_from_ssizecCs&|�t|jd�Gdd�d�}|�t|jdg�|�t|jdg�|�t|jdg�|�t|j|�g�|jt|jdd�|jt|jdd�|�t|jd	d�|�t|jd
d�|jt|jd	dd�|jt|jd
dd�|�t|jd�|jt|jddd�|�t|jdd�|�t|jddd
�dS)Ngc@seZdZdS)z5BaseBytesTest.test_constructor_type_errors.<locals>.CN�rrrrrrr�C�srsrmrn)�encoding�ignore)�errorsrr0rsasciisignore)r>rhr )rrsrrr�test_constructor_type_errors�s z*BaseBytesTest.test_constructor_type_errorscCs�|�t|jdg�|�t|jtjg�|�t|jtjdg�|�t|jtjdg�|�t|jddg�|�t|jdg�|�t|jdg�|�t|jtjg�|�t|jtjdg�|�t|jddg�dS)Nr:r2r<r7r8rAi)r>rer r4r5rrrr�test_constructor_value_errors�sz+BaseBytesTest.test_constructor_value_errorsc	CsFt}|�ttf|j|�zt|d�Wnttfk
r@YnXdS)N�)rr>rp�MemoryErrorr �	bytearray)r�sizerrr�test_constructor_overflow�sz'BaseBytesTest.test_constructor_overflowcCsXGdd�d�}|�t|j|��|�t|j|�g�Gdd�d�}|�t|j|��dS)Nc@seZdZdd�ZdS)z9BaseBytesTest.test_constructor_exceptions.<locals>.BadIntcSsdddS�Nr2rrrrrrr�szCBaseBytesTest.test_constructor_exceptions.<locals>.BadInt.__index__Nr[rrrr�BadInt�src@seZdZdd�ZdS)z>BaseBytesTest.test_constructor_exceptions.<locals>.BadIterablecSsdddSr~rrrrr�__iter__�szGBaseBytesTest.test_constructor_exceptions.<locals>.BadIterable.__iter__N)rrrr�rrrr�BadIterable�sr�)r>�ZeroDivisionErrorr )rrr�rrr�test_constructor_exceptions�s
z)BaseBytesTest.test_constructor_exceptionscCs|�dddg�}|�dddg�}|�ddg�}|�||�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�dS)Nr2r<rL)r r!�
assertTrue�assertFalse)r�b1�b2�b3rrr�test_compare�s&zBaseBytesTest.test_comparecCs�|�|�d�dkd�|�|�d�dkd�|�|�d�dkd�|�|�d�dkd�|�|��t�kd�|�|��t�kd�dS)Nsabc�abcFsabcsabcsabcT)r!r �strrrrr�test_compare_to_str�s��z!BaseBytesTest.test_compare_to_strcCs<tttd��}|�|�}tt|��}|��|�||�dS)N�Hello)rQ�map�ordr �reversed�reverser!)r�inputr%�outputrrr�
test_reverseds

zBaseBytesTest.test_reversedcsP�fdd�}|d�}��|dd�|d����|dd�|d����|dd�|d	����|dd�|d
����|dd�|d
����|dd�|d
����|dd
�|d����|dd
�|d����|d
d�|d	����|dd�|d
����|dd�|d
����|dd�|d
����|dd�|d��dS)Ncs��tt|��Sr)r r�r���srrr�by	sz'BaseBytesTest.test_getslice.<locals>.by�Hello, worldrlr�r2Zello�z, �world�r8���i����������)r!�rr�r%rrr�
test_getsliceszBaseBytesTest.test_getslicecCs�ttd��}|�|�}ddddddtjddd	d
f}|D]F}|D]<}|dd�D]*}|�||||�|�||||���qNq>q6dS)Nrdrr2rL�r8r:r;���r�)rQrPr r4r5r!)r�Lr%�indices�start�stop�steprrr�test_extended_getslices
z$BaseBytesTest.test_extended_getslicec	Csrd}dD](}|�||�}|�||�|�|���q|�t|j|d�|�|dd�}|�||�|dd�d��dS)N�Hello world
ሴ噸骼��utf-8zutf-16�latin-1ru���r�)r r!�encoder>�UnicodeEncodeError�r�sample�encr%rrr�
test_encoding'szBaseBytesTest.test_encodingcCs�d}dD]"}|�||�}|�|�|�|�qd}|�|d�}|�t|jd�|�|�dd�d�|�|jddd�d�|�|�d	���d
�dS)Nr�r�uHello world
€þÿr�r�ruzHello world
)rvrts☃u☃)r r!�decoder>�UnicodeDecodeErrorr�rrr�test_decode0s�zBaseBytesTest.test_decodecCsb|�d�}|�||���|�d�}|�||�dgd��|�d�}|�||�dgd��dS)Nrr7i')r r!r$rrr�
test_from_int>s


zBaseBytesTest.test_from_intcsx|�d��|�d��|���d�|��td�d�|�td��d�|�t�fdd��|�t�fdd��dS)N�abc�def�abcdefsdefabccs�dS)N�defrr)r�rrr/Lr0z+BaseBytesTest.test_concat.<locals>.<lambda>csd�S)Nr�rr)r�rrr/Mr0)r r!rar>rhrr)r�r�r�test_concatFs

zBaseBytesTest.test_concatc
s�d|�d�fD]��|��dd�|��dd�|��dd�|�t�fdd��|�t�fd	d��|�ttf���tj}W5QRX|�ttf���tj9�W5QRXqdS)
Nr�rL�	abcabcabcrr0r:cs�dS�Ng��Q�	@rrr.rrr/Tr0z+BaseBytesTest.test_repeat.<locals>.<lambda>csd�Sr�rrr.rrr/Ur0)r r!r>rhrprzr4r5�r�crr.r�test_repeatOszBaseBytesTest.test_repeatcCs*|�|�d�d|�td�gd��dS)N�xr8�x)r!r r�rrrr�test_repeat_1char\szBaseBytesTest.test_repeat_1charcst|�d��|�td���|�ttd����|�d��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fd	d��|�t�fd
d��tt	fD]�}|�|d���|�|d���|�|d
���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���q�dS)Nr�r,��csd�kS)N�,rrr.rrr/dr0z-BaseBytesTest.test_contains.<locals>.<lambda>csd�kSr9rrr.rrr/er0cstjd�kSr1r3rr.rrr/fr0csd�kSrrrr.rrr/gr0csttd���kS�Nr,)�floatr�rr.rrr/hr0csd�kSr�rrr.rrr/ir0r0�a�b�c�ab�bc�ac�dsdabsabd)
r rRr��intZassertNotInr>rerhrar{�r�frr.r�
test_contains_s,
zBaseBytesTest.test_containsc
Cs�|�t|jj�|�t|jjd�|�|j�d�|���tdddg�}|�|j�d�|�|�|j�d�|�|�|j�d�|�d	D]}|�|j�|�|���q�d
D]}|�t|jj|�q�|�|j�d�d�|�t|jjd
�|�t|jjd�|�t|jjd�|�t|jjd�|�t|jjd�|�t|jjd�dD]B\}}|�t��}|j�|�W5QRX|�d|t|j	���qFdS)Nr2r�rD�0�1a2B30z  1A 2B  30   z
 1A
2B	30z	

 u…   
Z0000ss1Br,Zrtz1a b cd�z12      34))z12 x4 56rL)z12 3x 56ry)z12 xy 56rL)u	12 3ÿ 56ryzat position %s)
r>rhr �fromhexr!r{rerRr��	exception)rr%r��data�pos�cmrrr�test_fromhexws,
zBaseBytesTest.test_fromhexcCs�|�t|jj�|�t|jjd�|�|�d���d�|�tdddg���d�|�|�d���d�|�td���d�dS)	Nr2r0rr�rDr�Z1a2b30�+0)r>rhr �hexr!r{�
memoryviewrrrr�test_hex�szBaseBytesTest.test_hexc	CsP|�d�}|�|��d�|�t��|�d�W5QRX|�t��|�d�W5QRX|�|�dd�d�|�t��|�dd�W5QRX|�t��|�d�W5QRX|�t��|�d�W5QRX|�t��|�d	�W5QRX|�t��|�td
��W5QRX|�|�dd�d�|�|�d�d�|�|�d
�d�|�|�d�d�|�|�d�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�d�d�|�|�d�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�d}|�|�dd �d!�dS)"Ns��Zb901efrZxx�:r�ÿ����rArkzb901efr��zb901ef�rLry���zb9:01:ef�$zb9$01$efr2r:r<zb9:01ef�*r;zb901*efs {sworldishelloi0�.�zC7b7305000000776f.726c646902000000.730500000068656c.6c6f690100000030)r r!r�r>rerh�chr)rZthree_bytesrrrr�test_hex_separator_basics�sD
z'BaseBytesTest.test_hex_separator_basicscCs$|�tdd��}|�|��d�dS)N�Z�_Z
5a5b5c5d5e�r rPr!r�)rZ
five_bytesrrr�test_hex_separator_five_bytes�sz+BaseBytesTest.test_hex_separator_five_bytescCs|�dd�tdd�D��}|�|��d�|�|�dd�d�|�|�dd	�d
�|�|�dd�d
�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�dS)Ncss|]}|dVqdS)rLNr�rGr�rrrrI�sz=BaseBytesTest.test_hex_separator_six_bytes.<locals>.<genexpr>r2r�Z0306090c0f12r�z03.06.09.0c.0f.12� r<z0306 090c 0f12�-rLz
030609-0c0f12r�ryz
0306:090c0f12rlz
03:06090c0f12�r��_r�Z
030609_0c0f12r�z
0306090c:0f12�@r�z
0306090c0f@12i����i����r�)rZ	six_bytesrrr�test_hex_separator_six_bytes�sz*BaseBytesTest.test_hex_separator_six_bytesc	Cs�|�|�d��g�d�|�|�d��dg�d�dgddgddgdddgfD]d}tt|j|��}|�|�d��|�d�|�|�d��t|��d�|�|�d��t|��d�qN|�d�j}|�|dd	g�d
�|�|td�d	g�d
�|�|dtd	�g�d
�|�|td�d	g�d
�|�|dtd	�g�d
�dgd}ddd
}|�||�|�|�	t
|�d�jd�|�	t
��|td�ddg�W5QRX|�	t
��|td�ddg�W5QRXdS)Nr0r�r�r�r�r�r�s.:scdsab.:cdr]s.:abci�� Zcdsef)r!r �joinrQr�rSrTr�r{r>rh)rZlstZdot_join�seqZexpectedrrr�	test_join�s* 
zBaseBytesTest.test_joincCs|�d�}d}d}d}|�|�d�d�|�|�d�d�|�|�d	�d
�|�|�|�d�|�|�|�d
�|�|�dd�d�|�|�dd�d�|�|�dd
d�d
�|�|�ddd�d
�|�|�|d�d�|�|�|d�d�|�|�|d
d�d
�|�|�|dd�d
�dS)N�mississippi�i�p�w�iry�ssr<�wrr��pr2rLr��	)r r!�count)rr%rH�p�wrrr�
test_count�s"
zBaseBytesTest.test_countc	Cs�|�d�}|�|���d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�t��}|�dg�W5QRXt|j�}|�d|�|�d|�dS)	N�hello�anythingshel�hshellowshararS)	r r��
startswithr�r>rhr�r�rR�rr%r��excrrr�test_startswiths

zBaseBytesTest.test_startswithc	Cs�|�d�}|�t��d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�t��}|�dg�W5QRXt|j�}|�	d|�|�	d|�dS)	Nrrsllo�oswhellosnorarS)
r r�r{�endswithr�r>rhr�r�rRrrrr�
test_endswiths

zBaseBytesTest.test_endswithcCs|�d�}d}d}|�|�d�d�|�|�d�d�|�|�d�d�|�|�|�d	�|�|�|�d�|�|�dd
�d�|�|�dd	d�d�|�|�dd	d
�d�|�|�|d
�d�|�|�|d	d
�d	�|�|�|d	d
�d�ddtjd	fD]}|�td|j|�q�dS)Nr�r�rrr<rr:�
mississippianr2rLrlr�r�rAzbyte must be in range\(0, 256\))r r!�findr4r5�assertRaisesRegexre)rr%rHr	�indexrrr�	test_find*s*
�zBaseBytesTest.test_findcCs�|�d�}d}d}|�|�d�d�|�|�d�d�|�|�d�d�|�|�|�d	�|�|�|�d�|�|�dd
�d�|�|�ddd�d
�|�|�|dd
�d�|�|�|d
d�d�|�|�|dd
�d�dS)Nr�r�rrrlrr:rr7rLrr�r<r2rr�)r r!�rfind�rr%rHr	rrr�
test_rfindCs
zBaseBytesTest.test_rfindcCs�|�d�}d}d}|�|�d�d�|�t|jd�|�t|jd�|�|�|�d�|�t|j|�|�|�dd	�d
�|�|�ddd�d�|�t|jddd	�|�|�|d�d�|�|�|dd	�d�|�t|j|dd	�dS)
Nr�r�rrr<rrr2rLrlr�r�)r r!rr>rerrrr�
test_indexVs
zBaseBytesTest.test_indexcCs�|�d�}d}d}|�|�d�d�|�t|jd�|�t|jd�|�|�|�d�|�t|j|�|�|�dd	�d�|�|�dd
d�d�|�|�|d
d	�d
�|�|�|d	d�d�|�t|j|d
d	�dS)Nr�r�rrrlrrr7rLrr�r<r2rr�)r r!�rindexr>rerrrr�test_rindexjs
zBaseBytesTest.test_rindexcCs�|�d�}|}|d}|�|d�|�|d�|�||k�|�d�}|d}|�|d�|�t|�|j�|�d�}|d}|�|d�|�t|�|j�dS�	Ns
hello, %b!�worlds
hello, world!s%s / 100 = %d%%)sseventy-nine�Osseventy-nine / 100 = 79%s
hello,%b!s
hello,world!�r r!r��assertIsr")rr%�origr,rrr�test_mod}s


zBaseBytesTest.test_modcCs�|�d�}|}|d;}|�|d�|�|d�|�||k�|�d�}|d;}|�|d�|�t|�|j�|�d�}|d;}|�|d�|�t|�|j�dSr r#)rr%r%rrr�	test_imod�s


zBaseBytesTest.test_imodc	CsB|�t��t�|�d�W5QRX|�|�d��d�t�dS)Nr�z%r)r>rh�objectr r$�__rmod__�NotImplementedrrrr�	test_rmod�szBaseBytesTest.test_rmodcCs6|�d�}|�|�dd�d�|�|�dd�d�dS)Nr�rr�smassassapparr�s	mixixippi)r r!�replacer$rrr�test_replace�s
zBaseBytesTest.test_replacecCs|�t|�d�jdd�dS)N�a b� r0)r>rhr r,rrrr�test_replace_int_error�sz$BaseBytesTest.test_replace_int_errorcCs0|�t|�d�jd�|�t|�d�jd�dS�Nr.r��r>rhr �split�rsplitrrrr�test_split_string_error�sz%BaseBytesTest.test_split_string_errorcCs0|�t|�d�jd�|�t|�d�jd�dS�Nr.r/r2rrrr�test_split_int_error�sz"BaseBytesTest.test_split_int_errorcCsFdD] }|�|�}|�|��|g�q|�d�}|�|��dg�dS)N)sabsabsabsab�		

�)r r!r3r$rrr�test_split_unicodewhitespace�s


z*BaseBytesTest.test_split_unicodewhitespacecCs |�d�}|�|��dg�dS)Nr8r9)r r!r4r$rrr�test_rsplit_unicodewhitespace�s
z+BaseBytesTest.test_rsplit_unicodewhitespacecCs2|�d�}|�|�d�d�|�|�d�d�dS)Nr�r)smirsissippir)r�r0r0)r r!�	partitionr$rrr�test_partition�s
zBaseBytesTest.test_partitioncCsD|�d�}|�|�d�d�|�|�d�d�|�|�d�d�dS)Nr�r)smissirsippir)s
mississipprr0r)r0r0r�)r r!�
rpartitionr$rrr�test_rpartition�s
zBaseBytesTest.test_rpartitioncCs0|�t|�d�jd�|�t|�d�jd�dSr1�r>rhr r<r>rrrr�test_partition_string_error�sz)BaseBytesTest.test_partition_string_errorcCs0|�t|�d�jd�|�t|�d�jd�dSr6r@rrrr�test_partition_int_error�sz&BaseBytesTest.test_partition_int_errorcCsNttjd�D]:}dD]0}|�|�}t�||�}t�|�}|�||�qqdS�Nr2)r0r�r�s�ab�s�)rP�pickle�HIGHEST_PROTOCOLr �dumps�loadsr!)r�protor%Zps�qrrr�
test_pickling�s

zBaseBytesTest.test_picklingcCs�ttjd�D]�}dD]�}t|�|��}}t|�|��}t�||�}t�|�}|�t	|�t	|��|�t|�|�t�|�}|s�qt
|�t�||�}t�|�}|�t|�|dd��qqdSrC)rPrDrErTr rQrFrGr!r"�next)rrHr%�itZitorgr��drrr�test_iterator_pickling�s


z$BaseBytesTest.test_iterator_picklingcCsX|�|�d��td��d�|�|�d��td��d�|�|�d��td��d�dS)Nr�r�r�r�r�)r!r �stripr��lstrip�rstriprrrr�test_strip_bytearray�sz"BaseBytesTest.test_strip_bytearraycCsF|�t|�d�jd�|�t|�d�jd�|�t|�d�jd�dS)Nr�Zac�r>rhr rOrPrQrrrr�test_strip_string_error�sz%BaseBytesTest.test_strip_string_errorcCsF|�t|�d�jd�|�t|�d�jd�|�t|�d�jd�dS)Ns abc r/rSrrrr�test_strip_int_error�sz"BaseBytesTest.test_strip_int_errorcCs:|�d�}ttfD]"}|�|�d|d��|�d��qdS)Nr�r��-s--abc--)r rar{r!�center�rr%Z	fill_typerrr�test_center�s

�zBaseBytesTest.test_centercCs:|�d�}ttfD]"}|�|�d|d��|�d��qdS)Nr�r�rVsabc----)r rar{r!�ljustrXrrr�
test_ljusts

�zBaseBytesTest.test_ljustcCs:|�d�}ttfD]"}|�|�d|d��|�d��qdS)Nr�r�rVs----abc)r rar{r!�rjustrXrrr�
test_rjust	s

�zBaseBytesTest.test_rjustcCsL|�t|�d�jdd�|�t|�d�jdd�|�t|�d�jdd�dS)Nr�r�r/)r>rhr rWrZr\rrrr�test_xjust_int_errorsz"BaseBytesTest.test_xjust_int_errorcs:|�d��|��fdd�tt���D�dddddg�dS)	NsA��cs g|]}t�||d���qS)r2)r�rFr.rr�
<listcomp>sz*BaseBytesTest.test_ord.<locals>.<listcomp>r�A�rJrd)r r!rPr=rrr.r�test_ords
�zBaseBytesTest.test_ordcCs`d}|�|j�dd�|�d}|�|j�dd�|�|�t|jjdd�|�t|jjdd�dS)	Ns	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`xyzdefghijklmnopqrstuvwxyz{|}~�����������������������������������������������������������������������������������������������������������������������������r��xyzs	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~��������������������������������������������������������������������������������������������������������������������������xyzs���sxyzqr�r�)r!r �	maketransr>rerh)rZ
transtablerrr�test_maketransszBaseBytesTest.test_maketranscCs�|�d�}|�d�}|�d�}|�d�}|�d�}|�d|�|d��|�d|�|dd��|�d|�|dd��|�d	|�|dd��|�d|�|d��|�d|�|dd��|�d|�|dd��|�d	|�|dd��|�d|�|d��|�d|�|dd��|�d|�|dd��|�d	|�|dd��|�d|�|d��|�d|�|dd��|�d|�|dd��|�d	|�|dd��|�d|�|d��|�d
|�|dd��|�d
|�|dd��|�d	|�|dd��|�d|�|d��|�d|�|dd��|�d|�|dd��|�d|�|dd��|�d|�|d��|�d|�|dd��|�d|�|dd��|�d|�|dd��dS)
Nr�lr
r�rr<rLr;rr2TF)	r r!rrrrrrr)rr%�l�hr��orrr�test_none_arguments"sB




z!BaseBytesTest.test_none_argumentscCsV|�d�}|j|j|j|j|jfD].}|�t|d�|�t|d�|�t|d�q"dS)Nrr:rAi')r rrrrrr>re)rr%�methodrrr�(test_integer_arguments_out_of_byte_rangeMs

z6BaseBytesTest.test_integer_arguments_out_of_byte_rangec	Cs�|�d�}|�d�}|�td|j|ddd�|�td|j|ddd�|�td|j|ddd�|�td|j|ddd�|�td|j|ddd�|�td|j|ddd�|�td	|j	|ddd�dS)
Nrr�z\bfind\bz	\brfind\bz	\bindex\bz
\brindex\bz	\bcount\bz\bstartswith\bz\bendswith\b)
r rrhrrrrrrr)rr%r�rrr�*test_find_etc_raise_correct_error_messagesUsX

�������z8BaseBytesTest.test_find_etc_raise_correct_error_messagescCs(tj�|t|j�tj�|t|j�dSr)rrZcheck_free_after_iteratingrTr r�rrrr�test_free_after_iteratinghsz'BaseBytesTest.test_free_after_iteratingcCs4|�d�}ttd��}td�|td�<|�t|j�|�t|jdd�|�t|jttd���|�|d�}|�	|d�|�
||j�|�|�}|�|d�}|�	||�|�	|d�|�|d�}|�	|d	�|�dd
�}|�	|d�|j|dd�}|�	|d�|j|dd�}|�	|d	�|jdd
d�}|�	|d�dS)
NrrA�erirdr0shellerfshee�eshllo)�delete)r r{rPr�r>rh�	translatererar!�assertIsInstance)rr%Zrosettar�rMrrr�test_translatels.

zBaseBytesTest.test_translateN)Irrrr&r-r@rUrVrWrbrfrjrqrwrxrr}r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rrrrrrr&r'r+r-r0r5r7r:r;r=r?rArBrJrNrRrTrUrYr[r]r^rbrerjrlrmrnrtrrrrr+s�




		
%%+rc@s8eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)�	BytesTestc	Cs,d}d}|�t|��|dW5QRXdS)N�pythonz'byte indices must be integers or slicesr,)rrh�rr%�msgrrr�test_getitem_error�szBytesTest.test_getitem_errorc	Cs<t�ttj�}t|ddd��}|�t|jd�W5QRXdS)N�rbr)�	bufferingr0)�os�open�__file__�O_RDONLYr>rh�readinto)r�fdr�rrr�test_buffer_is_readonly�sz!BytesTest.test_buffer_is_readonlycCsGdd�d�}|�t|��d�Gdd�d�}|�tt|��Gdd�d�}|�tt|��Gdd�d�}|�t|��d�Gdd�dt�}|�t|d	��d�|�t|d	�d
�d�Gdd�d�}|�t|��d�|�tt|���t�|�t|��d�|�tt|���t�dS)
Nc@seZdZdd�ZdS)� BytesTest.test_custom.<locals>.AcSsdS�Nr�rrrrr�	__bytes__�s�*BytesTest.test_custom.<locals>.A.__bytes__N�rrrr�rrrr�A�sr�r�c@seZdZdS)r�Nrrrrrrr��sc@seZdZdd�ZdS)r�cSsdSrrrrrrr��sr�Nr�rrrrr��sc@seZdZdd�Zdd�ZdS)r�cSsdS)Nr�rrrrrr��sr�cSsdSrXrrrrrr�sz*BytesTest.test_custom.<locals>.A.__index__N)rrrr�rrrrrr��sr�c@seZdZdd�ZdS)r�cSsdSr�rrrrrr��sr�Nr�rrrrr��su€z
iso8859-15��c@seZdZdd�ZdS)r�cSstd�Sr�)�OtherBytesSubclassrrrrr��sr�Nr�rrrrr��s)	r!rar>rhr�r$r"r��
BytesSubclass)rr�rrr�test_custom�s zBytesTest.test_customcsxtj�d�}tj�d�}ddlm}m}ddlm}m}m}m	}m
}	m}
m}|j
}|f|_||_|�|d�d�|�|dd�d	�|�|d
|d��d�|�|d
|td���d
�|�|d
|d��d�|�|d|d�|d�|	d��d�|�|d|d�|d�|	d��d�|�|d|d�|d�|	d��d�|�|d|d��d�|�|d|d ��d!�|�|d"|d#��d$�|�|�}
tjd%k�r�d&�d|
���fd'd(�}nd)d(�}d*}|�|d+||��d,||��d-��|�|d.|d/��d0�|	d�j}d1||jtfd1||jtfd2||jtfd2||jtfd3||jtfd4|
|jtfd4|
|jtfd5|	|tfd6|||ff	D]0\}}}}|�||||��||��d-��f�q^|�|d7d8�d8�|�|d9d:�d;�|�|d<�d=�|�|d>�d?�|�|d@|tdA���dB�|�|dC�dD�|�|d=�d=�|�|dE|d�|d��dF�|� t!|dG|d��|� t!|dG|dH��|�|dI�dI�|�|dDdI�dI�dS)JN�ctypes�	_testcapir)�	pythonapi�	py_object)�c_int�c_uint�c_long�c_ulong�c_size_t�	c_ssize_t�c_char_psformats
Hello %s !r!s
Hello world !sc=%csc=�@sc=@rdsc=�sd=%d ld=%ld zd=%zdr2r<rLs
d=1 ld=2 zd=3r:r;r�sd=-1 ld=-2 zd=-3su=%u lu=%lu zu=%zu�{i�isu=123 lu=456 zu=789si=%isi=123i����si=-123sx=%xi�
sx=abc�ntz0x%0{}Xcs�|Srr��ptr�Z
ptr_formatrr�
ptr_formatter�sz1BytesTest.test_from_format.<locals>.ptr_formattercSsd|S)Nz%#xrr�rrrr��si�ͫsptr=%pzptr=rnss=%sscstrss=cstrs%ds%lds%lus%zds%zus%ps%5sr�s%.3sr�r�s%%�%s[%%]s[%]s%%%cr�s%_s%%ss%ssx=%i y=%sx=2 y=%s%crAr0)"rr�
import_moduler�r�r�r�r�r�r�r�r�r��PyBytes_FromFormatZargtypesZrestyper!r�Zsizeofr|�name�formatr�rZINT_MINr�ZINT_MAXZLONG_MINZLONG_MAXZ	ULONG_MAXZPY_SSIZE_T_MINZPY_SSIZE_T_MAXr>rp)rr�r�r�r�r�r�r�r�r�r�r�r�Z
sizeof_ptrr�r�Zsize_maxZ	formatstrZctypes_typerZpy_formatterrr�r�test_from_format�s�$
��������������
��


��
��
�
��
����
��zBytesTest.test_from_formatcCs�Gdd�dt�}ddddg}|�t|�d�|�tt||��Gdd	�d	t�}|�td�d
�|�tt|d��Gdd�dt�}|�td
�d
�|�tt|d
��Gdd�dt�}td
�|d
�}}|�t|�d
�|�tt|�dS)Nc@seZdZdZdS)z7BytesTest.test_bytes_blocking.<locals>.IterationBlockedNr�rrrr�IterationBlocked.sr�rr2r<rLsc@seZdZdZdS)z1BytesTest.test_bytes_blocking.<locals>.IntBlockedNr�rrrr�
IntBlocked7sr�sc@seZdZdZdS)z;BytesTest.test_bytes_blocking.<locals>.BytesSubclassBlockedNr�rrrr�BytesSubclassBlocked@sr�r�c@seZdZdZdS)z4BytesTest.test_bytes_blocking.<locals>.BufferBlockedNr�rrrr�
BufferBlockedEsr�)rQr!rar>rhr�r{)rr�rHr�r�r��ba�bbrrr�test_bytes_blocking-szBytesTest.test_bytes_blockingN)
rrrrar ryr�r�r�r�rrrrru�s!rruc@s2eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"e#j$j%d=d>��Z&d?d@�Z'e#j(j)j*Z*dAdB�Z+dCdD�Z,dES)F�
ByteArrayTestc	Cs0td�}d}|�t|��|dW5QRXdS)Nrv�,bytearray indices must be integers or slicesr,�r{rrhrwrrrryOsz ByteArrayTest.test_getitem_errorc	Cs0td�}d}|�t|��d|d<W5QRXdS)Nrvr�Zpythonr,r�rwrrr�test_setitem_errorUsz ByteArrayTest.test_setitem_errorcCs|�ttt��dSr)r>rh�hashr{rrrr�test_nohash[szByteArrayTest.test_nohashcCsd}|ddt|�}t��}z�t|d��}|�|�W5QRXt|d��}td�}|�	|�}W5QRX|�
|t|��|�
t|�t|��t|d��}|�|�W5QRXt|d��}|�
|��|�W5QRXW5zt�|�Wntk
r�YnXXdS)NsHello world
rk��wbrz)
r=�tempfile�mktempr|�remove�OSErrorr}�writer{r�r!rQ�read)rZshort_sampler�Ztfnr�r%�nrrr�test_bytearray_api^s&z ByteArrayTest.test_bytearray_apicCs\td�}|�|��d�|�|d�td�}|��|�|d�t�}|��|�|�dS)Nrsollehshello1s1olleh)r{r!r�r�r$rrr�test_reversexszByteArrayTest.test_reversecCsttd�}|��|�|d�td�}|��|�|d�td�}|�td��|��|�td��|�|d�dS)Nrvr0�rrr)r{rYr!r^r�r$rrr�
test_clear�szByteArrayTest.test_clearcCs�td�}|��}|�|d�td�}|��}|�|d�td�}|��}|�||�|�||�|�td��|�|d�|�|d�dS)Nr�r0rMr()r{r)r!�assertIsNotr^r�)rr%r�rrrr-�szByteArrayTest.test_copycCs4dd�}|d�}|�t�d|�|d�|d�g�dS)NcSsttt|��Sr)r{r�r�r�rrrr��sz&ByteArrayTest.test_regexps.<locals>.byr�s\w+r�r�)r!�re�findallr�rrr�test_regexps�szByteArrayTest.test_regexpscCsTtdddg�}d|d<|�|tdddg��d|d<|�|tdddg��td�|d<|�|tdddg��zd|d<|�d	�Wntk
r�YnXzd|d
<|�d	�Wntk
r�YnXzd|d<|�d�Wntk
r�YnXztd�|d<|�d�Wntk
�r YnXzd|d<|�d
�Wntk
�rNYnXdS)Nr2r<rLr8r�r:r7rzDidn't raise IndexErrori����rAzDidn't raise ValueErrorzDidn't raise TypeError)r{r!r�failr?rerhr$rrr�test_setitem�s@zByteArrayTest.test_setitemcCslttd��}|d=|�|ttdd���|d=|�|ttdd���|d=|�|tddddd	d
dg��dS)Nr7rr2r:rryr<rLr�r�r�)r{rPr!r$rrr�test_delitem�szByteArrayTest.test_delitemcCsTttd��}|�t|�ttd���tdddddg�|dd�<|�|tddddddddddg
��|dd	�=|�|tdddddg��tddd
ddg�|dd�<|�|ttd���td
dg�|dd�<|�|tddd
d
ddddg��ddddg|dd�<|�|ttd���dddg|dd�<|�|tddd
ddddddddddg
��d|dd�<|�|tddd
dddg��td�|dd�<|�|tddddddg��g|dd�<|�|tdddddg��dd	dtd�ddddgddgggf	D](}|�t��||dd�<W5QRX�q�dddgdd gfD](}|�t��||dd�<W5QRX�q&dS)!Nr7r2rrlr�r�r�rr�r<rLryr8�er�r�rBsfoo�f�ogP����KDr�gffffff@r,r%r�r�rcrdrAi���i(#)	r{rPr!rQr�r�r>rhre)rr%�elemrrr�
test_setslice�s<$
 *�zByteArrayTest.test_setslicecCsvttd��}|�t|�ttd���|dd�=|�t|�ttdd���|�tdd��|�t|�ttdd���dS)Nr8r7�n)r{rPr!rQ�extendr$rrr�test_setslice_extend�s
z"ByteArrayTest.test_setslice_extendcCs,td�}|��|dd�=|td�7}~dS)Nr7r2r<)r{�poprar$rrr�test_fifo_overruns

zByteArrayTest.test_fifo_overruncCs2td�}t�|�}|dd�=|�t�|�|�dS)Nr7r2)r{r4�	getsizeof�assertLessEqual)rr%r|rrr�test_del_expands

zByteArrayTest.test_del_expandcCs�dddddddd>tjddd	d
f}|D]�}|D]�}|dd�D]�}ttd��}t|�}||||�}|��|||||�<|||||�<|�|t|��||||�=||||�=|�|t|��q>q.q&dS)Nrr2rLr�r�iMr:r;r�i���rd)r4r5rQrPr{r�r!)rr�r�r�r�r�r%r�rrr�test_extended_set_del_slices&�z)ByteArrayTest.test_extended_set_del_slicecCs@ttd��}||dd�<|�|tttd��ttd����dS)NrAr�)r{rPr!rQr$rrr�test_setslice_trap+sz ByteArrayTest.test_setslice_trapcCs|td�}|}|d7}|�|d�|�||�|�||�|d7}|�|d�z|d7}Wntk
rlYnX|�d�dS)Nr�r�r�rcs	abcdefxyzrz'bytes += unicode didn't raise TypeError)r{r!r$rhr��rr%r�rrr�test_iconcat2szByteArrayTest.test_iconcatcCs<td�}|}|d9}|�|d�|�||�|�||�dS)Nr�rLr��r{r!r$r�rrr�test_irepeatBszByteArrayTest.test_irepeatcCs<td�}|}|d9}|�|d�|�||�|�||�dS)Nr�r8sdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr�r�rrr�test_irepeat_1charJsz ByteArrayTest.test_irepeat_1charcCsdt�}|��}|�|d�|g}td�D]6}|d7}|��}|�|t|��||kr(|�|�q(dS)Nrr8r�)r{�	__alloc__ZassertGreaterEqualrP�
assertGreaterr=r^)rr%�allocr�rHrrr�
test_allocRszByteArrayTest.test_alloccsft����fdd�}��|����t��ttdd�����t��d����}��|t���dS)Nc	3s|tdd�D]l}|Vt��}��|ttdt|�d�����t��t|����t��|����}��|t���q
dS)Nr2r8)rPrQr!r=r�r�r�)rHr,r��r%rrr�g`sz(ByteArrayTest.test_init_alloc.<locals>.gr2r8�c)r{rr!rQrPr=r�r�)rr�r�rr�r�test_init_alloc^s	zByteArrayTest.test_init_alloccCs�d}t|�}|�|�|�|||�|�|dd�|�td�}|�tt|d��|�dd�|dD��|�||d�|�|dd�|�td�}|�ttt|d���|�||d�|�|dd�|�td�}|�ttt|d���|�||d�|�|dd�|�td�}|�t|jd	d
ddg�|�t|jd	d
dd
g�|�t	|�d	�td�}|�t
td��g�|�|d�dS)Nrrlr0�css|]}t|�VqdSr)r�r�rrrrIxsz,ByteArrayTest.test_extend.<locals>.<genexpr>�2r�rr2r<rAr:r,r�)r{r�r!r�r�rTrQr>rer=rr�)rr%r,rrr�test_extendos2
zByteArrayTest.test_extendcs$td����td��|��d���td��|��d�|�t�fdd��|�t�fdd��|�t�fdd����td	����td
��|��d�|�t�fdd����ttd
���|��d�tddddg�}|�d�|�|tdddg��|�d�|�|tddg��dS)Nrrgshelosheocs��td��S)Nrg)r�r�rr.rrr/�r0z+ByteArrayTest.test_remove.<locals>.<lambda>cs
��d�S)Ni��r�rr.rrr/�r0cs
��d�S)Nror�rr.rrr/�r0rirhrpcs
��d�S)Nrpr�rr.rrr/�r0ror0�~rarJ�)	r{r�r�r!r>rerhrrar�rr.r�test_remove�s&

zByteArrayTest.test_removecs�td��|����td��|���d�td��|���d�td��|�t�fdd��|�td	d��|�td
���d�dS)Nr!rMrr	r;r�cs
��d�S)Nr7)r�rr.rrr/�r0z(ByteArrayTest.test_pop.<locals>.<lambda>cSs
t���Sr)r{r�rrrrr/�r0r�rd)r{r!r�r�r>r?rrr.r�test_pop�szByteArrayTest.test_popcCs|�tdd��dS)NcSs
t���Sr)r{�sortrrrrr/�r0z+ByteArrayTest.test_nosort.<locals>.<lambda>)r>�AttributeErrorrrrr�test_nosort�szByteArrayTest.test_nosortcs�td����td��|��d�|���d�d�t����td��|�t��d�|�t�fdd��t����ttd���|��d	�dS)
Nshellrirr8r�r2cs
��d�S)Nr)r^rr.rrr/�r0z+ByteArrayTest.test_append.<locals>.<lambda>�A)r{r^r�r!r=r>rhrrrr.r�test_append�szByteArrayTest.test_appendcs�td����dtd����dtd����dtd����dtd��|��d�|�t�fdd	��t����d
ttd���|��d�dS)
Nsmssssppr2rHryr;r]r�cs��dd�S)Nr�1)�insertrr.rrr/�r0z+ByteArrayTest.test_insert.<locals>.<lambda>rr�r�)r{r�r�r!r>rhrrrr.r�test_insert�szByteArrayTest.test_insertcCsRtd�}|�||�ddd��tdd�td�D��}td�}|�||�|��dS)Nr�scdercSsg|]}|�qSrrrFrrrr_�sz-ByteArrayTest.test_copied.<locals>.<listcomp>rAr0)r{r�r,rPrr)rr%�tr�rrr�test_copied�s
zByteArrayTest.test_copiedcCs�td��d�\}}}|�|d�|�|d�|�||�|d7}|�|d�td��d�\}}}|�|d�|�|d�td��d�\}}}|�|d�|�|d�|�||�|d7}|�|d�td��d�\}}}|�|d�|�|d�dS)Nr��yr0�!)r{r<r!r�r>)rr,r%r�rrr�0test_partition_bytearray_doesnt_share_nullstring�s$z>ByteArrayTest.test_partition_bytearray_doesnt_share_nullstringcs
ttd���t��}�fdd�}|d��dd�}|�t|d�|��|�|�t|d�|��|�|�t|d�|��|�|�t�jd�|��|�|�t�j�d�|��|��fdd	�}|�t|�|��|��fd
d�}|�t|�|��|�dS)Nr7cs"t|dd|d��dd�<dS)Nr2r<r:)rP)r�r.rr�resize�sz3ByteArrayTest.test_resize_forbidden.<locals>.resize�rrr2cs
�d=dSr1rrr.rr�delitem�sz4ByteArrayTest.test_resize_forbidden.<locals>.delitemcsd�ddd�<dS)Nr0r2r:r<rrr.rr�delslicesz5ByteArrayTest.test_resize_forbidden.<locals>.delslice)r{rPr�r>�BufferErrorr!r�r�)r�vr�r%r�r�rr.r�test_resize_forbidden�s*z#ByteArrayTest.test_resize_forbiddencCs ddlm}|�t|t��dS)Nr)�getbuffer_with_null_view)r�r�r>r�r{)rr�rrr�test_obsolete_write_locksz&ByteArrayTest.test_obsolete_write_lockc	Cs�td�}td�}ttjd�D�]v}t|�}t�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|�t
|�t�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|dd��tdt|��D]}t
|�q�t�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|t|�d��|�t
t
|�t�||f|�}t�|�\}}||dd�<|�t|�g�qdS)Nr�sqwertyr2)r{rQrPrDrErTrFrGr!r"rKr=r>�
StopIteration)	rr%r�rHZitorigrMrLr%rHrrr�test_iterator_pickling2
s6
z%ByteArrayTest.test_iterator_pickling2cCs4td�}t|�}t|�|��|�t|�g�dS)Nr�)r{rTrKrYr!rQ)rr�rLrrr�test_iterator_length_hint3s
z'ByteArrayTest.test_iterator_length_hintcCsLtd�}d|dd�<|d}|d}|�|d�|�||�|�|d�dS)Nr�r�r<r2rLsxcsxcxcxc�r{r!)rr%r�r�rrr�test_repeat_after_setslice<sz(ByteArrayTest.test_repeat_after_setsliceN)-rrrr{r ryr�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�rrZcpython_onlyr�rZ
list_testsZ
CommonTestZtest_exhausted_iteratorrrrrrrr�LsJ"	(		


 
$
	r�c@s�eZdZedd��Zedd��Zdd�Zejj	dd��Z
d	d
�Zedd��Zd
d�Z
dd�Zdd�Zdd�Ze�ejjd�dd��ZdS)�AssortedBytesTestc	Cs�ttfD]x}|�|t��d�|�|tdg��d�|�|tddddg��d�|�|d�d	�|�|d
�d�|�|d�d
�qdS)N�bytearray(b'')rzbytearray(b'\x00')r2rcrdzbytearray(b'\x00\x01\xfe\xff')r�zb'abc'�'zb"'"s'"zb'\'"')r��reprr!r{r�rrr�
test_repr_strLs�zAssortedBytesTest.test_repr_strc
Csrdtd�fD]`}|�t|�t|��|�t|d�t|��|�tdt�t|�j	���t|d�W5QRXqdS)Nr�rz\b%s\br�)
r{r!r�r�rrhr��escaper"rr$rrr�test_formatWs�zAssortedBytesTest.test_formatcCs�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�dtd�kd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�|�td�dkd�dS)Nr�Tr�Fr`rrrr�test_compare_bytes_to_bytearray`s0z1AssortedBytesTest.test_compare_bytes_to_bytearraycCsH|�tj�|�tj�d�tj�|�tj�|�tj�d�tj�dS)Nz
bytearray(zbytes()ZassertIsNotNoner{�__doc__r�rrarrrr�test_doc}szAssortedBytesTest.test_doccCs,td�}t|�}t|�}|�|t|��dS)NsHello world
����)rar�r{r!)rr��bufr%rrr�test_from_bytearray�sz%AssortedBytesTest.test_from_bytearraycCsp|�td�d�|�td�d�|�td�d�|�ttd��d�|�ttd��d�|�ttd��d	�dS)
Nr0zb''r�zb'x'r�zb'\x80'rzbytearray(b'x')zbytearray(b'\x80'))r!r�r{rrrr�test_to_str�szAssortedBytesTest.test_to_strcCsVddddg}|D]\}}|�|t|d��qtdd�D]}|�ttdt|��q6dS)	N)sWonderful spamzWonderful spam)sWonderful spam toozWonderful spam too)s��uª€)s\xaa\x00\000\200z\xaa\x00\000\200r�rJrAzb"%s")r!r{rPr>�SyntaxError�evalr�)rZtestsr%r�r�rrr�test_literal�s�
�zAssortedBytesTest.test_literalcCs|�d�td��ddg�dS�Nr.r�r�r�)r!r3r�rrrr�test_split_bytearray�sz&AssortedBytesTest.test_split_bytearraycCs|�d�td��ddg�dSr)r!r4r�rrrr�test_rsplit_bytearray�sz'AssortedBytesTest.test_rsplit_bytearraycCst�}|�|�dd�|�dS)Nr0)r{r�r,r$rrr�test_return_self�sz"AssortedBytesTest.test_return_selfz4BytesWarning is needed for this test: use -bb optionc	CsTdd�}|��ddkW5QRX|��ddkW5QRX|��ddkW5QRX|��ddkW5QRX|��td�dkW5QRX|��dtd�kW5QRX|��td�dkW5QRX|��dtd�kW5QRX|��ddkW5QRX|��ddkW5QRX|��ddkW5QRX|��ddkW5QRXdS)NcSstj�dtf�Srrrrrr�
bytes_warning�sz5AssortedBytesTest.test_compare.<locals>.bytes_warningr0rrkr�r{)rrrrrr��s2zAssortedBytesTest.test_compareN)rrrrr	rrrrZrequires_docstringsrrrrrrr�unittestZ
skipUnlessr4�flagsrr�rrrrrGs$






�rc@seZdZdd�Zdd�ZdS)�BytearrayPEP3137TestcCst|�Srr)rr�rrr�marshal�szBytearrayPEP3137Test.marshalcCs�|�d�}dD]4}t||�}|d�}|�||�|�|||d�qdD]*}t|�}|�||�|�|||d�qH|�d�}|�|g�}|�||�|�||�dS)Ns1234)�zfillr\rZrWrLz" returned self on a mutable object)zval.split()[0]zval.rsplit()[0]zval.partition(b".")[0]zval.rpartition(b".")[2]zval.splitlines()[0]zval.replace(b"", b"")z! returned val on a mutable objectr0)r�getattrr!r�rr�)r�valZmethnamerkZnewval�expr�seprrr�test_returns_new_copy�s$

��
z*BytearrayPEP3137Test.test_returns_new_copyN)rrrrr$rrrrr�srcs eZdZ�fdd�ZdZ�ZS)�FixedStringTestcs&t|t�r|�|�d��St��|�S)Nr�)�
isinstancer�r r��super�fixtype)r�obj�r#rrr(�s
zFixedStringTest.fixtypeT)rrrr(Zcontains_bytes�
__classcell__rrr*rr%�sr%c@seZdZeZdS)�ByteArrayAsStringTestN)rrrr{r rrrrr,�sr,c@seZdZeZdS)�BytesAsStringTestN)rrrrar rrrrr-�sr-c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SubclassTestcCs�|�t|j|j��|�|��|j�d\}}|�|�|�|�}}|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||�|�||||�|�||||�|�||||�|�|d|dk�dS)N)r(�efghrl)r��
issubclassr �basetypersr�r!)rr,r%Z_aZ_brrr�
test_basicszSubclassTest.test_basiccCs`|�d�}|���|g�}|�||�|�t|�|jt|��|�dg�}|�t|�|j�dSr')r r1r�r�r$r")r�s1�s2Zs3rrrr�s
zSubclassTest.test_joincCs�|�d�}d|_|�d�|_ttjd�D]�}t�t�||��}|�t	|�t	|��|�
||�|�
|j|j�|�
|j|j�|�
t|�t|��|�
t|j�t|j��q*dS)Nr(r7r/r2)r r��yrPrDrErGrF�assertNotEqual�idr!r")rr,rHr%rrr�test_pickle)s
zSubclassTest.test_picklecCs�|�d�}d|_|�d�|_tjtjfD]x}||�}|�t|�t|��|�||�|�|j|j�|�|j|j�|�t|�t|��|�t|j�t|j��q(dS)Nr(r7r/)	r r�r5r)r*r6r7r!r"r+rrrr-6s
zSubclassTest.test_copycs��j�d�}��|d���t|��j�G�fdd�d�j�}|�d�}��|d���t|�|���|jd�G�fdd�d�j�}|�d�}��|d���t|�|���|jd�dS)Nr�r�cseZdZ�fdd�ZdS)z%SubclassTest.test_fromhex.<locals>.B1cs�j�||�}d|_|S�N�bar)r1�__new__�foo)�clsr�merrrr;Isz-SubclassTest.test_fromhex.<locals>.B1.__new__N)rrrr;rrrr�B1Hsr?r:cseZdZ�fdd�ZdS)z%SubclassTest.test_fromhex.<locals>.B2cs(�jtk	r�jj|f|�|�d|_dSr9)r1rarr<)r>r
�kwargsrrrrTs
z.SubclassTest.test_fromhex.<locals>.B2.__init__N�rrrrrrrr�B2SsrB)r r�r!r$r"r1r<)rr%r?rBrrrr�Cs

zSubclassTest.test_fromhexN)rrrr2r�r8r-r�rrrrr.s



r.c@seZdZdS)�ByteArraySubclassNrrrrrrrC_srCc@seZdZdS)r�Nrrrrrrr�bsr�c@seZdZdS)r�Nrrrrrrr�esr�c@seZdZeZeZdd�ZdS)�ByteArraySubclassTestcCsNGdd�dt�}|dd�}|ddd�}|�|d�|ddd�}|�|d�dS)Nc@seZdZddd�ZdS)z:ByteArraySubclassTest.test_init_override.<locals>.subclassr2c_stj|f|�|�dSr)r{r)r>�newargr
r@rrrrnszCByteArraySubclassTest.test_init_override.<locals>.subclass.__init__N)r2rArrrr�subclassmsrFryr()�source)rErGr)rrFr�rrr�test_init_overridels
z(ByteArraySubclassTest.test_init_overrideN)rrrr{r1rCr rHrrrrrDhsrDc@seZdZeZeZdS)�BytesSubclassTestN)rrrrar1r�r rrrrrIwsrI�__main__)(rir|r�r4r)rrDr�rZtest.supportrZtest.string_testsZtest.list_testsrrrrrrrZTestCaserur�rrZstring_testsZBaseTestr%r,r-r.r{rCrar�r�rDrIr�mainrrrr�<module>sV
gA~]


F1le Man4ger