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_fileinput.cpython-310.pyc
o

�9j���@stdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	zddl
Z
Wney7dZ
YnwzddlZWneyIdZYnwddlm
Z
mZddlmZmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddl	mZGd
d�d�ZGdd�d�ZGdd�dee	j �Z!Gdd�d�Z"Gdd�dee	j �Z#Gdd�d�Z$Gdd�de	j �Z%Gdd�de%�Z&Gdd�de%�Z'Gdd �d e%�Z(Gd!d"�d"e%�Z)Gd#d$�d$e%�Z*Gd%d&�d&e%�Z+Gd'd(�d(e%�Z,Gd)d*�d*e%�Z-Gd+d,�d,e%�Z.Gd-d.�d.�Z/Gd/d0�d0e	j �Z0Gd1d2�d2e	j �Z1Gd3d4�d4e	j �Z2e3d5k�r8e	�4�dSdS)6z,
Tests for fileinput module.
Nick Mathewson
�N)�BytesIO�StringIO)�	FileInput�hook_encoded)�Path)�verbose)�TESTFN)�unlink)�	os_helper)�warnings_helper)�support)�mockc@seZdZdd�dd�ZdS)�	BaseTests�w��modecCsht��\}}|�tj|�d|vrdnd}t|||d��}|�|�Wd�|S1s-wY|S)N�b�utf-8��encoding)�tempfile�mkstemp�
addCleanupr
r	�open�write)�self�contentr�fd�namer�f�r �*/usr/lib/python3.10/test/test_fileinput.py�writeTmp,s
��zBaseTests.writeTmpN)�__name__�
__module__�__qualname__r"r r r r!r)src@sDeZdZdd�Zedd��Zdd�Zddd	�Zddd�Zd
d�Z	dS)�
LineReadercCs
g|_dS�N��
_linesread�rr r r!�__init__6�
zLineReader.__init__cCs z|jdd�Wg|_Sg|_wr'r(r*r r r!�	linesread9szLineReader.linesreadcCst|�d��|_|S�NT)�iter�
splitlines�it)r�filenamerr r r!�openhook@szLineReader.openhookNcCst|jd�}|j�|�|S)N�)�nextr1r)�append)r�size�liner r r!�readlineDszLineReader.readline���cCs>g}d}	|��}|s
|S|�|�|t|�7}||kr|Sq�Nr)r9r6�len)r�hint�linesr7r8r r r!�	readlinesIs
�zLineReader.readlinescC�dSr'r r*r r r!�closeUszLineReader.closer')r:)
r#r$r%r+�propertyr-r3r9r?rAr r r r!r&4s


r&c@�eZdZdd�ZdS)�BufferSizesTestsc
Cs�|�d�dd�td�D���}|�d�dd�td�D���}|�d�dd�td�D���}|�d�d	d�td
�D���}t�d�}trGtd�t||||fd
d�}t|�}|�	�|�
t|�d�|�
|dd�|�
|dd�|�
|��d�|�
|�
�|�tr�td�t||||fd
d�}d}|r�|dkr�|��}|r�|dks�|�
|�
�|�|�
|��d�|�
|��d�|�|���|�|���tr�td�|��|�
|��d�|�
|��d�|�	�tr�td�t||||dfd
d�}tj}	z*td�t_t|�}|�
t|�d�|�
|d d!�|�
|�
�d"�|��W|	t_n|	t_wt�r1td#�t||||fd
d�}|�
|��d$�|�
|�
�d�|��|�
|��d$�|�
|�
�d�t�rftd%�tj}
z&t||||fd
d
d&�}|D]}|dd'���}t|��qw|�	�W|
t_n|
t_wt||||fd
d�}|D]'}|�
|d'd(�|�|dd'��}|�|d�|�
t|�d
��|����q�|�	�dS))Nr4cs��|]	}d|dVqdS)zLine %s of file 1
�Nr ��.0�ir r r!�	<genexpr>[��z5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>�csrE)zLine %s of file 2
rFNr rGr r r!rJ\rK�
csrE)zLine %s of file 3
rFNr rGr r r!rJ]rK�csrE)zLine %s of file 4
rFNr rGr r r!rJ^rKrFzLINE (\d+) OF FILE (\d+)z1. Simple iterationr��filesr��zLine 5 of file 1
�zLine 1 of file 4
z2. Status variables�xzLine 6 of file 2
��z3. NextfilezLine 1 of file 3
�z4. Stdin�-z Line 1 of stdin
Line 2 of stdin
�!� zLine 2 of stdin
z<stdin>z5. Boundary conditionsrz
6. Inplace�rP�inplacerr:�
)r"�join�range�re�compiler�printr�listrA�assertEqualr<�linenor2r9�
filelineno�assertFalse�isfirstline�isstdin�nextfile�sys�stdinr�stdout�upper�match�assertNotEqual�int�group)
r�t1�t2�t3�t4�pat�fir>�s�	savestdin�
savestdoutr8�mr r r!�test_buffer_sizesYs�
�


z"BufferSizesTests.test_buffer_sizesN)r#r$r%r}r r r r!rDXsrDc@�eZdZdd�Zdd�ZdS)�UnconditionallyRaisecCs||_d|_dS�NF)�exception_type�invoked)rr�r r r!r+�s
zUnconditionallyRaise.__init__cOsd|_|���r.)r�r��r�args�kwargsr r r!�__call__�szUnconditionallyRaise.__call__N�r#r$r%r+r�r r r r!r�src@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zejed�d d!��Zd"d#�Zejed�d$d%��Zejed�d&d'��Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8S)9�FileInputTestscCs�|�d�}|�d�}|�d�}|�d�}t||||fdd�}|��}|�|d�|�|��d�|�|��d�|�|��|�|��}|�|�|�|��d�|�|��d�|�|��|�|��dS)Nr4zThe only line there is.
rrOrFr)	r"rr9rdrerfr2rgrA)rrsrtrurvrxr8r r r!�test_zero_byte_files�s 




z#FileInputTests.test_zero_byte_filescCs`|�d�}|�d�}t||fdd�}t|�}|�|gd��|�|��d�|�|��d�dS)N�A
B
C�D
E
FrrO��A
�B
�CzD
zE
�F�rV)r"rrcrdrfre�rrsrtrxr>r r r!�%test_files_that_dont_end_with_newline�s

z4FileInputTests.test_files_that_dont_end_with_newlinecCs�|�d�}|�d�}t||fdd�}|�|��d�t|�}|�|��d�|��|�|��d�t|�}|�|��d�dS)NzA
BzC
DrrOr:)r"rrd�filenor5rprjrc)rrsrtrxr8r r r!�test_fileno�s

zFileInputTests.test_filenocCs�z
tddd�}|�d�Wn	tyYnw|jddd�}t�dtf��t|d	dd
�}Wd�n1s7wYt�dtf��t|�}Wd�n1sRwY|�|gd��dS)Nrr)rrz-FileInput should reject invalid mode argument�A
B
C
D�wbrr4�U)rPrr)r�r��C
�D)	r�fail�
ValueErrorr"r�check_warnings�DeprecationWarningrcrd)rrxrsr>r r r!�test_opening_mode�s��
�z FileInputTests.test_opening_modecCs^t�d�� }td�|_tdgdd�}t|�}|�|dg�Wd�dS1s(wYdS)Nz	sys.stdin�spam, bacon, sausage, and spamrX�rb�rPr)r
�patchr�bufferrrcrd)r�m_stdinrxr>r r r!�test_stdin_binary_mode�s
"�z%FileInputTests.test_stdin_binary_modecCs\tj}z&td�t_|�ttjd��tdgdd�}t|�}|�|dg�W|t_dS|t_w)Nr�r�rXr�r�)rkrlrrg�hasattrrrcrd)r�
orig_stdinrxr>r r r!�test_detached_stdin_binary_mode�s
z.FileInputTests.test_detached_stdin_binary_modecCs�ztddd�d�}|�d�Wn	tyYnwztdd�}|�d�Wn	ty.YnwGdd	�d	�}|�d
�}|�}t|g|d��}|��Wd�n1sTwY|�|jd�dS)NrFcSr@r'r )rr|r r r!�<lambda>
�z7FileInputTests.test_file_opening_hook.<locals>.<lambda>)r\r3zGFileInput should raise if both inplace and openhook arguments are given�r3z2FileInput should check openhook for being callablec@r~)z=FileInputTests.test_file_opening_hook.<locals>.CustomOpenHookcS�
d|_dSr�)r�r*r r r!r+r,zFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__c_sd|_t|ddi�S)NTrr)r�r)rr��kargsr r r!r�szFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__Nr�r r r r!�CustomOpenHook�r�r]zopenhook not invoked)rr�r�r"r9�
assertTruer�)rrxr��t�custom_open_hookr r r!�test_file_opening_hook
s&�
�

�z%FileInputTests.test_file_opening_hookc	Cs2ttd��}|�d�|�dd�|�d�Wd�n1s!wY|�tt�tttd�d��[}z|�|��d�|�|��d	�|�|��d
�Wnt	y]|�
d�Ynw|�t	��t|�Wd�n1srwY|�|��d�|�|��d�Wd�dS1s�wYdS)
Nr�sA
B
C
s
123456789
i����ascii�rPr3r�r�r�zRead to end of filer4)
rrrr�safe_unlinkrrrdr9�UnicodeDecodeErrorr��assertRaisesrc�rrrxr r r!�
test_readline%s.
���
�"�zFileInputTests.test_readlinecCs�ttd��
}|�d�Wd�n1swY|�tt�ttdd��1}|�|��d�|�|��d�|�|��d�|�|��d�|�|��d�Wd�dS1sZwYdS)	Nr�r�r�r�sA
sB
sC
D�)rrrrr�rrdr9r�r r r!�test_readline_binary_mode<s�"�z(FileInputTests.test_readline_binary_modecCs�|jddd�}t|ddd��}|��}|�|d�tj�d�Wd�n1s)wYt|d��}|�|��d�Wd�dS1sGwYdS)Ns
Initial text.r�rr�T)rr\s	New line.)	r"rr9rdrkrmrr�read�r�	temp_file�fobjr8rr r r!�test_inplace_binary_write_modeIs�"�z-FileInputTests.test_inplace_binary_write_modecCs�|jddd�}t|dddd��}|��}|�|d�td	�Wd�n1s(wYt|d
��}|�|���d�d�Wd�dS1sIwYdS)
NsInitial text �r�rTr��replace)r\r�errorsuInitial text �uNew line ˆr�s
s
New line ?)r"rr9rdrbrr��rstripr�r r r!�test_inplace_encoding_errorsSs�
�"�z+FileInputTests.test_inplace_encoding_errorscCsXdd�}|�d�}t|g|d��}|��}Wd�n1swY|�|d�dS)NcS�
t�d�S)N�(I used to receive only filename and mode)�ior�r2rr r r!�old_hook^r,zFFileInputTests.test_file_hook_backward_compatibility.<locals>.old_hookr]r�r�)r"rr9rd)rr�r�rx�resultr r r!�%test_file_hook_backward_compatibility]s

�z4FileInputTests.test_file_hook_backward_compatibilitycCs�|�d�}|�d�}t||fdd��}t|�}Wd�n1s!wY|�|gd��|�|��d�|�|��d�|�|jd�dS)	Nr�r�rrOr�r�rVr )r"rrcrdrfre�_filesr�r r r!�test_context_manageres


�z#FileInputTests.test_context_managercCsV|�d�}zt|dd��}t�1swYWdSty*|�|jd�YdSw)Nr4rrOr )r"r�OSErrorrdr�)rrsrxr r r!�test_close_on_exceptionos
��z&FileInputTests.test_close_on_exceptioncCs@tgdd��}|�|jd�Wd�dS1swYdS)NrrO)rX)rrdr�)rrxr r r!�.test_empty_files_list_specified_to_constructorws"�z=FileInputTests.test_empty_files_list_specified_to_constructor)�categorycCsf|�d�}t|gdd��}|d}|�|d�|d}|�|d�Wd�dS1s,wYdS)	zNTests invoking FileInput.__getitem__() with the current
           line number�line1
line2
rrOr�line1
rFzline2
N)r"rrd)rr�rx�retval1�retval2r r r!�test__getitem__{s
"�zFileInputTests.test__getitem__c	Cs�|�d�}|�td��/t|gd��}|�|dd�Wd�n1s%wYWd�dSWd�dS1s=wYdS)Nr�zUse iterator protocol instead)rPrr�)r"�assertWarnsRegexr�rrd)rr�rxr r r!�test__getitem___deprecation�s
���"�z*FileInputTests.test__getitem___deprecationc	C�~|�d�}t|gdd��!}|�t��}|dWd�n1s!wYWd�n1s0wY|�|jjd�dS)zZTests invoking FileInput.__getitem__() with an index unequal to
           the line numberr�rrOrFN)zaccessing lines out of order)r"rr��RuntimeErrorrd�	exceptionr��rr�rx�cmr r r!�test__getitem__invalid_key��

���z)FileInputTests.test__getitem__invalid_keyc	Cr�)zZTests invoking FileInput.__getitem__() with the line number but at
           end-of-inputr4rrOrN)zend of input reached)r"rr��
IndexErrorrdr�r�r�r r r!�test__getitem__eof�r�z!FileInputTests.test__getitem__eofcCs�tj}tt�}z5|�d�}|�t|d�t|gddd��}t|�|t_|�	�Wd�n1s3wYW|t_n|t_w|�
|jd�dS)z�Tests invoking FileInput.nextfile() when the attempt to delete
           the backup file would raise OSError.  This error is expected to be
           silently ignoredr]z.bakTrr[Nzos.unlink() was not invoked)�osr	rr�r"rr�rr5rjr�r�)r�os_unlink_orig�os_unlink_replacementr�rxr r r!�%test_nextfile_oserror_deleting_backup�s

���z4FileInputTests.test_nextfile_oserror_deleting_backupcC�|tj}tt�}z)|�d�}t|gddd��}|t_|��Wd�n1s'wYW|t_n|t_w|�|jd�dS)z{Tests invoking FileInput.readline() when os.fstat() raises OSError.
           This exception should be silently discarded.r]Trr[N�os.fstat() was not invoked)	r��fstatrr�r"rr9r�r�)r�
os_fstat_orig�os_fstat_replacementr�rxr r r!�%test_readline_os_fstat_raises_OSError��

���z4FileInputTests.test_readline_os_fstat_raises_OSErrorcCr�)z{Tests invoking FileInput.readline() when os.chmod() raises OSError.
           This exception should be silently discarded.r]Trr[Nr�)	r��chmodrr�r"rr9r�r�)r�
os_chmod_orig�os_chmod_replacementr�rxr r r!�%test_readline_os_chmod_raises_OSError�r�z4FileInputTests.test_readline_os_chmod_raises_OSErrorc	Cs�Gdd�dt�}|�}|�d�}t|gdd��}|j}z||_|��}W||_n||_wWd�n1s6wY|�|jd�|�|dd�dS)	Nc@r~)zQFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrorcS�t�|t�dSr')rr+r�r*r r r!r+��zZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__cSs|��dSr')r�r*r r r!r���zXFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.filenoN)r#r$r%r+r�r r r r!�FilenoRaisesValueError�r�r�r]rrOz_file.fileno() was not invokedr:zfileno() should return -1)rr"r�_filer�r�r�rd)rr�� unconditionally_raise_ValueErrorr�rx�file_backupr�r r r!�"test_fileno_when_ValueError_raised�s

�	�z1FileInputTests.test_fileno_when_ValueError_raisedcCs�t�}tddg|jd��`}|�|jg�|�|��d�|�|jdg�|�|��d�|�|jdg�|�|��d�|�|jddg�|�|��d�|�|jdg�|�|��d�|�|jg�Wd�dS1sowYdS�Nzline1
line2zline3
r�r��line2r4)r&rr3rdr-r9�r�srcrxr r r!�test_readline_buffering�s"�"�z&FileInputTests.test_readline_bufferingcCs�t�}tddg|jd��^}|�|jg�|�t|�d�|�|jdg�|�t|�d�|�|jdg�|�t|�d�|�|jddg�|�tt|�|�|jdg�|�tt|�|�|jg�Wd�dS1smwYdSr�)r&rr3rdr-r5r��
StopIterationr�r r r!�test_iteration_bufferings"�"�z'FileInputTests.test_iteration_bufferingcCs�t|�d��}t|dd��.}|��}|�|d�|�|��d�|�|��d�|�|��t�	|��Wd�dS1s>wYdS)N�
Pathlib file.rrrF)
rr"rr9rdrerfr2r��fspath)rrsrxr8r r r!�test_pathlib_files"�z FileInputTests.test_pathlib_filecCs�t|�d��}t|ddd��}|��}|�|d�td|�Wd�n1s)wYt|dd��}|�|��d�Wd�dS1sHwYdS)NrTr)r\rzModified %srzModified Pathlib file.
)rr"rr9rdrbrr�)rrsrxr8rr r r!�test_pathlib_file_inplaces�"�z(FileInputTests.test_pathlib_file_inplaceN)!r#r$r%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ignore_warningsr�r�r�r�r�r�r�r�r�rrrrr r r r!r��s>









	
		r�c@sfeZdZdZdddddd�dd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dd�Z
dd�Zdd�ZdS)�
MockFileInputzDA class that mocks out fileinput.FileInput for use during unit testsNFr4�r)rr3rr�cCsJ||_||_||_||_||_||_||_d|_t�	dd��|_
i|_dS)NcSsdSr;r r r r r!r�1r�z(MockFileInput.__init__.<locals>.<lambda>)rPr\�backuprr3rr�r��collections�defaultdict�invocation_counts�
return_values)rrPr\r
rr3rr�r r r!r+'s
zMockFileInput.__init__cCs|jdd7<dS)NrArF)r
r*r r r!rA4szMockFileInput.closecC�|jdd7<|jdS)NrjrF�r
rr*r r r!rj7�
zMockFileInput.nextfilecCr)Nr2rFrr*r r r!r2;rzMockFileInput.filenamecCr)NrerFrr*r r r!re?rzMockFileInput.linenocCr)NrfrFrr*r r r!rfCrzMockFileInput.filelinenocCr)Nr�rFrr*r r r!r�GrzMockFileInput.filenocCr)NrhrFrr*r r r!rhKrzMockFileInput.isfirstlinecCr)NrirFrr*r r r!riOrzMockFileInput.isstdin)NFr4)
r#r$r%�__doc__r+rArjr2rerfr�rhrir r r r!r$s�
rc@�(eZdZdZdd�Zdd�Zdd�ZdS)	�BaseFileInputGlobalMethodsTestzQBase class for unit tests for the global function of
       the fileinput module.cCstj|_tj|_tt_dSr')�	fileinput�_state�_orig_stater�_orig_FileInputrr*r r r!�setUpWs
z$BaseFileInputGlobalMethodsTest.setUpcCs|jt_|jt_dSr')rrrrrr*r r r!�tearDown\sz'BaseFileInputGlobalMethodsTest.tearDowncCs2|j|}|�|d|�t|j�}|�|d�dS)NrF)r
rdr<)r�mock_file_input�method_name�actual_count�actual_total_countr r r!�assertExactlyOneInvocation`s

z9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocationN)r#r$r%rrrrr r r r!rSs
rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_fileinput_inputz Unit tests for fileinput.input()cCsjt�}t�|_|t_|�t��}t��Wd�n1swY|�d|j	j
�|�|tjd�dS)z�Tests invoking fileinput.input() when fileinput._state is not None
           and its _file attribute is also not None.  Expect RuntimeError to
           be raised with a meaningful error message and for fileinput._state
           to *not* be modified.N)zinput() already active�fileinput._state)r�objectr�rrr�r��inputrdr�r��assertIs)r�instancer�r r r!�1test_state_is_not_None_and_state_file_is_not_Noneks
�zFTest_fileinput_input.test_state_is_not_None_and_state_file_is_not_NonecCst�}d|_|t_|��dS)a\Tests invoking fileinput.input() when fileinput._state is not None
           but its _file attribute *is* None.  Expect it to create and return
           a new fileinput.FileInput object with all method parameters passed
           explicitly to the __init__() method; also ensure that
           fileinput._state is set to the returned instance.N)rr�rr�do_test_call_input�rr%r r r!�-test_state_is_not_None_and_state_file_is_NonexszBTest_fileinput_input.test_state_is_not_None_and_state_file_is_NonecCsdt_|��dS)a4Tests invoking fileinput.input() when fileinput._state is None
           Expect it to create and return a new fileinput.FileInput object
           with all method parameters passed explicitly to the __init__()
           method; also ensure that fileinput._state is set to the returned
           instance.N)rrr'r*r r r!�test_state_is_None�sz'Test_fileinput_input.test_state_is_NonecCs�t�}t�}t�}t�}t�}t�}tj||||||d�}|�|tjd�|�||jd�|�||jd�|�||jd�|�||jd�|�||j	d�dS)	aTests that fileinput.input() creates a new fileinput.FileInput
           object, passing the given parameters unmodified to
           fileinput.FileInput.__init__().  Note that this test depends on the
           monkey patching of fileinput.FileInput done by setUp().)rPr\r
rr3rr!rPr\r
rr3N)
r"rr#r$rrPr\r
rr3)rrPr\r
rr3rr�r r r!r'�s
�z'Test_fileinput_input.do_test_call_inputN)r#r$r%rr&r)r*r'r r r r!r hs
	r c@� eZdZdZdd�Zdd�ZdS)�Test_fileinput_closez Unit tests for fileinput.close()cCsdt_t��|�tj�dS)zPTests that fileinput.close() does nothing if fileinput._state
           is NoneN)rrrA�assertIsNoner*r r r!r*�sz'Test_fileinput_close.test_state_is_NonecCs0t�}|t_t��|�|d�|�tj�dS)z`Tests that fileinput.close() invokes close() on fileinput._state
           and sets _state=NonerAN)rrrrArr-r(r r r!�test_state_is_not_None�s
z+Test_fileinput_close.test_state_is_not_NoneN�r#r$r%rr*r.r r r r!r,�sr,c@r+)�Test_fileinput_nextfilez#Unit tests for fileinput.nextfile()cC�Xdt_|�t��}t��Wd�n1swY|�d|jj�|�tj�dS)z�Tests fileinput.nextfile() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�zno active input())	rrr�r�rjrdr�r�r-�rr�r r r!r*��
�z*Test_fileinput_nextfile.test_state_is_NonecC�Nt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)aTests fileinput.nextfile() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.nextfile() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.rjN)r"rrrrrjrr$)r�nextfile_retvalr%�retvalr r r!r.��
z.Test_fileinput_nextfile.test_state_is_not_NoneNr/r r r r!r0��
r0c@r+)�Test_fileinput_filenamez#Unit tests for fileinput.filename()cCr1)z�Tests fileinput.filename() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�r2rdr�r�r-r3r r r!r*�r4z*Test_fileinput_filename.test_state_is_NonecCr5)aTests fileinput.filename() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.filename() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.r2N)r"rrrrr2rr$)r�filename_retvalr%r7r r r!r.�r8z.Test_fileinput_filename.test_state_is_not_NoneNr/r r r r!r:�r9r:c@r+)�Test_fileinput_linenoz!Unit tests for fileinput.lineno()cCr1)z�Tests fileinput.lineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�rerdr�r�r-r3r r r!r*�r4z(Test_fileinput_lineno.test_state_is_NonecCr5)z�Tests fileinput.lineno() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.lineno() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.reN)r"rrrrrerr$)r�
lineno_retvalr%r7r r r!r.�r8z,Test_fileinput_lineno.test_state_is_not_NoneNr/r r r r!r<�r9r<c@r+)�Test_fileinput_filelinenoz%Unit tests for fileinput.filelineno()cCr1)z�Tests fileinput.filelineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�rfrdr�r�r-r3r r r!r*r4z,Test_fileinput_filelineno.test_state_is_NonecCr5)aTests fileinput.filelineno() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.filelineno() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.rfN)r"rrrrrfrr$)r�filelineno_retvalr%r7r r r!r.r8z0Test_fileinput_filelineno.test_state_is_not_NoneNr/r r r r!r>r9r>c@r+)�Test_fileinput_filenoz!Unit tests for fileinput.fileno()cCr1)z�Tests fileinput.fileno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�r�rdr�r�r-r3r r r!r*)r4z(Test_fileinput_fileno.test_state_is_NonecCsTt�}t�}||jd<||_|t_t��}|�|d�|�||�|�tj|�dS)z�Tests fileinput.fileno() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.fileno() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.r�N)	r"rr�
fileno_retvalrrr�rr$)rrAr%r7r r r!r.3s
z,Test_fileinput_fileno.test_state_is_not_NoneNr/r r r r!r@&r9r@c@r+)�Test_fileinput_isfirstlinez&Unit tests for fileinput.isfirstline()cCr1)z�Tests fileinput.isfirstline() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�rhrdr�r�r-r3r r r!r*Er4z-Test_fileinput_isfirstline.test_state_is_NonecCr5)aTests fileinput.isfirstline() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.isfirstline() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.rhN)r"rrrrrhrr$)r�isfirstline_retvalr%r7r r r!r.Or8z1Test_fileinput_isfirstline.test_state_is_not_NoneNr/r r r r!rBBr9rBc@r+)�Test_fileinput_isstdinz"Unit tests for fileinput.isstdin()cCr1)z�Tests fileinput.isstdin() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr2)	rrr�r�rirdr�r�r-r3r r r!r*`r4z)Test_fileinput_isstdin.test_state_is_NonecCr5)z�Tests fileinput.isstdin() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.isstdin() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.riN)r"rrrrrirr$)r�isstdin_retvalr%r7r r r!r.jr8z-Test_fileinput_isstdin.test_state_is_not_NoneNr/r r r r!rD]r9rDc@r~)�InvocationRecordercCr�r;)�invocation_countr*r r r!r+zr,zInvocationRecorder.__init__cOs"|jd7_||f|_t�d�S)NrFs
some bytes)rG�last_invocationr�rr�r r r!r�}s

zInvocationRecorder.__call__Nr�r r r r!rFxsrFc@s�eZdZdZdd�Zdd�Zdd�Ze�e	d�d	d
��Z
e�e	d�dd��Ze�ed
�dd��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zd S)!�Test_hook_compressedz*Unit tests for fileinput.hook_compressed()cCst�|_dSr')rF�	fake_openr*r r r!r�r�zTest_hook_compressed.setUpcC�|�dd�dS)Nr4r	��do_test_use_builtin_open_textr*r r r!�test_empty_string�r�z&Test_hook_compressed.test_empty_stringcCrK�N�abcdr	rLr*r r r!�test_no_ext�r�z Test_hook_compressed.test_no_extzRequires gzip and zlibcC�Vtj}|jt_zt�dd�}W|t_n|t_w|�|jjd�|�|jjdif�dS)N�test.gzr	rF)rSr	)�gziprrJr�hook_compressedrdrGrH�r�
original_openr�r r r!�test_gz_ext_fake��z%Test_hook_compressed.test_gz_ext_fakecCsJtj}dd�t_z
tjdddd�}W|t_n|t_w|�t|�dg�dS)NcSr�)NsEx-binary string)r�rr�r r r!r��s
zATest_hook_compressed.test_gz_with_encoding_fake.<locals>.<lambda>rSr	rrzEx-binary string)rTrrrUrdrcrVr r r!�test_gz_with_encoding_fake�s
z/Test_hook_compressed.test_gz_with_encoding_fakezRequires bz2cCrR)N�test.bz2r	rF)r[r	)�bz2�BZ2FilerJrrUrdrGrHrVr r r!�test_bz2_ext_fake�rYz&Test_hook_compressed.test_bz2_ext_fakecCrK)Nz	abcd.blahr���do_test_use_builtin_open_binaryr*r r r!�
test_blah_ext�r�z"Test_hook_compressed.test_blah_extcCrK)Nzabcd.Gzr�r_r*r r r!�test_gz_ext_builtin�r�z(Test_hook_compressed.test_gz_ext_builtincCrK)Nzabcd.Bz2r�r_r*r r r!�test_bz2_ext_builtin�r�z)Test_hook_compressed.test_bz2_ext_builtincCrK)NrPr�r_r*r r r!�test_binary_mode_encoding�r�z.Test_hook_compressed.test_binary_mode_encodingcCrKrOrLr*r r r!�test_text_mode_encoding�r�z,Test_hook_compressed.test_text_mode_encodingc	Csf|�|j�}z
t�||�}W|�|�n|�|�w|�|jjd�|�|jj||fddd�f�dS)NrF�rr���replace_builtin_openrJrrUrdrGrH�rr2rrWr�r r r!r`��
�z4Test_hook_compressed.do_test_use_builtin_open_binaryc	Csf|�|j�}z
t�||�}W|�|�n|�|�w|�|jjd�|�|jj||fddd�f�dS)NrF�localerfrgrir r r!rM�rjz2Test_hook_compressed.do_test_use_builtin_open_textcCstj}|t_|Sr')�builtinsr)�
new_open_funcrWr r r!rh�sz)Test_hook_compressed.replace_builtin_openN)r#r$r%rrrNrQ�unittest�
skipUnlessrTrXrZr\r^rarbrcrdrer`rM�staticmethodrhr r r r!rI�s(




	
rIc@r)	�Test_hook_encodedz'Unit tests for fileinput.hook_encoded()cCs�t�}t�}tj||d�}t�}tj}|t_zt�}t�}|||�}W|t_n|t_w|�|jd�|j\}	}
|�	|	d|�|�	|	d|�|�	|
�
d�|�|�	|
�
d�|�|�|
�dS)N�r�rFrrr�)r"rrrFrlrrdrGrHr$�poprg)rrr�r�rJrWr2r�open_resultr�r�r r r!�test�s$
zTest_hook_encoded.testcs�ttd��
}|�d�Wd�n1swY��tt��fdd�}|ddg���t��|ddg�Wd�n1sBwY|dd	g�|d
dg�dS)Nr�s�abccsNttdtd|d�d��}t|�}Wd�n1swY��||�dS)Nr	rrr�rPrr3�rrrrcrd)r��expected_linesrxr>r*r r!�check�s
�
�z,Test_hook_encoded.test_errors.<locals>.check�ignore�abc�strictr�u�abc�backslashreplacez\x80abc)rrrrr�r�r��rrryr r*r!�test_errors�s��zTest_hook_encoded.test_errorscsttd��
}|�d�Wd�n1swY��tt��fdd�}|dgd����t��|dgd��Wd�n1sDwY��t��|dgd��Wd�n1s`wY��t��|d	gd
��Wd�dS1s}wYdS)Nr�s
A
B
C
D+IKw-csJtt|td�d��}t|�}Wd�n1swY��||�dS)Nzutf-7rvrw)rrxrxr>r*r r!rys�
�z+Test_hook_encoded.test_modes.<locals>.checkr	)r�r�r��D€�rUr�r�)r�zB
zC
r�)	rrrrr��assertWarnsr�r�r�r~r r*r!�
test_modess���"�zTest_hook_encoded.test_modesN)r#r$r%rrurr�r r r r!rq�s
rqc@rC)�MiscTestcCr�r')r�check__all__rr*r r r!�test_allr�zMiscTest.test_allN)r#r$r%r�r r r r!r�sr��__main__)5rr�r�rkr`rrrlrrnr\�ImportErrorrTrrrr�pathlibr�test.supportr�test.support.os_helperrr	r�r
rrurr
rr&�TestCaserDrr�rrr r,r0r:r<r>r@rBrDrFrIrqr�r#�mainr r r r!�<module>sn��$Ss/?YA
�

Youez - 2016 - github.com/yon3zu
LinuXploit