403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_bytes.cpython-36.pyc
3

�w2_��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
Zddl
mZmZejjr�dd�Zndd�ZGdd�d�ZGd	d
�d
�ZGdd�dee	j�ZGd
d�dee	j�ZGdd�de	j�ZGdd�de	j�ZGdd�dejj�ZGdd�dee	j�ZGdd�dee	j�ZGdd�d�ZGdd�de �Z!Gdd�de"�Z#Gdd �d e"�Z$Gd!d"�d"ee	j�Z%Gd#d$�d$ee	j�Z&e'd%k�r�e	j(�dS)&z�Unit tests for the bytes and bytearray types.

XXX This is a mess.  Common tests should be unified with string_tests.py (and
the latter should be modernized).
�N)�bigaddrspacetest�MAX_Py_ssize_tcstj���fdd��}|S)Nc
s&tjjdtf���||�SQRXdS)N�)�test�support�check_warnings�BytesWarning)�args�kw)�func��4/opt/alt/python36/lib64/python3.6/test/test_bytes.py�wrappersz%check_bytes_warnings.<locals>.wrapper)�	functools�wraps)rrr)rr
�check_bytes_warningssrcCs|S)Nr)rrrr
r sc@seZdZddd�Zdd�ZdS)�	IndexablercCs
||_dS)N)�value)�selfrrrr
�__init__%szIndexable.__init__cCs|jS)N)r)rrrr
�	__index__'szIndexable.__index__N)r)�__name__�
__module__�__qualname__rrrrrr
r$s
rc@seZdZdd�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�S)��
BaseBytesTestcCs.|j�}|jt|�|j�|j|j|j�dS)N)�	type2test�assertEqual�type�	__class__)r�brrr
�test_basics-szBaseBytesTest.test_basicscCsL|jd�}x<tjtjfD],}||�}|j||�|jt|�t|��qWdS)Nsabcd)r�copy�deepcopyrr)r�a�copy_methodrrrr
�	test_copy2s

zBaseBytesTest.test_copycs�|j��|jt��d�|jt�fdd��|jt�fdd��|jt�fdd��|jt�fdd��|jt�fdd��|jt�fdd��|jt�fd	d��|jt�fd
d��|jt�fdd��|jt�fdd��|jt�fd
d��dS)Nrcs�dS)Nrrr)rrr
�<lambda><sz3BaseBytesTest.test_empty_sequence.<locals>.<lambda>cs�dS)N�rr)rrr
r&=scs
�tjS)N)�sys�maxsizer)rrr
r&>scs�tjdS)Nr')r(r)r)rrr
r&?scs�ddS)N�
�drr)rrr
r&@scs�dS)Nr'���rr)rrr
r&Ascs�dS)N����rr)rrr
r&Bscs�tjS)N)r(r)r)rrr
r&Cscs�tjdS)Nr')r(r)r)rrr
r&Dscs�tjdS)Nr-)r(r)r)rrr
r&Escs�ddS)Nr*r+rr)rrr
r&Fs)rr�len�assertRaises�
IndexError)rr)rr
�test_empty_sequence9sz!BaseBytesTest.test_empty_sequencecCs|jtd��}|jt|�d�|jt|�ttd���|jdh�}|j|d�|jddh�}|jt|�ddh�|jttd���}|jt|�d�|jt|�ttd���|jdd�td�D��}|jt|�d�|jt|�ttd��d	dd
��Gdd�d�}|j|��}|j|d
�dS)N��*�*�+�-css|]}|dr|VqdS)r-Nr)�.0�irrr
�	<genexpr>Ysz3BaseBytesTest.test_from_iterable.<locals>.<genexpr>�r'r-c@seZdZdd�ZdS)z+BaseBytesTest.test_from_iterable.<locals>.ScSsd|S)Nr'r-�)r'r-r<r)rr9rrr
�__getitem___sz7BaseBytesTest.test_from_iterable.<locals>.S.__getitem__N)rrrr=rrrr
�S^sr>s)r6r7)r7r6)r�rangerr/�list�assertIn�tuple�iter)rrr>rrr
�test_from_iterableHs "z BaseBytesTest.test_from_iterablecCsT|jttd���}|jt|�d�|jt|�ttd���|jd�}|j|d�dS)Nr3r'r-r<s)r'r-r<)rrBr?rr/r@)rrrrr
�test_from_tupleds

zBaseBytesTest.test_from_tuplecCsZ|jttd���}|jt|�d�|jt|�ttd���|jdddg�}|j|d�dS)Nr3r'r-r<s)rr@r?rr/)rrrrr
�test_from_listls
zBaseBytesTest.test_from_listcs`G�fdd�d�}|�|�g�|jt��d�G�fdd�d�}|�g�|jt��dd�dS)NcseZdZ�fdd�ZdS)z0BaseBytesTest.test_from_mutating_list.<locals>.Xcs�j�dS)Nr4)�clear)r)r#rr
rwsz:BaseBytesTest.test_from_mutating_list.<locals>.X.__index__N)rrrrr)r#rr
�XvsrHr5cseZdZ�fdd�ZdS)z0BaseBytesTest.test_from_mutating_list.<locals>.Ycst��dkr�j|�dS)Ni�r4)r/�append)r)r#rr
r~s
z:BaseBytesTest.test_from_mutating_list.<locals>.Y.__index__N)rrrrr)r#rr
�Y}srJi�)r�bytes)rrHrJr)r#r
�test_from_mutating_listtsz%BaseBytesTest.test_from_mutating_listcCsh|jt�td�td�td�g�}|jt|�ddddg�|jt|jtd�g�|jt|jtd�g�dS)Nr'��rr3r,)rrrr@r0�
ValueError)rrrrr
�test_from_index�s
zBaseBytesTest.test_from_indexcCsd|jtjddddg��}|j|d�|jd�}|j|d�Gdd�dt�}|j|j|d��d�dS)N�Br'r-r<sc@seZdZdd�ZdS)z)BaseBytesTest.test_from_buffer.<locals>.BcSst�dS)N)�	TypeError)rrrr
r�sz3BaseBytesTest.test_from_buffer.<locals>.B.__index__N)rrrrrrrr
rQ�ssfoobar)r�arrayrrK)rr#rQrrr
�test_from_buffer�s
zBaseBytesTest.test_from_buffercCs�|j|jd�d�|j|jd�d�|j|jd�d�|jt|jd
�|j|jdd�d	�|j|jd	�d	�|jt|jtjd�dS)Nr�r'��s�0�ascii�0r,)rrr0rO�
OverflowErrorr(r))rrrr
�test_from_ssize�szBaseBytesTest.test_from_ssizecCs|jt|jd�Gdd�d�}|jt|jdg�|jt|jdg�|jt|jdg�|jt|j|�g�|jt|jdd�|jt|jdd�|jt|jddd	�|jt|jddd	�|jt|jd
�|jt|jd
dd	�|jt|jd
d�|jt|jd
dd�dS)
Ngc@seZdZdS)z5BaseBytesTest.test_constructor_type_errors.<locals>.CN)rrrrrrr
�C�sr]rXrrYrU�ignore)�errorsrsasciisignore)r0rRr)rr]rrr
�test_constructor_type_errors�sz*BaseBytesTest.test_constructor_type_errorscCs�|jt|jdg�|jt|jtjg�|jt|jtjdg�|jt|jtjdg�|jt|jddg�|jt|jdg�|jt|jdg�|jt|jtjg�|jt|jtjdg�|jt|jddg�dS)Nr'r-r*r+r3ir,)r0rOrr(r))rrrr
�test_constructor_value_errors�sz+BaseBytesTest.test_constructor_value_errorscCsFt}|jttf|j|�yt|d�Wnttfk
r@YnXdS)N�)rr0r[�MemoryErrorr�	bytearray)r�sizerrr
�test_constructor_overflow�sz'BaseBytesTest.test_constructor_overflowcCsXGdd�d�}|jt|j|��|jt|j|�g�Gdd�d�}|jt|j|��dS)Nc@seZdZdd�ZdS)z9BaseBytesTest.test_constructor_exceptions.<locals>.BadIntcSsdddS)Nr'rr)rrrr
r�szCBaseBytesTest.test_constructor_exceptions.<locals>.BadInt.__index__N)rrrrrrrr
�BadInt�srgc@seZdZdd�ZdS)z>BaseBytesTest.test_constructor_exceptions.<locals>.BadIterablecSsdddS)Nr'rr)rrrr
�__iter__�szGBaseBytesTest.test_constructor_exceptions.<locals>.BadIterable.__iter__N)rrrrhrrrr
�BadIterable�sri)r0�ZeroDivisionErrorr)rrgrirrr
�test_constructor_exceptions�s
z)BaseBytesTest.test_constructor_exceptionscCs|jdddg�}|jdddg�}|jddg�}|j||�|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)Nr'r-r<)rr�
assertTrue�assertFalse)r�b1�b2Zb3rrr
�test_compare�s&zBaseBytesTest.test_comparecCs�|j|jd�dkd�|j|jd�dkd�|j|jd�dkd�|j|jd�dkd�|j|j�t�kd�|j|j�t�kd�dS)Nsabc�abcFsabcsabcsabcT)rr�str)rrrr
�test_compare_to_str�sz!BaseBytesTest.test_compare_to_strcCs<tttd��}|j|�}tt|��}|j�|j||�dS)N�Hello)r@�map�ordr�reversed�reverser)r�inputr�outputrrr
�
test_reversed�s

zBaseBytesTest.test_reversedcsP�fdd�}|d�}�j|dd�|d���j|dd�|d���j|dd�|d	���j|dd�|d
���j|dd�|d
���j|dd�|d
���j|dd�|d���j|dd�|d���j|dd�|d	���j|dd�|d
���j|dd�|d
���j|dd�|d
���j|dd�|d��dS)Ncs�jtt|��S)N)rrurv)�s)rrr
�bysz'BaseBytesTest.test_getslice.<locals>.byzHello, worldrWrtr'Zello�z, �world�r+�i����i����i����i�������r�r�r�i����)r)rr}rr)rr
�
test_getsliceszBaseBytesTest.test_getslicec
Csvttd��}|j|�}d
}xV|D]N}xH|D]@}x:|dd�D]*}|j||||�|j||||���q<Wq*Wq WdS)NrNrr'r<�r+r-�r,r.������)
rNr'r<r�r+r,r.r�r�)r@r?rr)r�Lr�indices�start�stop�steprrr
�test_extended_getslices


z$BaseBytesTest.test_extended_getslicecCsvd}x0dD](}|j||�}|j||j|j|���q
W|jt|j|d�|j|dd�}|j||j|dd�d��dS)	NuHello world
ሴ噸骼�utf-8�utf-16zlatin-1r^r<)r�r����)rr�encoder0�UnicodeEncodeError)r�sample�encrrrr
�
test_encoding%s
zBaseBytesTest.test_encodingcCs�d}x*dD]"}|j||�}|j|j|�|�q
Wd}|j|d�}|jt|jd�|j|jdd�d�|j|jddd�d�|j|jd	�j�d
�dS)NuHello world
ሴ噸骼�utf-8�utf-16uHello world
€þÿzlatin-1r^zHello world
)r_�encodings☃u☃)r�r�)rr�decoder0�UnicodeDecodeError)rr�r�rrrr
�test_decode.s
zBaseBytesTest.test_decodecCsb|jd�}|j||j��|jd�}|j||jdgd��|jd�}|j||jdgd��dS)Nrr*i')rr)rrrrr
�
test_from_int<s


zBaseBytesTest.test_from_intcsx|jd��|jd��|j��d�|j�td�d�|jtd��d�|jt�fdd��|jt�fdd��dS)Nsabcsdefsabcdefsdefabccs�dS)N�defrr)rnrr
r&Jsz+BaseBytesTest.test_concat.<locals>.<lambda>csd�S)Nrqrr)rorr
r&Ks)rrrKr0rR)rr)rnror
�test_concatDs

zBaseBytesTest.test_concatcs�x�d|jd�fD]��|j�dd�|j�dd�|j�d
d�|jt�fdd��|jt�fd	d��|jttf���tj}WdQRX|jttf���tj9�WdQRXqWdS)Nsabcr<s	abcabcabcrrUr'cs�dS)Ng��Q�	@rr)rrr
r&Rsz+BaseBytesTest.test_repeat.<locals>.<lambda>csd�S)Ng��Q�	@rr)rrr
r&Ssr,)rrr0rRr[rcr(r))r�cr)rr
�test_repeatMszBaseBytesTest.test_repeatcCs*|j|jd�d|jtd�gd��dS)N�xr+�x)rrrv)rrrr
�test_repeat_1charZszBaseBytesTest.test_repeat_1charcsx|jd��|jtd���|jttd����|jd��|jt�fdd��|jt�fdd��|jt�fdd��|jt�fdd��|jt�fd	d��|jt�fd
d��x�tt	fD]�}|j|d���|j|d���|j|d
���|j|d���|j|d���|j|d���|j|d���|j|d���|j|d���|j|d���|j|d���q�WdS)Nsabcr#��csd�kS)Ni,rr)rrr
r&bsz-BaseBytesTest.test_contains.<locals>.<lambda>csd�kS)Nr'r,rr)rrr
r&cscstjd�kS)Nr')r(r)r)rrr
r&dscsd�kS)Nrr)rrr
r&escsttd���kS)Nr#)�floatrvr)rrr
r&fscsd�kS)Nr#rr)rrr
r&gsrU�a�b�csabsbcsac�dsdabsabd)
rrArv�intZassertNotInr0rOrRrKrd)r�fr)rr
�
test_contains]s,
zBaseBytesTest.test_containscCs@|jt|jj�|jt|jjd�|j|jjd�|j��tdddg�}|j|jjd�|�|j|jjd�|�|j|jjd�d	�|jt|jjd
�|jt|jjd�|jt|jjd�|jt|jjd
�|jt|jjd�|jt|jjd�xJdD]B\}}|jt��}|jj|�WdQRX|jd|t|j	���q�WdS)Nr'r�r6�0�1a2B30z  1A 2B  30   Z0000ss1Br#Zrtz1a b cd�z12      34�12 x4 56r<�12 3x 56rb�12 xy 56�	12 3ÿ 56zat position %s�r�r<�r�rb�r�r<�r�rb)r�r�r�r�)
r0rRr�fromhexrrdrOrArr�	exception)rr�data�pos�cmrrr
�test_fromhexus*zBaseBytesTest.test_fromhexcCs�|jt|jj�|jt|jjd�|j|jd�j�d�|jtdddg�j�d�|j|jd�j�d�|jtd�j�d�dS)	Nr'rUrr�r6r�Z1a2b30s+0)r0rRr�hexrrd�
memoryview)rrrr
�test_hex�szBaseBytesTest.test_hexcCs�|j|jd�jg�d�|j|jd�jdg�d�x�dgddgddgdddggD]d}tt|j|��}|j|jd�j|�d�|j|jd�jt|��d�|j|jd�jt|��d�qPW|jd�j}|j|dd	g�d
�|j|td�d	g�d
�|j|dtd	�g�d
�|j|td�d	g�d
�|j|dtd	�g�d
�dgd}ddd
}|j||�|�|j	t
|jd�jd�|j	t
��|td�ddg�WdQRX|j	t
��|td�ddg�WdQRXdS)NrUsabcr�sbcsabr�r�s.:scdsab.:cdi�s.:abci�� Zcdsef)rr�joinr@rurBrCr�rdr0rR)rZlstZdot_join�seqZexpectedrrr
�	test_join�s*" 
zBaseBytesTest.test_joincCs|jd�}d}d}d}|j|jd�d�|j|jd�d�|j|jd	�d
�|j|j|�d�|j|j|�d
�|j|jdd�d�|j|jdd�d�|j|jdd
d�d
�|j|jddd�d
�|j|j|d�d�|j|j|d�d�|j|j|d
d�d
�|j|j|dd�d
�dS)Nsmississippi�i�p�w�irbsssr-�wr��pr'r<r~�	)rr�count)rrr9�p�wrrr
�
test_count�s"
zBaseBytesTest.test_countc
Cs�|jd�}|j|j�jd��|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��|jt��}|jdg�WdQRXt|j�}|jd|�|jd|�dS)	Nshellosanythingshel�hshellowsharKrB)	rrm�
startswithrlr0rRrrr�rA)rrr��excrrr
�test_startswith�s

zBaseBytesTest.test_startswithc
Cs�|jd�}|jt�jd��|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��|jt��}|jdg�WdQRXt|j�}|j	d|�|j	d|�dS)	Nshellosanythingsllo�oswhellosnorKrB)
rrmrd�endswithrlr0rRrrr�rA)rrr�r�rrr
�
test_endswith�s

zBaseBytesTest.test_endswithcCs|jd�}d}d}|j|jd�d�|j|jd�d�|j|jd�d�|j|j|�d�|j|j|�d�|j|jdd	�d
�|j|jddd�d�|j|jddd	�d�|j|j|d�d�|j|j|dd	�d�|j|j|dd	�d�x,dd
tjdfD]}|jtd|j|��q�WdS)Nsmississippir�r�sssr-r�r's
mississippianr<rWr~r�r3zbyte must be in range\(0, 256\)r,r,r,r,r,r,)rr�findr(r)�assertRaisesRegexrO)rrr9r��indexrrr
�	test_find�s$
zBaseBytesTest.test_findcCs�|jd�}d}d}|j|jd�d�|j|jd�d�|j|jd�d�|j|j|�d	�|j|j|�d�|j|jdd
�d�|j|jddd�d
�|j|j|dd
�d�|j|j|d
d�d�|j|j|dd
�d�dS)Nsmississippir�r�sssrWr�r's
mississippianr*r<rr�r-r�r~r,r,r,r,)rr�rfind)rrr9r�rrr
�
test_rfinds
zBaseBytesTest.test_rfindcCs�|jd�}d}d}|j|jd�d�|jt|jd�|jt|jd�|j|j|�d�|jt|j|�|j|jdd	�d
�|j|jddd�d�|jt|jddd	�|j|j|d�d�|j|j|dd	�d�|jt|j|dd	�dS)
Nsmississippir�r�sssr-r�s
mississippianr'r<rWr~r�)rrr�r0rO)rrr9r�rrr
�
test_indexs
zBaseBytesTest.test_indexcCs�|jd�}d}d}|j|jd�d�|jt|jd�|jt|jd�|j|j|�d�|jt|j|�|j|jdd	�d�|j|jdd
d�d�|j|j|d
d	�d
�|j|j|d	d�d�|jt|j|d
d	�dS)Nsmississippir�r�sssrWr�s
mississippianr*r<rr�r-r'r�r~)rr�rindexr0rO)rrr9r�rrr
�test_rindex's
zBaseBytesTest.test_rindexcCs�|jd�}|}|d}|j|d�|j|d�|j||k�|jd�}|d
}|j|d�|jt|�|j�|jd�}|d}|j|d	�|jt|�|j�dS)Ns
hello, %b!sworlds
hello, world!s%s / 100 = %d%%�seventy-nine�Osseventy-nine / 100 = 79%s
hello,%b!s
hello,world!)r�r�)rrrm�assertIsr)rr�origr#rrr
�test_mod:s


zBaseBytesTest.test_modcCs�|jd�}|}|d;}|j|d�|j|d�|j||k�|jd�}|d
;}|j|d�|jt|�|j�|jd�}|d;}|j|d	�|jt|�|j�dS)Ns
hello, %b!sworlds
hello, world!s%s / 100 = %d%%�seventy-niner�sseventy-nine / 100 = 79%s
hello,%b!s
hello,world!)r�r�)rrrmr�r)rrr�rrr
�	test_imodKs


zBaseBytesTest.test_imodc
CsB|jt��t�|jd�WdQRX|j|jd�jd�t�dS)Nsabcz%r)r0rR�objectrr��__rmod__�NotImplemented)rrrr
�	test_rmod\szBaseBytesTest.test_rmodcCs6|jd�}|j|jdd�d�|j|jdd�d�dS)Nsmississippir�r�smassassappasssr�s	mixixippi)rr�replace)rrrrr
�test_replaceas
zBaseBytesTest.test_replacecCs|jt|jd�jdd�dS)Nsa b� rU)r0rRrr�)rrrr
�test_replace_int_errorfsz$BaseBytesTest.test_replace_int_errorcCs0|jt|jd�jd�|jt|jd�jd�dS)Nsa b� )r0rRr�split�rsplit)rrrr
�test_split_string_errorisz%BaseBytesTest.test_split_string_errorcCs0|jt|jd�jd�|jt|jd�jd�dS)Nsa br�)r0rRrr�r�)rrrr
�test_split_int_errormsz"BaseBytesTest.test_split_int_errorcCsJx(dD] }|j|�}|j|j�|g�qW|jd�}|j|j�dg�dS)N�ab�ab�ab�abs		

s)r�r�r�r�)rrr�)rrrrr
�test_split_unicodewhitespaceqs



z*BaseBytesTest.test_split_unicodewhitespacecCs |jd�}|j|j�dg�dS)Ns		

s)rrr�)rrrrr
�test_rsplit_unicodewhitespacexs
z+BaseBytesTest.test_rsplit_unicodewhitespacecCs2|jd�}|j|jd�d�|j|jd�d�dS)	N�mississippi�ss�mi�issippir�rU)r�r�r�)r�rUrU)rr�	partition)rrrrr
�test_partition|s
zBaseBytesTest.test_partitioncCsD|jd�}|j|jd�d	�|j|jd�d
�|j|jd�d�dS)N�mississippi�ss�missi�ippir��
mississipprUr�)rrr)rr�rU)rUrUr)rr�
rpartition)rrrrr
�test_rpartition�s
zBaseBytesTest.test_rpartitioncCs0|jt|jd�jd�|jt|jd�jd�dS)Nsa br�)r0rRrrr)rrrr
�test_partition_string_error�sz)BaseBytesTest.test_partition_string_errorcCs0|jt|jd�jd�|jt|jd�jd�dS)Nsa br�)r0rRrrr)rrrr
�test_partition_int_error�sz&BaseBytesTest.test_partition_int_errorcCsVxPttjd�D]>}x8dD]0}|j|�}tj||�}tj|�}|j||�qWqWdS)Nr'rUr��abc��ab���)rUr�rrr
)r?�pickle�HIGHEST_PROTOCOLr�dumps�loadsr)r�protorZps�qrrr
�
test_pickling�s


zBaseBytesTest.test_picklingcCs�x�ttjd�D]�}x�dD]�}t|j|��}}t|j|��}tj||�}tj|�}|jt	|�t	|��|jt|�|�tj|�}|s�qt
|�tj||�}tj|�}|jt|�|dd��qWqWdS)Nr'rUr��abc��ab���)rUr�rrr)r?rrrCrr@rrrr�next)rrr�itZitorgr��drrr
�test_iterator_pickling�s



z$BaseBytesTest.test_iterator_picklingcCsX|j|jd�jtd��d�|j|jd�jtd��d�|j|jd�jtd��d�dS)Nsabcsacr�sbcsab)rr�stripr��lstrip�rstrip)rrrr
�test_strip_bytearray�sz"BaseBytesTest.test_strip_bytearraycCsF|jt|jd�jd�|jt|jd�jd�|jt|jd�jd�dS)NsabcZac)r0rRrrrr)rrrr
�test_strip_string_error�sz%BaseBytesTest.test_strip_string_errorcCsF|jt|jd�jd�|jt|jd�jd�|jt|jd�jd�dS)Ns abc r�)r0rRrrrr)rrrr
�test_strip_int_error�sz"BaseBytesTest.test_strip_int_errorcCs>|jd�}x.ttfD]"}|j|jd|d��|jd��qWdS)Nsabcr~�-s--abc--)rrKrdr�center)rr�	fill_typerrr
�test_center�s
zBaseBytesTest.test_centercCs>|jd�}x.ttfD]"}|j|jd|d��|jd��qWdS)Nsabcr~r"sabc----)rrKrdr�ljust)rrr$rrr
�
test_ljust�s
zBaseBytesTest.test_ljustcCs>|jd�}x.ttfD]"}|j|jd|d��|jd��qWdS)Nsabcr~r"s----abc)rrKrdr�rjust)rrr$rrr
�
test_rjust�s
zBaseBytesTest.test_rjustcCsL|jt|jd�jdd�|jt|jd�jdd�|jt|jd�jdd�dS)Nsabcr~r�)r0rRrr#r&r()rrrr
�test_xjust_int_error�sz"BaseBytesTest.test_xjust_int_errorcs:|jd��|j�fdd�tt���D�dddddg�dS)	NsA��cs g|]}t�||d���qS)r')rv)r8r9)rrr
�
<listcomp>�sz*BaseBytesTest.test_ord.<locals>.<listcomp>r�A�r;rN)rrr?r/)rr)rr
�test_ord�s
zBaseBytesTest.test_ordcCs`d}|j|jjdd�|�d}|j|jjdd�|�|jt|jjdd�|jt|jjdd�dS)	Ns	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`xyzdefghijklmnopqrstuvwxyz{|}~�����������������������������������������������������������������������������������������������������������������������������sabcsxyzs	

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~��������������������������������������������������������������������������������������������������������������������������xyzs���sxyzqrqr�)rr�	maketransr0rOrR)rZ
transtablerrr
�test_maketrans�szBaseBytesTest.test_maketranscCs�|jd�}|jd�}|jd�}|jd�}|jd�}|jd|j|d��|jd|j|dd��|jd|j|dd
��|jd|j|dd��|jd|j|d��|jd|j|dd��|jd|j|dd��|jd|j|dd��|jd|j|d��|jd|j|dd��|jd|j|dd��|jd|j|dd��|jd|j|d��|jd|j|dd��|jd|j|dd��|jd|j|dd��|jd|j|d��|jd	|j|dd��|jd	|j|dd��|jd|j|dd��|jd
|j|d��|jd
|j|dd��|jd
|j|dd��|jd|j|dd��|jd
|j|d��|jd
|j|dd��|jd
|j|dd��|jd|j|dd��dS)Nshello�lr�r�r�r-r<rr'TFr.r.r.r.r.r.r.r.r.r.r.r.r.r.)	rrr�r�r�r�r�r�r�)rr�l�hr��orrr
�test_none_arguments�sB




z!BaseBytesTest.test_none_argumentscCsZ|jd�}xJ|j|j|j|j|jfD].}|jt|d�|jt|d�|jt|d�q$WdS)Nshellor'r3i'r,)rr�r�r�r�r�r0rO)rr�methodrrr
�(test_integer_arguments_out_of_byte_range
s

z6BaseBytesTest.test_integer_arguments_out_of_byte_rangecCs�|jd�}|jd�}|jtd|j|ddd�|jtd|j|ddd�|jtd|j|ddd�|jtd|j|ddd�|jtd|j|ddd�|jtd|j|ddd�|jtd	|j	|ddd�dS)
Nshellor�z\bfind\bz	\brfind\bz	\bindex\bz
\brindex\bz	\bcount\bz\bstartswith\bz\bendswith\b)
rr�rRr�r�r�r�r�r�r�)rrr�rrr
�*test_find_etc_raise_correct_error_messagess 

z8BaseBytesTest.test_find_etc_raise_correct_error_messagescCs(tjj|t|j�tjj|t|j�dS)N)rrZcheck_free_after_iteratingrCrrw)rrrr
�test_free_after_iterating%sz'BaseBytesTest.test_free_after_iteratingcCs4|jd�}ttd��}td�|td�<|jt|j�|jt|jdd�|jt|jttd���|j|d�}|j	|d�|j
||j�|j|�}|j|d�}|j	||�|j	|d�|j|d�}|j	|d	�|jdd
�}|j	|d�|j|dd�}|j	|d�|j|dd�}|j	|d	�|jdd
d�}|j	|d�dS)
Nshellor3�er4rNrUsheller1shee�eshllo)�delete)rrdr?rvr0rR�	translaterOrKr�assertIsInstance)rrZrosettar�rrrr
�test_translate)s.

zBaseBytesTest.test_translateN)Frrrr r%r2rDrErFrLrPrTr\r`rarrfrkrprrsr{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	r
rrrr r!r%r'r)r*r.r0r5r7r8r9r?rrrr
r+s�
		
+rc@s8eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)�	BytesTestc	Cs(d}|jt|��ddWdQRXdS)Nz'byte indices must be integers or slicesspythonr#)r�rR)r�msgrrr
�test_getitem_errorLszBytesTest.test_getitem_errorcCs<tjttj�}t|ddd��}|jt|jd�WdQRXdS)N�rbr)�	bufferingrU)�os�open�__file__�O_RDONLYr0rR�readinto)r�fdr�rrr
�test_buffer_is_readonlyQsz!BytesTest.test_buffer_is_readonlycCsGdd�d�}|jt|��d�Gdd�d�}|jtt|��Gdd�d�}|jtt|��Gdd�d�}|jt|��d�Gdd�dt�}|jt|d	��d�|jt|d	�d
�d�Gdd�d�}|jt|��d�|jtt|���t�|jt|��d�|jtt|���t�dS)
Nc@seZdZdd�ZdS)z BytesTest.test_custom.<locals>.AcSsdS)Nsabcr)rrrr
�	__bytes__Xsz*BytesTest.test_custom.<locals>.A.__bytes__N)rrrrLrrrr
�AWsrMsabcc@seZdZdS)z BytesTest.test_custom.<locals>.AN)rrrrrrr
rM[sc@seZdZdd�ZdS)z BytesTest.test_custom.<locals>.AcSsdS)Nr)rrrr
rL^sz*BytesTest.test_custom.<locals>.A.__bytes__N)rrrrLrrrr
rM]sc@seZdZdd�Zdd�ZdS)z BytesTest.test_custom.<locals>.AcSsdS)Nr�r)rrrr
rLbsz*BytesTest.test_custom.<locals>.A.__bytes__cSsdS)Nr4r)rrrr
rdsz*BytesTest.test_custom.<locals>.A.__index__N)rrrrLrrrrr
rMasr�c@seZdZdd�ZdS)z BytesTest.test_custom.<locals>.AcSsdS)Nsabcr)rrrr
rLisz*BytesTest.test_custom.<locals>.A.__bytes__N)rrrrLrrrr
rMhsu€z
iso8859-15��c@seZdZdd�ZdS)z BytesTest.test_custom.<locals>.AcSstd�S)Nsabc)�OtherBytesSubclass)rrrr
rLosz*BytesTest.test_custom.<locals>.A.__bytes__N)rrrrLrrrr
rMns)	rrKr0rRrrr�rrO�
BytesSubclass)rrMrrr
�test_customVs zBytesTest.test_customcsRtjjd�}tjjd�}ddlm}m}ddlm}m}m}m	}m
}	m}
m}|j
}||_|j|d�d�|j|dd�d	�|j|d
|d��d�|j|d
|td���d
�|j|d
|d��d�|j|d|d�|d�|	d��d�|j|d|dE�|dF�|	dG��d�|j|d|d�|d�|	d��d�|j|d|d��d�|j|d|dH��d�|j|d|d��d �|j|�}
tjd!k�r�d"jd|
���fd#d$�}nd%d$�}d&}|j|d'||��d(||�jd)��|j|d*|d+��d,�|	dI�j}x�d-||jtfd-||jtfd.||jtfd.||jtfd/||jtfd0|
|jtfd0|
|jtfd1|	|tfd2|||ff	D]0\}}}}|j||||��||�jd)��f�qXW|j|d3d4�d4�|j|d5d6�d7�|j|d8�d9�|j|d:�d;�|j|d<|td=���d>�|j|d?�d@�|j|d9�d9�|j|dA|d�|d��dB�|jt |dC|dJ��|jt |dC|dD��dS)KN�ctypes�	_testcapir)�	pythonapi�	py_object)�c_int�c_uint�c_long�c_ulong�c_size_t�	c_ssize_t�c_char_psformats
Hello %s !sworlds
Hello world !sc=%csc=�@sc=@rNsc=�sd=%d ld=%ld zd=%zdr'r-r<s
d=1 ld=2 zd=3sd=-1 ld=-2 zd=-3su=%u lu=%lu zu=%zu�{i�isu=123 lu=456 zu=789si=%isi=123si=-123sx=%xi�
sx=abc�ntz0x%0{}Xcs�|S)Nr)�ptr)�
ptr_formatrr
�
ptr_formatter�sz1BytesTest.test_from_format.<locals>.ptr_formattercSsd|S)Nz%#xr)r`rrr
rb�si�ͫsptr=%pzptr=rYss=%sscstrss=cstrs%ds%lds%lus%zds%zus%ps%5sr�s%.3ssabcdefsabcs%%�%s[%%]s[%]s%%%c�_s%_s%%ss%ssx=%i y=%sx=2 y=%s%cr3r,r.r�i����r,r,)!rr�
import_modulerRrTrUrVrWrXrYrZr[r\�PyBytes_FromFormatZrestyperrvZsizeofrE�name�formatr�rZINT_MINrrZINT_MAXZLONG_MINZLONG_MAXZ	ULONG_MAXZPY_SSIZE_T_MINZPY_SSIZE_T_MAXr0r[)rrRrSrTrUrVrWrXrYrZr[r\rfZ
sizeof_ptrrbr`Zsize_maxZ	formatstrZctypes_typerZpy_formatterr)rar
�test_from_formatws�$






zBytesTest.test_from_formatcCs�Gdd�dt�}ddddg}|jt|�d�|jtt||��Gdd	�d	t�}|jtd�d
�|jtt|d��Gdd�dt�}|jtd
�d
�|jtt|d
��Gdd�dt�}td
�|d
�}}|jt|�d
�|jtt|�dS)Nc@seZdZdZdS)z7BytesTest.test_bytes_blocking.<locals>.IterationBlockedN)rrrrLrrrr
�IterationBlocked�srjrr'r-r<sc@seZdZdZdS)z1BytesTest.test_bytes_blocking.<locals>.IntBlockedN)rrrrLrrrr
�
IntBlocked�srksc@seZdZdZdS)z;BytesTest.test_bytes_blocking.<locals>.BytesSubclassBlockedN)rrrrLrrrr
�BytesSubclassBlocked�srlsabc@seZdZdZdS)z4BytesTest.test_bytes_blocking.<locals>.BufferBlockedN)rrrrLrrrr
�
BufferBlocked�srm)r@rrKr0rRr�rd)rrjr9rkrlrm�ba�bbrrr
�test_bytes_blocking�szBytesTest.test_bytes_blockingN)
rrrrKrrBrKrQrirprrrr
r@Is!kr@c@s*eZdZeZdd�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+dCS)D�
ByteArrayTestc	Cs,d}|jt|��td�dWdQRXdS)Nz,bytearray indices must be integers or slicesspythonr#)r�rRrd)rrArrr
rBsz ByteArrayTest.test_getitem_errorc
Cs0d}|jt|��td�}d|d<WdQRXdS)Nz,bytearray indices must be integers or slicesspython�pythonr#)r�rRrd)rrArrrr
�test_setitem_error	sz ByteArrayTest.test_setitem_errorcCs|jttt��dS)N)r0rR�hashrd)rrrr
�test_nohashszByteArrayTest.test_nohashc.Csd}|ddt|�}tj�}z�t|d��}|j|�WdQRXt|d��}td�}|j|�}WdQRX|j|t|��|jt|�t|��t|d��}|j|�WdQRXt|d��}|j|j	�|�WdQRXWdyt
j|�Wntk
r�YnXXdS)NsHello world
rV��wbrC)
r/�tempfileZmktemprF�writerdrIrr@�readrE�remove�OSError)rZshort_sampler�Ztfnr�r�nrrr
�test_bytearray_apis&z ByteArrayTest.test_bytearray_apicCs\td�}|j|j�d�|j|d�td�}|j�|j|d�t�}|j�|j|�dS)Nshellosollehshello1s1olleh)rdrrxrm)rrrrr
�test_reverse,szByteArrayTest.test_reversecCsttd�}|j�|j|d�td�}|j�|j|d�td�}|jtd��|j�|jtd��|j|d�dS)NspythonrU�rr�r�)rdrGrrIrv)rrrrr
�
test_clear7szByteArrayTest.test_clearcCs�td�}|j�}|j|d�td�}|j�}|j|d�td�}|j�}|j||�|j||�|jtd��|j|d�|j|d�dS)NsabcrUrsabcd)rdr!r�assertIsNotrIrv)rrrorrr
r%FszByteArrayTest.test_copycCs4dd�}|d�}|jtjd|�|d�|d�g�dS)NcSsttt|��S)N)rdrurv)r|rrr
r}Ysz&ByteArrayTest.test_regexps.<locals>.byzHello, worlds\w+rtr)r�re�findall)rr}rrrr
�test_regexpsXszByteArrayTest.test_regexpsc+CsTtdddg�}d|d<|j|tdddg��d|d<|j|tdddg��td�|d<|j|tdddg��yd|d<|jd�Wntk
r�YnXyd|d
<|jd�Wntk
r�YnXyd	|d<|jd
�Wntk
r�YnXytd�|d<|jd
�Wntk
�r YnXyd|d<|jd�Wntk
�rNYnXdS)Nr'r-r<r+r�r*rzDidn't raise IndexErrorr3zDidn't raise ValueErrorzDidn't raise TypeErrorr,i����r,)rdrr�failr1rOrR)rrrrr
�test_setitem^s@zByteArrayTest.test_setitemc
Cslttd��}|d=|j|ttdd���|d=|j|ttdd���|d=|j|tdddddd	d
g��dS)Nr*rr'r�rbr-r<r�r~�r,)rdr?r)rrrrr
�test_delitem�szByteArrayTest.test_delitemcCs\ttd��}|jt|�ttd���tdddddg�|dd�<|j|tddddddddddg
��|dd�=|j|tdddddg��tddd	d
dg�|dd�<|j|ttd���tdd
g�|dd�<|j|tddd	dd
dddg��d
dddg|d
d�<|j|ttd���dddg|d
d�<|j|tddd	dddd
ddddddg
��d|d
d�<|j|tddd	dddg��td�|dd
�<|j|tddddddg��g|d
d�<|j|tdddddg��xPdd dtd�ddddgddgggg	D](}|jt��||d
d�<WdQRX�q�Wx>dddgd!dggD](}|jt��||d
d�<WdQRX�q,WdS)"Nr*r'rrWr�r~r�r�r-r<rbr+�er4sfoo�f�ogP����KDrrgffffff@r#rr�r�rMrNr3i(#r�i����r�r�i���)	rdr?rr@r�r�r0rRrO)rr�elemrrr
�
test_setslice�s6$
 *zByteArrayTest.test_setslicecCsvttd��}|jt|�ttd���|dd�=|jt|�ttdd���|jtdd��|jt|�ttdd���dS)Nr+r*�n)rdr?rr@�extend)rrrrr
�test_setslice_extend�s
z"ByteArrayTest.test_setslice_extendcCs,td�}|j�|dd�=|td�7}~dS)Nr*r'r-)rd�poprK)rrrrr
�test_fifo_overrun�s

zByteArrayTest.test_fifo_overruncCs2td�}tj|�}|dd�=|jtj|�|�dS)Nr*r')rdr(�	getsizeof�assertLessEqual)rrrerrr
�test_del_expand�s

zByteArrayTest.test_del_expandcCs�dddddddd>d
ddd
f}x�|D]�}x�|D]�}x�|dd�D]�}ttd	��}t|�}||||�}|j�|||||�<|||||�<|j|t|��||||�=||||�=|j|t|��q@Wq.Wq$WdS)Nrr'r<r�i,iMr-r�rNr,r.i��i���)r@r?rdrxr)rr�r�r�r�r�rr�rrr
�test_extended_set_del_slice�s

z)ByteArrayTest.test_extended_set_del_slicecCs@ttd��}||dd�<|j|tttd��ttd����dS)Nr3r�)rdr?rr@)rrrrr
�test_setslice_trap�sz ByteArrayTest.test_setslice_trapcCs~td�}|}|d7}|j|d�|j||�|j||k�|d7}|j|d�y|d7}Wntk
rnYnX|jd�dS)Nsabcsdefsabcdefsxyzs	abcdefxyzrz'bytes += unicode didn't raise TypeError)rdrrlrRr�)rrrnrrr
�test_iconcat�szByteArrayTest.test_iconcatcCs>td�}|}|d9}|j|d�|j||�|j||k�dS)Nsabcr<s	abcabcabc)rdrrl)rrrnrrr
�test_irepeat�szByteArrayTest.test_irepeatcCsBtd�}|}|d9}|j|dd�|j||�|j||k�dS)Nr�r+)rdrrl)rrrnrrr
�test_irepeat_1char�sz ByteArrayTest.test_irepeat_1charcCsjt�}|j�}|j|dk�|g}xBtd�D]6}|d7}|j�}|j|t|��||kr,|j|�q,WdS)Nrr+r�)rd�	__alloc__rlr?�
assertGreaterr/rI)rr�allocr�r9rrr
�
test_allocszByteArrayTest.test_alloccsft����fdd�}�j|���jt��ttdd����jt��d��j�}�j|t���dS)Nc3s�xztdd�D]l}|Vt��}�j|ttdt|�d����jt��t|���jt��|��j�}�j|t���qWdS)Nr'r+)r?r@rr/r�r�r�)r9r#r�)rrrr
�gsz(ByteArrayTest.test_init_alloc.<locals>.gr'r+�c)rdrrr@r?r/r�r�)rr�r�r)rrr
�test_init_allocs	zByteArrayTest.test_init_alloccCs�d}t|�}|j|�|j|||�|j|dd�|�td�}|jtt|d��|jdd�|dD��|j||d�|j|dd�|�td�}|jttt|d���|j||d�|j|dd�|�td�}|jttt|d���|j||d�|j|dd�|�td�}|jt|jdd	d
dg�|jt|jdd	d
dg�|jt	|�d�td�}|jt
td��g�|j|d
�dS)NshellorWrU�css|]}t|�VqdS)N)r�)r8r�rrr
r:+sz,ByteArrayTest.test_extend.<locals>.<genexpr>�2rr'r-r3r#r�r�r�r�r,)rdr�rrur�rCr@r0rOr/rrv)rr�r#rrr
�test_extend"s2
zByteArrayTest.test_extendcs$td���jtd��|j�d��jtd��|j�d�|jt�fdd��|jt�fdd��|jt�fdd���jtd	���jtd
��|j�d�|jt�fdd���jttd
���|j�d�tddddg�}|jd�|j|tdddg��|jd�|j|tddg��dS)Nshellor2shelosheocs�jtd��S)Nr2)r{rvr)rrr
r&Dsz+ByteArrayTest.test_remove.<locals>.<lambda>cs
�jd�S)Ni�)r{r)rrr
r&Escs
�jd�S)Nr:)r{r)rrr
r&Fsr4r3r;cs
�jd�S)Nr;)r{r)rrr
r&Ksr:rU�~r-r;�)	rdr{rvrr0rOrRrrK)rr�r)rr
�test_remove>s&

zByteArrayTest.test_removecs�td��|j�j�td��|j�jd�td��|j�jd�td��|jt�fdd��|jtd	d��|jtd
�j�d�dS)
Nsworldrrr�r-r�cs
�jd�S)Nr*)r�r)rrr
r&[sz(ByteArrayTest.test_pop.<locals>.<lambda>cSs
t�j�S)N)rdr�rrrr
r&\s��rNr.)rdrr�rvr0r1)rr)rr
�test_popVszByteArrayTest.test_popcCs|jtdd��dS)NcSs
t�j�S)N)rd�sortrrrr
r&asz+ByteArrayTest.test_nosort.<locals>.<lambda>)r0�AttributeError)rrrr
�test_nosort`szByteArrayTest.test_nosortcs�td���jtd��|j�d�|j�jd�d�t���jtd��|jt��d�|jt�fdd��t���jttd���|j�d	�dS)
Nshellr4shellor+rMr'cs
�jd�S)Nr�)rIr)rrr
r&ksz+ByteArrayTest.test_append.<locals>.<lambda>�A)rdrIrvrr/r0rRr)rr)rr
�test_appendcszByteArrayTest.test_appendcs�td���jdtd���jdtd���jd
td���jdtd��|j�d�|jt�fdd	��t���jd
ttd���|j�d�dS)Nsmssssppr'r9rbr-i�smississippics�jdd�S)Nr�1)�insertr)rrr
r&wsz+ByteArrayTest.test_insert.<locals>.<lambda>rrMr�r.)rdr�rvrr0rRr)rr)rr
�test_insertpszByteArrayTest.test_insertcCsVtd�}|j||jddd�k�tdd�td�D��}td�}|j||j|�k�dS)NsabcscdercSsg|]}|�qSrr)r8r9rrr
r+�sz-ByteArrayTest.test_copied.<locals>.<listcomp>r3rU)rdrmr�r?r=)rr�tr�rrr
�test_copied|s
zByteArrayTest.test_copiedcCs�td�jd�\}}}|j|d�|j|d�|j||k	�|d7}|j|d�td�jd�\}}}|j|d�|j|d�td�jd�\}}}|j|d�|j|d�|j||k	�|d7}|j|d�td�jd�\}}}|j|d�|j|d�dS)Nr��yrU�!)rdrrrlr)rr#rr�rrr
�0test_partition_bytearray_doesnt_share_nullstring�s$z>ByteArrayTest.test_partition_bytearray_doesnt_share_nullstringcs
ttd���t��}�fdd�}|d��dd�}|jt|d�|j�|�|jt|d�|j�|�|jt|d�|j�|�|jt�jd�|j�|�|jt�j�d�|j�|��fdd	�}|jt|�|j�|��fd
d�}|jt|�|j�|�dS)Nr*cs"t|dd|d��dd�<dS)Nr'r-r,)r?)r})rrr
�resize�sz3ByteArrayTest.test_resize_forbidden.<locals>.resizer�r�rr'cs
�d=dS)Nr'rr)rrr
�delitem�sz4ByteArrayTest.test_resize_forbidden.<locals>.delitemcsd�ddd�<dS)NrUr'r-r,rr)rrr
�delslice�sz5ByteArrayTest.test_resize_forbidden.<locals>.delslice)rdr?r�r0�BufferErrorrr�r{)r�vr�r�r�r�r)rr
�test_resize_forbidden�s*z#ByteArrayTest.test_resize_forbiddencCs ddlm}|jt|t��dS)Nr)�getbuffer_with_null_view)rSr�r0r�rd)rr�rrr
�test_obsolete_write_lock�sz&ByteArrayTest.test_obsolete_write_lockc	Cs�td�}td�}�x�ttjd�D�]z}t|�}tj||f|�}tj|�\}}||dd�<|jt	|�t	|��|jt|�|�t
|�tj||f|�}tj|�\}}||dd�<|jt	|�t	|��|jt|�|dd��xtdt|��D]}t
|�q�Wtj||f|�}tj|�\}}||dd�<|jt	|�t	|��|jt|�|t|�d��|jt
t
|�tj||f|�}tj|�\}}||dd�<|jt|�g�q"WdS)Nsabcsqwertyr')rdr@r?rrrCrrrrrr/r0�
StopIteration)	rr�r�rZitorigrrrr9rrr
�test_iterator_pickling2�s6z%ByteArrayTest.test_iterator_pickling2cCs4td�}t|�}t|�|j�|jt|�g�dS)Nsab)rdrCrrGrr@)rrnrrrr
�test_iterator_length_hint�s
z'ByteArrayTest.test_iterator_length_hintN),rrrrdrrBrsrur~rr�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�r�Z
list_testsZ
CommonTestZtest_exhausted_iteratorr�rrrr
rqsF"	(		


 $
rqc@s�eZdZedd��Zedd��Zdd�Zejj	dd��Z
d	d
�Zedd��Zd
d�Z
dd�Zdd�Zdd�Zejejjd�dd��ZdS)�AssortedBytesTestcCs�x�ttfD]x}|j|t��d�|j|tdg��d�|j|tddddg��d�|j|d�d	�|j|d
�d�|j|d�d
�q
WdS)Nzbytearray(b'')rzbytearray(b'\x00')r'rMrNzbytearray(b'\x00\x01\xfe\xff')sabczb'abc'�'zb"'"s'"zb'\'"')rr�reprrrd)rr�rrr
�
test_repr_str�szAssortedBytesTest.test_repr_strcCsvxpdtd�fD]`}|jt|�t|��|jt|d�t|��|jtdtjt|�j	���t|d�WdQRXqWdS)Nsabcrz\b%s\br|)
rdrrhrrr�rRr��escaperr)rrrrr
�test_formatszAssortedBytesTest.test_formatcCs�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jdtd�kd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�|jtd�dkd�dS)NsabcTsabF)rrK)rrrr
�test_compare_bytes_to_bytearray	s0z1AssortedBytesTest.test_compare_bytes_to_bytearraycCsH|jtj�|jtjjd�tj�|jtj�|jtjjd�tj�dS)Nz
bytearray(zbytes()ZassertIsNotNonerd�__doc__rlr�rK)rrrr
�test_doc&szAssortedBytesTest.test_doccCs,td�}t|�}t|�}|j|t|��dS)NsHello world
����)rKr�rdr)rr�Zbufrrrr
�test_from_bytearray-sz%AssortedBytesTest.test_from_bytearraycCsp|jtd�d�|jtd�d�|jtd�d�|jttd��d�|jttd��d�|jttd��d	�dS)
NrUzb''r�zb'x'��zb'\x80'zbytearray(b'')zbytearray(b'x')zbytearray(b'\x80'))rrrrd)rrrr
�test_to_str3szAssortedBytesTest.test_to_strcCs^d
dddg}x"|D]\}}|j|t|d	��qWx(td
d�D]}|jttdt|��q<WdS)N�Wonderful spam�Wonderful spam�Wonderful spam too�Wonderful spam too����ª€�\xaa\x00\000\200�\xaa\x00\000\200zlatin-1r;r3zb"%s")r�r�)r�r�)r�r�)r�r�)rrdr?r0�SyntaxError�eval�chr)rZtestsrr|r�rrr
�test_literal<szAssortedBytesTest.test_literalcCs|jdjtd��ddg�dS)Nsa br�r�r�)rr�r�)rrrr
�test_split_bytearrayIsz&AssortedBytesTest.test_split_bytearraycCs|jdjtd��ddg�dS)Nsa br�r�r�)rr�r�)rrrr
�test_rsplit_bytearrayLsz'AssortedBytesTest.test_rsplit_bytearraycCs t�}|j|jdd�|k�dS)NrU)rdrmr�)rrrrr
�test_return_selfOsz"AssortedBytesTest.test_return_selfz4BytesWarning is needed for this test: use -bb optioncVCsTdd�}|��ddkWdQRX|��ddkWdQRX|��ddkWdQRX|��ddkWdQRX|��td�dkWdQRX|��dtd�kWdQRX|��td�dkWdQRX|��dtd�kWdQRX|��ddkWdQRX|��ddkWdQRX|��ddkWdQRX|��ddkWdQRXdS)NcSstjjdtf�S)Nr)rrrrrrrr
�
bytes_warningWsz5AssortedBytesTest.test_compare.<locals>.bytes_warningrUrrVr)rd)rr�rrr
rpTs2zAssortedBytesTest.test_compareN)rrrrr�r�r�rrZrequires_docstringsr�r�r�r�r�r�r��unittestZ
skipUnlessr(�flagsr�rprrrr
r��s		

r�c@seZdZdd�Zdd�ZdS)�BytearrayPEP3137TestcCst|�S)N)rd)rr�rrr
�marshal�szBytearrayPEP3137Test.marshalcCs�|jd�}x>dD]6}t||�}|d�}|j||�|j||k	|d�qWx4dD],}t|�}|j||�|j||k	|d�qPW|jd�}|j|g�}|j||�|j||�dS)Ns1234�zfillr(r&r#r<z" returned self on a mutable object�val.split()[0]�val.rsplit()[0]�val.partition(b".")[0]�val.rpartition(b".")[2]�val.splitlines()[0]�val.replace(b"", b"")z! returned val on a mutable objectrU)r�r(r&r#)r�r�r�r�r�r�)r��getattrrrlr�r�r�)r�valZmethnamer6Znewval�expr�seprrr
�test_returns_new_copy�s$





z*BytearrayPEP3137Test.test_returns_new_copyN)rrrr�r�rrrr
r��sr�cs eZdZ�fdd�ZdZ�ZS)�FixedStringTestcs&t|t�r|j|jd��St�j|�S)Nzutf-8)�
isinstancerrrr��super�fixtype)r�obj)rrr
r��s
zFixedStringTest.fixtypeT)rrrr�Zcontains_bytes�
__classcell__rr)rr
r��sr�c@seZdZeZdS)�ByteArrayAsStringTestN)rrrrdrrrrr
r��sr�c@seZdZeZdS)�BytesAsStringTestN)rrrrKrrrrr
r��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SubclassTestcCs�|jt|j|j��|j|j�|j�d\}}|j|�|j|�}}|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�|j||k	�|j||||�|j||||�|j||||�|j|d|dk�dS)N�abcd�efghrW)r�r�)rl�
issubclassr�basetyper>r)rr#rZ_aZ_brrr
�
test_basic�szSubclassTest.test_basiccCsf|jd�}|j�j|g�}|j||k	�|jt|�|jkt|��|jdg�}|jt|�|jk�dS)Nsabcd)rr�r�rlr)r�s1�s2Zs3rrr
r��s
zSubclassTest.test_joincCs�|jd�}d|_|jd�|_x�ttjd�D]�}tjtj||��}|jt	|�t	|��|j
||�|j
|j|j�|j
|j|j�|j
t|�t|��|j
t|j�t|j��q,WdS)Nsabcdr*sefghr')rr��yr?rrrr�assertNotEqual�idrr)rr#rrrrr
�test_pickle�s
zSubclassTest.test_picklecCs�|jd�}d|_|jd�|_x�tjtjfD]x}||�}|jt|�t|��|j||�|j|j|j�|j|j|j�|jt|�t|��|jt|j�t|j��q*WdS)Nsabcdr*sefgh)	rr�r�r!r"rrrr)rr#r$rrrr
r%�s
zSubclassTest.test_copycs��jjd�}�j|d��jt|��j�G�fdd�d�j�}|jd�}�j|d��jt|�|��j|jd�G�fdd�d�j�}|jd�}�j|d��jt|�|��j|jd�dS)Nr�s+0cseZdZ�fdd�ZdS)z%SubclassTest.test_fromhex.<locals>.B1cs�jj||�}d|_|S)N�bar)r��__new__�foo)�clsr�me)rrr
r�sz-SubclassTest.test_fromhex.<locals>.B1.__new__N)rrrrr)rrr
�B1�srrcseZdZ�fdd�ZdS)z%SubclassTest.test_fromhex.<locals>.B2cs(�jtk	r�jj|f|�|�d|_dS)Nr)r�rKrr)rr	�kwargs)rrr
r�s
z.SubclassTest.test_fromhex.<locals>.B2.__init__N)rrrrr)rrr
�B2�sr
)rr�rr�rr�r)rrrr
r)rr
r��s

zSubclassTest.test_fromhexN)rrrr�r�rr%r�rrrr
r��s



r�c@seZdZdS)�ByteArraySubclassN)rrrrrrr
rsrc@seZdZdS)rPN)rrrrrrr
rPsrPc@seZdZdS)rON)rrrrrrr
rOsrOc@seZdZeZeZdd�ZdS)�ByteArraySubclassTestcCsNGdd�dt�}|dd�}|ddd�}|j|d�|ddd�}|j|d�dS)Nc@seZdZddd�ZdS)z:ByteArraySubclassTest.test_init_override.<locals>.subclassr'c_stj|f|�|�dS)N)rdr)r�newargr	r	rrr
rszCByteArraySubclassTest.test_init_override.<locals>.subclass.__init__N)r')rrrrrrrr
�subclasssrrbsabcd)�source)r
r)rdr)rrr�rrr
�test_init_overrides
z(ByteArraySubclassTest.test_init_overrideN)rrrrdr�rrrrrrr
rsrc@seZdZeZeZdS)�BytesSubclassTestN)rrrrKr�rPrrrrr
r sr�__main__))r�rSrEr�r(r!rrrxr�Ztest.supportrZtest.string_testsZtest.list_testsrrr�r�rrrZTestCaser@rqr�r�Zstring_testsZBaseTestr�r�r�r�rdrrKrPrOrrr�mainrrrr
�<module>sX
$9r]


Youez - 2016 - github.com/yon3zu
LinuXploit