403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.51
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python313/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python313/Lib/test/__pycache__/test_fileinput.cpython-313.pyc
�

��id���f�SrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKJ
r
Jr SSKJrJr SSKJr SSKJrJr SSKJr SSKJr SS	KJr SS
K	Jr "SS5r"S
S5r"SS\\	R<5r"SS5r "SS\\	R<5r!"SS5r""SS\	R<5r#"SS\#5r$"SS\#5r%"SS\#5r&"SS \#5r'"S!S"\#5r("S#S$\#5r)"S%S&\#5r*"S'S(\#5r+"S)S*\#5r,"S+S,5r-"S-S.\	R<5r."S/S0\	R<5r/"S1S2\	R<5r0\1S3:Xa\	Rd"5 gg!\a Sr
GNtf=f!\a SrGN~f=f)4z,
Tests for fileinput module.
Nick Mathewson
�N)�BytesIO�StringIO)�	FileInput�hook_encoded)�verbose)�TESTFN�FakePath)�unlink)�	os_helper)�support)�mockc�"�\rSrSrSS.SjrSrg)�	BaseTests�'�w��modec���[R"5up4UR[RU5 SU;aSOSn[X2US9nUR
U5 SSS5 U$!,(df   U$=f)N�b�utf-8��encoding)�tempfile�mkstemp�
addCleanuprr
�open�write)�self�contentr�fd�namer�fs       �(C:\Python313\\Lib\test\test_fileinput.py�writeTmp�BaseTests.writeTmp*sc���#�#�%������	�(�(�$�/��$�;�4�G��
�"�X�
.�!�
�G�G�G��/���/�
.���s�A(�(
A7�N)�__name__�
__module__�__qualname__�__firstlineno__r$�__static_attributes__r&�r#rr's��),��r,rc�J�\rSrSrSr\S5rSrS
SjrSSjr	Sr
S	rg)�
LineReader�2c��/Ulg�N��
_linesread�rs r#�__init__�LineReader.__init__4s	����r,c�H�URSS/Ul$!/Ulf=fr1r2r4s r#�	linesread�LineReader.linesread7s"��	!��?�?�1�%� �D�O��b�D�O�s��	!c�D�[URS55UlU$�NT)�iter�
splitlines�it)r�filenamers   r#�openhook�LineReader.openhook>s���x�*�*�4�0�1����r,Nc�h�[URS5nURRU5 U$)N�)�nextr>r3�append)r�size�lines   r#�readline�LineReader.readlineBs)���D�G�G�R� �������t�$��r,c��/nSnUR5nU(dU$URU5 U[U5-
nX1:�aU$MA�Nr)rHrE�len)r�hint�linesrFrGs     r#�	readlines�LineReader.readlinesGsK��������=�=�?�D�����L�L����C��I��D��|���r,c��gr1r&r4s r#�close�LineReader.closeSs��r,)r3r>r1)���)r'r(r)r*r5�propertyr8r@rHrOrRr+r&r,r#r.r.2s/����!��!���

�
r,r.c��\rSrSrSrSrg)�BufferSizesTests�Vc�8�URSRS[S5555nURSRS[S5555nURSRS[S5555nURSRS[S	5555n[R"S
5n[
(a[
S5 [XX44SS
9n[U5nUR5 UR[U5S5 URUSS5 URUSS5 URUR5S5 URUR5U5 [
(a[
S5 [XX44SS
9nSnU(a%US:waUR5nU(aUS:waMURUR5U5 URUR5S5 URUR5S5 UR!UR#55 UR!UR%55 [
(a[
S5 UR'5 URUR5S5 URUR5S5 UR5 [
(a[
S5 [XX4S4SS
9n[(R*n	[-S5[(l[U5nUR[U5S5 URUSS 5 URUR5S!5 UR'5 U	[(l[
(a[
S"5 [XX44SS
9nURUR5S#5 URUR5S5 UR'5 URUR5S#5 URUR5S5 [
(a[
S$5 [(R.n
[XX44S%SS&9nUH!nUSS'R15n[
U5 M# UR5 U
[(l[XX44SS
9nUHvnURUS'S(5 UR3USS'5nUR5US5 UR[7UR9S	55UR55 Mx UR5 g!U	[(lf=f!U
[(lf=f))NrCc3�2# �UH
nSUS--v� M g7f)zLine %s of file 1
�Nr&��.0�is  r#�	<genexpr>�5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>Y����"T�)�Q�#8�A�a�C�#@�)����c3�2# �UH
nSUS--v� M g7f)zLine %s of file 2
r[Nr&r\s  r#r_r`Zrarb�
c3�2# �UH
nSUS--v� M g7f)zLine %s of file 3
r[Nr&r\s  r#r_r`[����"S�(�Q�#8�A�a�C�#@�(�rb�c3�2# �UH
nSUS--v� M g7f)zLine %s of file 4
r[Nr&r\s  r#r_r`\rgrbr[zLINE (\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. InplaceT�rk�inplacerrT�
)r$�join�range�re�compiler�printr�listrR�assertEqualrL�linenor?rH�
filelineno�assertFalse�isfirstline�isstdin�nextfile�sys�stdinr�stdout�upper�match�assertNotEqual�int�group)
r�t1�t2�t3�t4�pat�firN�s�	savestdin�
savestdoutrG�ms
             r#�test_buffer_sizes�"BufferSizesTests.test_buffer_sizesWs=��
�]�]�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���7��'�(�
�b�b�-��
@���R���
���
�����U��R�(�����q��#7�8�����r��$8�9��������b�)���������+��7��'�(�
�b�b�-��
@�����A�-�-����
�A��A�-�-���������+��������b�)��������!�,�������)�*��������&��7��-� �
���
��������(<�=��������b�)�
���
��7��*��
�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��7��*�+�
�b�b�-��
@���������a�(���������-�
���
��������a�(���������-��7��,���Z�Z�
�	$��"�"�!1�4�'�R�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�1A?U<�AV�<
V	�
Vr&N)r'r(r)r*r�r+r&r,r#rWrWVs��Pr,rWc� �\rSrSrSrSrSrg)�UnconditionallyRaise�c��XlSUlg�NF��exception_type�invoked)rr�s  r#r5�UnconditionallyRaise.__init__�s��,����r,c�0�SUlUR5er;)r�r��r�args�kwargss   r#�__call__�UnconditionallyRaise.__call__�s������!�!�#�#r,r�N�r'r(r)r*r5r�r+r&r,r#r�r��s���$r,r�c��\rSrSrSrSrSrSrSrSr	Sr
S	rS
rSr
SrS
rSrSrSrSrSrSrSrSrSrSrSrSrg)�FileInputTests�c���URS5nURS5nURS5nURS5n[XX44SS9nUR5nURUS5 URUR	5S5 URUR5S5 URUR
5U5 UR5nURU5 URUR	5S5 URUR5S5 URUR
5U5 UR5 g)NrCzThe only line there is.
rrjr[r)	r$rrHrr�r�r?r�rR)rr�r�r�r�r�rGs       r#�test_zero_byte_files�#FileInputTests.test_zero_byte_files�s��
�]�]�2�
��
�]�]�2�
��
�]�]�6�
7��
�]�]�2�
��
�b�b�-��
@���{�{�}������:�;��������a�(��������!�,���������+��{�{�}��������������a�(��������!�,���������+�
���
r,c��URS5nURS5n[X4SS9n[U5nURU/SQ5 URUR	5S5 URUR5S5 g)N�A
B
C�D
E
Frrj��A
�B
�CzD
zE
�F�rq)r$rr~rr�r��rr�r�r�rNs     r#�%test_files_that_dont_end_with_newline�4FileInputTests.test_files_that_dont_end_with_newline�sr��
�]�]�9�
%��
�]�]�9�
%��
�b�X��
8���R������� F�G��������!�,��������a�(r,c��URS5nURS5n[X4SS9nURUR5S5 [	U5nURUR5S5 UR
5 URUR5S5 [U5nURUR5S5 g)NzA
BzC
DrrjrT)r$rr�filenorDr�r�r~)rr�r�r�rGs     r#�test_fileno�FileInputTests.test_fileno�s���
�]�]�6�
"��
�]�]�6�
"��
�b�X��
8���������b�)��B�x�����B�I�I�K��,�
���
��������b�)��B�x���������b�)r,c���SHBnURUS9 UR[5 [US9 SSS5 SSS5 MD g!,(df   N=f!,(df   Mg=f)N)r�rU�Ur)�subTest�assertRaises�
ValueErrorr)rrs  r#�test_invalid_opening_mode�(FileInputTests.test_invalid_opening_mode�sM��$�D����4��(��&�&�z�2��4�(�3�)�(�%�2�2��)�(�s!�A�
A
�A�

A�A�
A*	c���[R"S5n[S5Ul[	S/SS9n[U5nUR
US/5 SSS5 g!,(df   g=f)Nz	sys.stdin�spam, bacon, sausage, and spamrs�rb�rkr)r
�patchr�bufferrr~r)r�m_stdinr�rNs    r#�test_stdin_binary_mode�%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�(�[Rn[S5[lUR[	[RS55 [S/SS9n[
U5nURUS/5 U[lg!U[lf=f)Nr�r�rsr�r�)r�r�rr��hasattrrr~r)r�
orig_stdinr�rNs    r#�test_detached_stdin_binary_mode�.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��[SSS9nURS5 [SS9nURS5 "SS	5nURS
5nU"5n[U/US9nUR	5 SSS5 URURS5 g![a N�f=f![a Nf=f!,(df   NK=f)NTc��gr1r&)r"r�s  r#�<lambda>�7FileInputTests.test_file_opening_hook.<locals>.<lambda>s��tr,)rwr@zGFileInput should raise if both inplace and openhook arguments are givenr[�r@z2FileInput should check openhook for being callablec� �\rSrSrSrSrSrg)�=FileInputTests.test_file_opening_hook.<locals>.CustomOpenHooki
c��SUlgr��r�r4s r#r5�FFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__s	��$��r,c�&�SUl[USS06$)NTrr)r�r)rr��kargss   r#r��FFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__s��#����T�4�G�4�4r,r�Nr�r&r,r#�CustomOpenHookr�
s��
%�
5r,r�rxzopenhook not invoked)r�failr�r$rH�
assertTruer�)rr�r��t�custom_open_hooks     r#�test_file_opening_hook�%FileInputTests.test_file_opening_hook�s���	��4�2C�D�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�B,�&B<�
B)�(B)�,
B9�8B9�<
C
c�T�[[S5nURS5 URSS-5 URS5 SSS5 UR[[5 [[[
S5S9nURUR5S5 URUR5S	5 URUR5S
5 UR[5 [U5 SSS5 URUR5S5 URUR5S5 SSS5 g!,(df   GN=f![a URS5 N�f=f!,(df   N�=f!,(df   g=f)
N�wbsA
B
C
s
123456789
�����ascii�rkr@r�r��C
zRead to end of filerC)
rrrr�safe_unlinkrrrrH�UnicodeDecodeErrorr�r�r~�rr"r�s   r#�
test_readline�FileInputTests.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�8F�AF�
E$�'F�F�F�F�
F	�F�
F'c�>�[[S5nURS5 SSS5 UR[[5 [[SS9nUR
UR5S5 UR
UR5S5 UR
UR5S5 UR
UR5S5 UR
UR5S5 SSS5 g!,(df   N�=f!,(df   g=f)	Nr�sA
B
C
Dr�r�sA
sB
sC
Dr,)rrrrr�rrrHr�s   r#�test_readline_binary_mode�(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�C=�B!D�=
D�
Dc�|�URSSS9n[USSS9nUR5nURUS5 [R
R
S5 SSS5 [US5nURUR5S5 SSS5 g!,(df   ND=f!,(df   g=f)Ns
Initial text.r�rr�T)rrws	New line.)	r$rrHrr�r�rr�read�r�	temp_file�fobjrGr"s     r#�test_inplace_binary_write_mode�-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�2!B-�
B*�-
B;c�t�URSSS9n[USSSS9nUR5nURUS5 [	S	5 SSS5 [US
5nURUR
5RS5S5 SSS5 g!,(df   NS=f!,(df   g=f)
NsInitial text �r�rTr��replace)rwr�errorsuInitial text �uNew line ˆr�s
s
New line ?)r$rrHrr}rr��rstripr�s     r#�test_inplace_encoding_errors�+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&�)
B7c��SnURS5n[U/US9nUR5nSSS5 URWS5 g!,(df   N!=f)Nc�.�[R"S5$)N�(I used to receive only filename and mode)�ior�r?rs  r#�old_hook�FFileInputTests.test_file_hook_backward_compatibility.<locals>.old_hookSs���;�;�I�J�Jr,rxr�r)r$rrHr)rrr�r��results     r#�%test_file_hook_backward_compatibility�4FileInputTests.test_file_hook_backward_compatibilityRsN��	K��M�M�$���
��s�X�
.�"��[�[�]�F�/�����!K�L�/�
.�s�A�
Ac��URS5nURS5n[X4SS9n[U5nSSS5 URW/SQ5 URWR	5S5 URUR5S5 URURS5 g!,(df   N=f)	Nr�r�rrjr�r�rqr&)r$rr~rr�r��_filesr�s     r#�test_context_manager�#FileInputTests.test_context_managerZs���
�]�]�9�
%��
�]�]�9�
%��
�b�X��
8�B���H�E�9����� F�G��������!�,��������a�(�������B�'�9�
8�s�B3�3
Cc���URS5n[USS9n[e!,(df   g=f![a URWRS5 gf=f)NrCrrjr&)r$r�OSErrorrr)rr�r�s   r#�test_close_on_exception�&FileInputTests.test_close_on_exceptiondsQ��
�]�]�2�
��	,���g�6�"��
�7�6���	,����R�Y�Y��+�	,�s�
5�$�
2�5�5�&A�Ac��[/SS9nURURS5 SSS5 g!,(df   g=f)Nrrj)rs)rrr)rr�s  r#�.test_empty_files_list_specified_to_constructor�=FileInputTests.test_empty_files_list_specified_to_constructorls.��
�R�'�
2�b����R�Y�Y��/�3�
2�
2�s�1�
?c��[Rn[[5nUR	S5nUR[US-5 [U/SSS9n[U5 U[lUR5 SSS5 U[lURURS5 g!,(df   N6=f!U[lf=f)z�Tests invoking FileInput.nextfile() when the attempt to delete
the backup file would raise OSError.  This error is expected to be
silently ignoredrxz.bakTrrvNzos.unlink() was not invoked)�osr
r�rr$rr�rrDr�r�r�)r�os_unlink_orig�os_unlink_replacementr�r�s     r#�%test_nextfile_oserror_deleting_backup�4FileInputTests.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#�6B?�'B.�>B?�.
B<�8B?�?
Cc�V�[Rn[[5nUR	S5n[U/SSS9nU[lUR
5 SSS5 U[lURURS5 g!,(df   N6=f!U[lf=f)zpTests invoking FileInput.readline() when os.fstat() raises OSError.
This exception should be silently discarded.rxTrrvN�os.fstat() was not invoked)	r�fstatr�rr$rrHr�r�)r�
os_fstat_orig�os_fstat_replacementr�r�s     r#�%test_readline_os_fstat_raises_OSError�4FileInputTests.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�V�[Rn[[5nUR	S5n[U/SSS9nU[lUR
5 SSS5 U[lURURS5 g!,(df   N6=f!U[lf=f)zpTests invoking FileInput.readline() when os.chmod() raises OSError.
This exception should be silently discarded.rxTrrvNr")	r�chmodr�rr$rrHr�r�)r�
os_chmod_orig�os_chmod_replacementr�r�s     r#�%test_readline_os_chmod_raises_OSError�4FileInputTests.test_readline_os_chmod_raises_OSError�r(r)c�d�"SS[5nU"5nURS5n[U/SS9nURnX$lUR	5nXTlSSS5 URURS5 URWSS5 g!XTlf=f!,(df   NI=f)	Nc� �\rSrSrSrSrSrg)�QFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrori�c�8�[RU[5 gr1)r�r5r�r4s r#r5�ZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__�s��$�-�-�d�J�?r,c�$�UR5 gr1)r�r4s r#r��XFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.fileno�s���
�
�r,r&N)r'r(r)r*r5r�r+r&r,r#�FilenoRaisesValueErrorr2�s
��
@�
 r,r7rxrrjz_file.fileno() was not invokedrTzfileno() should return -1)r�r$r�_filer�r�r�r)rr7� unconditionally_raise_ValueErrorr�r��file_backupr
s       r#�"test_fileno_when_ValueError_raised�1FileInputTests.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!�!
B/c��[5n[SS/URS9nURUR/5 URUR5S5 URURS/5 URUR5S5 URURS/5 URUR5S5 URURSS/5 URUR5S5 URURS/5 URUR5S5 URUR/5 SSS5 g!,(df   g=f�Nzline1
line2zline3
r�zline1
�line2rC)r.rr@rr8rH�r�srcr�s   r#�test_readline_buffering�&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�EE8�8
Fc���[5n[SS/URS9nURUR/5 UR[U5S5 URURS/5 UR[U5S5 URURS/5 UR[U5S5 URURSS/5 UR
[[
U5 URURS/5 UR
[[
U5 URUR/5 SSS5 g!,(df   g=fr>)r.rr@rr8rDr��
StopIterationr@s   r#�test_iteration_buffering�'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��[URS55n[USS9nUR5nUR	US5 UR	UR5S5 UR	UR
5S5 UR	UR5[R"U55 SSS5 g!,(df   g=f)N�Path-like file.rrr[)
r	r$rrHrr�r�r?r�fspath)rr�r�rGs    r#�test_pathlike_file�!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�j�[URS55n[USSS9nUR5nUR	US5 [SU-5 SSS5 [
USS9nUR	UR5S5 SSS5 g!,(df   NB=f!,(df   g=f)NrITr)rwrzModified %srzModified Path-like file.
)r	r$rrHrr}rr�)rr�r�rGr"s     r#�test_pathlike_file_inplace�)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!�$
B2r&N)r'r(r)r*r�r�r�r�r�r�r�r�r�r�rrrrrrr&r.r;rBrFrKrNr+r&r,r#r�r��s{���()�(
*�)�I�	#�J�60�.1�5�F�M�(�,�0�7�*6�$6�$B�.0� 0� ;�Er,r�c�`�\rSrSrSrSSSSSS.SjjrSrSrS	rS
r	Sr
SrS
rSr
Srg)�
MockFileInputi�zDA class that mocks out fileinput.FileInput for use during unit testsN�r)rr@rrc��XlX lX0lX@lXPlX`lXplSUl[R"S5Ul
0Ulg)Nc��grKr&r&r,r#r��(MockFileInput.__init__.<locals>.<lambda>s��r,)rkrw�backuprr@rrr8�collections�defaultdict�invocation_counts�
return_values)rrkrwrVrr@rrs        r#r5�MockFileInput.__init__�sG���
������	� �
� �
�����
�!,�!8�!8��!C�����r,c�2�URS==S-
ss'g)NrRr[)rYr4s r#rR�MockFileInput.closes�����w�'�1�,�'r,c�N�URS==S-
ss'URS$)Nr�r[�rYrZr4s r#r��MockFileInput.nextfile�)�����z�*�a�/�*��!�!�*�-�-r,c�N�URS==S-
ss'URS$)Nr?r[r_r4s r#r?�MockFileInput.filename
rar,c�N�URS==S-
ss'URS$)Nr�r[r_r4s r#r��MockFileInput.lineno�)�����x�(�A�-�(��!�!�(�+�+r,c�N�URS==S-
ss'URS$)Nr�r[r_r4s r#r��MockFileInput.filelinenos)�����|�,��1�,��!�!�,�/�/r,c�N�URS==S-
ss'URS$)Nr�r[r_r4s r#r��MockFileInput.filenorfr,c�N�URS==S-
ss'URS$)Nr�r[r_r4s r#r��MockFileInput.isfirstlines)�����}�-��2�-��!�!�-�0�0r,c�N�URS==S-
ss'URS$)Nr�r[r_r4s r#r��MockFileInput.isstdins)�����y�)�Q�.�)��!�!�)�,�,r,)
r8rVrrrkrwrYrr@rZ)NFrC)r'r(r)r*�__doc__r5rRr�r?r�r�r�r�r�r+r&r,r#rQrQ�s@��N� ��D�4�� �-�.�.�,�0�,�1�-r,rQc�*�\rSrSrSrSrSrSrSrg)�BaseFileInputGlobalMethodsTesti"zJBase class for unit tests for the global function of
the fileinput module.c�v�[RUl[RUl[
[lgr1)�	fileinput�_state�_orig_stater�_orig_FileInputrQr4s r#�setUp�$BaseFileInputGlobalMethodsTest.setUp&s&��$�+�+���(�2�2���+�	�r,c�X�UR[lUR[lgr1)rvrsrrurtr4s r#�tearDown�'BaseFileInputGlobalMethodsTest.tearDown+s��"�2�2�	���+�+�	�r,c��URUnURUSU5 [UR5nURUS5 g)Nr[)rYrrL)r�mock_file_input�method_name�actual_count�actual_total_counts     r#�assertExactlyOneInvocation�9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocation/sF��&�8�8��E������q�+�6� ��!B�!B�C�����+�Q�/r,)rvruN)	r'r(r)r*rorwrzr�r+r&r,r#rqrq"s�� �,�
,�0r,rqc�0�\rSrSrSrSrSrSrSrSr	g)	�Test_fileinput_inputi7z Unit tests for fileinput.input()c�b�[5n[5UlU[lUR[5n[R"5 SSS5 URSWRR5 URU[RS5 g!,(df   NV=f)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)rQ�objectr8rsrtr��RuntimeError�inputr�	exceptionr��assertIs)r�instance�cms   r#�1test_state_is_not_None_and_state_file_is_not_None�FTest_fileinput_input.test_state_is_not_None_and_state_file_is_not_None:sv��
!�?������#�	��
�
�
�|�
,���O�O��-����4�b�l�l�6G�6G�H��
�
�h�	� 0� 0�2D�E�-�
,�s�B � 
B.c�\�[5nSUlU[lUR	5 g)a0Tests 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)rQr8rsrt�do_test_call_input�rr�s  r#�-test_state_is_not_None_and_state_file_is_None�BTest_fileinput_input.test_state_is_not_None_and_state_file_is_NoneGs&��!�?�����#�	�����!r,c�:�S[lUR5 g)aTests 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)rsrtr�r4s r#�test_state_is_None�'Test_fileinput_input.test_state_is_NoneRs�� �	�����!r,c	��[5n[5n[5n[5n[5n[5n[R"XUXEUS9nURU[RS5 URXR
S5 URX'RS5 URX7RS5 URXGRS5 URXWRS5 g)	z�Tests 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().)rkrwrVrr@rr�rkrwrVrr@N)
r�rsr�r�rtrkrwrVrr@)rrkrwrVrr@rr
s        r#r��'Test_fileinput_input.do_test_call_input[s���
����(������x���8���8�����u�f��8�=��	
�
�
�f�i�.�.�0B�C�	
�
�
�e�\�\�7�3��
�
�g�~�~�y�9��
�
�f�m�m�X�6��
�
�d�K�K��0��
�
�h����<r,r&N)
r'r(r)r*ror�r�r�r�r+r&r,r#r�r�7s��*�F�	"�"�=r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_closeivz Unit tests for fileinput.close()c��S[l[R"5 UR[R5 g)zETests that fileinput.close() does nothing if fileinput._state
is NoneN)rsrtrR�assertIsNoner4s r#r��'Test_fileinput_close.test_state_is_Noneys*�� �	���������)�*�*�+r,c��[5nU[l[R"5 UR	US5 UR[R5 g)zUTests that fileinput.close() invokes close() on fileinput._state
and sets _state=NonerRN)rQrsrtrRr�r�r�s  r#�test_state_is_not_None�+Test_fileinput_close.test_state_is_not_None�sA��!�?��#�	�������'�'��'�:����)�*�*�+r,r&N�r'r(r)r*ror�r�r+r&r,r#r�r�vs��*�,�,r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_nextfilei�z#Unit tests for fileinput.nextfile()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)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())	rsrtr�r�r�rr�r�r��rr�s  r#r��*Test_fileinput_nextfile.test_state_is_None��e�� �	��
�
�
�|�
,����� �-����/����1B�1B�C����)�*�*�+�-�
,���B�
Bc��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)z�Tests 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.r�N)r�rQrZrsrtr�r�r�)r�nextfile_retvalr��retvals    r#r��.Test_fileinput_nextfile.test_state_is_not_None��f��
!�(�� �?��-<���z�*�#�	���#�#�%���'�'��*�=��
�
�f�.��
�
�i�&�&��1r,r&Nr�r&r,r#r�r�����-�,�2r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_filenamei�z#Unit tests for fileinput.filename()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.filename() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r?rr�r�r�r�s  r#r��*Test_fileinput_filename.test_state_is_None�r�r�c��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)z�Tests 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�rQrZrsrtr?r�r�)r�filename_retvalr�r�s    r#r��.Test_fileinput_filename.test_state_is_not_None�r�r,r&Nr�r&r,r#r�r��r�r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_linenoi�z!Unit tests for fileinput.lineno()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.lineno() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r�rr�r�r�r�s  r#r��(Test_fileinput_lineno.test_state_is_None��e�� �	��
�
�
�|�
,������-����/����1B�1B�C����)�*�*�+�-�
,�r�c��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)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�rQrZrsrtr�r�r�)r�
lineno_retvalr�r�s    r#r��,Test_fileinput_lineno.test_state_is_not_None�sf��
��
� �?��+8���x�(�#�	���!�!�#���'�'��(�;��
�
�f�,��
�
�i�&�&��1r,r&Nr�r&r,r#r�r��s��+�,�2r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_filelinenoi�z%Unit tests for fileinput.filelineno()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.filelineno() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r�rr�r�r�r�s  r#r��,Test_fileinput_filelineno.test_state_is_None�se�� �	��
�
�
�|�
,��� � �"�-����/����1B�1B�C����)�*�*�+�-�
,�r�c��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)z�Tests 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�rQrZrsrtr�r�r�)r�filelineno_retvalr�r�s    r#r��0Test_fileinput_filelineno.test_state_is_not_None�sg��
#�H�� �?��/@���|�,�#�	���%�%�'���'�'��,�?��
�
�f�0��
�
�i�&�&��1r,r&Nr�r&r,r#r�r��s��/�,�2r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_filenoi�z!Unit tests for fileinput.fileno()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.fileno() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r�rr�r�r�r�s  r#r��(Test_fileinput_fileno.test_state_is_None�r�r�c��[5n[5nXRS'XlU[l[R"5nURUS5 URX15 UR[R
U5 g)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�rQrZ�
fileno_retvalrsrtr�r�r�)rr�r�r�s    r#r��,Test_fileinput_fileno.test_state_is_not_Nonesl��
��
� �?��+8���x�(�!.��#�	���!�!�#���'�'��(�;��
�
�f�,��
�
�i�&�&��1r,r&Nr�r&r,r#r�r��s��+�,�
2r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_isfirstlineiz&Unit tests for fileinput.isfirstline()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.isfirstline() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r�rr�r�r�r�s  r#r��-Test_fileinput_isfirstline.test_state_is_Nonese�� �	��
�
�
�|�
,���!�!�#�-����/����1B�1B�C����)�*�*�+�-�
,�r�c��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)z�Tests 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�rQrZrsrtr�r�r�)r�isfirstline_retvalr�r�s    r#r��1Test_fileinput_isfirstline.test_state_is_not_Nonesg��
$�X�� �?��0B���}�-�#�	���&�&�(���'�'��-�@��
�
�f�1��
�
�i�&�&��1r,r&Nr�r&r,r#r�r�s��0�,�2r,r�c�$�\rSrSrSrSrSrSrg)�Test_fileinput_isstdini,z"Unit tests for fileinput.isstdin()c�,�S[lUR[5n[R"5 SSS5 URSWRR5 UR[R5 g!,(df   NT=f)z�Tests fileinput.isstdin() when fileinput._state is None.
Ensure that it raises RuntimeError with a meaningful error message
and does not modify fileinput._stateNr�)	rsrtr�r�r�rr�r�r�r�s  r#r��)Test_fileinput_isstdin.test_state_is_None/se�� �	��
�
�
�|�
,������-����/����1B�1B�C����)�*�*�+�-�
,�r�c��[5n[5nXRS'U[l[R
"5nUR
US5 URX15 UR[RU5 g)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.r�N)r�rQrZrsrtr�r�r�)r�isstdin_retvalr�r�s    r#r��-Test_fileinput_isstdin.test_state_is_not_None9sf��
 ��� �?��,:���y�)�#�	���"�"�$���'�'��)�<��
�
�f�-��
�
�i�&�&��1r,r&Nr�r&r,r#r�r�,s��,�,�2r,r�c� �\rSrSrSrSrSrg)�InvocationRecorderiGc��SUlgrK)�invocation_countr4s r#r5�InvocationRecorder.__init__Is
�� !��r,c�h�U=RS-
slX4Ul[R"S5$)Nr[s
some bytes)r��last_invocationr	rr�s   r#r��InvocationRecorder.__call__Ls,������"�� $�~����z�z�-�(�(r,)r�r�Nr�r&r,r#r�r�Gs��"�)r,r�c��\rSrSrSrSrSrSr\R"\
S5S5r\R"\
S5S5r\R"\
S	5S
5rSrSrS
rSrSrSrSr\S5rSrg)�Test_hook_compressediRz*Unit tests for fileinput.hook_compressed()c�"�[5Ulgr1)r��	fake_openr4s r#rw�Test_hook_compressed.setUpUs��+�-��r,c�(�URSS5 g)NrCrR��do_test_use_builtin_open_textr4s r#�test_empty_string�&Test_hook_compressed.test_empty_stringXs���*�*�2�s�3r,c�(�URSS5 g�N�abcdrRr�r4s r#�test_no_ext� Test_hook_compressed.test_no_ext[����*�*�6�3�7r,zRequires gzip and zlibc�P�[RnUR[l[R"SS5nU[lURURRS5 URURRS045 g!U[lf=f)N�test.gzrRr[)r�rR)�gziprr�rs�hook_compressedrr�r��r�
original_openr
s   r#�test_gz_ext_fake�%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���[RnS[l[R"SSSS9nU[lUR	[U5S/5 g!U[lf=f)Nc�.�[R"S5$)NsEx-binary string)r	rr
s  r#r��ATest_hook_compressed.test_gz_with_encoding_fake.<locals>.<lambda>ms��2�:�:�6I�+Jr,r�rRrrzEx-binary string)r�rrsr�rr~r�s   r#�test_gz_with_encoding_fake�/Test_hook_compressed.test_gz_with_encoding_fakejsU���	�	�
�J��	�	&��.�.�y�#��P�F�%�D�I�����f��(:�';�<��&�D�I�s�A�
A)zRequires bz2c�P�[RnUR[l[R"SS5nU[lURURRS5 URURRS045 g!U[lf=f)N�test.bz2rRr[)rrR)�bz2�BZ2Filer�rsr�rr�r�r�s   r#�test_bz2_ext_fake�&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�(�URSS5 g)Nz	abcd.blahr���do_test_use_builtin_open_binaryr4s r#�
test_blah_ext�"Test_hook_compressed.test_blah_ext�s���,�,�[�$�?r,c�(�URSS5 g)Nzabcd.Gzr�r	r4s r#�test_gz_ext_builtin�(Test_hook_compressed.test_gz_ext_builtin�s���,�,�Y��=r,c�(�URSS5 g)Nzabcd.Bz2r�r	r4s r#�test_bz2_ext_builtin�)Test_hook_compressed.test_bz2_ext_builtin�s���,�,�Z��>r,c�(�URSS5 g)Nr�r�r	r4s r#�test_binary_mode_encoding�.Test_hook_compressed.test_binary_mode_encoding�s���,�,�V�T�:r,c�(�URSS5 gr�r�r4s r#�test_text_mode_encoding�,Test_hook_compressed.test_text_mode_encoding�r�r,c�Z�URUR5n[R"X5nURU5 UR	URR
S5 UR	URRX4SSS.45 g!URU5 f=f)Nr[�rr��replace_builtin_openr�rsr�rr�r��rr?rr�r
s     r#r
�4Test_hook_compressed.do_test_use_builtin_open_binary�s����1�1�$�.�.�A�
�	5��.�.�x�>�F��%�%�m�4�������8�8�!�<�������7�7�#�*���,N�O�	Q��
�%�%�m�4���B�B*c�Z�URUR5n[R"X5nURU5 UR	URR
S5 UR	URRX4SSS.45 g!URU5 f=f)Nr[�localerrrs     r#r��2Test_hook_compressed.do_test_use_builtin_open_text�s����1�1�$�.�.�A�
�	5��.�.�x�>�F��%�%�m�4�������8�8�!�<�������7�7�#�*��T�,R�S�	U��
�%�%�m�4�rc�<�[RnU[lU$r1)�builtinsr)�
new_open_funcr�s  r#r�)Test_hook_compressed.replace_builtin_open�s�� �
�
�
�%��
��r,)r�N)r'r(r)r*rorwr�r��unittest�
skipUnlessr�r�rrrrrrrrr
r��staticmethodrr+r&r,r#r�r�Rs���4�.�4�8�����7�8�	Q�9�	Q�����7�8�=�9�=�����n�-�	R�.�	R�@�>�?�;�8�	Q�	U����r,r�c�*�\rSrSrSrSrSrSrSrg)�Test_hook_encodedi�z'Unit tests for fileinput.hook_encoded()c�\�[5n[5n[R"XS9n[5n[R
nU[l[5n[5nU"Xg5nU[lUR
URS5 URup�URU	SU5 URU	SU5 URU
RS5U5 URU
RS5U5 URU
5 g!U[lf=f)N�rr[rrr)r�rsrr�r$rrr�r�r��popr�)rrrr
r�r�r?r�open_resultr�r�s           r#�test�Test_hook_encoded.test�s����8������'�'��@��&�(�	� �
�
�
�!��
�	*��x�H��8�D� ��0�K�)�H�M�����3�3�Q�7� �0�0����
�
�d�1�g�x�(��
�
�d�1�g�t�$��
�
�f�j�j��,�h�7��
�
�f�j�j��*�F�3����� ��*�H�M�s�D�
D+c�j^�[[S5nURS5 SSS5 TR[[5 U4SjnU"SS/5 TR[5 U"SS/5 SSS5 U"SS/5 U"S	S
/5 g!,(df   Nu=f!,(df   N4=f)Nr�s�abcc	�>�[[S[SUS9S9n[U5nSSS5 TR	WU5 g!,(df   N!=f)NrRrr-�rkrr@�rrrr~r)r�expected_linesr�rNrs    �r#�check�,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�strictru�abc�backslashreplacez\x80abc)rrrrr�r�r��rr"r7s`  r#�test_errors�Test_hook_encoded.test_errors�s����
�&�$�
�1�
�G�G�J�� �����V�,�	4�	�h��� �
�
�
�1�
2��(�U�G�$�3�
�i�+��'�
� �:�,�/� �
��3�
2�s�B�+B$�
B!�$
B2c�F^�[[S5nURS5 SSS5 TR[[5 U4SjnU"S/SQ5 TR[5 U"S/SQ5 SSS5 g!,(df   Nc=f!,(df   g=f)Nr�s
A
B
C
D+IKw-c�>�[[U[S5S9n[U5nSSS5 TR	WU5 g!,(df   N!=f)Nzutf-7r4r5)rr6r�rNrs    �r#r7�+Test_hook_encoded.test_modes.<locals>.check�sE�����d�$0��$9�;�>@��R���;�
���U�N�3�;�;�s�A�
ArR)r�r�r��D€r�)r�zB
zC
rC)rrrrr�r�r�r=s`  r#�
test_modes�Test_hook_encoded.test_modes�sv���
�&�$�
�1�
�G�G�(�)� �	
����V�,�	4�	�c�3�4�
�
�
�z�
*��$�:�;�+�
*� �
��+�
*�s�B�,B�
B�
B r&N)	r'r(r)r*ror0r>rDr+r&r,r#r+r+�s��1�!�00�"<r,r+c��\rSrSrSrSrg)�MiscTestr�c�:�[R"U[5 gr1)r�check__all__rsr4s r#�test_all�MiscTest.test_all�s�����T�9�-r,r&N)r'r(r)r*rJr+r&r,r#rGrG�s��.r,rG�__main__)3ror	rr�r{rsrWr$rr'r�ImportErrorr�rrrr�test.supportr�test.support.os_helperrr	r
r�rr0rr
rr.�TestCaserWr�r�rQrqr�r�r�r�r�r�r�r�r�r�r�r+rGr'�mainr&r,r#�<module>rRs����
�	�
�	����������!�-� �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���M�M�O���{��
�C������D��s"�F�F$�F!� F!�$F0�/F0

Youez - 2016 - github.com/yon3zu
LinuXploit