Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_largefile.cpython-310.opt-1.pyc

o

0�i�'�@sBdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddlmZddl
mZmZddlZddlZdZedZGd	d
�d
�ZGdd�de�Zd
d�ZGdd�deej�Ze�eed�d�Gdd�deej��Zdd�ZGdd�deej�ZGdd�deej�Zdd�Z e!dkr�e�"�dSdS)z9Test largefile support on system where this makes sense.
�N)�requires�
bigmemtest)�
SHORT_TIMEOUT)�
socket_helper)�TESTFN�unlinkly*�2c@s eZdZdd�Zedd��ZdS)�
LargeFileTestcCs�tj�t�r	d}nd}|�t|��N}t�|���tj}|t	dkr+	Wd�dS|dkr4|�
d�|�d�|�t	�|�
d�|��|�
t�|���tjt	d�Wd�dS1sbwYdS)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�:/opt/alt/python310/lib64/python3.10/test/test_largefile.py�setUps �



""�zLargeFileTest.setUpcCsV|�td��Wd�n1swYt�t�tjdks%|�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�dS1s(wYdS)N�rbr)rrr�len�readr�tell)rZ_sizerrrr�test_large_read>s"�zTestFileMethods.test_large_readcCs |�t�t�tjtd�dS)Nr)rrrrrr�rrrr�test_osstatEs zTestFileMethods.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�dS1s�wYdS)Nr+rrr�*�Tr*����
r
)rrrr.r-rr�rrrrr�test_seek_readHs:


"�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�dS1s�wYdS)
Nr+rr2rr3r*r4r5r
)rrrr�lseekrrr-r6rrr�
test_lseekgs"" "�zTestFileMethods.test_lseekcCs6|�td���}t|d�st�d��|�dd�|�|��td�td}|�|�|�	�|�|��|�|�dd�|�|��|�|d8}|�d�|�	|�|�|��d�|�dd�|�|��|�|�d�|�	d�|�|��d�|�d�|�t
|���d�Wd�dS1s�wYdS)	Nr
�truncatez.open().truncate() not available on this systemrr*rr5r2)rr�hasattr�unittest�SkipTestrrr.rr:r,r-)rrZnewsizerrr�
test_truncatets.







"�zTestFileMethods.test_truncatec	CsRdD]$}|�td��}|�|�|�|���Wd�n1s!wYqdS)N)i���l�r+)rrrZ
assertTrue�seekable)r�posrrrr�
test_seekable�s
���zTestFileMethods.test_seekableN)r%r&r'�__doc__rrr/r1r7r9r>rBrrrrr)7s

r)cs��fdd�}|S)Ncs���fdd�}|S)NcsHt�tj����j�krt�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�dS1s?wYdS)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.setUpcs0t���|jdur|j�|j�d|_dSdSrZ)r[�tearDownr\�join�timeoutr0r]rrr_�s



�zTestSocketSendfile.tearDowncsJ��fdd�}t���|��j�tj||fd��_�j�����dS)Nc
s�|�f|��\}}|��j�|�?ttd��*}���j�	|�d�}|s;	Wd�Wd�Wd�dS|�|�q1sDwYWd�n1sSwYWd�dSWd�dS1skwYdS)Nr!Ti)Zaccept�
settimeoutrarr"�waitZrecvr)�sockZconn�_r�chunk�Zeventrrr�run�s"
��
	�0��"�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��"}ttd��
}|�|�Wd�n1s.wYWd�n1s=wYWd�n1sLwY|�	�t
j�t�}|�
t
j�t�|�ttd��!}|�
|�d�d�|�|d�|�
|��d�Wd�dS1s�wYdS)N�z	127.0.0.1r+rQrRrS)rZfind_unused_port�socketZ
create_serverrmZcreate_connectionrrrXr_rrrTrr"r-r)rZportrdZclientrrrrrrU�s&
�����"�zTestSocketSendfile.test_it)r%r&r'rVrWrrrar r_rmrNrrrU�
__classcell__rrr]rrY�s
rYc	Cs�zddl}|�|j|j�WnttfyYnwtjdd�dks(tjdkr3tddtt	��dSt
tddd�}z*z|�d	�|�
d
�|��WnttfyYt�d��wW|��tt�dS|��tt�w)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@�eZdZeej�ZdS)�CLargeFileTestN)r%r&r'rVrWrrrrrr��r�c@r�)�PyLargeFileTestN)r%r&r'rV�pyiorrrrrr�r�r�cCstt�tt�dSrZ)rrr"rrrr�tearDownModulesr��__main__)#rCrrr{r<rorDrjZtest.supportrrrrZtest.support.os_helperrrrWZ_pyior�rr"r	r)rNZTestCaserOZskipIfr;rYr�r�r�r�r%�mainrrrr�<module>s: e5$�