Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_fileinput.cpython-39.opt-2.pyc

a

��gW��@sHddlZddlZddlZddlZddlZddlZddlZddlZzddlZWne	ybdZYn0zddl
Z
Wne	y�dZ
Yn0ddlmZm
Z
ddlmZmZddlmZddlmZmZmZddlmZddlmZddlmZGd	d
�d
�ZGdd�d�ZGd
d�deej�ZGdd�d�ZGdd�deej�Z Gdd�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/e0d1k�rDe�1�dS)2�N)�BytesIO�StringIO)�	FileInput�hook_encoded)�Path)�verbose�TESTFN�check_warnings)�unlink)�support)�mockc@seZdZdd�dd�ZdS)�	BaseTests�w��modecCsRt��\}}|�tj|�t||��}|�|�Wd�n1sD0Y|S�N)�tempfile�mkstemp�
addCleanuprr
�open�write)�selfZcontentr�fd�name�f�r�//usr/local/lib/python3.9/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|_dSr��
_linesread�rrrr�__init__1szLineReader.__init__cCs$z|jdd�Wg|_Sg|_0dSrr"r$rrr�	linesread4s
�zLineReader.linesreadcCst|�d��|_|S�NT)�iter�
splitlines�it)r�filenamerrrr�openhook;szLineReader.openhookNcCst|jd�}|j�|�|S)N�)�nextr*r#�append)r�size�linerrr�readline?szLineReader.readline���cCs@g}d}|��}|s|S|�|�|t|�7}||kr|SqdS�Nr)r2r/�len)r�hint�linesr0r1rrr�	readlinesDs
zLineReader.readlinescCsdSrrr$rrr�closePszLineReader.close)N)r3)
rrr r%�propertyr&r,r2r8r9rrrrr!/s


r!c@seZdZdd�ZdS)�BufferSizesTestsc
Cs�|�d�dd�td�D���}|�d�dd�td�D���}|�d�dd�td�D���}|�d�d	d�td
�D���}t�d�}tr�td�t||||fd
�}t|�}|�	�|�
t|�d�|�
|dd�|�
|dd�|�
|��d�|�
|�
�|�t�rtd�t||||fd
�}d}|�r@|dk�r@|��}�q$|�
|�
�|�|�
|��d�|�
|��d�|�|���|�|���t�r�td�|��|�
|��d�|�
|��d�|�	�t�r�td�t||||dfd
�}tj}	zTtd�t_t|�}|�
t|�d�|�
|dd �|�
|�
�d!�|��W|	t_n|	t_0t�r^td"�t||||fd
�}|�
|��d#�|�
|�
�d�|��|�
|��d#�|�
|�
�d�t�r�td$�tj}
zJt||||fd
d%�}|D]}|dd&���}t|��q�|�	�W|
t_n|
t_0t||||fd
�}|D]N}|�
|d&d'�|�|dd&��}|�|d�|�
t|�d
��|����q6|�	�dS)(Nr-css|]}d|dVqdS)zLine %s of file 1
�Nr��.0�irrr�	<genexpr>V�z5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>�css|]}d|dVqdS)zLine %s of file 2
r<Nrr=rrrr@WrA�
css|]}d|dVqdS)zLine %s of file 3
r<Nrr=rrrr@XrA�css|]}d|dVqdS)zLine %s of file 4
r<Nrr=rrrr@YrAr<zLINE (\d+) OF FILE (\d+)z1. Simple iteration��files��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�rF�inplacer3�
)r�join�range�re�compiler�printr�listr9�assertEqualr5�linenor+r2�
filelineno�assertFalse�isfirstline�isstdin�nextfile�sys�stdinr�stdout�upper�match�assertNotEqual�int�group)
r�t1�t2�t3�t4�pat�fir7�sZ	savestdinZ
savestdoutr1�mrrr�test_buffer_sizesTs�



z"BufferSizesTests.test_buffer_sizesN)rrr rqrrrrr;Ssr;c@seZdZdd�Zdd�ZdS)�UnconditionallyRaisecCs||_d|_dS�NF)�exception_type�invoked)rrtrrrr%�szUnconditionallyRaise.__init__cOsd|_|���dSr')rurt�r�args�kwargsrrr�__call__�szUnconditionallyRaise.__call__N�rrr r%ryrrrrrr�srrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zejed�dd��Zdd�Zejed�d d!��Zejed�d"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4S)5�FileInputTestscCs�|�d�}|�d�}|�d�}|�d�}t||||fd�}|��}|�|d�|�|��d�|�|��d�|�|��|�|��}|�|�|�|��d�|�|��d�|�|��|�|��dS)Nr-zThe only line there is.
rEr<r)	rrr2rZr[r\r+r]r9)rrirjrkrlrnr1rrr�test_zero_byte_files�s 




z#FileInputTests.test_zero_byte_filescCs^|�d�}|�d�}t||fd�}t|�}|�|gd��|�|��d�|�|��d�dS)N�A
B
C�D
E
FrE��A
�B
�CzD
zE
�F�rL)rrrYrZr\r[�rrirjrnr7rrr�%test_files_that_dont_end_with_newline�s

z4FileInputTests.test_files_that_dont_end_with_newlinecCs~|�d�}|�d�}t||fd�}|�|��d�t|�}|�|��d�|��|�|��d�t|�}|�|��d�dS)NzA
BzC
DrEr3)rrrZ�filenor.rfr`rY)rrirjrnr1rrr�test_fileno�s

zFileInputTests.test_filenocCs�ztdd�}|�d�Wnty*Yn0|jddd�}tdtf��t|dd�}Wd�n1sh0Ytdtf��t|�}Wd�n1s�0Y|�|gd	��dS)
Nrrz-FileInput should reject invalid mode argument�A
B
C
D�wbr-�U�rFr)r�r��C
�D)r�fail�
ValueErrorrr	�DeprecationWarningrYrZ)rrnrir7rrr�test_opening_mode�s
*&z FileInputTests.test_opening_modecCs\t�d��>}td�|_tdgdd�}t|�}|�|dg�Wd�n1sN0YdS)Nz	sys.stdin�spam, bacon, sausage, and spamrN�rbr�)rZpatchr�bufferrrYrZ)rZm_stdinrnr7rrr�test_stdin_binary_mode�s

z%FileInputTests.test_stdin_binary_modecCs^tj}zJtd�t_|�ttjd��tdgdd�}t|�}|�|dg�W|t_n|t_0dS)Nr�r�rNr�r�)rarbrr]�hasattrrrYrZ)rZ
orig_stdinrnr7rrr�test_detached_stdin_binary_mode�s
z.FileInputTests.test_detached_stdin_binary_modecCs�ztddd�d�}|�d�Wnty0Yn0ztdd�}|�d�Wnty\Yn0Gdd	�d	�}|�d
�}|�}t|g|d��}|��Wd�n1s�0Y|�|jd�dS)Nr<cSsdSrr)rrprrr�<lambda>rAz7FileInputTests.test_file_opening_hook.<locals>.<lambda>)rRr,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|_dSrs)rur$rrrr%szFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__cWsd|_t|�Sr')rur)rrwrrrryszFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__Nrzrrrr�CustomOpenHooksr�rSzopenhook not invoked)rr�r�rr2�
assertTrueru)rrnr��tZcustom_open_hookrrr�test_file_opening_hooks 

&z%FileInputTests.test_file_opening_hookc	Cs2ttd��2}|�d�|�dd�|�d�Wd�n1sB0Y|�tt�tttd�d���}z4|�|��d�|�|��d	�|�|��d
�Wnt	y�|�
d�Yn0|�t	��t|�Wd�n1s�0Y|�|��d�|�|��d�Wd�n1�s$0YdS)
Nr�sA
B
C
s
123456789
i����ascii�rFr,r�r�r�zRead to end of filer-)
rrrr�safe_unlinkrrrZr2�UnicodeDecodeErrorr��assertRaisesrY�rrrnrrr�
test_readline s&
(�&zFileInputTests.test_readlinecCs�ttd��}|�d�Wd�n1s*0Y|�tt�ttdd��`}|�|��d�|�|��d�|�|��d�|�|��d�|�|��d�Wd�n1s�0YdS)	Nr�r�r�r�sA
sB
sC
DrA)rrrrr�rrZr2r�rrr�test_readline_binary_mode7s(z(FileInputTests.test_readline_binary_modecCs�|jddd�}t|ddd��0}|��}|�|d�tj�d�Wd�n1sR0Yt|d�� }|�|��d�Wd�n1s�0YdS)Ns
Initial text.r�rr�T)rrRs	New line.)	rrr2rZrarcrr�read)rZ	temp_fileZfobjr1rrrr�test_inplace_binary_write_modeDs*z-FileInputTests.test_inplace_binary_write_modecCs�|�d�}|�d�}t||fd��}t|�}Wd�n1s@0Y|�|gd��|�|��d�|�|��d�|�|jd�dS)Nr}r~rErr�rLr)rrrYrZr\r[�_filesr�rrr�test_context_managerNs

&z#FileInputTests.test_context_managercCsb|�d�}z2t|d��}t�Wd�n1s00YWn ty\|�|jd�Yn0dS)Nr-rEr)rr�OSErrorrZr�)rrirnrrr�test_close_on_exceptionXs
&z&FileInputTests.test_close_on_exceptioncCs<tgd��}|�|jd�Wd�n1s.0YdS)NrE)rN)rrZr�)rrnrrr�.test_empty_files_list_specified_to_constructor`sz=FileInputTests.test_empty_files_list_specified_to_constructor)�categorycCsb|�d�}t|gd��8}|d}|�|d�|d}|�|d�Wd�n1sT0YdS)N�line1
line2
rEr�line1
r<zline2
)rrrZ)rr�rnZretval1Zretval2rrr�test__getitem__ds
zFileInputTests.test__getitem__c	Csv|�d�}|�td��Lt|gd�� }|�|dd�Wd�n1sJ0YWd�n1sh0YdS)Nr�zUse iterator protocol insteadrErr�)rZassertWarnsRegexr�rrZ)rr�rnrrr�test__getitem___deprecationos
�z*FileInputTests.test__getitem___deprecationc	Cs||�d�}t|gd��B}|�t��}|dWd�n1s@0YWd�n1s^0Y|�|jjd�dS)Nr�rEr<)zaccessing lines out of order)rrr��RuntimeErrorrZ�	exceptionrw�rr�rn�cmrrr�test__getitem__invalid_keyvs

Dz)FileInputTests.test__getitem__invalid_keyc	Cs||�d�}t|gd��B}|�t��}|dWd�n1s@0YWd�n1s^0Y|�|jjd�dS)Nr-rEr)zend of input reached)rrr��
IndexErrorrZr�rwr�rrr�test__getitem__eof�s

Dz!FileInputTests.test__getitem__eofcCs�tj}tt�}zj|�d�}|�tj|d�t|gdd��&}t|�|t_|�	�Wd�n1sf0YW|t_n|t_0|�
|jd�dS)NrSz.bakTrQzos.unlink() was not invoked)�osr
rrr�rrrrr.r`r�ru)rZos_unlink_origZos_unlink_replacementr�rnrrr�%test_nextfile_oserror_deleting_backup�s
(�z4FileInputTests.test_nextfile_oserror_deleting_backupcCsztj}tt�}zP|�d�}t|gdd��}|t_|��Wd�n1sL0YW|t_n|t_0|�|jd�dS�NrSTrQzos.fstat() was not invoked)	r��fstatrrr�rrr2r�ru)rZ
os_fstat_origZos_fstat_replacementr�rnrrr�%test_readline_os_fstat_raises_OSError�s
(�z4FileInputTests.test_readline_os_fstat_raises_OSErrorcCsztj}tt�}zP|�d�}t|gdd��}|t_|��Wd�n1sL0YW|t_n|t_0|�|jd�dSr�)	r��chmodrrr�rrr2r�ru)rZ
os_chmod_origZos_chmod_replacementr�rnrrr�%test_readline_os_chmod_raises_OSError�s
(�z4FileInputTests.test_readline_os_chmod_raises_OSErrorc	Cs�Gdd�dt�}|�}|�d�}t|gd��8}|j}z||_|��}W||_n||_0Wd�n1sj0Y|�|jd�|�|dd�dS)Nc@seZdZdd�Zdd�ZdS)zQFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrorcSst�|t�dSr)rrr%r�r$rrrr%�szZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__cSs|��dSr)ryr$rrrr��szXFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.filenoN)rrr r%r�rrrr�FilenoRaisesValueError�sr�rSrEz_file.fileno() was not invokedr3zfileno() should return -1)rrrr�_filer�r�rurZ)rr�Z unconditionally_raise_ValueErrorr�rnZfile_backup�resultrrr�"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�n1s�0YdS�Nzline1
line2zline3
r�r�Zline2r-)r!rr,rZr&r2�r�srcrnrrr�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�n1s�0YdSr�)r!rr,rZr&r.r��
StopIterationr�rrr�test_iteration_buffering�s �z'FileInputTests.test_iteration_bufferingcCs�t|�d��}t|��Z}|��}|�|d�|�|��d�|�|��d�|�|��t�	|��Wd�n1sv0YdS)N�
Pathlib file.r<)
rrrr2rZr[r\r+r��fspath)rrirnr1rrr�test_pathlib_file�s
z FileInputTests.test_pathlib_filecCs�t|�d��}t|dd��0}|��}|�|d�td|�Wd�n1sP0Yt|�� }|�|��d�Wd�n1s�0YdS)Nr�T)rRzModified %szModified Pathlib file.
)rrrr2rZrXrr�)rrirnr1rrrr�test_pathlib_file_inplaces*
z(FileInputTests.test_pathlib_file_inplaceN)rrr r|r�r�r�r�r�r�r�r�r�r�r�r�rZignore_warningsr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr{�s8







	

		r{c@s^eZdZdddd�dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Z	dd�Z
dd�ZdS)�
MockFileInputNFr-�r)rr,cCs>||_||_||_||_||_d|_t�dd��|_i|_	dS)NcSsdSr4rrrrrr�rAz(MockFileInput.__init__.<locals>.<lambda>)
rFrR�backuprr,r��collections�defaultdict�invocation_counts�
return_values)rrFrRr�rr,rrrr%szMockFileInput.__init__cCs|jdd7<dS)Nr9r<)r�r$rrrr9szMockFileInput.closecCs|jdd7<|jdS)Nr`r<�r�r�r$rrrr`szMockFileInput.nextfilecCs|jdd7<|jdS)Nr+r<r�r$rrrr+"szMockFileInput.filenamecCs|jdd7<|jdS)Nr[r<r�r$rrrr[&szMockFileInput.linenocCs|jdd7<|jdS)Nr\r<r�r$rrrr\*szMockFileInput.filelinenocCs|jdd7<|jdS)Nr�r<r�r$rrrr�.szMockFileInput.filenocCs|jdd7<|jdS)Nr^r<r�r$rrrr^2szMockFileInput.isfirstlinecCs|jdd7<|jdS)Nr_r<r�r$rrrr_6szMockFileInput.isstdin)NFr-)rrr r%r9r`r+r[r\r�r^r_rrrrr�
s�r�c@s$eZdZdd�Zdd�Zdd�ZdS)�BaseFileInputGlobalMethodsTestcCstj|_tj|_tt_dSr)�	fileinput�_state�_orig_stater�_orig_FileInputr�r$rrr�setUp>sz$BaseFileInputGlobalMethodsTest.setUpcCs|jt_|jt_dSr)r�r�rr�r�r$rrr�tearDownCsz'BaseFileInputGlobalMethodsTest.tearDowncCs2|j|}|�|d|�t|j�}|�|d�dS�Nr<)r�rZr5)rZmock_file_inputZmethod_nameZactual_countZactual_total_countrrr�assertExactlyOneInvocationGs

z9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocationN)rrr r�r�r�rrrrr�:sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_fileinput_inputcCsjt�}t�|_|t_|�t��}t��Wd�n1s<0Y|�d|j	j
�|�|tjd�dS)N)zinput() already active�fileinput._state)r��objectr�r�r�r�r��inputrZr�rw�assertIs)r�instancer�rrr�1test_state_is_not_None_and_state_file_is_not_NoneRs&zFTest_fileinput_input.test_state_is_not_None_and_state_file_is_not_NonecCst�}d|_|t_|��dSr)r�r�r�r��do_test_call_input�rr�rrr�-test_state_is_not_None_and_state_file_is_None_szBTest_fileinput_input.test_state_is_not_None_and_state_file_is_NonecCsdt_|��dSr)r�r�r�r$rrr�test_state_is_Nonejsz'Test_fileinput_input.test_state_is_NonecCs�t�}t�}t�}t�}t�}tj|||||d�}|�|tjd�|�||jd�|�||jd�|�||jd�|�||jd�|�||j	d�dS)N)rFrRr�rr,r�rFrRr�rr,)
r�r�r�r�r�rFrRr�rr,)rrFrRr�rr,r�rrrr�ss
�z'Test_fileinput_input.do_test_call_inputN)rrr r�r�r�r�rrrrr�Os
	r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_closecCsdt_t��|�tj�dSr)r�r�r9�assertIsNoner$rrrr��sz'Test_fileinput_close.test_state_is_NonecCs0t�}|t_t��|�|d�|�tj�dS)Nr9)r�r�r�r9r�r�r�rrr�test_state_is_not_None�s
z+Test_fileinput_close.test_state_is_not_NoneN�rrr r�r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�Test_fileinput_nextfilecCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dS�N)zno active input())	r�r�r�r�r`rZr�rwr��rr�rrrr��s
&z*Test_fileinput_nextfile.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr`)r�r�r�r�r�r`r�r�)rZnextfile_retvalr��retvalrrrr��s
z.Test_fileinput_nextfile.test_state_is_not_NoneNr�rrrrr��s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_filenamecCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r+rZr�rwr�r�rrrr��s
&z*Test_fileinput_filename.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr+)r�r�r�r�r�r+r�r�)rZfilename_retvalr�r�rrrr��s
z.Test_fileinput_filename.test_state_is_not_NoneNr�rrrrr��s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_linenocCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r[rZr�rwr�r�rrrr��s
&z(Test_fileinput_lineno.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr[)r�r�r�r�r�r[r�r�)rZ
lineno_retvalr�r�rrrr��s
z,Test_fileinput_lineno.test_state_is_not_NoneNr�rrrrr��s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_filelinenocCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r\rZr�rwr�r�rrrr��s
&z,Test_fileinput_filelineno.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr\)r�r�r�r�r�r\r�r�)rZfilelineno_retvalr�r�rrrr��s
z0Test_fileinput_filelineno.test_state_is_not_NoneNr�rrrrr��s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_filenocCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r�rZr�rwr�r�rrrr�s
&z(Test_fileinput_fileno.test_state_is_NonecCsTt�}t�}||jd<||_|t_t��}|�|d�|�||�|�tj|�dS)Nr�)	r�r�r��
fileno_retvalr�r�r�r�r�)rr�r�r�rrrr�s
z,Test_fileinput_fileno.test_state_is_not_NoneNr�rrrrr�s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_isfirstlinecCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r^rZr�rwr�r�rrrr�+s
&z-Test_fileinput_isfirstline.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr^)r�r�r�r�r�r^r�r�)rZisfirstline_retvalr�r�rrrr�5s
z1Test_fileinput_isfirstline.test_state_is_not_NoneNr�rrrrr�(s
r�c@seZdZdd�Zdd�ZdS)�Test_fileinput_isstdincCsXdt_|�t��}t��Wd�n1s.0Y|�d|jj�|�tj�dSr�)	r�r�r�r�r_rZr�rwr�r�rrrr�Fs
&z)Test_fileinput_isstdin.test_state_is_NonecCsNt�}t�}||jd<|t_t��}|�|d�|�||�|�tj|�dS)Nr_)r�r�r�r�r�r_r�r�)rZisstdin_retvalr�r�rrrr�Ps
z-Test_fileinput_isstdin.test_state_is_not_NoneNr�rrrrr�Cs
r�c@seZdZdd�Zdd�ZdS)�InvocationRecordercCs
d|_dSr4)�invocation_countr$rrrr%_szInvocationRecorder.__init__cOs|jd7_||f|_dSr�)r��last_invocationrvrrrryaszInvocationRecorder.__call__Nrzrrrrr�^sr�c@sxeZdZdd�Zdd�Zdd�Ze�ed�dd	��Z	e�e
d
�dd��Zd
d�Zdd�Z
dd�Zdd�Zedd��ZdS)�Test_hook_compressedcCst�|_dSr)r��	fake_openr$rrrr�hszTest_hook_compressed.setUpcCs|�dd�dS)Nr-r<��do_test_use_builtin_openr$rrr�test_empty_stringksz&Test_hook_compressed.test_empty_stringcCs|�dd�dS)NZabcd�r�r$rrr�test_no_extnsz Test_hook_compressed.test_no_extzRequires gzip and zlibcCsVtj}|jt_zt�dd�}W|t_n|t_0|�|jjd�|�|jjdif�dS)N�test.gzr�r<)rr�)�gziprr�r��hook_compressedrZr�r��r�
original_openr�rrr�test_gz_ext_fakeqsz%Test_hook_compressed.test_gz_ext_fakezRequires bz2cCsVtj}|jt_zt�dd�}W|t_n|t_0|�|jjd�|�|jjdif�dS)N�test.bz2rHr<)r
rH)�bz2�BZ2Filer�r�rrZr�r�rrrr�test_bz2_ext_fake}sz&Test_hook_compressed.test_bz2_ext_fakecCs|�dd�dS)Nz	abcd.blahrDr�r$rrr�
test_blah_ext�sz"Test_hook_compressed.test_blah_extcCs|�dd�dS)Nzabcd.GzrLr�r$rrr�test_gz_ext_builtin�sz(Test_hook_compressed.test_gz_ext_builtincCs|�dd�dS)Nzabcd.Bz2�r�r$rrr�test_bz2_ext_builtin�sz)Test_hook_compressed.test_bz2_ext_builtinc	Cs`|�|j�}zt�||�}W|�|�n|�|�0|�|jjd�|�|jj||fif�dSr�)�replace_builtin_openr�r�rrZr�r�)rr+rrr�rrrr�s

�z-Test_hook_compressed.do_test_use_builtin_opencCstj}|t_|Sr)�builtinsr)Z
new_open_funcrrrrr�sz)Test_hook_compressed.replace_builtin_openN)rrr r�rr�unittestZ
skipUnlessrr	rr
rrrr�staticmethodrrrrrr�es



r�c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_hook_encodedcCs�t�}t�}tj||d�}t�}tj}|t_z t�}t�}|||�}W|t_n|t_0|�|jd�|j\}	}
|�	|	d|�|�	|	d|�|�	|
�
d�|�|�	|
�
d�|�|�|
�dS)N��errorsr<r�encodingr)r�r�rr�rrrZr�r�r��popr])rrrr�r�rr+rZopen_resultrwrxrrr�test�s$
zTest_hook_encoded.testcs�ttd��}|�d�Wd�n1s*0Y��tt��fdd�}|ddg���t��|ddg�Wd�n1s�0Y|dd	g�|d
dg�dS)Nr�s�abccsNttdtd|d�d��}t|�}Wd�n1s40Y��||�dS)Nr�zutf-8r�rFrr,�rrrrYrZ)r�expected_linesrnr7r$rr�check�s
�&z,Test_hook_encoded.test_errors.<locals>.check�ignore�abc�strict�replaceu�abc�backslashreplacez\x80abc)rrrrr�r�r��rrrrr$r�test_errors�s(*zTest_hook_encoded.test_errorscsttd��}|�d�Wd�n1s*0Y��tt��fdd�}|dgd����t��|dgd��Wd�n1s�0Y��t��|dgd��Wd�n1s�0Y��t��|d	gd
��Wd�n1s�0YdS)Nr�s
A
B
C
D+IKw-csJtt|td�d��}t|�}Wd�n1s00Y��||�dS)Nzutf-7rr)rrrnr7r$rrr�s�&z+Test_hook_encoded.test_modes.<locals>.checkr�)r�r�r��D€ZrUr�r�)r�zB
zC
r')	rrrrr�ZassertWarnsr�r�r�r%rr$r�
test_modes�s(,,zTest_hook_encoded.test_modesN)rrr rr&r(rrrrr�src@seZdZdd�ZdS)�MiscTestcCst�|t�dSr)rZcheck__all__r�r$rrr�test_all�szMiscTest.test_allN)rrr r*rrrrr)�sr)�__main__)2r�rarVr�r�rrrr�ImportErrorr�iorrrr�pathlibrZtest.supportrrr	r
r�rrrr
r!ZTestCaser;rrr{r�r�r�r�r�r�r�r�r�r�r�r�r�rr)r�mainrrrr�<module>s\


$Sa->>A


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists