HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_fileio.cpython-37.opt-1.pyc
B

��g�L�@sddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZddlmZddlZddlZGdd�d�ZGd	d
�d
eej�ZGdd�deej�ZGd
d�d�ZGdd�deej�ZGdd�deej�Zdd�Zedk�re�dS)�N)�array)�proxy)�wraps)�TESTFN�TESTFN_UNICODE�check_warnings�run_unittest�make_bad_fd�cpython_only�	swap_attr)�UserListc@szeZdZdd�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(�Ze�ejd)kd*�d+d,��Zd-d.�Zd/d0�Zed1d2��Zed3d4��Zed5d6��Z ed7d8��Z!ed9d:��Z"ed;d<��Z#ed=d>��Z$ed?d@��Z%edAdB��Z&edCdD��Z'dEdF�Z(edGdH��Z)edIdJ��Z*edKdL��Z+dMS)N�
AutoFileTestscCs|�td�|_dS)N�w)�FileIOr�f)�self�r�,/usr/local/lib/python3.7/test/test_fileio.py�setUpszAutoFileTests.setUpcCs|jr|j��t�t�dS)N)r�close�os�remover)rrrr�tearDowns
zAutoFileTests.tearDowncCsVt|j�}|�ttd���|�|j��|���|j��d|_|�t	t
|d�dS)N�
�tell)rr�write�bytes�range�assertEqualrr�assertRaises�ReferenceError�getattr)r�prrr�testWeakRefss

zAutoFileTests.testWeakRefscCs�|j�ttd���|�|j��d�|j�d�|�|j��d�|j�d�|�|j��d�|j�dd�|�|j��d�|j�dd�|�|j��d�|j�dd�|�|j��d�dS)	N�rr�������)rrrrrr�seek)rrrr�testSeekTell(szAutoFileTests.testSeekTellcCsJ|j}|�|jd�|�|jd�x"dD]}|�ttft||d�q(WdS)N�wbF)�mode�closedZoops)rrr-r.r�AttributeError�	TypeError�setattr)rr�attrrrr�testAttributes6s

zAutoFileTests.testAttributescCs@tj}ttd�r,t�|j���}t|d|�}|�|jj	|�dS)N�fstat�
st_blksize)
�io�DEFAULT_BUFFER_SIZE�hasattrrr4r�filenor!r�_blksize)rZblksizeZfstrrr�testBlksizeBs

zAutoFileTests.testBlksizec	Csh|j�tddddg��|j��td�}|�td��}|�|�}WdQRX|�|d�|�|d�dS)	Nr&r)r�sabcdefgh�rs�efgh�)	rrrr�	bytearrayrr�readintor)rZbar�nrrr�testReadintoByteArrayLs
z#AutoFileTests.testReadintoByteArrayc	Cs�|j�tddddg��|j��ttd��}|�td��}|�|�}WdQRX|�	|d�|�	|d�ttd��j
d	ddgd
�}|�td��}|�|�}WdQRX|�	t|�d�|�	|d�dS)Nr&r)rr<sabcdefghr=s�efghr>�H)�shape)rrrr�
memoryviewr?rrr@r�cast)r�mrrArrr�_testReadintoMemoryviewVs
z%AutoFileTests._testReadintoMemoryviewc
Cs$|j�tddddg��|j��tdd�}|�td��}|�|�}WdQRX|�|tddddddd	d
dg��|�|d�td
d�}|�td��}|�|�}WdQRX|�|td
dddddd	d
dg��|�|d�tdd�}|�td��}|�|�}WdQRX|�|tdd��|�|d�dS)Nr&r)rr<�Bsabcdefghr=�e�f�g�hr>�b����Is�efgh)	rrrrrrrr@r)r�arrArrr�_testReadintoArrayfs"

"
"
z AutoFileTests._testReadintoArraycCsFddg}|j�|�|j��|�td�|_|j��}|�|d�dS)Ns123s456�rbs123456)r�
writelinesrrr�readr)r�l�bufrrr�testWritelinesList|s

z AutoFileTests.testWritelinesListcCsJtddg�}|j�|�|j��|�td�|_|j��}|�|d�dS)Ns123s456rSs123456)rrrTrrrrUr)rrVrWrrr�testWritelinesUserList�s

z$AutoFileTests.testWritelinesUserListcCs@|�t|jjdddg�|�t|jjd�|�t|jjd�dS)Nr&r)��abc)rr0rrT)rrrr�testWritelinesError�sz!AutoFileTests.testWritelinesErrorcCst|j�d�|j��|�td�|_|�|j�d�d�|j�d�|�|j�d�d�|�|j�	d�ddg�dS)Ns
hi
bye
abcr=rshi
sbye
sabc)
rrrrrrrUr*�readline�	readlines)rrrr�test_none_args�s
zAutoFileTests.test_none_argscCs|�t|jjd�dS)NzHello!)rr0rr)rrrr�test_reject�szAutoFileTests.test_rejectcCs||�t|j�d|j|jj|jjf�|j`|�t|j�d|j|j��|jjf�|j��|�t|j�d|jf�dS)Nz(<%s.FileIO name=%r mode=%r closefd=True>z&<%s.FileIO fd=%r mode=%r closefd=True>z<%s.FileIO [closed]>)r�reprr�
modulename�namer-r9r)rrrr�testRepr�s
zAutoFileTests.testReprc	Cs`t�ttj�}z@|j|ddd��&}|�t|�d|j|j|j	f�WdQRXWdt�
|�XdS)Nr=F)�closefdz)<%s.FileIO name=%r mode=%r closefd=False>)r�openr�O_RDONLYrrrarbrcr-r)r�fdrrrr�testReprNoCloseFD�s
"zAutoFileTests.testReprNoCloseFDc
Cs@t|jd|j��&|�t��t|j�WdQRXWdQRXdS)Nrc)rrr�RuntimeErrorra)rrrr�testRecursiveRepr�szAutoFileTests.testRecursiveReprcCs�|j}|�|���|�|j�|�t|jd�|��|�|j�|�	t
d�}|�t|jd�|�|j�|��|�|j�dS)Nrr=�)
rZassertFalse�isattyr.r�
ValueErrorrUr�
assertTruerrr0r@)rrrrr�
testErrors�szAutoFileTests.testErrorscCs�ddddddddd	d
ddg}|j��|�|jj�x$|D]}t|j|�}|�t|�q:W|�t|jj�|�t|jjt	d
��|�t|jj
�|�t|jj
d�|�t|jj�|�t|jjd�|�t|jj�|�t|jjd�dS)Nr9rm�seekable�readable�writablerU�readallr]r^r�truncate�flushr&r�)
rrror.r!rrnr0r@r?r*rrT)r�methodsZ
methodname�methodrrr�testMethods�s 



zAutoFileTests.testMethodsc
Cs^y|�dd�Wn>tk
rN}z |�|jd�|�|jd�Wdd}~XYnX|�d�dS)N�.r=rzShould have raised OSError)r�OSErrorZassertNotEqual�errnor�filename�fail)r�errr�testOpendir�s zAutoFileTests.testOpendir�ntz&test only works on a POSIX-like systemc	CsPt�dtj�}|�t��}|�|d�WdQRXt�|�|�|jj	t	j
�dS)Nr{r=)rrfrgrr|rrrZ	exceptionr}ZEISDIR)rrh�cmrrr�
testOpenDirFD�s

zAutoFileTests.testOpenDirFDcst���fdd��}|S)NcsN|j}t�|���z�||�Wdy|j��Wntk
rFYnXXdS)N)rrrr9r|)rr)�funcrr�wrapper�sz'AutoFileTests.ClosedFD.<locals>.wrapper)r)r�r�r)r�r�ClosedFD�szAutoFileTests.ClosedFDcst���fdd��}|S)Ncs�|j}t�|���zPy�||�Wn2tk
rV}z|�|jtj�Wdd}~XYnX|�d�Wdy|j��Wntk
r�YnXXdS)NzShould have raised OSError)	rrrr9r|rr}ZEBADFr)rrr�)r�rrr�s"z-AutoFileTests.ClosedFDRaises.<locals>.wrapper)r)r�r�r)r�r�ClosedFDRaisesszAutoFileTests.ClosedFDRaisescCs|��dS)N)r)rrrrr�testErrnoOnCloseszAutoFileTests.testErrnoOnClosecCs|�d�dS)N�a)r)rrrrr�testErrnoOnClosedWritesz$AutoFileTests.testErrnoOnClosedWritecCs|�d�dS)Nr)r*)rrrrr�testErrnoOnClosedSeeksz#AutoFileTests.testErrnoOnClosedSeekcCs|��dS)N)r)rrrrr�testErrnoOnClosedTell!sz#AutoFileTests.testErrnoOnClosedTellcCs|�d�dS)Nr)ru)rrrrr�testErrnoOnClosedTruncate%sz'AutoFileTests.testErrnoOnClosedTruncatecCs|��dS)N)rq)rrrrr�testErrnoOnClosedSeekable)sz'AutoFileTests.testErrnoOnClosedSeekablecCs|��dS)N)rr)rrrrr�testErrnoOnClosedReadable-sz'AutoFileTests.testErrnoOnClosedReadablecCs|��dS)N)rs)rrrrr�testErrnoOnClosedWritable1sz'AutoFileTests.testErrnoOnClosedWritablecCs|��dS)N)r9)rrrrr�testErrnoOnClosedFileno5sz%AutoFileTests.testErrnoOnClosedFilenocCs|�|��d�dS)NF)rrm)rrrrr�testErrnoOnClosedIsatty9sz%AutoFileTests.testErrnoOnClosedIsattycCsHy|j��Wntk
r"YnX|�td�|_t�|j���|jS)Nr=)rrr|rrrr9)rrrr�
ReopenForRead=szAutoFileTests.ReopenForReadcCs|��}|�d�dS)Nr&)r�rU)rrrrr�testErrnoOnClosedReadFsz#AutoFileTests.testErrnoOnClosedReadcCs|��}|��dS)N)r�rt)rrrrr�testErrnoOnClosedReadallKsz&AutoFileTests.testErrnoOnClosedReadallcCs |��}tdd�}|�|�dS)NrNs
xxxxxxxxxx)r�rr@)rrrQrrr�testErrnoOnClosedReadintoPs
z'AutoFileTests.testErrnoOnClosedReadintoN),�__name__�
__module__�__qualname__rrr#r+r3r;rBrHrRrXrYr\r_r`rdrirkrprzr��unittest�skipIfrrcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr
sJ	

	

	r
c@seZdZejZdZdS)�CAutoFileTests�_ioN)r�r�r�r�rrbrrrrr�Vsr�c@seZdZejZdZdS)�PyAutoFileTests�_pyioN)r�r�r�r�rrbrrrrr�Zsr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Ze�	e
��dkd�d
d��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�OtherFileTestsc	Cs��z�|�td�}|�|��d�|�|��d�|�|��d�|��|�td�}|�|��d�|�|��d�|�|��d�|��|�td�}|�|��d�|�|��d�|�|��d�|�|��d�|��tj	dk�r�y|�dd�}Wnt
k
�rYnpX|�|��d�|�|��d�tj	d	k�rjd
tj	k�rjtj	�d��sj|�|��d�|�|��d�|��Wdt�
t�XdS)NrFTr=za+�win32z/dev/ttyrQ�darwinZbsd)ZsunosZaix)rrrrrrsrqrrm�sys�platformr|�
startswithr�unlink)rrrrr�	testAblesas>zOtherFileTests.testAblesc	CsNxHdD]@}y|�t|�}Wntk
r.YqX|��|�d|�qWdS)N)rlZaUzwU+�rw�rtz%r is an invalid file mode)rrrnrr)rr-rrrr�testInvalidModeStrings�s
z%OtherFileTests.testInvalidModeStringsc
Cs^z@x:dD]2}|�t|d��}|�|j|d�WdQRXqWWdtj�t�rXt�t�XdS)N))rr,)r,r,)zwb+zrb+)zw+bzrb+)rQ�ab)r�r�)zab+zab+)za+bzab+)r=rS)rSrS)zrb+zrb+)zr+bzrb+rr&)rrrr-r�path�existsr�)rZmodesrrrr�testModeStrings�s
$zOtherFileTests.testModeStringscCs&|�tt�d�}|��t�t�dS)Nr)r�strrrrr�)rrrrr�testUnicodeOpen�szOtherFileTests.testUnicodeOpenc	Cs�yt�d�}Wn"tk
r0|�dt�YnX|�|d�}z<|�d�|��ttd��}|�|�	�d�WdQRXWdt
�t�XdS)N�asciizcould not encode %r to asciirsabcrS)r�encode�UnicodeEncodeError�skipTestrrrrfrrUrr�)r�fnrrrr�
testBytesOpen�s
zOtherFileTests.testBytesOpenzutf-8z%test only works for utf-8 filesystemsc	Cs�yt�d�}Wn"tk
r0|�dt�YnX|�|d�}z<|�d�|��ttd��}|�|�	�d�WdQRXWdt
�t�XdS)Nzutf-8zcould not encode %r to utf-8rsabcrS)rr�r�r�rrrrfrrUrr�)rr�rrrr�testUtf8BytesOpen�s
z OtherFileTests.testUtf8BytesOpencCs2d}|�t|j|d�|�t|jt|d�d�dS)Nzfoobarrr�)rrnrr)rZfn_with_NULrrr�testConstructorHandlesNULChars�sz-OtherFileTests.testConstructorHandlesNULCharscCsJ|�t|jd�|�t|jt��tjdkrFddl}|�t|jt��dS)Ni����r�r)	rrnrr|r	r�r��msvcrtZ
get_osfhandle)rr�rrr�
testInvalidFd�s

zOtherFileTests.testInvalidFdc
Cs�d}y|�t|�}WnVtk
rj}z8|jddkrZt|�}t|ksL||krZ|�d|�Wdd}~XYnX|��|�d|�dS)NZqwertyrz&bad error message for invalid mode: %szno error for invalid mode: %s)rrrn�argsr�rr)rZbad_moder�msg�srrr�testBadModeArgument�s z"OtherFileTests.testBadModeArgumentcCs�|�td�}|�tttd����|�|��d�|�d�|�|��d�|�|�	dt
j�d�|�d�|�|��d�|�|�	dt
j�d�|��dS)Nrrr%rr')
rrrrr?rrrrur*r6�SEEK_ENDr)rrrrr�testTruncate�s

zOtherFileTests.testTruncatec	s(�fdd�}z
|�Wdt�t�XdS)Ncs���td�}|�ttd���|����td�}|�d�}|ttd��krZ��d|�|��dkrx��d|���|�	�|��dkr���d|���|��t
j�t�}|dkrȈ�d|�dS)	Nr�zr+r%z(Read on file opened for update failed %rzFile pos after read wrong %dz!File pos after ftruncate wrong %dz"File size after ftruncate wrong %d)
rrrrrrrUrrrurr��getsize)r�data�size)rrr�	bug801631�s 
z7OtherFileTests.testTruncateOnWindows.<locals>.bug801631)rr�r)rr�r)rr�testTruncateOnWindows�s
z$OtherFileTests.testTruncateOnWindowscCs�zbttd�}|�d�|��ttd�}|�d�|��ttd�}|��}|��|�|d�Wdyt�t�WnYnXXdS)Nr,sspamr�seggsrSsspameggs)rfrrrrUrrr�)rr�drrr�
testAppends




zOtherFileTests.testAppendcCs|�t|jddd�dS)N�1r)rr0r)rrrr�testInvalidInit"szOtherFileTests.testInvalidInitc	Csftdd��R}|�|jg�|�t|jg�|�|jg�|�t|jdd�|�|jg�WdQRXdS)NT)�quietz/some/invalid/namer�)rr�warningsrr0rrn)rrrrr�testWarnings%szOtherFileTests.testWarningscsRGdd�dt��G��fdd�d|j��t�ttj�}|���|�t�|�dS)Nc@seZdZdS)z=OtherFileTests.testUnclosedFDOnException.<locals>.MyExceptionN)r�r�r�rrrr�MyException.sr�cs eZdZ���fdd�Z�ZS)z:OtherFileTests.testUnclosedFDOnException.<locals>.MyFileIOcs"|dkr�d��t�|��||�S)Nrczblocked setting name)�super�__setattr__)rrc�value)r��MyFileIO�	__class__rrr�0szFOtherFileTests.testUnclosedFDOnException.<locals>.MyFileIO.__setattr__)r�r�r�r��
__classcell__r)r�r�)r�rr�/sr�)�	Exceptionrrrf�__file__rgrr)rrhr)r�r�r�testUnclosedFDOnException-s
z(OtherFileTests.testUnclosedFDOnExceptionN)r�r�r�r�r�r�r�r�r�r�r��getfilesystemencodingr�r�r�r�r�r�r�r�r�r�rrrrr�_s *r�c@s"eZdZejZdZedd��ZdS)�COtherFileTestsr�cCs8ddl}|�t|j|jd�|�t|j|jd�dS)Nrr&)�	_testcapirr0rZINT_MAXZINT_MIN)rr�rrr�testInvalidFd_overflow<sz&COtherFileTests.testInvalidFd_overflowN)r�r�r�r�rrbr
r�rrrrr�8sr�c@seZdZejZdZdS)�PyOtherFileTestsr�N)r�r�r�r�rrbrrrrr�Csr�c	Cs0zttttt�Wdtj�t�r*t�	t�XdS)N)
rr�r�r�r�rr�r�rr�rrrr�	test_mainHs
r��__main__)r�rr6r}r�r�weakrefr�	functoolsrZtest.supportrrrrr	r
r�collectionsrr�r�r
ZTestCaser�r�r�r�r�r�r�rrrr�<module>s.$DZ