Your IP : 216.73.217.129


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_memoryio.cpython-38.opt-2.pyc

U

i�f�}�@s�ddlZddlmZddlZddlZddlZddlZGdd�d�ZGdd�d�Z	Gdd�d�Z
Gd	d
�d
e
e	ej�ZGdd�d�Z
Gd
d�de
e	e
ej�ZGdd�de
ej�ZGdd�de�ZGdd�de�ZGdd�de�Zedkr�e��dS)�N)�supportc@s eZdZdd�Zdd�ZeZdS)�IntLikecCs
||_dS�N�Z_num)�selfZnum�r�7/opt/alt/python38/lib64/python3.8/test/test_memoryio.py�__init__szIntLike.__init__cCs|jSrr�rrrr�	__index__szIntLike.__index__N)�__name__�
__module__�__qualname__r	r�__int__rrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�MemorySeekTestMixincCs|�d�}|�|�}dS�N�
1234567890)�buftype�ioclass�r�bufZbytesIorrr�testInits
zMemorySeekTestMixin.testInitcCsx|�d�}|�|�}|�|dd�|�d��|�|dd�|�d��|�|dd�|�d��|�|j|���dS)Nr�����rr�assertEqual�read�EOFrrrr�testReads

zMemorySeekTestMixin.testReadcCs:|�d�}|�|�}|�||���|�|j|���dSrrrrrr�testReadNoArgs$s

z"MemorySeekTestMixin.testReadNoArgscCsn|�d�}|�|�}|�d�|�d�|�||���|�d�|�|dd�|���|�t|jd�dS)Nrrr��)rrr�seekr�assertRaises�	TypeErrorrrrr�testSeek+s




zMemorySeekTestMixin.testSeekcCs\|�d�}|�|�}|�d|���|�d�|�d|���|�d�|�d|���dS�Nrrri')rrr�tellr$rrrr�testTell7s



zMemorySeekTestMixin.testTellN)rr
rrr r!r'r*rrrrrs
	rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�MemoryTestMixincCs|��}|�|j|j�dSr)rr%�UnsupportedOperation�detach�rrrrr�test_detachDszMemoryTestMixin.test_detachcCs�|�|�|d��d�|�|�d�d�|�|�|d��d�|�|��d�|�|�d�d�|�|��d�|�|�|d��d�|�|�d�d�|�|�|d��d	�|�|�d
�d
�|�|��d	�dS)Nzblah.rrzHello.�z	 world


�	�hr�)r�writer$r)�truncate)r�f�trrr�	write_opsHszMemoryTestMixin.write_opscCs�|�d�}|�|�}|�||j�|�|��|�|��}|�||j�|�|��|�|�t|jd�|��|�t	|j|�d��dS)Nzhello world
�)
rrr8r�getvaluer%r&r4�close�
ValueError�rr�memiorrr�
test_writeUs

zMemoryTestMixin.test_writecCs�|�d�}|��}|�|�|gd�d�|�|��|d�|�g�|�|��|d�|��}|�t|j|gdg�|�|��|�|�t|jd�|��|�t|jg�dS)Nr�dr)	rrr�
writelinesr:r%r&r;r<r=rrr�test_writelinesbs

zMemoryTestMixin.test_writelinescs*���}�fdd�}��t|j|��dS)Nc3s��d�Vt�dS)N�spam)r�KeyboardInterruptrr
rr�	error_genssz8MemoryTestMixin.test_writelines_error.<locals>.error_gen)rr%rDrA)rr>rErr
r�test_writelines_errorqsz%MemoryTestMixin.test_writelines_errorcCsn|�d�}|�|�}|�t|jd�|�t|jtd��|�d�|�|�td��d�|�|��|dd��|�|��d�|�|��|dd��|�|�d�d�|�|��|dd��|�|�	�d�|�dd�|�
|�|�|��|dd�|�|�	�}|�|�d�|�|�|�	�|�|�t|jd�|��|�t|jd�|�t|jtd��dS)	Nr���r0�rr��0)
rrr%r<r5rr$rr:r)r4r&r;)rrr>�posrrr�
test_truncateys,



zMemoryTestMixin.test_truncatecCs�|�d�}|�|�}|�|��|�|�d�}|�|��|j�|�|d�|�|��|d�|�|�|�|��|�|�t|jg�dS)NrrI)rrrr:rr	r%r&r=rrr�	test_init�s



zMemoryTestMixin.test_initcCsz|�d�}|�|�}|�|�d�|j�|�|�d�|dd��|�|�d�|dd��|�|�d�|dd��|�|��|j�|�d�|�|�td��|j�|�|�td��|dd��|�|�td��|dd��|�|�td��|dd��|�d�|�|��|�|�|��|j�|�|��d�|�d�|�|�d�|�|�d�|�|�td��|�|�d�|�t|���t|��|�d	�|�t|���t|��|�d�|�|�d�|�|�	t
|jd
�|�t|�d�|�|�d�|j�|�t|�d�|�|�td��|j�|�t|�d�|�|��|j�|��|�	t
|j�dS)Nrrrrrr�
rGr@r9)rrrrrr$rr)�typer%r&�lenr;r<r=rrr�	test_read�sF








zMemoryTestMixin.test_readcCs�|�d�}|�|d�}|�|�d�|j�|�|�td��|j�|�|��|�|�|��|�|�|��|j�|�d�|�|�d�|dd��|�|�d�|dd��|�|�d�|dd��|�d�|�|�td��|dd��|�|�td��|dd��|�|�td��|dd��|�d�|�|�d�|�|�d�|�|�td��|�|�d�|�|�d�|j�|�|�td��|j�|�t|�dd�|�|��|j�|�d�}|�|d	dd��}|�|��|�|�|��|�|�|��|dd��|�|��|j�|�d�|�t|���t|��|�|��|�|�	t
|jd
�|��|�	t|j�dS)N�1234567890
rIrrrN�rGrr"r9)
rrr�readlinerrr$rPrOr%r&r;r<r=rrr�
test_readline�sH







zMemoryTestMixin.test_readlinecCsZ|�d�}|�|d�}|�|��|gd�|�d�|�|��|dd�g|gd�|�d�|�|�d�|gd�|�d�|�|�d�|gd�|�d�|�|�d�|gd�|�d�|�t|��d�t|��|�d�|�|�d�|gd�|�t|jd	�|�t|�dd
�|�|��g�|�	�|�t
|j�dS)NrRrNrr1rrSrIrGr9r)rrr�	readlinesr$rOr%r&rPr;r<r=rrr�test_readlines�s(

$




zMemoryTestMixin.test_readlinescCs�|�d�}|�|d�}|�t|�|�|�t|d��|�t|d��d}|D]}|�||�|d7}qP|�|d�|�d�d}|D]}|�||�|d7}q�|�|d�|�t|�dd�|�t|�g�|�|d�}|�	�|�
t|j�dS)NrRrN�__iter__�__next__rrrI)
rrr�iterZ
assertTrue�hasattrr$rP�listr;r%r<rY)rrr>�i�linerrr�
test_iterators*



zMemoryTestMixin.test_iteratorcCs�|�d�}|�|�}|�|��|�|��|�|��|�|�t|���t|��|�|d�}|�|��dd�|�d��|�|�}|��|�t|j�dS)Nr�����Z890)	rrrr:rrOr;r%r<r=rrr�
test_getvalues


zMemoryTestMixin.test_getvaluecCs\|�d�}|�|�}|�d�|�t|jd�|�t|jdd�|�t|jdd�|�|�d�d�|�|�dd�d�|�|��|�|�|�d�d�|�|�dd�d�|�|��|dd��|�|�t|��t|��|�|��|j�|�t|�d�|�|��|j�|�|�dd�t|��|�|��|j�|�	�|�t|jd�dS)NrrrGrr"rrI)
rrrr%r<r$rrPrr;r=rrr�	test_seek,s(


zMemoryTestMixin.test_seekcCs�|�d�}|�|�}|�|�t|�d�d�|�|��|j�|�|��d�|�|��|�|�	|j�|�|��|�|�	|�|�|��||�d�|�dS)Nrr��)
rrrr$rPrrr)r:r4r=rrr�
test_overseekCs


zMemoryTestMixin.test_overseekcCsr|�d�}|�|�}|�|��d�|�d�|�|��d�|�d�|�|��d�|��|�t|j�dSr()rrrr)r$r;r%r<r=rrr�	test_tellPs



zMemoryTestMixin.test_tellcCs(|�d�}|�|�}|�|��d�dSr)rrr�flushr=rrr�
test_flush\s

zMemoryTestMixin.test_flushcCs�|��}|�|��d�|�|��d�|�|��d�|�|��d�|�|jd�|��|�t	|j�|�t	|j�|�t	|j�|�t	|j�|�|jd�dS)NTF)
rr�writable�readable�seekable�isatty�closedr;r%r<�rr>rrr�
test_flagsbszMemoryTestMixin.test_flagscsF��d����fdd�}��fdd�}��|�����|���dS)Nrcs"Gdd�d�j�}|��}|��S)Nc@seZdZdS)z>MemoryTestMixin.test_subclassing.<locals>.test1.<locals>.MemION)rr
rrrrr�MemIOtsrq�rr:�rq�m�rrrr�test1ssz/MemoryTestMixin.test_subclassing.<locals>.test1cs(G�fdd�d�j�}|�d�}|��S)NcseZdZ�fdd�ZdS)z>MemoryTestMixin.test_subclassing.<locals>.test2.<locals>.MemIOcs�j�||�dSr)rr	)�me�a�br
rrr	zszGMemoryTestMixin.test_subclassing.<locals>.test2.<locals>.MemIO.__init__N�rr
rr	rr
rrrqysrqrrrsrurr�test2xs
z/MemoryTestMixin.test_subclassing.<locals>.test2)rr)rrvr{rrur�test_subclassingqs

z MemoryTestMixin.test_subclassingcCs td�D]}|��}d|_qdS)Nr@r)�ranger�foo)r�_r>rrr�test_instance_dict_leak�sz'MemoryTestMixin.test_instance_dict_leakc	s��d�}��|�}d|_|�d�G�fdd�d�j�}ddl}d|_|j|_||_||d�}|�d�t	dt
jd	�D]�}||fD]z}t
�t
j
||d
��}��|��|�����|j|j���|j|j���|��|���|����tt
j
||�q�qz|`dS)Nr�*rIcseZdZ�fdd�ZdS)z6MemoryTestMixin.test_pickling.<locals>.PickleTestMemIOcs�j�||�||_dSr)rr	r~)rwZ	initvaluer~r
rrr	�sz?MemoryTestMixin.test_pickling.<locals>.PickleTestMemIO.__init__Nrzrr
rr�PickleTestMemIO�sr�r�__main__�Pr)Zprotocol)rrr~r$r�r
rrr�r}�pickleZHIGHEST_PROTOCOL�loads�dumpsrr:�	__class__r)r;r%r<)	rrr>r�r�Zsubmemio�proto�objZobj2rr
r�
test_pickling�s*




zMemoryTestMixin.test_picklingN)rr
rr/r8r?rBrFrLrMrQrUrWr_rbrcrfrgrirpr|r�r�rrrrr+Bs(

&)
r+c@s`eZdZejZedd��ZejZdZ	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�ZdS)�
PyBytesIOTestcCs
|�d�S)N�ascii)�encode)�srrrr�szPyBytesIOTest.buftype�cCs�|�d�}|��}|�t|�d�|�d�|��}|�t|�d�|�t|jd�|�t|j�|�t|j	�|�
|j�d|dd�<|�t|�d�|�|��d�~t
��|��|�	�|�t|j�dS)N�
1234567890rsdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsabcr"r0s
123abc7890)r�	getbufferr�bytesr$r%�BufferErrorr4r5r;�assertFalsernr:rZ
gc_collectr<)rr>rrrr�test_getbuffer�s$

zPyBytesIOTest.test_getbuffercCs<|�d�}|�|�|���|�|�|�|��d�|�dS)NrrG)rrr�read1r.rrr�
test_read1�s
zPyBytesIOTest.test_read1cCsj|�d�}|�|�}td�}|�|�|�d�|�|d�|�|�|�d�|�|d�|�|�|�d�|�|d�td�}|�d�|�|�|�d�|�|d	�td
�}|�d�|�|�|�d�|�|d
�|�t|jd�ddl}|�dd�}|�|�}|�|�|�|�	�d	�|�
�|�t|j|�|�d
�}t�}|�d�|�|�|�|d
�dS)Nrshellors12345s67890rshello worldrNs1234567890dr�r9rys123r�)rr�	bytearrayr�readintor$r%r&�array�tobytesr;r<)rrr>ryr�rxrrr�
test_readinto�s<








zPyBytesIOTest.test_readintocCs�|�d�}|�|�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d�|�|�dd�d	�|�|�dd�d
�|�dd�|�|��|dd��|�d�|�dd�|�|��|dd��dS)NrrGrrr"���rIr1rNrdra)rrrr$rr=rrr�test_relative_seek�s


z PyBytesIOTest.test_relative_seekcCs>|��}|�t|jd�|�t|jd�|�t|jdg�dSr)rr%r&r4rArorrr�test_unicodeszPyBytesIOTest.test_unicodecCs\d}ddl}|�dt|��}|�|�}|�|��|�|�|�|�d�|�|��|�dS)Nr�rryrN)r�r\rrr:r4)rrr�rxr>rrr�test_bytes_arrays
zPyBytesIOTest.test_bytes_arraycCs.|�d�}|j|d�|jt|j|dd�dS)Nr)Z
initial_bytes)r~)rrr%r&r.rrr�test_issue5449s
zPyBytesIOTest.test_issue5449N)rr
r�pyior,�staticmethodr�BytesIOrrr�r�r�r�r�r�r�rrrrr��s
!	r�c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TextIOTestMixincs�|jdd���fdd�}|��jd���d�|�|��jd���d�|�|��jd���d�|�|��jd	�dS)
N��newlinecs��d����dS)Nr)r$rr�r>rr�force_decode%s
z<TextIOTestMixin.test_newlines_property.<locals>.force_decode�a
�
�b
)r��
�c
d)�
r�r�)rr�newlinesr4)rr�rr�r�test_newlines_property s


z&TextIOTestMixin.test_newlines_propertycCsx|��}|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�dS)NrGrr"rarI)rr%�OSErrorr$rorrrr�3sz"TextIOTestMixin.test_relative_seekcCs0|��}|�|j�|�|j�|�|j�dSr)rZassertIsNone�encoding�errorsr��line_bufferingrorrr�test_textio_properties=sz&TextIOTestMixin.test_textio_propertiescCs~|�d�}|�t|�dddg�|�|��d�|��}|�|�d�d�|�d�|�t|�dddg�|�|��d�dS)N�a
b
c
dr�r�r�rHr�rrr\r:r4r$rorrr�test_newline_defaultFs

z$TextIOTestMixin.test_newline_defaultcCs|jddd�}|�t|�ddddg�|�d�|�|�d�d	�|�|�d
�d�|�|�d
�d�|�|�d�d
�|�|��d�|jdd�}|�d
|�d��|�d|�d��|�d|�d��|�d�|�|��d�|�|��d�|jddd�}|�|�d�d�dS)Nr�r�r�zb
zc
�drrrxrIz
b�
cr�za
b
c
dr"r�r�za
bza
b�rrr\r$rr:r4rorrr�test_newline_noneQs"

z!TextIOTestMixin.test_newline_nonecCs|jddd�}|�t|�ddddg�|�d�|�|�d	�d
�|�|�d�d�|�|�d
�d�|�|��d�|jdd�}|�d|�d��|�d|�d��|�d|�d��|�d|�d��|�d�|�t|�ddddg�|�|��d�dS)Nr�r9r�r�r��c
r�rrza
b
rIr�rr��b
z
dr�rorrr�test_newline_emptygs

z"TextIOTestMixin.test_newline_emptycCs�|jddd�}|�t|�dddg�|�|��d�|jdd�}|�|�d�d�|�d�|�t|�dddg�|�|��d�dS)	Nr�r�r�r�r�r�rHrr�rorrr�test_newline_lfzs
zTextIOTestMixin.test_newline_lfcCs�|jddd�}|�|��d�|�d�|�t|�ddddd	g�|�|��d�|jdd�}|�|�d�d
�|�d�|�t|�ddddd	g�|�d�|�|��ddddd	g�|�|��d�dS)Nr�r�r�za
b

c
drza
r�r�r�rH)rrrr$r\r:r4rVrorrr�test_newline_cr�s


zTextIOTestMixin.test_newline_crcCs�|jddd�}|�|��d�|�d�|�t|�dddg�|�d�|�|��dddg�|�|��d�|jdd�}|�|�d�d	�|�d�|�t|�dddg�|�|��d�dS)
Nr�r�r�z
a
b

c
drza
zb

r�rH)rrrr$r\rVr:r4rorrr�test_newline_crlf�s


z!TextIOTestMixin.test_newline_crlfcCs4|jddd�}|�|�d�d�|�|��d�dS)Nza
b
r�rza
b
)rrrr:rorrr�test_issue5265�szTextIOTestMixin.test_issue5265cCs>|jt|jdd�|jt|jdd�dD]}|j|d�q(dS)N�
r��error)Nr9r�r�r�)r%r&rr<)rr�rrr�test_newline_argument�sz%TextIOTestMixin.test_newline_argumentN)rr
rr�r�r�r�r�r�r�r�r�r�r�rrrrr�s
	r�c@s(eZdZeZejZejZdZ	dd�Z
dS)�PyStringIOTestr9cCs@|�d�}|�|��d�|��}|�d�|�|��d�dS)Nu�)rrrr4r:rorrr�test_lone_surrogates�s


z#PyStringIOTest.test_lone_surrogatesN)rr
r�strrr��StringIOrr,rr�rrrrr��s
r�c@s,eZdZeZejZdZGdd�dej�Z	dS)�PyStringIOPickleTestr9c@seZdZdd�Zdd�ZdS)zPyStringIOPickleTest.ioclasscOst�t�tj||���Sr)r�r�r�r�r���cls�args�kwargsrrr�__new__�sz$PyStringIOPickleTest.ioclass.__new__cOsdSrr�rr�r�rrrr	�sz%PyStringIOPickleTest.ioclass.__init__N�rr
rr�r	rrrrr�srN)
rr
rr�rr�r,rr�rrrrrr��sr�c@s|eZdZejZejZdd�Zdd�Ze	j
Z
e	jdd��Zdd�Z
e	jd	d
��Ze	jdd��Ze	jd
d��Ze	jdd��ZdS)�CBytesIOTestcCsr|��}|��}|�t|�d�t|d�|�|dt�|ddk	rX|�|dt�|��|�	t
|j�dS)Nr"rrrI)r�__getstate__rrPr��assertIsInstance�int�dictr;r%r<�rr>�staterrr�
test_getstate�szCBytesIOTest.test_getstatecCs�|��}|�d�|�td�ddf�|�ddddif�|�t|jd�|�t|jd�|�t|jd�|�t|jd	�|�t|jd
�|�t|j�|�t|jd�|��|�t|jd�dS)N)�no errorrNr�rrCr")r�rGN)ZunicoderN)r�r#N)r�rr)slen-testr)sclosedrN)r�__setstate__r�r%r<r&r;rorrr�
test_setstate�s
zCBytesIOTest.test_setstatecCs^t�d�}|j}|�t�t���|�|t��|�d}|t�d|�|t�	d|��dS)NZP2n2Pnr`�a)
rZcalcobjsize�check_sizeofr�object�
__sizeof__�ior��sys�	getsizeof)rZbasesizeZcheck�nrrr�test_sizeof�s
zCBytesIOTest.test_sizeofcCsLd}t�|�}|�|�}|�t�|�|d�||�|�t�|�|�dS)Ns                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                r)r��getrefcountrr)r�mutationZimm�old_rcr>rrr�_test_cow_mutation�s

zCBytesIOTest._test_cow_mutationcCsdd�}|�|�dS)NcSs|�d�dS)Nr)r5r�rrrr�sz0CBytesIOTest.test_cow_truncate.<locals>.mutation�r��rr�rrr�test_cow_truncateszCBytesIOTest.test_cow_truncatecCsdd�}|�|�dS)NcSs|�d�|�d�dS)Nrsfoo)r$r4r�rrrr�s
z-CBytesIOTest.test_cow_write.<locals>.mutationr�r�rrr�test_cow_writeszCBytesIOTest.test_cow_writecs,|�d�}|����fdd�}|�|�dS)Nsfoooooocs|���dSr)r�r��r�rrr�sz0CBytesIOTest.test_cow_setstate.<locals>.mutation)rr�r�)rr>r�rr�r�test_cow_setstates
zCBytesIOTest.test_cow_setstatecCs2td�}t�|�}|�|�}|�t�|�|�dS)Ni)r�r�r�rr)rZbar�r>rrr�test_cow_mutable s

zCBytesIOTest.test_cow_mutableN)rr
rr�r�rr,r�r�rr�Zcpython_onlyr�r�r�r�r�r�rrrrr��s 

	


r�c@s0eZdZejZejZdd�Zdd�Zdd�Z	dS)�
CStringIOTestcCs�|�d�}|�|�}|�|��|�|�|�|�t|��|�|��t|��|�|��|�|�|�|�t|��|�|��t|�d�|�|��||�dS)Nu𠌊𠍇rI)rrrr:r4rPr)r=rrr�
test_widechar0s

zCStringIOTest.test_widecharcCs�|��}|��}|�t|�d�|�|dt�|�|dt�|�|dt�|ddk	rl|�|dt�|��|�	t
|j�dS)NrrrrIr")rr�rrPr�r�r�r�r;r%r<r�rrrr�<szCStringIOTest.test_getstatecCs�|��}|�d�|�dddddif�|�t|jd�|�t|jd�|�t|jd	�|�t|jd
�|�t|jd�|�t|jd�|�t|jd
�|�t|j�|�t|jd�|��|�t|jd�dS)N)�no errorr�rNr�r9rrCr")r9r6rN)r9r9rGN)r�r9rN)r9r�rN)r9r9r#N)r9r9rr)zlen-testr)rnr9rN)rr�r%r<r&r;rorrrr�Hs
zCStringIOTest.test_setstateN)
rr
rr�r�rr,r�r�r�rrrrr�*s
r�c@s$eZdZejZGdd�dej�ZdS)�CStringIOPickleTestc@seZdZdd�Zdd�ZdS)zCStringIOPickleTest.ioclasscOst�t�tj||���Sr)r�r�r�r�r�r�rrrr�^sz#CStringIOPickleTest.ioclass.__new__cOsdSrrr�rrrr	`sz$CStringIOPickleTest.ioclass.__init__Nr�rrrrr]srN)rr
rr�r,r�rrrrrr�Zsr�r�)ZunittestZtestrr�Z_pyior�r�r�rrr+ZTestCaser�r�r�r�r�r�r�r�mainrrrr�<module>s.-np�W0