403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.109
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_fileinput.cpython-36.pyc
3

�w2_H��@sDdZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
rhdZ	YnXyddlZWne
k
r�dZYnXddlm
Z
mZddlmZmZddlmZmZmZddlmZddlmZddlmZGd	d
�d
�ZGdd�d�ZGd
d�deej�ZGdd�d�ZGdd�deej�ZGdd�d�Z Gdd�dej�Z!Gdd�de!�Z"Gdd�de!�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*�Z+Gd+d,�d,ej�Z,Gd-d.�d.ej�Z-Gd/d0�d0ej�Z.e/d1k�r@ej0�dS)2z,
Tests for fileinput module.
Nick Mathewson
�N)�BytesIO�StringIO)�	FileInput�hook_encoded)�verbose�TESTFN�check_warnings)�unlink)�support)�mockc@seZdZdd�dd�ZdS)�	BaseTests�w)�modec	Cs>tj�\}}|jtj|�t||��}|j|�WdQRX|S)N)�tempfileZmkstemp�
addCleanupr
r	�open�write)�selfZcontentr�fd�name�f�r�8/opt/alt/python36/lib64/python3.6/test/test_fileinput.py�writeTmp's
zBaseTests.writeTmpN)�__name__�
__module__�__qualname__rrrrrr$src@sDeZdZdd�Zedd��Zdd�Zddd	�Zddd�Zd
d�Z	dS)�
LineReadercCs
g|_dS)N)�
_linesread)rrrr�__init__0szLineReader.__init__cCsz|jdd�Sg|_XdS)N)r)rrrr�	linesread3szLineReader.linesreadcCst|jd��|_|S)NT)�iter�
splitlines�it)r�filenamerrrr�openhook:szLineReader.openhookNcCst|jd�}|jj|�|S)N�)�nextr#r�append)r�size�linerrr�readline>szLineReader.readline�cCsDg}d}x6|j�}|s|S|j|�|t|�7}||kr
|Sq
WdS)Nr)r+r(�len)rZhint�linesr)r*rrr�	readlinesCs
zLineReader.readlinescCsdS)Nr)rrrr�closeOszLineReader.close)N���)r1)
rrrr�propertyr r%r+r/r0rrrrr.s

rc@seZdZdd�Zddd�ZdS)�BufferSizesTestscCs�x�dD]�\}}|jdjdd�td�D���}|jdjdd�td	�D���}|jdjd
d�td�D���}|jdjdd�td�D���}|r�|jt��|j||||||�WdQRXq|j||||||�qWdS)Nrr,�r&css|]}d|dVqdS)zLine %s of file 1
r,Nr)�.0�irrr�	<genexpr>Vsz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>�css|]}d|dVqdS)zLine %s of file 2
r,Nr)r5r6rrrr7Ws�
css|]}d|dVqdS)zLine %s of file 3
r,Nr)r5r6rrrr7Xs�css|]}d|dVqdS)zLine %s of file 4
r,Nr)r5r6rrrr7Ys�rr�r,r4)r;r<)r�join�range�assertWarns�DeprecationWarning�buffer_size_test)r�round�bs�t1�t2�t3�t4rrr�test_buffer_sizesSs z"BufferSizesTests.test_buffer_sizesrcCsrtjd�}d|d}tr.td|d|f�t||||f|d�}	t|	�}
|	j�|jt|
�d�|j|
dd	�|j|
d
d�|j|	j	�d�|j|	j
�|�tr�td|d|f�t||||f|d�}	d
}x|r�|dkr�|	j�}q�W|j|	j
�|�|j|	j	�d�|j|	j�d�|j
|	j��|j
|	j��t�rRtd|d|f�|	j�|j|	j�d�|j|	j	�d�|	j�t�r�td|d|f�t||||df|d�}	tj}zNtd�t_t|	�}
|jt|
�d�|j|
dd�|j|	j
�d�|	j�Wd|t_Xt�r*td|d|f�t||||f|d�}	|j|	j	�d�|j|	j
�d�|	j�|j|	j	�d�|j|	j
�d�t�r�td|d|f�tj}
zJt||||fd|d�}	x&|	D]}|dd!�j�}t|��q�W|	j�Wd|
t_Xt||||f|d�}	xV|	D]N}|j|d"d �|j|dd#��}|j|d�|jt|jd��|	j���qW|	j�dS)$NzLINE (\d+) OF FILE (\d+)r,�z%s. Simple iteration (bs=%s)r)�files�bufsize��zLine 5 of file 1
r4zLine 1 of file 4
z%s. Status variables (bs=%s)�xzLine 6 of file 2
�z%s. Nextfile (bs=%s)�zLine 1 of file 3
�z%s. Stdin (bs=%s)��-z Line 1 of stdin
Line 2 of stdin
�!� zLine 2 of stdin
z<stdin>z%s. Boundary conditions (bs=%s)z%s. Inplace (bs=%s)r:)rJ�inplacerK�
r1r1r1)�re�compiler�printr�listr0�assertEqualr-�linenor$r+�
filelineno�assertFalse�isfirstline�isstdin�nextfile�sys�stdinr�stdout�upper�match�assertNotEqual�int�group)rrDrErFrGrCrBZpat�start�fir.�sZ	savestdinZ
savestdoutr*�mrrrrA`s�



 z!BufferSizesTests.buffer_size_testN)rr)rrrrHrArrrrr3Rs
r3c@seZdZdd�Zdd�ZdS)�UnconditionallyRaisecCs||_d|_dS)NF)�exception_type�invoked)rrprrrr�szUnconditionallyRaise.__init__cOsd|_|j��dS)NT)rqrp)r�args�kwargsrrr�__call__�szUnconditionallyRaise.__call__N)rrrrrtrrrrro�sroc@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"�Zejeed#�d$�d%d&��Zd'd(�Zd)d*�Zd+d,�Zd-S).�FileInputTestscCs�|jd�}|jd�}|jd�}|jd�}t||||fd�}|j�}|j|d�|j|j�d�|j|j�d�|j|j�|�|j�}|j|�|j|j�d�|j|j�d�|j|j�|�|j�dS)Nr&zThe only line there is.
)rJr,r)	rrr+r\r]r^r$r_r0)rrDrErFrGrlr*rrr�test_zero_byte_files�s 




z#FileInputTests.test_zero_byte_filescCsf|jd�}|jd�}t||fd�}t|�}|j|dddddd	g�|j|j�d
�|j|j�d�dS)NzA
B
CzD
E
F)rJzA
zB
�CzD
zE
�FrRrI)rrr[r\r^r])rrDrErlr.rrr�%test_files_that_dont_end_with_newline�s

z4FileInputTests.test_files_that_dont_end_with_newlinecCs~|jd�}|jd�}t||fd�}|j|j�d�t|�}|j|j�d�|j�|j|j�d�t|�}|j|j�d�dS)	NzA
BzC
D)rJr,r1r1r1r1)rrr\�filenor'rhrbr[)rrDrErlr*rrr�test_fileno�s

zFileInputTests.test_filenocCs�ytdd�}|jd�Wntk
r,YnX|jddd�}tdtf��t|dd�}WdQRXtdtf��t|�}WdQRX|j|d	d
ddg�dS)
Nr
)rz-FileInput should reject invalid mode argumentsA
B
C
D�wbr&�U)rJrzA
zB
zC
�D)r�fail�
ValueErrorrrr@r[r\)rrlrDr.rrr�test_opening_mode�s
z FileInputTests.test_opening_modecCsHtjd��4}td�|_tdgdd�}t|�}|j|dg�WdQRXdS)Nz	sys.stdinsspam, bacon, sausage, and spamrS�rb)rJr)rZpatchr�bufferrr[r\)rZm_stdinrlr.rrr�test_stdin_binary_mode�s

z%FileInputTests.test_stdin_binary_modecCsXtj}zDtd�t_|jttjd��tdgdd�}t|�}|j|dg�Wd|t_XdS)Nsspam, bacon, sausage, and spamr�rSr�)rJr)rcrdrr_�hasattrrr[r\)rZ
orig_stdinrlr.rrr�test_detached_stdin_binary_modes
z.FileInputTests.test_detached_stdin_binary_modecCs�ytddd�d�}|jd�Wntk
r2YnXytdd�}|jd�Wntk
r`YnXGdd	�d	�}|jd
�}|�}t|g|d��}|j�WdQRX|j|jd�dS)Nr,cSsdS)Nr)rrnrrr�<lambda>sz7FileInputTests.test_file_opening_hook.<locals>.<lambda>)rVr%zGFileInput should raise if both inplace and openhook arguments are given)r%z2FileInput should check openhook for being callablec@seZdZdd�Zdd�ZdS)z=FileInputTests.test_file_opening_hook.<locals>.CustomOpenHookcSs
d|_dS)NF)rq)rrrrrszFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__cWsd|_t|�S)NT)rqr)rrrrrrrtszFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__N)rrrrrtrrrr�CustomOpenHooksr�rWzopenhook not invoked)rrr�rr+�
assertTruerq)rrlr��tZcustom_open_hookrrr�test_file_opening_hooks 

z%FileInputTests.test_file_opening_hookc Cs�ttd��(}|jd�|jdd�|jd�WdQRX|jtt�tttd�d���}y4|j|j�d�|j|j�d	�|j|j�d
�Wnt	k
r�|j
d�YnX|jt	��t|�WdQRX|j|j�d�|j|j�d�WdQRXdS)
Nr|sA
B
C
s
123456789
i����ascii)rJr%zA
zB
zC
zRead to end of filer&)
rrrr�safe_unlinkrrr\r+�UnicodeDecodeErrorr�assertRaisesr[)rrrlrrr�
test_readline's"
zFileInputTests.test_readlinecCs�ttd��}|jd�WdQRX|jtt�ttdd��V}|j|j�d�|j|j�d�|j|j�d�|j|j�d�|j|j�d�WdQRXdS)	Nr|sA
B
C
Dr�)rJrsA
sB
sC
D�)rrrrr�rr\r+)rrrlrrr�test_readline_binary_mode>sz(FileInputTests.test_readline_binary_modecCs�|jd�}|jd�}t||fd��}t|�}WdQRX|j|dddddd	g�|j|j�d
�|j|j�d�|j|jf�dS)NzA
B
CzD
E
F)rJzA
zB
rwzD
zE
rxrRrI)rrr[r\r^r]�_files)rrDrErlr.rrr�test_context_managerKs

z#FileInputTests.test_context_managercCsP|jd�}yt|d��
}t�WdQRXWn"tk
rJ|j|jf�YnXdS)Nr&)rJ)rr�OSErrorr\r�)rrDrlrrr�test_close_on_exceptionUs
z&FileInputTests.test_close_on_exceptionc
Cs(tgd��}|j|jd�WdQRXdS)N)rJrS)rS)rr\r�)rrlrrr�.test_empty_files_list_specified_to_constructor]sz=FileInputTests.test_empty_files_list_specified_to_constructorc
CsN|jd�}t|gd��.}|d}|j|d�|d}|j|d�WdQRXdS)zNTests invoking FileInput.__getitem__() with the current
           line numberzline1
line2
)rJrzline1
r,zline2
N)rrr\)rr�rlZretval1Zretval2rrr�test__getitem__as
zFileInputTests.test__getitem__cCsT|jd�}t|gd��$}|jt��}|dWdQRXWdQRX|j|jjd�dS)zZTests invoking FileInput.__getitem__() with an index unequal to
           the line numberzline1
line2
)rJr,N�accessing lines out of order)r�)rrr��RuntimeErrorr\�	exceptionrr)rr�rl�cmrrr�test__getitem__invalid_keyks

z)FileInputTests.test__getitem__invalid_keycCsT|jd�}t|gd��$}|jt��}|dWdQRXWdQRX|j|jjd�dS)zZTests invoking FileInput.__getitem__() with the line number but at
           end-of-inputr&)rJrN�end of input reached)r�)rrr��
IndexErrorr\r�rr)rr�rlr�rrr�test__getitem__eofts

z!FileInputTests.test__getitem__eofcCsztj}tt�}zP|jd�}|jtj|d�t|gdd��}t|�|t_|j	�WdQRXWd|t_X|j
|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 ignoredrWz.bakT)rJrVNzos.unlink() was not invoked)�osr	ror�rrr
rr'rbr�rq)rZos_unlink_origZos_unlink_replacementr�rlrrr�%test_nextfile_oserror_deleting_backup}s
z4FileInputTests.test_nextfile_oserror_deleting_backupcCs`tj}tt�}z6|jd�}t|gdd��}|t_|j�WdQRXWd|t_X|j|jd�dS)z{Tests invoking FileInput.readline() when os.fstat() raises OSError.
           This exception should be silently discarded.rWT)rJrVNzos.fstat() was not invoked)	r��fstatror�rrr+r�rq)rZ
os_fstat_origZos_fstat_replacementr�rlrrr�%test_readline_os_fstat_raises_OSError�s
z4FileInputTests.test_readline_os_fstat_raises_OSError�chmodzos.chmod does not existcCs`tj}tt�}z6|jd�}t|gdd��}|t_|j�WdQRXWd|t_X|j|jd�dS)z{Tests invoking FileInput.readline() when os.chmod() raises OSError.
           This exception should be silently discarded.rWT)rJrVNzos.fstat() was not invoked)	r�r�ror�rrr+r�rq)rZ
os_chmod_origZos_chmod_replacementr�rlrrr�%test_readline_os_chmod_raises_OSError�s
z4FileInputTests.test_readline_os_chmod_raises_OSErrorcCszGdd�dt�}|�}|jd�}t|gd��(}|j}z||_|j�}Wd||_XWdQRX|j|jd�|j|dd�dS)	Nc@seZdZdd�Zdd�ZdS)zQFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrorcSstj|t�dS)N)rorr�)rrrrr�szZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__cSs|j�dS)N)rt)rrrrrz�szXFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.filenoN)rrrrrzrrrr�FilenoRaisesValueError�sr�rW)rJz_file.fileno() was not invokedr,zfileno() should return -1r1)rorr�_filerzr�rqr\)rr�Z unconditionally_raise_ValueErrorr�rlZfile_backup�resultrrr�"test_fileno_when_ValueError_raised�s
z1FileInputTests.test_fileno_when_ValueError_raisedcCs�t�}tddg|jd���}|j|jg�|j|j�d�|j|jdg�|j|j�d�|j|jdg�|j|j�d�|j|jddg�|j|j�d�|j|jdg�|j|j�d�|j|jg�WdQRXdS)Nzline1
line2zline3
)rJr%zline1
�line2r&)rrr%r\r r+)r�srcrlrrr�test_readline_buffering�sz&FileInputTests.test_readline_bufferingcCs�t�}tddg|jd���}|j|jg�|jt|�d�|j|jdg�|jt|�d�|j|jdg�|jt|�d�|j|jddg�|jtt|�|j|jdg�|jtt|�|j|jg�WdQRXdS)Nzline1
line2zline3
)rJr%zline1
r�r&)rrr%r\r r'r��
StopIteration)rr�rlrrr�test_iteration_buffering�sz'FileInputTests.test_iteration_bufferingN)rrrrvryr{r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZskipIfr�r�r�r�r�r�rrrrru�s*


		ruc@sZeZdZdZddd�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 testsNFr&r�rcCsD||_||_||_||_||_||_d|_tjdd��|_	i|_
dS)NcSsdS)Nrrrrrrr��sz(MockFileInput.__init__.<locals>.<lambda>)rJrV�backuprKrr%r��collections�defaultdict�invocation_counts�
return_values)rrJrVr�rKrr%rrrr�szMockFileInput.__init__cCs|jdd7<dS)Nr0r,)r�)rrrrr0�szMockFileInput.closecCs|jdd7<|jdS)Nrbr,)r�r�)rrrrrbszMockFileInput.nextfilecCs|jdd7<|jdS)Nr$r,)r�r�)rrrrr$szMockFileInput.filenamecCs|jdd7<|jdS)Nr]r,)r�r�)rrrrr]	szMockFileInput.linenocCs|jdd7<|jdS)Nr^r,)r�r�)rrrrr^
szMockFileInput.filelinenocCs|jdd7<|jdS)Nrzr,)r�r�)rrrrrzszMockFileInput.filenocCs|jdd7<|jdS)Nr`r,)r�r�)rrrrr`szMockFileInput.isfirstlinecCs|jdd7<|jdS)Nrar,)r�r�)rrrrraszMockFileInput.isstdin)NFr&rr�N)
rrr�__doc__rr0rbr$r]r^rzr`rarrrrr��s
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BaseFileInputGlobalMethodsTestzQBase class for unit tests for the global function of
       the fileinput module.cCstj|_tj|_tt_dS)N)�	fileinput�_state�_orig_stater�_orig_FileInputr�)rrrr�setUp!sz$BaseFileInputGlobalMethodsTest.setUpcCs|jt_|jt_dS)N)r�r�rr�r�)rrrr�tearDown&sz'BaseFileInputGlobalMethodsTest.tearDowncCs2|j|}|j|d|�t|j�}|j|d�dS)Nr,)r�r\r-)rZmock_file_inputZmethod_nameZactual_countZactual_total_countrrr�assertExactlyOneInvocation*s

z9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocationN)rrrr�r�r�r�rrrrr�sr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_fileinput_inputz Unit tests for fileinput.input()cCsVt�}t�|_|t_|jt��}tj�WdQRX|jd|j	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�input() already activezfileinput._state)r�)r��objectr�r�r�r�r��inputr\r�rr�assertIs)r�instancer�rrr�1test_state_is_not_None_and_state_file_is_not_None5szFTest_fileinput_input.test_state_is_not_None_and_state_file_is_not_NonecCst�}d|_|t_|j�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)r�r�r�r��do_test_call_input)rr�rrr�-test_state_is_not_None_and_state_file_is_NoneBszBTest_fileinput_input.test_state_is_not_None_and_state_file_is_NonecCsdt_|j�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)r�r�r�)rrrr�test_state_is_NoneMsz'Test_fileinput_input.test_state_is_NonecCs�t�}t�}t�}t�}t�}t�}tj||||||d�}|j|tjd�|j||jd�|j||jd�|j||jd�|j||jd�|j||j	d�|j||j
d�d	S)
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().)rJrVr�rKrr%zfileinput._staterJrVr�rKrr%N)r�r�r�r�r�rJrVr�rKrr%)rrJrVr�rKrr%r�rrrr�Vs 

z'Test_fileinput_input.do_test_call_inputN)rrrr�r�r�r�r�rrrrr�2s

	r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_closez Unit tests for fileinput.close()cCsdt_tj�|jtj�dS)zPTests that fileinput.close() does nothing if fileinput._state
           is NoneN)r�r�r0�assertIsNone)rrrrr�vsz'Test_fileinput_close.test_state_is_NonecCs0t�}|t_tj�|j|d�|jtj�dS)z`Tests that fileinput.close() invokes close() on fileinput._state
           and sets _state=Noner0N)r�r�r�r0r�r�)rr�rrr�test_state_is_not_None}s
z+Test_fileinput_close.test_state_is_not_NoneN)rrrr�r�r�rrrrr�ssr�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_nextfilez#Unit tests for fileinput.nextfile()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�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�no active input())r�)	r�r�r�r�rbr\r�rrr�)rr�rrrr��s
z*Test_fileinput_nextfile.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�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.rbN)r�r�r�r�r�rbr�r�)rZnextfile_retvalr��retvalrrrr��s
z.Test_fileinput_nextfile.test_state_is_not_NoneN)rrrr�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_filenamez#Unit tests for fileinput.filename()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.filename() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�r$r\r�rrr�)rr�rrrr��s
z*Test_fileinput_filename.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�dS)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.r$N)r�r�r�r�r�r$r�r�)rZfilename_retvalr�r�rrrr��s
z.Test_fileinput_filename.test_state_is_not_NoneN)rrrr�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_linenoz!Unit tests for fileinput.lineno()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.lineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�r]r\r�rrr�)rr�rrrr��s
z(Test_fileinput_lineno.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�dS)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.r]N)r�r�r�r�r�r]r�r�)rZ
lineno_retvalr�r�rrrr��s
z,Test_fileinput_lineno.test_state_is_not_NoneN)rrrr�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_filelinenoz%Unit tests for fileinput.filelineno()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.filelineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�r^r\r�rrr�)rr�rrrr��s
z,Test_fileinput_filelineno.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�dS)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.r^N)r�r�r�r�r�r^r�r�)rZfilelineno_retvalr�r�rrrr��s
z0Test_fileinput_filelineno.test_state_is_not_NoneN)rrrr�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_filenoz!Unit tests for fileinput.fileno()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.fileno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�rzr\r�rrr�)rr�rrrr��s
z(Test_fileinput_fileno.test_state_is_NonecCsTt�}t�}||jd<||_|t_tj�}|j|d�|j||�|jtj|�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.rzN)	r�r�r��
fileno_retvalr�r�rzr�r�)rr�r�r�rrrr��s
z,Test_fileinput_fileno.test_state_is_not_NoneN)rrrr�r�r�rrrrr��s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_isfirstlinez&Unit tests for fileinput.isfirstline()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.isfirstline() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�r`r\r�rrr�)rr�rrrr�s
z-Test_fileinput_isfirstline.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�dS)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.r`N)r�r�r�r�r�r`r�r�)rZisfirstline_retvalr�r�rrrr�s
z1Test_fileinput_isfirstline.test_state_is_not_NoneN)rrrr�r�r�rrrrr�s
r�c@s eZdZdZdd�Zdd�ZdS)�Test_fileinput_isstdinz"Unit tests for fileinput.isstdin()c
CsDdt_|jt��}tj�WdQRX|jd|jj�|jtj�dS)z�Tests fileinput.isstdin() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateN�no active input())r�)	r�r�r�r�rar\r�rrr�)rr�rrrr�,s
z)Test_fileinput_isstdin.test_state_is_NonecCsNt�}t�}||jd<|t_tj�}|j|d�|j||�|jtj|�dS)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.raN)r�r�r�r�r�rar�r�)rZisstdin_retvalr�r�rrrr�6s
z-Test_fileinput_isstdin.test_state_is_not_NoneN)rrrr�r�r�rrrrr�)s
r�c@seZdZdd�Zdd�ZdS)�InvocationRecordercCs
d|_dS)Nr)�invocation_count)rrrrrEszInvocationRecorder.__init__cOs|jd7_||f|_dS)Nr,)r��last_invocation)rrrrsrrrrtGszInvocationRecorder.__call__N)rrrrrtrrrrr�Dsr�c@s|eZdZdZdd�Zdd�Zdd�Zeje	d�d	d
��Z
ejed�dd
��Zdd�Z
dd�Zdd�Zdd�Zedd��ZdS)�Test_hook_compressedz*Unit tests for fileinput.hook_compressed()cCst�|_dS)N)r��	fake_open)rrrrr�NszTest_hook_compressed.setUpcCs|jdd�dS)Nr&r,)�do_test_use_builtin_open)rrrr�test_empty_stringQsz&Test_hook_compressed.test_empty_stringcCs|jdd�dS)NZabcdrP)r�)rrrr�test_no_extTsz Test_hook_compressed.test_no_extzRequires gzip and zlibcCsPtj}|jt_ztjdd�}Wd|t_X|j|jjd�|j|jjdif�dS)N�test.gzrRr,)r�rR)�gziprr�r��hook_compressedr\r�r�)r�
original_openr�rrr�test_gz_ext_fakeWsz%Test_hook_compressed.test_gz_ext_fakezRequires bz2cCsPtj}|jt_ztjdd�}Wd|t_X|j|jjd�|j|jjdif�dS)N�test.bz2rMr,)r�rM)�bz2ZBZ2Filer�r�r�r\r�r�)rr�r�rrr�test_bz2_ext_fakecsz&Test_hook_compressed.test_bz2_ext_fakecCs|jdd�dS)Nz	abcd.blahr:)r�)rrrr�
test_blah_extosz"Test_hook_compressed.test_blah_extcCs|jdd�dS)Nzabcd.GzrI)r�)rrrr�test_gz_ext_builtinrsz(Test_hook_compressed.test_gz_ext_builtincCs|jdd�dS)Nzabcd.Bz2�)r�)rrrr�test_bz2_ext_builtinusz)Test_hook_compressed.test_bz2_ext_builtincCsV|j|j�}ztj||�}Wd|j|�X|j|jjd�|j|jj||fif�dS)Nr,)�replace_builtin_openr�r�r�r\r�r�)rr$rr�r�rrrr�xs
z-Test_hook_compressed.do_test_use_builtin_opencCstj}|t_|S)N)�builtinsr)Z
new_open_funcr�rrrr��sz)Test_hook_compressed.replace_builtin_openN)rrrr�r�r�r�r�Z
skipUnlessr�r�r�r�r�r�r�r��staticmethodr�rrrrr�Ksr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_hook_encodedz'Unit tests for fileinput.hook_encoded()cCs�t�}t�}tj||d�}t�}tj}|t_zt�}t�}|||�}Wd|t_X|j|jd�|j\}	}
|j	|	d|�|j	|	d|�|j	|
j
d�|�|j	|
j
d�|�|j|
�dS)N)�errorsr,r�encodingr�)r�r�rr�r�rr\r�r�r��popr_)rr�r�r�r�r�r$rZopen_resultrrrsrrr�test�s$
zTest_hook_encoded.testcs�ttd��}|jd�WdQRX�jtt��fdd�}|ddg��jt��|ddg�WdQRX|dd	g�|d
dg�dS)Nr|s�abcc
s:ttdtd|d�d��}t|�}WdQRX�j||�dS)Nr�zutf-8)r�)rJrr%)rrrr[r\)r��expected_linesrlr.)rrr�check�sz,Test_hook_encoded.test_errors.<locals>.check�ignore�abc�strict�replaceu�abc�backslashreplacez\x80abc)rrrrr�r�r�)rrr�r)rr�test_errors�szTest_hook_encoded.test_errorsc"s�ttd��}|jd�WdQRX�jtt��fdd�}|ddddd	g��jt��|d
dddd	g�WdQRX�jt��|ddddd	g�WdQRX�jt��|ddd
dd	g�WdQRXdS)Nr|s
A
B
C
D+IKw-c
s6tt|td�d��}t|�}WdQRX�j||�dS)Nzutf-7)rJrr%)rrrr[r\)rr�rlr.)rrrr��sz+Test_hook_encoded.test_modes.<locals>.checkr�zA
zB
zC
uD€ZrUr}r�zB
zC
)	rrrrr�r?r@r�r�)rrr�r)rr�
test_modes�szTest_hook_encoded.test_modesN)rrrr�r�rrrrrrr��sr�c@seZdZdd�ZdS)�MiscTestcCstj|t�dS)N)r
Zcheck__all__r�)rrrr�test_all�szMiscTest.test_allN)rrrrrrrrr�sr�__main__)1r�r�rcrXr�r�r�rr�r��ImportErrorr��iorrrrZtest.supportrrrr	r�r�r
rrrZTestCaser3rorur�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�mainrrrr�<module>s\


$[<.A>A


Youez - 2016 - github.com/yon3zu
LinuXploit