Your IP : 216.73.216.85


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_largefile.cpython-39.opt-1.pyc

a

XC?h�'�@s8dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZddlm
Z
ddlmZddlZddlZdZe	dZGdd	�d	�ZGd
d�de�Zdd
�ZGdd�deej�Ze�eed�d�Gdd�deej��Zdd�ZGdd�deej�ZGdd�deej�Zdd�Ze dk�r4e�!�dS)z9Test largefile support on system where this makes sense.
�N)�TESTFN�requires�unlink�
bigmemtest)�
SHORT_TIMEOUT)�
socket_helperly*�2c@s eZdZdd�Zedd��ZdS)�
LargeFileTestcCs�tj�t�rd}nd}|�t|���}t�|���tj}|t	dkrTWd�dS|dkrf|�
d�|�d�|�t	�|�
d�|��|�
t�|���tjt	d�Wd�n1s�0YdS)N�r+bzw+b�r�z�a)�os�path�existsr�open�fstat�fileno�stat�ST_SIZE�size�write�seek�flush�assertEqual)�self�mode�fZcurrent_size�r�8/opt/alt/python39/lib64/python3.9/test/test_largefile.py�setUps



zLargeFileTest.setUpcCsV|�td��Wd�n1s"0Yt�t�tjdksJ|�d��tt�dS)N�wbrz0File was not truncated by opening with mode "wb")rrrrrZfailureExceptionr�TESTFN2)�clsrrr�
tearDownClass,s

zLargeFileTest.tearDownClassN)�__name__�
__module__�__qualname__r �classmethodr$rrrrr	sr	c@sNeZdZdZeeddd�dd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�TestFileMethodszWTest that each file function works as expected for large
    (i.e. > 2 GiB) files.
    �F)rZmemuseZdry_runcCs\|�td��<}|�t|���td�|�|��td�Wd�n1sN0YdS)N�rbr)rrr�len�readr�tell)rZ_sizerrrr�test_large_read=szTestFileMethods.test_large_readcCs |�t�t�tjtd�dS)Nr)rrrrrr�rrrr�test_osstatDszTestFileMethods.test_osstatcCs�|�td����}|�|��d�|�|�d�d�|�|��d�|�d�|�|��d�|�dd�|�|��d�|�d�|�|��d�|�dd�|�|��d�|�dd�|�|��d�|�dd�|�|��d�|�dd�|�|��tdd�|�dd�|�|��tdd	�|�tdd�|�|��d�|�t�|�|��t�|�|�d�d
�|�tdd�|�|�d�d�|�|��d�Wd�n1�s�0YdS)Nr+rrr�*�Tr*����
r
)rrrr.r-rr�rrrrr�test_seek_readGs8


zTestFileMethods.test_seek_readcCs,|�td���}|�t�|��dd�d�|�t�|��dd�d�|�t�|��dd�d�|�t�|��dd�d�|�t�|��dd�tdd�|�t�|��dd�tdd�|�t�|��tdd�d�|�t�|��td�t�|�|�d�d	�Wd�n1�s0YdS)
Nr+rr2rr3r*r4r5r
)rrrr�lseekrrr-r6rrr�
test_lseekfs"" zTestFileMethods.test_lseekcCs8|�td���}t|d�s$t�d��|�dd�|�|��td�td}|�|�|�	�|�|��|�|�dd�|�|��|�|d8}|�d�|�	|�|�|��d�|�dd�|�|��|�|�d�|�	d�|�|��d�|�d�|�t
|���d�Wd�n1�s*0YdS)	Nr
�truncatez.open().truncate() not available on this systemrr*rr5r2)rr�hasattr�unittest�SkipTestrrr.rr:r,r-)rrZnewsizerrr�
test_truncatess,







zTestFileMethods.test_truncatec	CsRdD]H}|�td��(}|�|�|�|���Wd�q1sB0YqdS)N)i���l�r+)rrrZ
assertTrue�seekable)r�posrrrr�
test_seekable�s
zTestFileMethods.test_seekableN)r%r&r'�__doc__rrr/r1r7r9r>rBrrrrr)6s

r)cs��fdd�}|S)Ncs���fdd�}|S)NcsHt�tj����j�kr:t�dd�}t�d|�d����|i|��S)Niz	required z MiB of free disk space)	�shutilZ
disk_usagerr�realpathZfree�intr<r=)�args�kwargsZhsize)�funr�requiredrr�wrapper�s
�z6skip_no_disk_space.<locals>.decorator.<locals>.wrapperr)rIrK�rrJ)rIr�	decorator�sz%skip_no_disk_space.<locals>.decoratorr)rrJrMrrLr�skip_no_disk_space�srNc@s,eZdZeej�Zeeed�dd��Z	dS)�TestCopyfile�@cCs�tj�t�}t�tt�|�tj�t�|�ttd��@}|�|�	d�d�|�
|d�|�|�	�d�Wd�n1s|0YdS)Nr+��z�a)rr�getsizerrDZcopyfiler"rrr-r)rrrrrr�test_it�szTestCopyfile.test_itN)
r%r&r'�staticmethod�iorrNrrrUrrrrrO�s
rO�sendfilezsendfile not supportedcsTeZdZeej�ZeZ�fdd�Z�fdd�Z	dd�Z
eee
d�dd	��Z�ZS)
�TestSocketSendfilecst���d|_dS�N)�superr �threadr0��	__class__rrr �s
zTestSocketSendfile.setUpcs,t���|jdur(|j�|j�d|_dSrZ)r[�tearDownr\�join�timeoutr0r]rrr_�s

zTestSocketSendfile.tearDowncsJ��fdd�}t���|��j�tj||fd��_�j�����dS)Nc
s�|��|��\}}|��j�|��ttd��^}���j�|�d�}|srWd�Wd�Wd�dS|�|�q<Wd�n1s�0YWd�n1s�0YWd�n1s�0YdS)Nr!i)Zaccept�
settimeoutrarr"�waitZrecvr)�sockZconn�_r�chunk�Zeventrrr�run�s
(z*TestSocketSendfile.tcp_server.<locals>.run)�targetrG)�	threadingZEventrbraZThreadr\�start�set)rrdrhrrgr�
tcp_server�s
zTestSocketSendfile.tcp_serverrPc
Cs*t��}t�d|f��|}|�|�t�d|f��D}ttd��}|�|�Wd�n1s\0YWd�n1sz0YWd�n1s�0Y|�	�t
j�t�}|�
t
j�t�|�ttd��@}|�
|�d�d�|�|d�|�
|��d�Wd�n1�s0YdS)N�z	127.0.0.1r+rQrRrS)rZfind_unused_port�socketZ
create_serverrmZcreate_connectionrrrXr_rrrTrr"r-r)rZportrdZclientrrrrrrU�s
dzTestSocketSendfile.test_it)r%r&r'rVrWrrrar r_rmrNrrrU�
__classcell__rrr]rrY�s
rYc	Cs�zddl}|�|j|j�Wnttfy2Yn0tjdd�dksPtjdkrdtddtt	��nxt
tddd�}zVz |�d	�|�
d
�|��Wn ttfy�t�d��Yn0W|��tt�n|��tt�0dS)Nr��win�darwinZ	largefilez-test requires %s bytes and a long time to runr!)�	bufferingr?�xz*filesystem does not have largefile support)�signal�SIGXFSZ�SIG_IGN�ImportError�AttributeError�sys�platformr�strrrrrrr�OSError�
OverflowErrorr<r=�closer)rvrrrr�setUpModule�s(
�


�r�c@seZdZeej�ZdS)�CLargeFileTestN)r%r&r'rVrWrrrrrr�sr�c@seZdZeej�ZdS)�PyLargeFileTestN)r%r&r'rV�pyiorrrrrr�sr�cCstt�tt�dSrZ)rrr"rrrr�tearDownModulesr��__main__)"rCrrr{r<rorDrjZtest.supportrrrrrrrWZ_pyior�rr"r	r)rNZTestCaserOZskipIfr;rYr�r�r�r�r%�mainrrrr�<module>s4 e5$