Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_bytes.cpython-310.pyc
o

�9j0�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlZddlZddlmZmZddlmZejjrYdd�Znd	d�ZGd
d�d�ZGdd
�d
�ZGdd�dee
j�ZGdd�dee
j�ZGdd�de
j�ZGdd�de
j�ZGdd�dejj �Z!Gdd�de!e
j�Z"Gdd�de!e
j�Z#Gdd�d�Z$Gdd�de%�Z&Gd d!�d!e'�Z(Gd"d#�d#e'�Z)Gd$d%�d%e$e
j�Z*Gd&d'�d'e$e
j�Z+e,d(kr�e
�-�dSdS))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)�
import_helper)�warnings_helper)�bigaddrspacetest�MAX_Py_ssize_t)�assert_python_failurecst����fdd��}|S)Ncs@t�dtf���|i|��Wd�S1swYdS�N��r�check_warnings�BytesWarning)�args�kw��func��&/usr/lib/python3.10/test/test_bytes.py�wrappers$�z%check_bytes_warnings.<locals>.wrapper)�	functools�wraps)rrrrr�check_bytes_warningssrcCs|S�Nrrrrrr$�c@seZdZddd�Zdd�ZdS)�	IndexablercCs
||_dSr��value)�selfrrrr�__init__)�
zIndexable.__init__cCs|jSrr�rrrr�	__index__+szIndexable.__index__N)r)�__name__�
__module__�__qualname__rrrrrrr(s
rc@sDeZdZdd�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�d��ZId�d��ZJd�S)��
BaseBytesTestcCs.|��}|�t|�|j�|�|j|j�dSr)�	type2test�assertEqual�type�	__class__�r�brrr�test_basics1szBaseBytesTest.test_basicscCsH|�d�}tjtjfD]}||�}|�||�|�t|�t|��qdS�N�abcd)r$�copy�deepcopyr%r&�r�a�copy_methodr)rrr�	test_copy6s
�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)Nrc��dS�Nrrr�r)rr�<lambda>@�z3BaseBytesTest.test_empty_sequence.<locals>.<lambda>cr3�N�rrr5rrr6Ar7cs
�tjSr��sys�maxsizerr5rrr6B�
cs�tjdSr8r:rr5rrr6C�cs�ddS�N�
�drrr5rrr6D�cr3�N���rrr5rrr6Er7cr3)N���rrr5rrr6Fr7cs�tjSrr:rr5rrr6GrBc��tjdSr8r:rr5rrr6H�crF)N�r:rr5rrr6IrGcs�ddSr?rrr5rrr6Jr>)r$r%�len�assertRaises�
IndexErrorrrr5r�test_empty_sequence=sz!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��*�*�+�-)rPrQ)rQrPcss�|]	}|dr|VqdS)rHNr��.0�irrr�	<genexpr>]s�z3BaseBytesTest.test_from_iterable.<locals>.<genexpr>�r9rHc@�eZdZdd�ZdS)z+BaseBytesTest.test_from_iterable.<locals>.ScSsd|S)N�r9rH�r)rrTrrr�__getitem__c�z7BaseBytesTest.test_from_iterable.<locals>.S.__getitem__N)r r!r"rZrrrr�Sb�r\�)r$�ranger%rI�list�assertIn�tuple�iter)rr)r\rrr�test_from_iterableLs "z BaseBytesTest.test_from_iterablecCsT|�ttd���}|�t|�d�|�t|�ttd���|�d�}|�|d�dS�NrMrXr^)r$rbr_r%rIr`r(rrr�test_from_tuplehs

zBaseBytesTest.test_from_tuplecCsX|�ttd���}|�t|�d�|�t|�ttd���|�gd��}|�|d�dSre)r$r`r_r%rIr(rrr�test_from_listps
zBaseBytesTest.test_from_listcs\G�fdd�d�}|�|�g�|�t��d�G�fdd�d�}|�g�|�t��d�dS)Nc�eZdZ�fdd�ZdS)z0BaseBytesTest.test_from_mutating_list.<locals>.Xc����dS�NrN��clearr�r0rrr{�z:BaseBytesTest.test_from_mutating_list.<locals>.X.__index__N�r r!r"rrrmrr�Xz�rprOcrh)z0BaseBytesTest.test_from_mutating_list.<locals>.Ycst��dkr��|�dS)N��rN)rI�appendrrmrrr�s
z:BaseBytesTest.test_from_mutating_list.<locals>.Y.__index__Nrorrmrr�Y�rqrts�****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************�r%�bytes)rrprtrrmr�test_from_mutating_listxsz%BaseBytesTest.test_from_mutating_listcCsd|�t�td�td�td�g�}|�t|�gd��|�t|jtd�g�|�t|jtd�g�dS)Nr9���rr9rxryrDrM)r$rr%r`rJ�
ValueErrorr(rrr�test_from_index�s�zBaseBytesTest.test_from_indexcCsb|�t�dgd���}|�|d�|�d�}|�|d�Gdd�dt�}|�|�|d��d�dS)N�BrXr^c@rW)z)BaseBytesTest.test_from_buffer.<locals>.BcSst�r)�	TypeErrorrrrrr�rz3BaseBytesTest.test_from_buffer.<locals>.B.__index__Nrorrrrr}�r]sfoobar)r$�arrayr%rv)rr0r}rrr�test_from_buffer�s
zBaseBytesTest.test_from_buffercCs�|�|�d�d�|�|�d�d�|�|�d�d�|�t|jd�|�|�dd	�d
�|�|�d
�d
�|�t|jtjd�dS)Nr�r9��srD�0�ascii�0)r%r$rJr{�
OverflowErrorr;r<rrrr�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@�eZdZdS)z5BaseBytesTest.test_constructor_type_errors.<locals>.CN�r r!r"rrrr�C��r�r�r�)�encoding�ignore)�errorsrr�rsasciisignore)rJr~r$)rr�rrr�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)NrDr9rHr@rArMi)rJr{r$r;r<rrrr�test_constructor_value_errors�sz+BaseBytesTest.test_constructor_value_errorsc	CsDt}|�ttf|j|�z	t|d�WdSttfy!YdSw)N�)rrJr��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@rW)z9BaseBytesTest.test_constructor_exceptions.<locals>.BadIntcS�dddS�Nr9rrrrrrr��zCBaseBytesTest.test_constructor_exceptions.<locals>.BadInt.__index__Nrorrrr�BadInt�r]r�c@rW)z>BaseBytesTest.test_constructor_exceptions.<locals>.BadIterablecSr�r�rrrrr�__iter__�r�zGBaseBytesTest.test_constructor_exceptions.<locals>.BadIterable.__iter__N)r r!r"r�rrrr�BadIterable�r]r�)rJ�ZeroDivisionErrorr$)rr�r�rrr�test_constructor_exceptions�s
z)BaseBytesTest.test_constructor_exceptionscCs|�gd��}|�gd��}|�ddg�}|�||�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�dS)NrXr9rY)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)r`�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, worldr�r�r9�ello�z, �world�rA���i����������)r%�rr�r)rrr�
test_getsliceszBaseBytesTest.test_getslicecCs�ttd��}|�|�}ddddddtjddd	d
f}|D]#}|D]}|dd�D]}|�||||�|�||||���q'qqdS)Nryrr9rY�rArDrE���r�)r`r_r$r;r<r%)r�Lr)�indices�start�stop�steprrr�test_extended_getslice s
(���z$BaseBytesTest.test_extended_getslicec	Csrd}dD]}|�||�}|�||�|�|���q|�t|j|d�|�|dd�}|�||�|dd�d��dS)N�Hello world
ሴ噸骼��utf-8zutf-16�latin-1r����r�)r$r%�encoderJ�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�r�zHello world
)r�r�s☃u☃)r$r%�decoderJ�UnicodeDecodeErrorr�rrr�test_decode4s�zBaseBytesTest.test_decodecCsdd}d}t�d|jj�d|�d|�d|�d|�d|�d	|�d
��}tddd
|�}|�|jd|�dS)NzBoom, Shaka Laka, Boom!)r��utf8�latin1z0
            import sys
            type2test = z
            encodings = zr

            for data in ('', 'short string'):
                try:
                    type2test(data, encoding=z�)
                except LookupError:
                    pass
                else:
                    sys.exit(21)

                for encoding in encodings:
                    try:
                        type2test(data, encoding=encoding, errors=a>)
                    except LookupError:
                        pass
                    else:
                        sys.exit(22)

            for data in (b'', b'short string'):
                data = type2test(data)
                print(repr(data))
                try:
                    data.decode(encoding=z�)
                except LookupError:
                    sys.exit(10)
                else:
                    sys.exit(23)

                try:
                    data.decode(errors=z�)
                except LookupError:
                    pass
                else:
                    sys.exit(24)

                for encoding in encodings:
                    try:
                        data.decode(encoding=encoding, errors=z�)
                    except LookupError:
                        pass
                    else:
                        sys.exit(25)

            sys.exit(10)
        z-X�devz-cr@)�textwrap�dedentr$r rr%�rc)r�invalid�	encodings�code�procrrr�test_check_encoding_errorsBs&����� �(
�0z(BaseBytesTest.test_check_encoding_errorscCsb|�d�}|�||���|�d�}|�||�dgd��|�d�}|�||�dgd��dS)Nrr@i')r$r%r(rrr�
test_from_intzs


zBaseBytesTest.test_from_intcsx|�d��|�d��|���d�|��td�d�|�td��d�|�t�fdd��|�t�fdd��dS)N�abc�def�abcdefsdefabccs�dS)N�defrr)r�rrr6�r7z+BaseBytesTest.test_concat.<locals>.<lambda>csd�S)Nr�rr)r�rrr6�r7)r$r%rvrJr~rr)r�r�r�test_concat�s

zBaseBytesTest.test_concatc	s�d|�d�fD]f�|��dd�|��dd�|��dd�|�t�fdd��|�t�fd	d��|�ttf��
�tj}Wd�n1sLwY|�ttf��
�tj9�Wd�n1shwYqdS)
Nr�rY�	abcabcabcrr�rDcs�dS�Ng��Q�	@rrr5rrr6�r7z+BaseBytesTest.test_repeat.<locals>.<lambda>csd�Sr�rrr5rrr6�r7)r$r%rJr~r�r�r;r<�r�crr5r�test_repeat�s����zBaseBytesTest.test_repeatcCs*|�|�d�d|�td�gd��dS)N�xrA�x)r%r$r�rrrr�test_repeat_1char�s*zBaseBytesTest.test_repeat_1charcst|�d��|�td���|�ttd����|�d��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fd	d��|�t�fd
d��tt	fD]Z}|�|d���|�|d���|�|d
���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���|�|d���q]dS)Nr�r0��c�d�vS)N�,rrr5rrr6�r7z-BaseBytesTest.test_contains.<locals>.<lambda>cr�rCrrr5rrr6�r7cstjd�vSr8r:rr5rrr6�r>csd�vSrrrr5rrr6�r7csttd���vS�Nr0)�floatr�rr5rrr6�rGcr�r�rrr5rrr6�r7r��a�b�c�ab�bc�ac�dsdabsabd)
r$rar��int�assertNotInrJr{r~rvr��r�frr5r�
test_contains�s.
�zBaseBytesTest.test_containsc	Cs�|�t|jj�|�t|jjd�|�|j�d�|���tgd��}|�|j�d�|�|�|j�d�|�|�|j�d�|�dD]}|�|j�|�|���qCdD]}|�t|jj|�qT|�|j�d	�d
�|�t|jjd�|�t|jjd�|�t|jjd
�|�t|jjd�|�t|jjd�|�t|jjd�dD]*\}}|�t��}|j�|�Wd�n1s�wY|�d|t|j	��q�dS)Nr9r��rP�0�1a2B30z  1A 2B  30   z
 1A
2B	30z	

 u…   
�0000ss1Br0�rtz1a b cd�z12      34))z12 x4 56rY)z12 3x 56r�)z12 xy 56rY)u	12 3ÿ 56r�zat position %s)
rJr~r$�fromhexr%r�r{rar��	exception)rr)r��data�pos�cmrrr�test_fromhex�s0
��zBaseBytesTest.test_fromhexcCs~|�t|jj�|�t|jjd�|�|�d���d�|�tgd����d�|�|�d���d�|�td���d�dS)Nr9r�rr��1a2b30�+0)rJr~r$�hexr%r��
memoryviewrrrr�test_hex�szBaseBytesTest.test_hexcCs�|�d�}|�|��d�|�t��
|�d�Wd�n1s"wY|�t��
|�d�Wd�n1s<wY|�|�dd�d�|�t��|�dd�Wd�n1sawY|�t��
|�d�Wd�n1s{wY|�t��
|�d�Wd�n1s�wY|�t��
|�d	�Wd�n1s�wY|�t��|�td
��Wd�n1s�wY|�|�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���b901efr�xx�:r�ÿ����rMr�zb901efr�zb901ef�rYr����zb9:01:ef�$zb9$01$efr9rDrHzb9:01ef�*rEzb901*efs {sworldishelloi0�.�zC7b7305000000776f.726c646902000000.730500000068656c.6c6f690100000030)r$r%rrJr{r~�chr)r�three_bytesrrrr�test_hex_separator_basics�sR
�������z'BaseBytesTest.test_hex_separator_basicscCs$|�tdd��}|�|��d�dS)N�Z�_�
5a5b5c5d5e�r$r_r%r)r�
five_bytesrrr�test_hex_separator_five_bytessz+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)rYNr�rSr�rrrrU
��z=BaseBytesTest.test_hex_separator_six_bytes.<locals>.<genexpr>r9r��0306090c0f12rz03.06.09.0c.0f.12� rHz0306 090c 0f12�-rYz
030609-0c0f12rr�z
0306:090c0f12r�z
03:06090c0f12�r �_r��
030609_0c0f12rz
0306090c:0f12�@r�z
0306090c0f@12i����i����r")r�	six_bytesrrr�test_hex_separator_six_bytes	sz*BaseBytesTest.test_hex_separator_six_bytescCs|�|�d��g�d�|�|�d��dg�d�dgddgddggd�fD]2}tt|j|��}|�|�d��|�d�|�|�d��t|��d�|�|�d��t|��d�q&|�d�j}|�|dd	g�d
�|�|td�d	g�d
�|�|dtd	�g�d
�|�|td�d	g�d
�|�|dtd	�g�d
�dgd}ddd
}|�||�|�dgd}dd}|�|�d��|�|�|�	t
|�d�jd�|�	t
��|td�ddg�Wd�n1s�wY|�	t
��|td�ddg�Wd�dS1�swYdS)Nr�r�r�r�r�r�)r�r�r�s.:scdsab.:cdi��s.:abci��� �cdsef)r%r$�joinr`r�rbrcr
r�rJr~)r�lst�dot_join�seq�expectedrrr�	test_joins4

�$�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�ir��ssrH�wrr*�pr9rYr��	)r$r%�count)rr)rT�p�wrrr�
test_count7s"
zBaseBytesTest.test_countcCs�|�d�}|�|���d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�t��}|�dg�Wd�n1sMwYt|j�}|�d|�|�d|�dS)	N�hello�anythingshel�hshellowsharvrb)	r$r��
startswithr�rJr~r�rra�rr)r�excrrr�test_startswithNs
�
zBaseBytesTest.test_startswithcCs�|�d�}|�t��d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�t��}|�dg�Wd�n1sLwYt|j�}|�	d|�|�	d|�dS)	NrErFsllo�oswhellosnorvrb)
r$r�r��endswithr�rJr~r�rrarIrrr�
test_endswith\s
�
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)Nr8r9r;r=rHr>rD�
mississippianr9rYr�r�r*rMzbyte must be in range\(0, 256\))r$r%�findr;r<�assertRaisesRegexr{)rr)rTrC�indexrrr�	test_findjs(
��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)Nr8r9r;r=r�r>rDrOr@rYrr*rHr9r@r�)r$r%�rfind�rr)rTrCrrr�
test_rfind�s
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)
Nr8r9r;r=rHr>rOr9rYr�r�r*)r$r%rRrJr{rUrrr�
test_index�s
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)Nr8r9r;r=r�r>rOr@rYrr*rHr9r@r�)r$r%�rindexrJr{rUrrr�test_rindex�s
zBaseBytesTest.test_rindexcCs�|�d�}|}|d}|�|d�|�|d�|�||u�|�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)�origr0rrr�test_mod��


zBaseBytesTest.test_modcCs�|�d�}|}|d;}|�|d�|�|d�|�||u�|�d�}|d;}|�|d�|�t|�|j�|�d�}|d;}|�|d�|�t|�|j�dSrZr])rr)r_rrr�	test_imod�razBaseBytesTest.test_imodcCsV|�t��t�|�d�Wd�n1swY|�|�d��d�t�dS)Nr�z%r)rJr~�objectr$r^�__rmod__�NotImplementedrrrr�	test_rmod�s�zBaseBytesTest.test_rmodcCs6|�d�}|�|�dd�d�|�|�dd�d�dS)Nr8r<r�smassassappar=r�s	mixixippi)r$r%�replacer(rrr�test_replace�s
zBaseBytesTest.test_replacecCs|�t|�d�jdd�dS)N�a b� r�)rJr~r$rgrrrr�test_replace_int_error��z$BaseBytesTest.test_replace_int_errorcC�0|�t|�d�jd�|�t|�d�jd�dS�Nrir(�rJr~r$�split�rsplitrrrr�test_split_string_error��z%BaseBytesTest.test_split_string_errorcCrm�Nrirjrorrrr�test_split_int_error�rsz"BaseBytesTest.test_split_int_errorcCsFdD]}|�|�}|�|��|g�q|�d�}|�|��dg�dS)N)sabsabsabsab�		

�)r$r%rpr(rrr�test_split_unicodewhitespace�s


z*BaseBytesTest.test_split_unicodewhitespacecCs |�d�}|�|��dg�dS)Nrvrw)r$r%rqr(rrr�test_rsplit_unicodewhitespace�s
z+BaseBytesTest.test_rsplit_unicodewhitespacecCs2|�d�}|�|�d�d�|�|�d�d�dS)Nr8r=)smir=sissippir>)r8r�r�)r$r%�	partitionr(rrr�test_partition�s
zBaseBytesTest.test_partitioncCsD|�d�}|�|�d�d�|�|�d�d�|�|�d�d�dS)Nr8r=)smissir=sippir<)s
mississippr<r�r>)r�r�r8)r$r%�
rpartitionr(rrr�test_rpartitions
zBaseBytesTest.test_rpartitioncCrmrn�rJr~r$rzr|rrrr�test_partition_string_error
rsz)BaseBytesTest.test_partition_string_errorcCrmrtr~rrrr�test_partition_int_errorrsz&BaseBytesTest.test_partition_int_errorcCsNttjd�D]}dD]}|�|�}t�||�}t�|�}|�||�qqdS�Nr9)r�r�r�s�ab�s�)r_�pickle�HIGHEST_PROTOCOLr$�dumps�loadsr%)r�protor)�ps�qrrr�
test_picklings

��zBaseBytesTest.test_picklingcCs�ttjd�D]W}dD]R}t|�|��}}t|�|��}t�||�}t�|�}|�t	|�t	|��|�t|�|�t�|�}|sBqt
|�t�||�}t�|�}|�t|�|dd��qqdSr�)r_r�r�rcr$r`r�r�r%r&�next)rr�r)�it�itorgr�drrr�test_iterator_picklings"


��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,s z"BaseBytesTest.test_strip_bytearraycC�F|�t|�d�jd�|�t|�d�jd�|�t|�d�jd�dS)Nr��ac�rJr~r$r�r�r�rrrr�test_strip_string_error1�z%BaseBytesTest.test_strip_string_errorcCr�)Ns abc rjr�rrrr�test_strip_int_error6r�z"BaseBytesTest.test_strip_int_errorcC�:|�d�}ttfD]}|�|�d|d��|�d��q	dS)Nr�r��-s--abc--)r$rvr�r%�center�rr)�	fill_typerrr�test_center;�
��zBaseBytesTest.test_centercCr�)Nr�r�r�sabc----)r$rvr�r%�ljustr�rrr�
test_ljustBr�zBaseBytesTest.test_ljustcCr�)Nr�r�r�s----abc)r$rvr�r%�rjustr�rrr�
test_rjustIr�zBaseBytesTest.test_rjustcCsL|�t|�d�jdd�|�t|�d�jdd�|�t|�d�jdd�dS)Nr�r�rj)rJr~r$r�r�r�rrrr�test_xjust_int_errorPsz"BaseBytesTest.test_xjust_int_errorcs4|�d��|��fdd�tt���D�gd��dS)NsA��cs g|]}t�||d���qS�r9)r�rRr5rr�
<listcomp>Ws z*BaseBytesTest.test_ord.<locals>.<listcomp>)r�A�rVry)r$r%r_rIrrr5r�test_ordUs
�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$�	maketransrJr{r~)r�
transtablerrr�test_maketransZs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)
NrE�lrGr�rLrHrYrErr9TF)	r$r%rPrTrRrXrArMrH)rr)�l�hr��orrr�test_none_argumentsbsB




z!BaseBytesTest.test_none_argumentscCsV|�d�}|j|j|j|j|jfD]}|�t|d�|�t|d�|�t|d�qdS)NrErDrMi')r$rArPrRrTrXrJr{)rr)�methodrrr�(test_integer_arguments_out_of_byte_range�s
�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)
NrEr�z\bfind\bz	\brfind\bz	\bindex\bz
\brindex\bz	\bcount\bz\bstartswith\bz\bendswith\b)
r$rQr~rPrTrRrXrArHrM)rr)r�rrr�*test_find_etc_raise_correct_error_messages�s.

�������z8BaseBytesTest.test_find_etc_raise_correct_error_messagescCs(tj�|t|j�tj�|t|j�dSr)�test�support�check_free_after_iteratingrcr$r�rrrr�test_free_after_iterating�sz'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)
NrErM�er�ryr�sheller�shee�eshllo)�delete)r$r�r_r�rJr~�	translater{rvr%�assertIsInstance)rr)�rosettar�r�rrr�test_translate�s.

zBaseBytesTest.test_translatecCs�t�d�}|�d�}|�t��|�|d�Wd�n1s wY|�t��|�|d�Wd�n1s;wY|�|�|d�d�dS)N�	_testcapi)rNrEr9rrN)r�
import_moduler$rJrK�sequence_getitemr%)rr��objrrr�test_sq_item�s

��zBaseBytesTest.test_sq_itemN)Kr r!r"r*r2rLrdrfrgrwr|r�r�r�r�rr�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r	rrr$r/r7rDrKrNrSrVrWrYr`rbrfrhrkrrrurxryr{r}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr#/s�




	8	
%%+r#c@s@eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
S)�	BytesTestcCsBd}d}|�t|��
|dWd�dS1swYdS)N�pythonz'byte indices must be integers or slicesr0)rQr~�rr)�msgrrr�test_getitem_error�s

"�zBytesTest.test_getitem_errorcCsRt�ttj�}t|ddd��}|�t|jd�Wd�dS1s"wYdS)N�rbr)�	bufferingr�)�os�open�__file__�O_RDONLYrJr~�readinto)r�fdr�rrr�test_buffer_is_readonly�s"�z!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@rW)� BytesTest.test_custom.<locals>.AcS�dS�Nr�rrrrr�	__bytes__�r�*BytesTest.test_custom.<locals>.A.__bytes__N�r r!r"r�rrrr�A�r]r�r�c@r�)r�Nr�rrrrr��rBc@rW)r�cSsdSrrrrrrr��rr�Nr�rrrrr��r]c@�eZdZdd�Zdd�ZdS)r�cSr�)Nr�rrrrrr��rr�cSr�rjrrrrrr�rz*BytesTest.test_custom.<locals>.A.__index__N)r r!r"r�rrrrrr��sr�c@rW)r�cSr�r�rrrrrr��rr�Nr�rrrrr��r]u€z
iso8859-15��c@rW)r�cSstd�Sr�)�OtherBytesSubclassrrrrr��r[r�Nr�rrrrr��r])	r%rvrJr~r�r^r&r��
BytesSubclass)rr�rrr�test_custom�s zBytesTest.test_customcsrt�d�}t�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%kr�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]\}}}}|�||||��||��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�ctypesr�r)�	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=@rysc=�sd=%d ld=%ld zd=%zdr9rHrYs
d=1 ld=2 zd=3rDrEr�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��
ptr_formatrr�
ptr_formatter7r[z1BytesTest.test_from_format.<locals>.ptr_formattercSsd|S)Nz%#xrr�rrrr�;r[i�ͫsptr=%pzptr=r�ss=%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%crMr�)!rr�r�r�r�r�r�r�r�r�r�r��PyBytes_FromFormat�argtypes�restyper%r��sizeofr��name�formatr�r�INT_MINr��INT_MAX�LONG_MIN�LONG_MAX�	ULONG_MAX�PY_SSIZE_T_MIN�PY_SSIZE_T_MAXrJr�)rr�r�r�r�r�r�r�r�r�r�r�r��
sizeof_ptrr�r��size_max�	formatstr�ctypes_typer�py_formatterrr�r�test_from_formats�

$
��������������

��


�
���
�
��
��
�
�
��zBytesTest.test_from_formatcCs�Gdd�dt�}gd�}|�t|�d�|�tt||��Gdd�dt�}|�td�d�|�tt|d��Gd	d
�d
t�}|�td�d�|�tt|d��Gdd
�d
t�}td�|d�}}|�t|�d�|�tt|�dS)Nc@�eZdZdZdS)z7BytesTest.test_bytes_blocking.<locals>.IterationBlockedNr�rrrr�IterationBlockedw�r)rr9rHrYsc@r)z1BytesTest.test_bytes_blocking.<locals>.IntBlockedNr�rrrr�
IntBlocked�rr	rYsc@r)z;BytesTest.test_bytes_blocking.<locals>.BytesSubclassBlockedNr�rrrr�BytesSubclassBlocked�rr
r�c@r)z4BytesTest.test_bytes_blocking.<locals>.BufferBlockedNr�rrrr�
BufferBlocked�rr)r`r%rvrJr~r�r�)rrrTr	r
r�ba�bbrrr�test_bytes_blockingvszBytesTest.test_bytes_blockingcCsPd}d}|�t|�t|��|�t|�t|��|�t|�t|d��|�t|�t|d��|�t|�t|d��|�t|�td|��|�t|�t|d��Gdd�dt�}|d	�}|�t|�t|��|�t|�t|d��|�t|�t|d��|�t|�t|d��|�t|�td|��|�t|�t|d��dS)
Ns123abc1@s456zyx-+rrr9rHc@r�)z5BytesTest.test_repeat_id_preserving.<locals>.SubBytesNr�rrrr�SubBytes�r�rsqwerty())r%�id�assertNotEqualrv)rr0r)rr�rrr�test_repeat_id_preserving�s"z#BytesTest.test_repeat_id_preservingN)r r!r"rvr$r�r�r�rrrrrrrr��s!rr�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+dCdD�Z,dEdF�Z-dGS)H�
ByteArrayTestcCsFtd�}d}|�t|��
|dWd�dS1swYdS)Nr��,bytearray indices must be integers or slicesr0�r�rQr~r�rrrr���

"�z ByteArrayTest.test_getitem_errorcCsFtd�}d}|�t|��
d|d<Wd�dS1swYdS)Nr�r�pythonr0rr�rrr�test_setitem_error�rz ByteArrayTest.test_setitem_errorcCs|�ttt��dSr)rJr~�hashr�rrrr�test_nohash��zByteArrayTest.test_nohashcCsnd}|ddt|�}t��}z�t|d��
}|�|�Wd�n1s&wYt|d��}td�}|�|�}Wd�n1sDwY|�|t|��|�t|�t|��t|d��
}|�|�Wd�n1spwYt|d��}|�|�	�|�Wd�n1s�wYWzt
�|�WdSty�YdSwzt
�|�Wwty�Yww)NsHello world
r���wbr�)
rI�tempfile�mktempr��writer�r�r%r`�readr��remove�OSError)r�short_sampler��tfnr�r)�nrrr�test_bytearray_api�s<��������z ByteArrayTest.test_bytearray_apicCs\td�}|�|��d�|�|d�td�}|��|�|d�t�}|��|�|�dS)NrEsollehshello1s1olleh)r�r%r�r�r(rrr�test_reverse�szByteArrayTest.test_reversecCsttd�}|��|�|d�td�}|��|�|d�td�}|�td��|��|�td��|�|d�dS)Nr�r��rrBr?)r�rlr%rsr�r(rrr�
test_clear�szByteArrayTest.test_clearcCs�td�}|��}|�|d�td�}|��}|�|d�td�}|��}|�||�|�||�|�td��|�|d�|�|d�dS)Nr�r�r�r,)r�r-r%�assertIsNotrsr�)rr)r
rrrr2�szByteArrayTest.test_copycCs4dd�}|d�}|�t�d|�|d�|d�g�dS)NcSsttt|��Sr)r�r�r�r�rrrr��z&ByteArrayTest.test_regexps.<locals>.byr�s\w+r�r�)r%�re�findallr�rrr�test_regexpss$zByteArrayTest.test_regexpscCs>tgd��}d|d<|�|tgd���d|d<|�|tgd���td�|d	<|�|tgd
���zd	|d<|�d�Wn	tyFYnwzd	|d
<|�d�Wn	ty[Ynwzd|d	<|�d�Wn	typYnwz
td�|d	<|�d�Wn	ty�Ynwzd|d	<|�d�WdSty�YdSw)NrXrAr9)r9rArYr�rD)r9rAr�r@r)r@rAr�rYzDidn't raise IndexErrori����rMzDidn't raise ValueErrorzDidn't raise TypeError)r�r%r�failrKr{r~r(rrr�test_setitem	sJ�����zByteArrayTest.test_setitemcCsbttd��}|d=|�|ttdd���|d=|�|ttdd���|d=|�|tgd���dS)Nr@rr9rDr@r�)r9rHrYr�r*r�r)r�r_r%r(rrr�test_delitem+szByteArrayTest.test_delitemc	Csttd��}|�t|�ttd���tgd��|dd�<|�|tgd���|dd�=|�|tgd���tgd��|dd�<|�|ttd���td	d
g�|dd�<|�|tgd
���gd�|dd�<|�|ttd���gd�|dd�<|�|tgd���d|dd�<|�|tgd���td�|dd�<|�|tgd���g|dd�<|�|tgd���dddtd�ddddgddgggf	D]}|�t��||dd�<Wd�n1s�wYq�gd�dd gfD]}|�t��||dd�<Wd�n	1�swYq�dS)!Nr@)r9r9r9r9r9rr�)
r9r9r9r9r9r�r*r�rr@r�)r�r*r�rr@)rr9rHrYr�rA�er�r�)rr9rHrAr3r�rr@)rYr�r�r*rY)rNrNrN)
rr9rHrNrNrNrYr�r�r*r�rr@sfoo)rr9rH�f�or5)r4r5r5r4r5r5r�)r4r5r5r5r5gP����KDr�gffffff@r0r)r�r�)rxryrMi���i(#)	r�r_r%r`r
r�rJr~r{)rr)�elemrrr�
test_setslice4sB
������zByteArrayTest.test_setslicecCsvttd��}|�t|�ttd���|dd�=|�t|�ttdd���|�tdd��|�t|�ttdd���dS)NrAr@�n)r�r_r%r`�extendr(rrr�test_setslice_extend\s
z"ByteArrayTest.test_setslice_extendcCs,td�}|��|dd�=|td�7}~dS)Nr@r9rH)r��poprvr(rrr�test_fifo_overrunes

zByteArrayTest.test_fifo_overruncCs2td�}t�|�}|dd�=|�t�|�|�dS)Nr@r9)r�r;�	getsizeof�assertLessEqual)rr)r�rrr�test_del_expandns

zByteArrayTest.test_del_expandcCs�dddddddd>tjddd	d
f}|D]O}|D]J}|dd�D]A}ttd��}t|�}||||�}|��|||||�<|||||�<|�|t|��||||�=||||�=|�|t|��qqqdS)Nrr9rYr�r�iMrDrEr�i���ry)r;r<r`r_r�r�r%)rr�r�r�r�r�r)rrrr�test_extended_set_del_sliceus&����z)ByteArrayTest.test_extended_set_del_slicecCs@ttd��}||dd�<|�|tttd��ttd����dS)NrMr)r�r_r%r`r(rrr�test_setslice_trap�s(z ByteArrayTest.test_setslice_trapcCs|td�}|}|d7}|�|d�|�||�|�||�|d7}|�|d�z|d7}Wn
ty6YdSw|�d�dS)Nr�r�r�r�s	abcdefxyzrz'bytes += unicode didn't raise TypeError)r�r%r^r~r0�rr)r�rrr�test_iconcat�s�zByteArrayTest.test_iconcatcC�<td�}|}|d9}|�|d�|�||�|�||�dS)Nr�rYr��r�r%r^rBrrr�test_irepeat��zByteArrayTest.test_irepeatcCrD)Nr�rAsdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrErBrrr�test_irepeat_1char�rGz ByteArrayTest.test_irepeat_1charcCsdt�}|��}|�|d�|g}td�D]}|d7}|��}|�|t|��||vr/|�|�qdS)NrrAr�)r��	__alloc__�assertGreaterEqualr_�
assertGreaterrIrs)rr)�allocr5rTrrr�
test_alloc�s
��zByteArrayTest.test_alloccsft����fdd�}��|����t��ttdd�����t��d����}��|t���dS)Nc	3s~�tdd�D]6}|Vt��}��|ttdt|�d�����t��t|����t��|����}��|t���qdS)Nr9rA)r_r`r%rIr>rIrK)rTr0rL�r)rrr�g�s��z(ByteArrayTest.test_init_alloc.<locals>.gr9rA�c)r�rr%r`r_rIrIrK)rrOrLrrNr�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|jgd	��|�t|jgd
��|�t	|�d�td�}|�t
td��g�|�|d
�dS)NrEr�r��css�|]}t|�VqdSr)r�r%rrrrU�r&z,ByteArrayTest.test_extend.<locals>.<genexpr>�2r�)rr9rHrM)rr9rHrDrr0r�)r�r9r%r�r�rcr`rJr{rIrr�)rr_r0rrr�test_extend�s2
zByteArrayTest.test_extendcstd����td��|��d���td��|��d�|�t�fdd��|�t�fdd��|�t�fdd����td	����td
��|��d�|�t�fdd����ttd
���|��d�tgd��}|�d�|�|tgd���|�d�|�|tddg��dS)NrEr�shelosheocs��td��S)Nr�)r"r�rr5rrr6�r>z+ByteArrayTest.test_remove.<locals>.<lambda>c�
��d�S)Ni��r"rr5rrr6�r=crU)Nr�rVrr5rrr6�r=r�r�r�crU)Nr�rVrr5rrr6�r=r�r�)�~r�rV�r�)rWrVrXrXrWrV)	r�r"r�r%rJr{r~rrvr�rr5r�test_remove�s&

zByteArrayTest.test_removecs�td��|����td��|���d�td��|���d�td��|�t�fdd��|�td	d��|�td
���d�dS)Nr[r�rrCrEr)crU)Nr@)r;rr5rrr6r=z(ByteArrayTest.test_pop.<locals>.<lambda>cS�
t���Sr)r�r;rrrrr6r=rry)r�r%r;r�rJrKrrr5r�test_popszByteArrayTest.test_popcCs|�tdd��dS)NcSrZr)r��sortrrrrr6
r=z+ByteArrayTest.test_nosort.<locals>.<lambda>)rJ�AttributeErrorrrrr�test_nosortrzByteArrayTest.test_nosortcs�td����td��|��d�|���d�d�t����td��|�t��d�|�t�fdd��t����ttd���|��d	�dS)
Nshellr�rErAr�r9crU)NrL)rsrr5rrr6r=z+ByteArrayTest.test_append.<locals>.<lambda>�A)r�rsr�r%rIrJr~rrrr5r�test_appendszByteArrayTest.test_appendcs�td����dtd����dtd����dtd����dtd��|��d�|�t�fdd	��t����d
ttd���|��d�dS)
Nsmssssppr9rTr�rErrr8cs��dd�S)Nr�1)�insertrr5rrr6#rBz+ByteArrayTest.test_insert.<locals>.<lambda>rr�r_)r�rbr�r%rJr~rrrr5r�test_insertszByteArrayTest.test_insertcCsRtd�}|�||�ddd��tdd�td�D��}td�}|�||�|��dS)Nr�scdercSsg|]}|�qSrrrRrrrr�.rGz-ByteArrayTest.test_copied.<locals>.<listcomp>rMr�)r�r+rgr_r�)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��yr��!)r�rzr%r+r|)rr0r)r�rrr�0test_partition_bytearray_doesnt_share_nullstring2s$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)Nr@cs"t|dd|d��dd�<dS)Nr9rHrD)r_)r&r5rr�resizeNs"z3ByteArrayTest.test_resize_forbidden.<locals>.resize�r@rr9cs
�d=dSr8rrr5rr�delitem]rz4ByteArrayTest.test_resize_forbidden.<locals>.delitemcsd�ddd�<dS)Nr�r9rDrHrrr5rr�delslicebsz5ByteArrayTest.test_resize_forbidden.<locals>.delslice)r�r_r
rJ�BufferErrorr%r;r")r�vrir_rkrlrr5r�test_resize_forbiddenGs*z#ByteArrayTest.test_resize_forbiddencCs ddlm}|�t|t��dS)Nr)�getbuffer_with_null_view)r�rprJrmr�)rrprrr�test_obsolete_write_lockgsz&ByteArrayTest.test_obsolete_write_lockc	Cs�td�}td�}ttjd�D]�}t|�}t�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|�t
|�t�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|dd��tdt|��D]}t
|�qrt�||f|�}t�|�\}}||dd�<|�t	|�t	|��|�t|�|t|�d��|�t
t
|�t�||f|�}t�|�\}}||dd�<|�t|�g�qdS)Nr�sqwertyr9)r�r`r_r�r�rcr�r�r%r&r�rIrJ�
StopIteration)	rr_rr��itorigr�r�r)rTrrr�test_iterator_pickling2ls8
�z%ByteArrayTest.test_iterator_pickling2cCs4td�}t|�}t|�|��|�t|�g�dS)Nr�)r�rcr�rlr%r`)rrr�rrr�test_iterator_length_hint�s
z'ByteArrayTest.test_iterator_length_hintcCsLtd�}d|dd�<|d}|d}|�|d�|�||�|�|d�dS)Nr�r�rHr9rYsxcsxcxcxc�r�r%)rr)r�r�rrr�test_repeat_after_setslice�sz(ByteArrayTest.test_repeat_after_setslicec	sG�fdd�d�}|�d��&td��|�t��
|��d<Wd�n1s(wYWd�n1s7wY|�d��7t�d�}td��|�t��|��d|��Wd�n1scwYWd�dSWd�dS1s{wYdS)Ncrh)z/ByteArrayTest.test_mutating_index.<locals>.Boomcrir4rkrr5rrr�rnz9ByteArrayTest.test_mutating_index.<locals>.Boom.__index__Nrorr5rr�Boom�rqrx�
tp_as_mappingsNow you see me...r�tp_as_sequencer�)�subTestr�rJrKrr��sequence_setitem)rrxr�rr5r�test_mutating_index�s"���
��"�z!ByteArrayTest.test_mutating_indexN).r r!r"r�r$r�rrr'r(r*r2r/r1r2r7r:r<r?r@rArCrFrHrMrQrTrYr[r^r`rcrerhror�r��cpython_onlyrqrt�
list_tests�
CommonTest�test_exhausted_iteratorrurwr}rrrrr�sN"	(		


 

$	
rc@s�eZdZedd��Zedd��Zdd�Zejj	dd��Z
d	d
�Zedd��Zd
d�Z
dd�Zdd�Zdd�Ze�ejjd�dd��ZdS)�AssortedBytesTestcCs�ttfD]:}|�|t��d�|�|tdg��d�|�|tgd���d�|�|d�d�|�|d�d	�|�|d
�d�qdS)N�bytearray(b'')rzbytearray(b'\x00')rzzbytearray(b'\x00\x01\xfe\xff')r�zb'abc'�'zb"'"s'"zb'\'"')r��reprr%r�r�rrr�
test_repr_str�s��zAssortedBytesTest.test_repr_strc	Cs�dtd�fD]:}|�t|�t|��|�t|d�t|��|�tdt�t|�j	���
t|d�Wd�n1s;wYqdS)Nr�rz\b%s\br�)
r�r%r�r�rQr~r-�escaper&r r(rrr�test_format�s����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�Frurrrr�test_compare_bytes_to_bytearray�s0z1AssortedBytesTest.test_compare_bytes_to_bytearraycCsH|�tj�|�tj�d�tj�|�tj�|�tj�d�tj�dS)Nz
bytearray(zbytes()�assertIsNotNoner��__doc__r�rHrvrrrr�test_doc�szAssortedBytesTest.test_doccCs,td�}t|�}t|�}|�|t|��dS)NsHello world
����)rvr
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)
Nr�zb''r�zb'x'rzb'\x80'r�zbytearray(b'x')zbytearray(b'\x80'))r%r�r�rrrr�test_to_str�szAssortedBytesTest.test_to_strcCsRgd�}|D]
\}}|�|t|d��qtdd�D]
}|�ttdt|��qdS)N))sWonderful spamzWonderful spam)sWonderful spam toozWonderful spam too)s��uª€)s\xaa\x00\000\200z\xaa\x00\000\200r�rVrMzb"%s")r%r�r_rJ�SyntaxError�evalr)r�testsr)r�r�rrr�test_literals
��zAssortedBytesTest.test_literalcC�|�d�td��ddg�dS�Nrir0r�r�)r%rpr
rrrr�test_split_bytearray�z&AssortedBytesTest.test_split_bytearraycCr�r�)r%rqr
rrrr�test_rsplit_bytearrayr�z'AssortedBytesTest.test_rsplit_bytearraycCst�}|�|�dd�|�dS)Nr�)r�r+rgr(rrr�test_return_selfsz"AssortedBytesTest.test_return_selfz4BytesWarning is needed for this test: use -bb optioncCsJdd�}|��ddkWd�n1swY|��ddkWd�n1s-wY|��ddkWd�n1sDwY|��ddkWd�n1s[wY|��td�dkWd�n1stwY|��dtd�kWd�n1s�wY|��td�dkWd�n1s�wY|��dtd�kWd�n1s�wY|��ddkWd�n1s�wY|��ddkWd�n1s�wY|��ddkWd�n	1�swY|��
ddkWd�dS1�swYdS)NcSst�dtf�Srr	rrrr�
bytes_warningr,z5AssortedBytesTest.test_compare.<locals>.bytes_warningr�rr�r�r�)rr�rrrr�sJ
�
�
�
�����
�
�
�
$�zAssortedBytesTest.test_compareN)r r!r"rr�r�r�r�r��requires_docstringsr�r�r�r�r�r�r��unittest�
skipUnlessr;�flagsr�r�rrrrr��s&






�r�c@r�)�BytearrayPEP3137TestcCst|�Srr�)rr�rrr�marshalIr[zBytearrayPEP3137Test.marshalcCs�|�d�}dD]}t||�}|d�}|�||�|�|||d�qdD]}t|�}|�||�|�|||d�q$|�d�}|�|g�}|�||�|�||�dS)Ns1234)�zfillr�r�r�rYz" 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 objectr�)r��getattrr%r+r�r2)r�val�methnamer��newval�expr�seprrr�test_returns_new_copyLs$

��
z*BytearrayPEP3137Test.test_returns_new_copyN)r r!r"r�r�rrrrr�Hsr�cs eZdZ�fdd�ZdZ�ZS)�FixedStringTestcs&t|t�r
|�|�d��St��|�S)Nr�)�
isinstancer�r$r��super�fixtype)rr��r'rrr�ds
zFixedStringTest.fixtypeT)r r!r"r��contains_bytes�
__classcell__rrr�rr�csr�c@�eZdZeZdS)�ByteArrayAsStringTestN)r r!r"r�r$rrrrr�krr�c@r�)�BytesAsStringTestN)r r!r"rvr$rrrrr�nrr�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,�efghr�)r��
issubclassr$�basetyper�r+r%)rr0r)�_a�_brrr�
test_basictszSubclassTest.test_basiccCs`|�d�}|���|g�}|�||�|�t|�|jt|��|�dg�}|�t|�|j�dSr+)r$r�r2r+r^r&)r�s1�s2�s3rrrr7�s
zSubclassTest.test_joincCs�|�d�}d|_|�d�|_ttjd�D]A}t�t�||��}|�t	|�t	|��|�
||�|�
|j|j�|�
|j|j�|�
t|�t|��|�
t|j�t|j��qdS)Nr,r@r�r9)r$r��yr_r�r�r�r�rrr%r&)rr0r�r)rrr�test_pickle�s
�zSubclassTest.test_picklecCs�|�d�}d|_|�d�|_tjtjfD]<}||�}|�t|�t|��|�||�|�|j|j�|�|j|j�|�t|�t|��|�t|j�t|j��qdS)Nr,r@r�)	r$r�r�r-r.rrr%r&r/rrrr2�s
�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)Nrrcrh)z%SubclassTest.test_fromhex.<locals>.B1cs�j�||�}d|_|S�N�bar)r��__new__�foo)�clsr�merrrr��sz-SubclassTest.test_fromhex.<locals>.B1.__new__N)r r!r"r�rrrr�B1�rqr�r�crh)z%SubclassTest.test_fromhex.<locals>.B2cs.�jtur�jj|g|�Ri|��d|_dSr�)r�rvrr�)r�r�kwargsrrrr�s

z.SubclassTest.test_fromhex.<locals>.B2.__init__N�r r!r"rrrrr�B2�rqr�)r$rr%r^r&r�r�)rr)r�r�rrrr	�s

zSubclassTest.test_fromhexN)r r!r"r�r7r�r2r	rrrrr�rs


r�c@r�)�ByteArraySubclassNr�rrrrr��r�r�c@r�)r�Nr�rrrrr��r�r�c@r�)r�Nr�rrrrr��r�r�c@seZdZeZeZdd�ZdS)�ByteArraySubclassTestcCsNGdd�dt�}|dd�}|ddd�}|�|d�|ddd�}|�|d�dS)Nc@seZdZddd�ZdS)z:ByteArraySubclassTest.test_init_override.<locals>.subclassr9c_stj|g|�Ri|��dSr)r�r)r��newargrr�rrrr�rlzCByteArraySubclassTest.test_init_override.<locals>.subclass.__init__Nr�r�rrrr�subclass�sr�r�r,)�source)r�r�rv)rr�r�rrr�test_init_override�s
z(ByteArraySubclassTest.test_init_overrideN)r r!r"r�r�r�r$r�rrrrr��sr�c@seZdZeZeZdS)�BytesSubclassTestN)r r!r"rvr�r�r$rrrrr��sr��__main__).r�rr�r-r;r-rr�rr�r��test.supportr�rr�test.string_tests�test.list_testsrr�test.support.script_helperrr�r�rrr#�TestCaser�rr�r��string_tests�BaseTestr�r�r�r�r�r�rvr�r�r�r�r �mainrrrr�<module>sh
-W]�

Youez - 2016 - github.com/yon3zu
LinuXploit