Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_fileinput.cpython-312.opt-2.pyc

�

'Μgo���^�	ddlZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl	Z		ddlZddlmZm
Z
ddlmZmZddlmZddlmZmZddlmZddlmZddlmZdd	lmZGd
�d�ZGd�d
�ZGd�deej:�ZGd�d�ZGd�deej:�Z Gd�d�Z!Gd�dej:�Z"Gd�de"�Z#Gd�de"�Z$Gd�de"�Z%Gd�de"�Z&Gd �d!e"�Z'Gd"�d#e"�Z(Gd$�d%e"�Z)Gd&�d'e"�Z*Gd(�d)e"�Z+Gd*�d+�Z,Gd,�d-ej:�Z-Gd.�d/ej:�Z.Gd0�d1ej:�Z/e0d2k(rejb�yy#e
$rdZ	Y��rwxYw#e
$rdZY��{wxYw)3�N)�BytesIO�StringIO)�	FileInput�hook_encoded)�verbose)�TESTFN�FakePath)�unlink)�	os_helper)�support)�mockc��eZdZdd�d�Zy)�	BaseTests�w��modec���tj�\}}|jtj|�d|vrdnd}t|||��5}|j
|�ddd�|S#1swY|SxYw)N�b�utf-8��encoding)�tempfile�mkstemp�
addCleanuprr
�open�write)�self�contentr�fd�namer�fs       �0/usr/local/lib/python3.12/test/test_fileinput.py�writeTmpzBaseTests.writeTmp*sd���#�#�%���D����	�(�(�$�/��$�;�4�G��
�"�d�X�
.�!�
�G�G�G��/���/���s�A*�*A4N)�__name__�
__module__�__qualname__r#��r"rr's��),�r(rc�>�eZdZd�Zed��Zd�Zdd�Zd	d�Zd�Z	y)
�
LineReaderc��g|_y�N��
_linesread�rs r"�__init__zLineReader.__init__4s	����r(c�H�	|jddg|_S#g|_wxYwr,r-r/s r"�	linesreadzLineReader.linesread7s"��	!��?�?�1�%� �D�O��b�D�O�s��	!c�D�t|jd��|_|S�NT)�iter�
splitlines�it)r�filenamers   r"�openhookzLineReader.openhook>s���x�*�*�4�0�1����r(Nc�h�t|jd�}|jj|�|S)N�)�nextr7r.�append)r�size�lines   r"�readlinezLineReader.readlineBs)���D�G�G�R� �������t�$��r(c��g}d}	|j�}|s|S|j|�|t|�z
}||k\r|S�;�Nr)r@r=�len)r�hint�linesr>r?s     r"�	readlineszLineReader.readlinesGsM��������=�=�?�D�����L�L����C��I��D��t�|���r(c��yr,r'r/s r"�closezLineReader.closeSs��r(r,)���)
r$r%r&r0�propertyr2r9r@rFrHr'r(r"r*r*2s/����!��!���

�
r(r*c��eZdZd�Zy)�BufferSizesTestsc��|jdjd�td�D���}|jdjd�td�D���}|jdjd�td�D���}|jdjd�td	�D���}tjd
�}t
rt
d�t||||fd�
�}t|�}|j�|jt|�d�|j|dd�|j|dd�|j|j�d�|j|j�|�t
rt
d�t||||fd�
�}d}|r|dk7r|j�}|r|dk7r�|j|j�|�|j|j�d�|j|j�d�|j!|j#��|j!|j%��t
rt
d�|j'�|j|j�d�|j|j�d�|j�t
rt
d�t||||dfd�
�}t(j*}		t-d�t(_t|�}|jt|�d�|j|dd �|j|j�d!�|j'�|	t(_t
rt
d"�t||||fd�
�}|j|j�d#�|j|j�d�|j'�|j|j�d#�|j|j�d�t
rt
d$�t(j.}
	t||||fd	d�%�}|D] }|dd&j1�}t
|��"|j�|
t(_t||||fd�
�}|D]u}|j|d&d'�|j3|dd&�}|j5|d�|jt7|j9d	��|j���w|j�y#|	t(_wxYw#|
t(_wxYw)(Nr;c3�,K�|]}d|dzz���y�w)zLine %s of file 1
�Nr'��.0�is  r"�	<genexpr>z5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>Y�����"T�)�Q�#8�A�a�C�#@�)����c3�,K�|]}d|dzz���y�w)zLine %s of file 2
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>ZrTrU�
c3�,K�|]}d|dzz���y�w)zLine %s of file 3
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>[�����"S�(�Q�#8�A�a�C�#@�(�rU�c3�,K�|]}d|dzz���y�w)zLine %s of file 4
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>\rZrUrOzLINE (\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�r^�inplacerrI�
)r#�join�range�re�compiler�printr�listrH�assertEqualrC�linenor8r@�
filelineno�assertFalse�isfirstline�isstdin�nextfile�sys�stdinr�stdout�upper�match�assertNotEqual�int�group)
r�t1�t2�t3�t4�pat�firE�s�	savestdin�
savestdoutr?�ms
             r"�test_buffer_sizesz"BufferSizesTests.test_buffer_sizesWsI��
�]�]�2�7�7�"T�%�PR�)�"T�T�
U��
�]�]�2�7�7�"T�%�PR�)�"T�T�
U��
�]�]�2�7�7�"S�%�PQ�(�"S�S�
T��
�]�]�2�7�7�"S�%�PQ�(�"S�S�
T���j�j�4�5����'�(�
�b�"�b�"�-��
@���R���
���
�����U��R�(�����q��#7�8�����r��$8�9��������b�)���������+���'�(�
�b�"�b�"�-��
@�����A�-�-����
�A��A�-�-���������+��������b�)��������!�,�������)�*��������&���-� �
���
��������(<�=��������b�)�
���
���*��
�b�"�b�"�c�2�W�
E���I�I�	�	"� �!E�F�C�I���H�E����S��Z��,����U�2�Y�(;�<����R�[�[�]�I�6��K�K�M�!�C�I���*�+�
�b�"�b�"�-��
@���������a�(���������-�
���
��������a�(���������-���,���Z�Z�
�	$��"�b�"�b�!1�1�w�O�B����C�R�y���(���d���
�H�H�J�#�C�J�
�b�"�b�"�-��
@���D����T�"�X�t�,��	�	�$�s��)�$�A�����4�(����S������_�b�m�m�o�>�	�
	���
��;"�C�I��*$�C�J�s�A?U*�<AU:�*
U7�:
VN)r$r%r&r�r'r(r"rLrLVs��Pr(rLc��eZdZd�Zd�Zy)�UnconditionallyRaisec� �||_d|_y�NF)�exception_type�invoked)rr�s  r"r0zUnconditionallyRaise.__init__�s��,�����r(c�0�d|_|j��r4)r�r��r�args�kwargss   r"�__call__zUnconditionallyRaise.__call__�s������!�!�#�#r(N�r$r%r&r0r�r'r(r"r�r��s���$r(r�c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�FileInputTestsc���|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�y)Nr;zThe only line there is.
rr]rOr)	r#rr@rrrsrtr8rurH)rr�r�r�r�r�r?s       r"�test_zero_byte_filesz#FileInputTests.test_zero_byte_files�s��
�]�]�2�
��
�]�]�2�
��
�]�]�6�
7��
�]�]�2�
��
�b�"�b�"�-��
@���{�{�}������:�;��������a�(��������!�,���������+��{�{�}��������������a�(��������!�,���������+�
���
r(c�$�|jd�}|jd�}t||fd��}t|�}|j|gd��|j|j	�d�|j|j�d�y)N�A
B
C�D
E
Frr]��A
�B
�CzD
zE
�F�rd)r#rrqrrrtrs�rr�r�r�rEs     r"�%test_files_that_dont_end_with_newlinez4FileInputTests.test_files_that_dont_end_with_newline�st��
�]�]�9�
%��
�]�]�9�
%��
�b�"�X��
8���R������� F�G��������!�,��������a�(r(c��|jd�}|jd�}t||fd��}|j|j�d�t	|�}|j|j�d�|j
�|j|j�d�t|�}|j|j�d�y)NzA
BzC
Drr]rI)r#rrr�filenor<r~rxrq)rr�r�r�r?s     r"�test_filenozFileInputTests.test_fileno�s���
�]�]�6�
"��
�]�]�6�
"��
�b�"�X��
8���������b�)��B�x�����B�I�I�K��,�
���
��������b�)��B�x���������b�)r(c���dD]G}|j|��5|jt�5t|��ddd�ddd��Iy#1swY�xYw#1swY�`xYw)N)r�rU�Ur)�subTest�assertRaises�
ValueErrorr)rrs  r"�test_invalid_opening_modez(FileInputTests.test_invalid_opening_mode�sM��$�D����4��(��&�&�z�2��4�(�3�)�(�%�2�2��)�(�s!�A�
A�A�A�A�A#	c���tjd�5}td�|_t	dgd��}t|�}|j
|dg�ddd�y#1swYyxYw)Nz	sys.stdin�spam, bacon, sausage, and spamrf�rb�r^r)r
�patchr�bufferrrqrr)r�m_stdinr�rEs    r"�test_stdin_binary_modez%FileInputTests.test_stdin_binary_mode�sT��
�Z�Z��
$��$�%F�G�G�N��#��T�2�B���H�E����U�%F�$G�H�	%�
$�
$�s�=A�A%c�.�tj}	td�t_|jt	tjd��tdgd��}t
|�}|j|dg�|t_y#|t_wxYw)Nr�r�rfr�r�)ryrzrru�hasattrrrqrr)r�
orig_stdinr�rEs    r"�test_detached_stdin_binary_modez.FileInputTests.test_detached_stdin_binary_mode�sp���Y�Y�
�	#�� A�B�C�I����W�S�Y�Y��9�:��#��T�2�B���H�E����U�%F�$G�H�"�C�I��
�C�I�s�A)B�
Bc��	tdd���}|jd�	td��}|jd�Gd�d�}|jd	�}|�}t|g|��5}|j	�ddd�|j|jd
�y#t$rY��wxYw#t$rY��wxYw#1swY�DxYw)NrOc��yr,r')r!r�s  r"�<lambda>z7FileInputTests.test_file_opening_hook.<locals>.<lambda>s��Dr()rjr9zGFileInput should raise if both inplace and openhook arguments are given�r9z2FileInput should check openhook for being callablec��eZdZd�Zd�Zy)�=FileInputTests.test_file_opening_hook.<locals>.CustomOpenHookc��d|_yr�)r�r/s r"r0zFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__s	��$��r(c�&�d|_t|ddi�S)NTrr)r�r)rr��kargss   r"r�zFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__s��#����T�4�G�4�4r(Nr�r'r(r"�CustomOpenHookr�
s��
%�
5r(r�rkzopenhook not invoked)r�failr�r#r@�
assertTruer�)rr�r��t�custom_open_hooks     r"�test_file_opening_hookz%FileInputTests.test_file_opening_hook�s���	��1�/@�A�B��I�I�@�
A�	��A�&�B��I�I�J�K�	5�	5�
�M�M�$���)�+��
��s�%5�
6�"��K�K�M�7����(�0�0�2H�I��'�	��	��
�	��	��7�
6�s.�B%�B4�/C�%	B1�0B1�4	C�?C�Cc�:�ttd�5}|jd�|jddz�|jd�ddd�|jtt�ttt
d���5}	|j|j�d�|j|j�d	�|j|j�d
�|jt�5t|�ddd�|j|j�d�|j|j�d�ddd�y#1swY��xYw#t$r|jd�Y��wxYw#1swY�xYw#1swYyxYw)
N�wbsA
B
C
s
123456789
i����ascii�r^r9r�r��C
zRead to end of filer;)
rrrr�safe_unlinkrrrrr@�UnicodeDecodeErrorr�r�rq�rr!r�s   r"�
test_readlinezFileInputTests.test_readlines5��
�&�$�
�1�
�G�G�N�#�
�G�G�N�T�)�*�
�G�G�G�� �	
����V�,�
�V� ,�W� 5�7�:<�
1�� � ������6�� � ������6�� � ������6��"�"�#5�6��R��7�
���R�[�[�]�B�/����R�[�[�]�B�/�7�7� �
��&�
1��	�	�/�0�
1��6�6��7�7�sU�7E�F�A E%�&F�;F�AF�E"�%F�?F�F�F�F	�
F�Fc�0�ttd�5}|jd�ddd�|jtt�ttd��5}|j
|j�d�|j
|j�d�|j
|j�d�|j
|j�d�|j
|j�d�ddd�y#1swY��xYw#1swYyxYw)	Nr�sA
B
C
Dr�r�sA
sB
sC
Dr()rrrrr�rrrr@r�s   r"�test_readline_binary_modez(FileInputTests.test_readline_binary_mode1s���
�&�$�
�1�
�G�G�O�$� �����V�,�
�V�$�
/�2����R�[�[�]�F�3����R�[�[�]�H�5����R�[�[�]�G�4����R�[�[�]�C�0����R�[�[�]�C�0�
0�
/�	 �
��0�
/�s�D�B!D�D	�Dc�t�|jdd��}t|dd��5}|j�}|j|d�tj
j
d�ddd�t|d�5}|j|j�d�ddd�y#1swY�?xYw#1swYyxYw)Ns
Initial text.r�rr�T)rrjs	New line.)	r#rr@rrryr{rr�read�r�	temp_file�fobjr?r!s     r"�test_inplace_binary_write_modez-FileInputTests.test_inplace_binary_write_mode>s����M�M�"2��M�>�	�
�y�t�T�
:�d��=�=�?�D����T�#3�4��J�J���\�*�	;�
�)�T�
"�a����Q�V�V�X�|�4�#�
"�;�
:��
#�
"�s�AB"�8!B.�"B+�.B7c�l�|jdd��}t|ddd��5}|j�}|j|d�t	d	�ddd�t|d
�5}|j|j
�jd�d�ddd�y#1swY�NxYw#1swYyxYw)
NsInitial text �r�rTr��replace)rjr�errorsuInitial text �uNew line ˆr�s
s
New line ?)r#rr@rrrprr��rstripr�s     r"�test_inplace_encoding_errorsz+FileInputTests.test_inplace_encoding_errorsHs����M�M�"6�T�M�B�	�
�y�$� '�	�;�>B��=�=�?�D����T�#8�9��/�"�	;�
�)�T�
"�a����Q�V�V�X�_�_�W�5�}�E�#�
"�;�;��
#�
"�s�.B�%0B*�B'�*B3c��d�}|jd�}t|g|��5}|j�}ddd�|jd�y#1swY�xYw)Nc�,�tjd�S)N�(I used to receive only filename and mode)�ior�r8rs  r"�old_hookzFFileInputTests.test_file_hook_backward_compatibility.<locals>.old_hookSs���;�;�I�J�Jr(rkr�r�)r#rr@rr)rr�r�r��results     r"�%test_file_hook_backward_compatibilityz4FileInputTests.test_file_hook_backward_compatibilityRsN��	K��M�M�$���
��s�X�
.�"��[�[�]�F�/�����!K�L�/�
.�s�A�Ac��|jd�}|jd�}t||fd��5}t|�}ddd�|jgd��|jj	�d�|j|j�d�|j|jd�y#1swY�zxYw)	Nr�r�rr]r�r�rdr')r#rrqrrrtrs�_filesr�s     r"�test_context_managerz#FileInputTests.test_context_managerZs���
�]�]�9�
%��
�]�]�9�
%��
�b�"�X��
8�B���H�E�9����� F�G��������!�,��������a�(�������B�'�9�
8�s�B7�7Cc��|jd�}	t|d��5}t�#1swYyxYw#t$r|jjd�YywxYw)Nr;rr]r')r#r�OSErrorrrr�)rr�r�s   r"�test_close_on_exceptionz&FileInputTests.test_close_on_exceptiondsQ��
�]�]�2�
��	,���g�6�"��
�7�6���	,����R�Y�Y��+�	,�s�
3�'�0�3�3�%A�Ac��tgd��5}|j|jd�ddd�y#1swYyxYw)Nrr])rf)rrrr�)rr�s  r"�.test_empty_files_list_specified_to_constructorz=FileInputTests.test_empty_files_list_specified_to_constructorls.��
�R�'�
2�b����R�Y�Y��/�3�
2�
2�s�4�=c��	tj}tt�}	|j	d�}|jt|dz�t|gdd��5}t|�|t_|j�ddd�|t_|j|jd�y#1swY�1xYw#|t_wxYw)Nrkz.bakTrrizos.unlink() was not invoked)�osr
r�r�r#rr�rr<rxr�r�)r�os_unlink_orig�os_unlink_replacementr�r�s     r"�%test_nextfile_oserror_deleting_backupz4FileInputTests.test_nextfile_oserror_deleting_backupps���	����� 4�W� =��	'��
�
�d�#�A��O�O�K��V��4��!��d�W�E���R��1��	����
�F�
'�B�I�	
���-�5�5�5�	7�F�E��
'�B�I�s#�9B>�'B2�B>�2B;�7B>�>
Cc�T�	tj}tt�}	|j	d�}t|gdd��5}|t_|j
�ddd�|t_|j|jd�y#1swY�1xYw#|t_wxYw�NrkTrrizos.fstat() was not invoked)	r��fstatr�r�r#rr@r�r�)r�
os_fstat_orig�os_fstat_replacementr�r�s     r"�%test_readline_os_fstat_raises_OSErrorz4FileInputTests.test_readline_os_fstat_raises_OSError����	;����
�3�G�<��	%��
�
�d�#�A��!��d�W�E��/������
�F�%�B�H�	
���,�4�4�4�	6�F�E��%�B�H��#� B�B�B�B�B�
B'c�T�	tj}tt�}	|j	d�}t|gdd��5}|t_|j
�ddd�|t_|j|jd�y#1swY�1xYw#|t_wxYwr�)	r��chmodr�r�r#rr@r�r�)r�
os_chmod_orig�os_chmod_replacementr�r�s     r"�%test_readline_os_chmod_raises_OSErrorz4FileInputTests.test_readline_os_chmod_raises_OSError�r�r�c�f�Gd�dt�}|�}|jd�}t|gd��5}|j}	||_|j	�}||_	ddd�|j|jd�|jdd�y#||_wxYw#1swY�ExYw)	Nc��eZdZd�Zd�Zy)�QFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrorc�8�tj|t�yr,)r�r0r�r/s r"r0zZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__�s��$�-�-�d�J�?r(c�$�|j�yr,)r�r/s r"r�zXFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.fileno�s���
�
�r(N)r$r%r&r0r�r'r(r"�FilenoRaisesValueErrorr�s
��
@�
 r(r
rkrr]z_file.fileno() was not invokedrIzfileno() should return -1)r�r#r�_filer�r�r�rr)rr
� unconditionally_raise_ValueErrorr�r��file_backupr�s       r"�"test_fileno_when_ValueError_raisedz1FileInputTests.test_fileno_when_ValueError_raised�s���	 �%9�	 �,B�+C�(��M�M�$���
�a�S�7�
3�r��(�(�K�
'�;��������&���
4�	
���8�@�@�8�	:�	
�����%@�A��
'����
4�
3�s#�
B'�B�B'�	B$�$B'�'B0c��t�}tddg|j��5}|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�ddd�y#1swYyxYw�Nzline1
line2zline3
r�zline1
�line2r;)r*rr9rrr2r@�r�srcr�s   r"�test_readline_bufferingz&FileInputTests.test_readline_buffering�s"���l��
�n�i�8� #���.�13����S�]�]�B�/����R�[�[�]�I�6����S�]�]�Y�K�8����R�[�[�]�G�4����S�]�]�W�I�6����R�[�[�]�I�6����S�]�]�R��O�<����R�[�[�]�B�/����S�]�]�R�D�1����R�[�[�]�B�/����S�]�]�B�/�.�.�.�s�EE;�;Fc���t�}tddg|j��5}|j|jg�|jt|�d�|j|jdg�|jt|�d�|j|jdg�|jt|�d�|j|jddg�|j
tt
|�|j|jdg�|j
tt
|�|j|jg�ddd�y#1swYyxYwr)r*rr9rrr2r<r��
StopIterationrs   r"�test_iteration_bufferingz'FileInputTests.test_iteration_buffering�s���l��
�n�i�8� #���.�13����S�]�]�B�/����T�"�X�y�1����S�]�]�Y�K�8����T�"�X�w�/����S�]�]�W�I�6����T�"�X�y�1����S�]�]�R��O�<����m�T�2�6����S�]�]�R�D�1����m�T�2�6����S�]�]�B�/�.�.�.�s�D5E"�"E+c��t|jd��}t|d��5}|j�}|j	|d�|j	|j�d�|j	|j
�d�|j	|j�tj|��ddd�y#1swYyxYw)N�Path-like file.rrrO)
r	r#rr@rrrsrtr8r��fspath)rr�r�r?s    r"�test_pathlike_filez!FileInputTests.test_pathlike_file�s���
�d�m�m�$5�6�
7��
�r�G�
,���;�;�=�D����T�#4�5����R�Y�Y�[�!�,����R�]�]�_�a�0����R�[�[�]�B�I�I�b�M�:�-�
,�
,�s�BC�Cc�b�t|jd��}t|dd��5}|j�}|j	|d�td|z�ddd�t
|d��5}|j	|j�d�ddd�y#1swY�@xYw#1swYyxYw)NrTr)rjrzModified %srzModified Path-like file.
)r	r#rr@rrrprr�)rr�r�r?r!s     r"�test_pathlike_file_inplacez)FileInputTests.test_pathlike_file_inplace�s���
�d�m�m�$5�6�
7��
�r�4�'�
:�b��;�;�=�D����T�#4�5��-�$�&�'�;��"�w�
'�1����Q�V�V�X�'C�D�(�
'�	;�
:��(�
'�s�1B�/!B%�B"�%B.N)r$r%r&r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr'r(r"r�r��s{���()�(
*�)�I�	#�J�60�.1�5�F�M�(�,�0�7�*6�$6�$B�.0� 0� ;�Er(r�c�R�eZdZ	d
ddddd�d�Zd�Zd�Zd�Zd�Zd	�Zd
�Z	d�Z
d�Zy)�
MockFileInputN�r)rr9rr�c��||_||_||_||_||_||_||_d|_tjd��|_
i|_y)Nc��yrBr'r'r(r"r�z(MockFileInput.__init__.<locals>.<lambda>s��r()r^rj�backuprr9rr�r�collections�defaultdict�invocation_counts�
return_values)rr^rjr#rr9rr�s        r"r0zMockFileInput.__init__�sU����
���������	� ��
� ��
������
�!,�!8�!8��!C�����r(c�2�|jdxxdz
cc<y)NrHrO)r&r/s r"rHzMockFileInput.closes�����w�'�1�,�'r(c�N�|jdxxdz
cc<|jdS)NrxrO�r&r'r/s r"rxzMockFileInput.nextfile�)�����z�*�a�/�*��!�!�*�-�-r(c�N�|jdxxdz
cc<|jdS)Nr8rOr*r/s r"r8zMockFileInput.filename
r+r(c�N�|jdxxdz
cc<|jdS)NrsrOr*r/s r"rszMockFileInput.lineno�)�����x�(�A�-�(��!�!�(�+�+r(c�N�|jdxxdz
cc<|jdS)NrtrOr*r/s r"rtzMockFileInput.filelinenos)�����|�,��1�,��!�!�,�/�/r(c�N�|jdxxdz
cc<|jdS)Nr�rOr*r/s r"r�zMockFileInput.filenor.r(c�N�|jdxxdz
cc<|jdS)NrvrOr*r/s r"rvzMockFileInput.isfirstlines)�����}�-��2�-��!�!�-�0�0r(c�N�|jdxxdz
cc<|jdS)NrwrOr*r/s r"rwzMockFileInput.isstdins)�����y�)�Q�.�)��!�!�)�,�,r()NFr;)r$r%r&r0rHrxr8rsrtr�rvrwr'r(r"rr�s@��N� ��D�4�� �-�.�.�,�0�,�1�-r(rc� �eZdZ	d�Zd�Zd�Zy)�BaseFileInputGlobalMethodsTestc�v�tj|_tj|_t
t_yr,)�	fileinput�_state�_orig_stater�_orig_FileInputrr/s r"�setUpz$BaseFileInputGlobalMethodsTest.setUp&s&��$�+�+���(�2�2���+�	�r(c�X�|jt_|jt_yr,)r9r6rr8r7r/s r"�tearDownz'BaseFileInputGlobalMethodsTest.tearDown+s��"�2�2�	���+�+�	�r(c��|j|}|j|d|�t|j�}|j|d�y)NrO)r&rrrC)r�mock_file_input�method_name�actual_count�actual_total_counts     r"�assertExactlyOneInvocationz9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocation/sF��&�8�8��E������q�+�6� ��!B�!B�C�����+�Q�/r(N)r$r%r&r:r<rBr'r(r"r4r4"s�� �,�
,�0r(r4c�&�eZdZ	d�Zd�Zd�Zd�Zy)�Test_fileinput_inputc�X�	t�}t�|_|t_|jt�5}tj�ddd�|jdjj�|j|tjd�y#1swY�QxYw)N)zinput() already active�fileinput._state)r�objectrr6r7r��RuntimeError�inputrr�	exceptionr��assertIs)r�instance�cms   r"�1test_state_is_not_None_and_state_file_is_not_NonezFTest_fileinput_input.test_state_is_not_None_and_state_file_is_not_None:s{��	$�!�?������#�	��
�
�
�|�
,���O�O��-����4�b�l�l�6G�6G�H��
�
�h�	� 0� 0�2D�E�-�
,�s�B � B)c�^�	t�}d|_|t_|j	�yr,)rrr6r7�do_test_call_input�rrLs  r"�-test_state_is_not_None_and_state_file_is_NonezBTest_fileinput_input.test_state_is_not_None_and_state_file_is_NoneGs,��	@�
!�?�����#�	�����!r(c�<�	dt_|j�yr,)r6r7rPr/s r"�test_state_is_Nonez'Test_fileinput_input.test_state_is_NoneRs��	�
 �	�����!r(c��	t�}t�}t�}t�}t�}t�}tj||||||��}|j|tjd�|j||j
d�|j||jd�|j||jd�|j||jd�|j||jd�y)N)r^rjr#rr9rrFr^rjr#rr9)
rGr6rIrKr7r^rjr#rr9)rr^rjr#rr9rr�s        r"rPz'Test_fileinput_input.do_test_call_input[s���	F�����(������x���8���8�����u�g�f���8�=��	
�
�
�f�i�.�.�0B�C�	
�
�
�e�V�\�\�7�3��
�
�g�v�~�~�y�9��
�
�f�f�m�m�X�6��
�
�d�F�K�K��0��
�
�h�����<r(N)r$r%r&rNrRrTrPr'r(r"rDrD7s��*�F�	"�"�=r(rDc��eZdZ	d�Zd�Zy)�Test_fileinput_closec��	dt_tj�|jtj�yr,)r6r7rH�assertIsNoner/s r"rTz'Test_fileinput_close.test_state_is_Noneys-��	��	���������)�*�*�+r(c��	t�}|t_tj�|j	|d�|jtj�y)NrH)rr6r7rHrBrYrQs  r"�test_state_is_not_Nonez+Test_fileinput_close.test_state_is_not_None�sD��	#� �?��#�	�������'�'��'�:����)�*�*�+r(N�r$r%r&rTr[r'r(r"rWrWvs��*�,�,r(rWc��eZdZ	d�Zd�Zy)�Test_fileinput_nextfilec�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYw�N)zno active input())	r6r7r�rHrxrrrJr�rY�rrMs  r"rTz*Test_fileinput_nextfile.test_state_is_None��j��	3� �	��
�
�
�|�
,����� �-����/����1B�1B�C����)�*�*�+�-�
,���B�Bc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nrx)rGrr'r6r7rxrBrK)r�nextfile_retvalrL�retvals    r"r[z.Test_fileinput_nextfile.test_state_is_not_None��o��	.�!�(�� �?��-<����z�*�#�	���#�#�%���'�'��*�=��
�
�f�o�.��
�
�i�&�&��1r(Nr\r'r(r"r^r^����-�,�2r(r^c��eZdZ	d�Zd�Zy)�Test_fileinput_filenamec�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHr8rrrJr�rYras  r"rTz*Test_fileinput_filename.test_state_is_None�rbrcc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nr8)rGrr'r6r7r8rBrK)r�filename_retvalrLrfs    r"r[z.Test_fileinput_filename.test_state_is_not_None�rgr(Nr\r'r(r"rjrj�rhr(rjc��eZdZ	d�Zd�Zy)�Test_fileinput_linenoc�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHrsrrrJr�rYras  r"rTz(Test_fileinput_lineno.test_state_is_None��j��	3� �	��
�
�
�|�
,������-����/����1B�1B�C����)�*�*�+�-�
,�rcc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nrs)rGrr'r6r7rsrBrK)r�
lineno_retvalrLrfs    r"r[z,Test_fileinput_lineno.test_state_is_not_None�so��	.���
� �?��+8����x�(�#�	���!�!�#���'�'��(�;��
�
�f�m�,��
�
�i�&�&��1r(Nr\r'r(r"roro�s��+�,�2r(roc��eZdZ	d�Zd�Zy)�Test_fileinput_filelinenoc�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHrtrrrJr�rYras  r"rTz,Test_fileinput_filelineno.test_state_is_None�sj��	3� �	��
�
�
�|�
,��� � �"�-����/����1B�1B�C����)�*�*�+�-�
,�rcc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nrt)rGrr'r6r7rtrBrK)r�filelineno_retvalrLrfs    r"r[z0Test_fileinput_filelineno.test_state_is_not_None�sq��	.�#�H�� �?��/@����|�,�#�	���%�%�'���'�'��,�?��
�
�f�/�0��
�
�i�&�&��1r(Nr\r'r(r"ruru�s��/�,�2r(ruc��eZdZ	d�Zd�Zy)�Test_fileinput_filenoc�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHr�rrrJr�rYras  r"rTz(Test_fileinput_fileno.test_state_is_None�rqrcc� �	t�}t�}||jd<||_|t_t	j�}|j|d�|j||�|jtj
|�y)Nr�)	rGrr'�
fileno_retvalr6r7r�rBrK)rr}rLrfs    r"r[z,Test_fileinput_fileno.test_state_is_not_Nonesw��	.���
� �?��+8����x�(�!.���#�	���!�!�#���'�'��(�;��
�
�f�m�,��
�
�i�&�&��1r(Nr\r'r(r"rzrz�s��+�,�
2r(rzc��eZdZ	d�Zd�Zy)�Test_fileinput_isfirstlinec�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHrvrrrJr�rYras  r"rTz-Test_fileinput_isfirstline.test_state_is_Nonesj��	3� �	��
�
�
�|�
,���!�!�#�-����/����1B�1B�C����)�*�*�+�-�
,�rcc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nrv)rGrr'r6r7rvrBrK)r�isfirstline_retvalrLrfs    r"r[z1Test_fileinput_isfirstline.test_state_is_not_Nonesq��	.�$�X�� �?��0B����}�-�#�	���&�&�(���'�'��-�@��
�
�f�0�1��
�
�i�&�&��1r(Nr\r'r(r"rrs��0�,�2r(rc��eZdZ	d�Zd�Zy)�Test_fileinput_isstdinc�"�	dt_|jt�5}tj�ddd�|jdjj�|jtj�y#1swY�OxYwr`)	r6r7r�rHrwrrrJr�rYras  r"rTz)Test_fileinput_isstdin.test_state_is_None/sj��	3� �	��
�
�
�|�
,������-����/����1B�1B�C����)�*�*�+�-�
,�rcc��	t�}t�}||jd<|t_tj
�}|j
|d�|j||�|jtj|�y)Nrw)rGrr'r6r7rwrBrK)r�isstdin_retvalrLrfs    r"r[z-Test_fileinput_isstdin.test_state_is_not_None9so��	.� ��� �?��,:����y�)�#�	���"�"�$���'�'��)�<��
�
�f�n�-��
�
�i�&�&��1r(Nr\r'r(r"r�r�,s��,�,�2r(r�c��eZdZd�Zd�Zy)�InvocationRecorderc��d|_yrB)�invocation_countr/s r"r0zInvocationRecorder.__init__Is
�� !��r(c�h�|xjdz
c_||f|_tjd�S)NrOs
some bytes)r��last_invocationr�rr�s   r"r�zInvocationRecorder.__call__Ls.������"�� $�f�~����z�z�-�(�(r(Nr�r'r(r"r�r�Gs��"�)r(r�c���eZdZ	d�Zd�Zd�Zejed�d��Z	ejed�d��Z
ejed�d��Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zed��Zy)�Test_hook_compressedc�"�t�|_yr,)r��	fake_openr/s r"r:zTest_hook_compressed.setUpUs��+�-��r(c�(�|jdd�y)Nr;r ��do_test_use_builtin_open_textr/s r"�test_empty_stringz&Test_hook_compressed.test_empty_stringXs���*�*�2�s�3r(c�(�|jdd�y�N�abcdr r�r/s r"�test_no_extz Test_hook_compressed.test_no_ext[����*�*�6�3�7r(zRequires gzip and zlibc�N�tj}|jt_	tjdd�}|t_|j|jjd�|j|jjdif�y#|t_wxYw)N�test.gzr rO)r�r )�gziprr�r6�hook_compressedrrr�r��r�
original_openr�s   r"�test_gz_ext_fakez%Test_hook_compressed.test_gz_ext_fake^sy���	�	�
��N�N��	�	&��.�.�y�#�>�F�%�D�I�������8�8�!�<�������7�7�:J�B�9O�P��&�D�I���B�
B$c���tj}d�t_	tjddd��}|t_|j	t|�dg�y#|t_wxYw)Nc�,�tjd�S)NsEx-binary string)r�rr�s  r"r�zATest_hook_compressed.test_gz_with_encoding_fake.<locals>.<lambda>ms��2�:�:�6I�+Jr(r�r rrzEx-binary string)r�rr6r�rrrqr�s   r"�test_gz_with_encoding_fakez/Test_hook_compressed.test_gz_with_encoding_fakejsU���	�	�
�J��	�	&��.�.�y�#��P�F�%�D�I�����f��(:�';�<��&�D�I�s�A�
A+zRequires bz2c�N�tj}|jt_	tjdd�}|t_|j|jjd�|j|jjdif�y#|t_wxYw)N�test.bz2r rO)r�r )�bz2�BZ2Filer�r6r�rrr�r�r�s   r"�test_bz2_ext_fakez&Test_hook_compressed.test_bz2_ext_faketsy�����
��n�n���	(��.�.�z�3�?�F�'�C�K�������8�8�!�<�������7�7�:K�R�9P�Q��(�C�K�r�c�(�|jdd�y)Nz	abcd.blahr���do_test_use_builtin_open_binaryr/s r"�
test_blah_extz"Test_hook_compressed.test_blah_ext�s���,�,�[�$�?r(c�(�|jdd�y)Nzabcd.Gzr�r�r/s r"�test_gz_ext_builtinz(Test_hook_compressed.test_gz_ext_builtin�s���,�,�Y��=r(c�(�|jdd�y)Nzabcd.Bz2r�r�r/s r"�test_bz2_ext_builtinz)Test_hook_compressed.test_bz2_ext_builtin�s���,�,�Z��>r(c�(�|jdd�y)Nr�r�r�r/s r"�test_binary_mode_encodingz.Test_hook_compressed.test_binary_mode_encoding�s���,�,�V�T�:r(c�(�|jdd�yr�r�r/s r"�test_text_mode_encodingz,Test_hook_compressed.test_text_mode_encoding�r�r(c�\�|j|j�}	tj||�}|j|�|j	|jj
d�|j	|jj||fddd�f�y#|j|�wxYw)NrO�rr���replace_builtin_openr�r6r�rrr�r��rr8rr�r�s     r"r�z4Test_hook_compressed.do_test_use_builtin_open_binary�s����1�1�$�.�.�A�
�	5��.�.�x��>�F��%�%�m�4�������8�8�!�<�������7�7�#�T�*���,N�O�	Q��
�%�%�m�4���B�B+c�\�|j|j�}	tj||�}|j|�|j	|jj
d�|j	|jj||fddd�f�y#|j|�wxYw)NrO�localer�r�r�s     r"r�z2Test_hook_compressed.do_test_use_builtin_open_text�s����1�1�$�.�.�A�
�	5��.�.�x��>�F��%�%�m�4�������8�8�!�<�������7�7�#�T�*��T�,R�S�	U��
�%�%�m�4�r�c�<�tj}|t_|Sr,)�builtinsr)�
new_open_funcr�s  r"r�z)Test_hook_compressed.replace_builtin_open�s�� �
�
�
�%��
��r(N)r$r%r&r:r�r��unittest�
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r��staticmethodr�r'r(r"r�r�Rs���4�.�4�8��X����7�8�	Q�9�	Q��X����7�8�=�9�=��X����n�-�	R�.�	R�@�>�?�;�8�	Q�	U����r(r�c� �eZdZ	d�Zd�Zd�Zy)�Test_hook_encodedc�f�t�}t�}tj||��}t�}tj
}|t_	t�}t�}|||�}|t_|j
|jd�|j\}	}
|j|	d|�|j|	d|�|j|
jd�|�|j|
jd�|�|j|
�y#|t_wxYw)N�r�rOrrr�)rGr6rr�r�rrrr�r�rK�popru)rrr�r�r�r�r8r�open_resultr�r�s           r"�testzTest_hook_encoded.test�s����8������'�'���@��&�(�	� �
�
�
�!��
�	*��x�H��8�D� ��4�0�K�)�H�M�����3�3�Q�7� �0�0���f��
�
�d�1�g�x�(��
�
�d�1�g�t�$��
�
�f�j�j��,�h�7��
�
�f�j�j��*�F�3����� ��*�H�M�s�D#�#
D0c�T��ttd�5}|jd�ddd��jtt��fd�}|ddg��jt�5|ddg�ddd�|ddg�|d	d
g�y#1swY�oxYw#1swY�*xYw)Nr�s�abcc���ttdtd|����5}t|�}ddd��j	|�y#1swY�xYw)Nr rr��r^rr9�rrrrqrr)r��expected_linesr�rErs    �r"�checkz,Test_hook_encoded.test_errors.<locals>.check�sK�����c�$0���$H�J�MO��R���J�
���U�N�3�J�J�s�A�A�ignore�abc�strictr�u�abc�backslashreplacez\x80abc)rrrrr�r�r��rr!r�s`  r"�test_errorszTest_hook_encoded.test_errors�s����
�&�$�
�1�
�G�G�J�� �����V�,�	4�	�h��� �
�
�
�1�
2��(�U�G�$�3�
�i�+��'�
� �:�,�/� �
��3�
2�s�B�*B�B�B'c�0��ttd�5}|jd�ddd��jtt��fd�}|dgd���jt�5|dgd��ddd�y#1swY�]xYw#1swYyxYw)Nr�s
A
B
C
D+IKw-c���tt|td���5}t|�}ddd��j	|�y#1swY�xYw)Nzutf-7r�r�)rr�r�rErs    �r"r�z+Test_hook_encoded.test_modes.<locals>.check�sE�����d�$0��$9�;�>@��R���;�
���U�N�3�;�;�s�A�A
r )r�r�r��D€r�)r�zB
zC
r�)rrrrr�r�r�r�s`  r"�
test_modeszTest_hook_encoded.test_modes�sv���
�&�$�
�1�
�G�G�(�)� �	
����V�,�	4�	�c�3�4�
�
�
�z�
*��$�:�;�+�
*� �
��+�
*�s�B�+B�B	�BN)r$r%r&r�r�r�r'r(r"r�r��s��1�!�00�"<r(r�c��eZdZd�Zy)�MiscTestc�8�tj|t�yr,)r�check__all__r6r/s r"�test_allzMiscTest.test_all�s�����T�9�-r(N)r$r%r&r�r'r(r"r�r��s��.r(r��__main__)2r�r�ryrnr6r$r�rr�r��ImportErrorr�rrrr�test.supportr�test.support.os_helperrr	r
r�rr�rr
rr*�TestCaserLr�r�rr4rDrWr^rjrorurzrr�r�r�r�r�r$�mainr'r(r"�<module>r�s����
�	�
�	����������!�-� �3�8�"���	�	�"
�"
�HQ�y�(�"3�"3�Q�f$�$�E�Y�� 1� 1�E�D
--�--�^0�X�%6�%6�0�*==�9�==�~,�9�,�&2�<�2�62�<�2�62�:�2�62� >�2�62�:�2�82�!?�2�62�;�2�6)�)�W�8�,�,�W�r:<��)�)�:<�z.�x� � �.��z���H�M�M�O���{��
�C������D��s"�F�F!�F�F�!F,�+F,

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