python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_fileinput.cpython-311.opt-1.pyc

ejdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z		ddl
Z
n
#e$rdZ
YnwxYw	ddlZn
#e$rdZYnwxYwddlm
Z
mZddlmZmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddl	mZGdd
ZGddZGddee	jZ GddZ!Gddee	jZ"GddZ#Gdde	jZ$Gdde$Z%Gdde$Z&Gdde$Z'Gd d!e$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/e	jZ/Gd0d1e	jZ0Gd2d3e	jZ1e2d4kre	j3dSdS)5z,
Tests for fileinput module.
Nick Mathewson
N)BytesIOStringIO)	FileInputhook_encoded)Path)verbose)TESTFN)unlink)	os_helper)support)mockceZdZdddZdS)	BaseTestswmodectj\}}|tj|d|vrdnd}t|||5}||dddn#1swxYwY|S)Nbutf-8encoding)tempfilemkstemp
addCleanuprr
openwrite)selfcontentrfdnamerfs       G/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_fileinput.pywriteTmpzBaseTests.writeTmp+s#%%D	($///$;;44G
"dX
.
.
.	!
GGG															sA33A7:A7N)__name__
__module____qualname__r#r"rr(s2),r(rcFeZdZdZedZdZd	dZd
dZdZ	dS)
LineReadercg|_dSN
_linesreadrs r"__init__zLineReader.__init__5s
r(cH	|jddg|_S#g|_wxYwr,r-r/s r"	linesreadzLineReader.linesread8s1	!?111% DOObDO    s	!cTt|d|_|SNT)iter
splitlinesit)rfilenamers   r"openhookzLineReader.openhook?s$x**40011r(Ncdt|jd}|j||S)N)nextr7r.append)rsizelines   r"readlinezLineReader.readlineCs.DGR  t$$$r(cg}d}	|}|s|S|||t|z
}||kr|SHNr)r@r=len)rhintlinesr>r?s     r"	readlineszLineReader.readlinesHs`	==??D
LLCIIDt||	r(cdSr,r'r/s r"closezLineReader.closeTsr(r,)rA)
r$r%r&r0propertyr2r9r@rGrIr'r(r"r*r*3s!!X!









r(r*ceZdZdZdS)BufferSizesTestsc
|ddtdD}|ddtdD}|ddtdD}|ddtd	D}tjd
}t
rt
dt||||fd
}t|}|	|
t|d|
|dd|
|dd|
|d|
|
|t
rt
dt||||fd
}d}|r"|dkr|}|r|dk|
|
||
|d|
|d||||t
rt
d||
|d|
|d|	t
rt
dt||||dfd
}t(j}		t-dt(_t|}|
t|d|
|dd |
|
d!||	t(_n#|	t(_wxYwt
rt
d"t||||fd
}|
|d#|
|
d||
|d#|
|
dt
rt
d$t(j}
	t||||fd	d%}|D]-}|dd&}t
|.|	|
t(_n#|
t(_wxYwt||||fd
}|D]}|
|d&d'||dd&}||d|
t7|d	||	dS)(Nr;c3&K|]}d|dzzV
dS)zLine %s of file 1
Nr'.0is  r"	<genexpr>z5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>Z,"T"TQ#8AaC#@"T"T"T"T"T"Tr(c3&K|]}d|dzzV
dS)zLine %s of file 2
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>[rTr(
c3&K|]}d|dzzV
dS)zLine %s of file 3
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>\,"S"SQ#8AaC#@"S"S"S"S"S"Sr(c3&K|]}d|dzzV
dS)zLine %s of file 4
rONr'rPs  r"rSz5BufferSizesTests.test_buffer_sizes.<locals>.<genexpr>]rYr(rOzLINE (\d+) OF FILE (\d+)z1. Simple iterationrfilesrzLine 5 of file 1
zLine 1 of file 4
z2. Status variablesxzLine 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. Inplacer]inplacerrA
)r#joinrangerecompilerprintrlistrIassertEqualrDlinenor8r@
filelinenoassertFalseisfirstlineisstdinnextfilesysstdinrstdoutuppermatchassertNotEqualintgroup)
rt1t2t3t4patfirFs	savestdin
savestdoutr?ms
             r"test_buffer_sizesz"BufferSizesTests.test_buffer_sizesXs
]]277"T"T%PR))"T"T"TTT
U
U
]]277"T"T%PR))"T"T"TTT
U
U
]]277"S"S%PQ(("S"S"SSS
T
T
]]277"S"S%PQ(("S"S"SSS
T
Tj455	)'(((
b"b"-
@
@
@R



UR(((q#7888r$8999b)))+++	)'(((
b"b"-
@
@
@	A---

A	A---+++b)))!,,,))***&&&	!-   



(<===b)))



	*
b"b"c2W
E
E
EI		" !EFFCIHHESZZ,,,U2Y(;<<<R[[]]I666KKMMM!CII	CI!!!!	,*+++
b"b"-
@
@
@a(((---



a(((---	 ,Z
	$"b"b!11wOOOB

CRCy((dHHJJJ#CJJCJ####
b"b"-
@
@
@	?	?DT"Xt,,,		$ss)$$A4(((S__bmmoo>>>>





s(B#RR&+AXX N)r$r%r&rr'r(r"rLrLWs(PPPPPr(rLceZdZdZdZdS)UnconditionallyRaisec"||_d|_dSNF)exception_typeinvoked)rrs  r"r0zUnconditionallyRaise.__init__s,r(c8d|_|r4)rrrargskwargss   r"__call__zUnconditionallyRaise.__call__s!!###r(Nr$r%r&r0rr'r(r"rrs2$$$$$r(rceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdS)FileInputTestsc|d}|d}|d}|d}t||||fd}|}||d||d||d||||}||||d||d||||dS)Nr;zThe only line there is.
rr\rOr)	r#rr@rqrrrsr8rtrI)rrrrrrr?s       r"test_zero_byte_filesz#FileInputTests.test_zero_byte_filessl
]]2


]]2


]]6
7
7
]]2


b"b"-
@
@
@{{}}:;;;a(((!,,,+++{{}}a(((!,,,+++





r(cn|d}|d}t||fd}t|}||gd||d||ddS)NA
B
CD
E
Frr\A
B
CzD
zE
Frc)r#rrprqrsrrrrrrrFs     r"%test_files_that_dont_end_with_newlinez4FileInputTests.test_files_that_dont_end_with_newlines
]]9
%
%
]]9
%
%
b"X
8
8
8R F F FGGG!,,,a(((((r(c$|d}|d}t||fd}||dt	|}||d|||dt|}||ddS)NzA
BzC
Drr\rA)r#rrqfilenor<r}rwrp)rrrrr?s     r"test_filenozFileInputTests.test_filenos
]]6
"
"
]]6
"
"
b"X
8
8
8b)))BxxBIIKK,,,



b)))Bxxb)))))r(cdD]r}||5|t5t|dddn#1swxYwYdddn#1swxYwYsdS)N)rrUUr)subTestassertRaises
ValueErrorr)rrs  r"test_invalid_opening_modez(FileInputTests.test_invalid_opening_modes$	)	)D4((
)
)&&z22))4(((()))))))))))))))
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)	)	)s4A*AA*AA*AA**A.	1A.	ctjd5}td|_t	dgd}t|}||dgddddS#1swxYwYdS)Nz	sys.stdinspam, bacon, sausage, and spamrerbr]r)r
patchrbufferrrprq)rm_stdinrrFs    r"test_stdin_binary_modez%FileInputTests.test_stdin_binary_modes
Z
$
$	I$%FGGGN#T222BHHEU%F$GHHH		I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	IsA
A//A36A3cVtj}	tdt_|t	tjdtdgd}t
|}||dg|t_dS#|t_wxYw)Nrrrerr)rxryrrthasattrrrprq)r
orig_stdinrrFs    r"test_detached_stdin_binary_modez.FileInputTests.test_detached_stdin_binary_modesY
	# ABBCIWSY99:::#T222BHHEU%F$GHHH"CIII
CI""""sA>BB(c	tdd}|dn#t$rYnwxYw	td}|dn#t$rYnwxYwGdd}|d	}|}t|g|5}|dddn#1swxYwY||jd
dS)NrOcdSr,r')r!rs  r"<lambda>z7FileInputTests.test_file_opening_hook.<locals>.<lambda>sDr()rir9zGFileInput should raise if both inplace and openhook arguments are givenr9z2FileInput should check openhook for being callableceZdZdZdZdS)=FileInputTests.test_file_opening_hook.<locals>.CustomOpenHookcd|_dSr)rr/s r"r0zFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__init__s
$r(c(d|_t|ddiS)NTrr)rr)rrkargss   r"rzFFileInputTests.test_file_opening_hook.<locals>.CustomOpenHook.__call__s#T4G444r(Nrr'r(r"CustomOpenHookrs2
%
%
%
5
5
5
5
5r(rrjzopenhook not invoked)rfailrr#r@
assertTruer)rrrtcustom_open_hooks     r"test_file_opening_hookz%FileInputTests.test_file_opening_hooks	1/@/@AAABII@
A
A
A
A			D		A&&&BIIJKKKK			D		5	5	5	5	5	5	5	5
MM$)>++
s%5
6
6
6	"KKMMM															(02HIIIIIs/'*
77%A!!
A.-A./CCCcttd5}|d|ddz|ddddn#1swxYwY|ttttt
d5}	||d||d	||d
n%#t$r|
dYnwxYw|t5t|dddn#1swxYwY||d||dddddS#1swxYwYdS)
NwbsA
B
C
s
123456789
iasciir]r9rrC
zRead to end of filer;)
rr	rrsafe_unlinkrrrqr@UnicodeDecodeErrorrrrprr!rs   r"
test_readlinezFileInputTests.test_readlines
&$

	1
GGN###
GGNT)***
GGG																
V,,,
V ,W 5 5777	0:<
1  666  666  6666%
1
1
1		/00000
1""#566

R















R[[]]B///R[[]]B///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0snAA%%A),A)3G15A8D.-G1.E
G1EG1-F	=G1	F
	
G1F
	AG11G58G5cttd5}|ddddn#1swxYwY|ttttd5}||d||d||d||d||dddddS#1swxYwYdS)	NrsA
B
C
DrrsA
sB
sC
Dr()rr	rrrrrqr@rs   r"test_readline_binary_modez(FileInputTests.test_readline_binary_mode2s
&$

	%1
GGO$$$	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%V,,,
V$
/
/
/	12R[[]]F333R[[]]H555R[[]]G444R[[]]C000R[[]]C000
	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1s8<<9C	EEEc|dd}t|dd5}|}||dtjddddn#1swxYwYt|d5}||dddddS#1swxYwYdS)Ns
Initial text.rrrT)rris	New line.)	r#rr@rqrxrzrrreadr	temp_filefobjr?r!s     r"test_inplace_binary_write_modez-FileInputTests.test_inplace_binary_write_mode?sJMM"2M>>	
ytT
:
:
:	+d==??DT#3444J\***		+	+	+	+	+	+	+	+	+	+	+	+	+	+	+
)T
"
"	5aQVVXX|444	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5s$A
BBB)CCCc|dd}t|ddd5}|}||dt	d	dddn#1swxYwYt|d
5}||ddddddS#1swxYwYdS)
NsInitial text rrTrreplace)rirerrorsuInitial text �uNew line ˆrs
s
New line ?)r#rr@rqrorrrstriprs     r"test_inplace_encoding_errorsz+FileInputTests.test_inplace_encoding_errorsIskMM"6TMBB	
y$ '	;;;	#>B==??DT#8999/"""		#	#	#	#	#	#	#	#	#	#	#	#	#	#	#
)T
"
"	FaQVVXX__W55}EEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	Fs#:A11A58A5<CCCcd}|d}t|g|5}|}dddn#1swxYwY||ddS)Nc*tjdS)N(I used to receive only filename and mode)iorr8rs  r"old_hookzFFileInputTests.test_file_hook_backward_compatibility.<locals>.old_hookTs;IJJJr(rjrr)r#rr@rq)rrrrresults     r"%test_file_hook_backward_compatibilityz4FileInputTests.test_file_hook_backward_compatibilitySs	K	K	KMM$
sX
.
.
.	#"[[]]F	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#!KLLLLLsAAAc|d}|d}t||fd5}t|}dddn#1swxYwY||gd||d||d||jddS)	Nrrrr\rrrcr')r#rrprqrsrr_filesrs     r"test_context_managerz#FileInputTests.test_context_manager[s
]]9
%
%
]]9
%
%
b"X
8
8
8	BHHE															 F F FGGG!,,,a(((B'''''sAA!Ac|d}	t|d5}t#1swxYwYdS#t$r||jdYdSwxYw)Nr;rr\r')r#rOSErrorrqr)rrrs   r"test_close_on_exceptionz&FileInputTests.test_close_on_exceptiones
]]2

	,g666
"










	,	,	,RY++++++	,s#=04=4=%A&%A&ctgd5}||jdddddS#1swxYwYdS)Nrr\)re)rrqr)rrs  r".test_empty_files_list_specified_to_constructorz=FileInputTests.test_empty_files_list_specified_to_constructorms
R'
2
2
2	0bRY///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0s
;??ctj}tt}	|d}|t|dzt|gdd5}t||t_|	dddn#1swxYwY|t_n#|t_wxYw|
|jddS)zTests invoking FileInput.nextfile() when the attempt to delete
           the backup file would raise OSError.  This error is expected to be
           silently ignoredrjz.bakTrrhNzos.unlink() was not invoked)osr
rrr#rrrr<rwrr)ros_unlink_origos_unlink_replacementrrs     r"%test_nextfile_oserror_deleting_backupz4FileInputTests.test_nextfile_oserror_deleting_backupqs
 4W = =	'

d##AOOKV444!dWEEE
R1	


















'BIIBI&&&&	
-55	7	7	7	7	7s0AB<(0B$B<$B((B<+B(,B<<C
cztj}tt}	|d}t|gdd5}|t_|dddn#1swxYwY|t_n#|t_wxYw||jddS)z{Tests invoking FileInput.readline() when os.fstat() raises OSError.
           This exception should be silently discarded.rjTrrhNos.fstat() was not invoked)	rfstatrrr#rr@rr)r
os_fstat_origos_fstat_replacementrrs     r"%test_readline_os_fstat_raises_OSErrorz4FileInputTests.test_readline_os_fstat_raises_OSError
3G<<	%

d##A!dWEEE
/

















%BHH}BH$$$$	
,44	6	6	6	6	6/(B
!A7+B7A;;B>A;?BBcztj}tt}	|d}t|gdd5}|t_|dddn#1swxYwY|t_n#|t_wxYw||jddS)z{Tests invoking FileInput.readline() when os.chmod() raises OSError.
           This exception should be silently discarded.rjTrrhNr)	rchmodrrr#rr@rr)r
os_chmod_origos_chmod_replacementrrs     r"%test_readline_os_chmod_raises_OSErrorz4FileInputTests.test_readline_os_chmod_raises_OSErrorrrcGddt}|}|d}t|gd5}|j}	||_|}||_n#||_wxYw	dddn#1swxYwY||jd||dddS)	NceZdZdZdZdS)QFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueErrorcFt|tdSr,)rr0rr/s r"r0zZFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.__init__s$--dJ?????r(c.|dSr,)rr/s r"rzXFileInputTests.test_fileno_when_ValueError_raised.<locals>.FilenoRaisesValueError.filenos

r(N)r$r%r&r0rr'r(r"FilenoRaisesValueErrorrs5
@
@
@
 
 
 
 
 r(r	rjrr\z_file.fileno() was not invokedrAzfileno() should return -1)rr#r_filerrrrq)rr	 unconditionally_raise_ValueErrorrrfile_backuprs       r""test_fileno_when_ValueError_raisedz1FileInputTests.test_fileno_when_ValueError_raiseds7	 	 	 	 	 %9	 	 	 ,B+A+C+C(MM$
aS7
3
3
3	'r(K
';&;&&&&
	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	
8@8	:	:	:	
%@AAAAAs*B
A1)B
1	A::B

BBcbt}tddg|j5}||jg||d||jdg||d||jdg||d||jddg||d||jdg||d||jgddddS#1swxYwYdSNzline1
line2zline3
rzline1
line2r;)r*rr9rqr2r@rsrcrs   r"test_readline_bufferingz&FileInputTests.test_readline_bufferingsll
ni8 #...	013S]B///R[[]]I666S]YK888R[[]]G444S]WI666R[[]]I666S]RO<<<R[[]]B///S]RD111R[[]]B///S]B///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0sE0F$$F(+F(c(t}tddg|j5}||jg|t|d||jdg|t|d||jdg|t|d||jddg|tt
|||jdg|tt
|||jgddddS#1swxYwYdSr)r*rr9rqr2r<r
StopIterationrs   r"test_iteration_bufferingz'FileInputTests.test_iteration_bufferingsll
ni8 #...	013S]B///T"XXy111S]YK888T"XXw///S]WI666T"XXy111S]RO<<<mT2666S]RD111mT2666S]B///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0sEFFFct|d}t|d5}|}||d||d||d||tj	|ddddS#1swxYwYdS)N
Pathlib file.rrrO)
rr#rr@rqrrrsr8rfspath)rrrr?s    r"test_pathlib_filez FileInputTests.test_pathlib_files
$--00
1
1
rG
,
,
,	;;;==DT?333RYY[[!,,,R]]__a000R[[]]BIbMM:::	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;sB5C66C:=C:ct|d}t|dd5}|}||dtd|zdddn#1swxYwYt
|d5}||dddddS#1swxYwYdS)NrTr)rirzModified %srzModified Pathlib file.
)rr#rr@rqrorr)rrrr?r!s     r"test_pathlib_file_inplacez(FileInputTests.test_pathlib_file_inplaces`
$--00
1
1
r4'
:
:
:	(b;;==DT?333-$&'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	("w
'
'
'	C1QVVXX'ABBB	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	Cs#=A>>BB)CCCN)r$r%r&rrrrrrrrrrrrrrrrrrr
rrrrr'r(r"rrs()))(
*
*
*)))III	#	#	#JJJ6000.111555FFFMMM(((,,,000777*666$666$BBB.000 000 ;;;CCCCCr(rcVeZdZdZdddddddZdZd	Zd
ZdZdZ	d
Z
dZdZdS)
MockFileInputzDA class that mocks out fileinput.FileInput for use during unit testsNFr;r)rr9rrc||_||_||_||_||_||_||_d|_tj	d|_
i|_dS)NcdSrCr'r'r(r"rz(MockFileInput.__init__.<locals>.<lambda>sr()r]ribackuprr9rrr
collectionsdefaultdictinvocation_counts
return_values)rr]rir"rr9rrs        r"r0zMockFileInput.__init__s]
	 
 

!,!8!C!Cr(c0|jdxxdz
cc<dS)NrIrO)r%r/s r"rIzMockFileInput.closes'w'''1,'''''r(cF|jdxxdz
cc<|jdS)NrwrOr%r&r/s r"rwzMockFileInput.nextfile/z***a/***!*--r(cF|jdxxdz
cc<|jdS)Nr8rOr)r/s r"r8zMockFileInput.filenamer*r(cF|jdxxdz
cc<|jdS)NrrrOr)r/s r"rrzMockFileInput.lineno/x(((A-(((!(++r(cF|jdxxdz
cc<|jdS)NrsrOr)r/s r"rszMockFileInput.filelinenos/|,,,1,,,!,//r(cF|jdxxdz
cc<|jdS)NrrOr)r/s r"rzMockFileInput.filenor-r(cF|jdxxdz
cc<|jdS)NrurOr)r/s r"ruzMockFileInput.isfirstlines/}---2---!-00r(cF|jdxxdz
cc<|jdS)NrvrOr)r/s r"rvzMockFileInput.isstdins/y)))Q.)))!),,r()NFr;)
r$r%r&__doc__r0rIrwr8rrrsrrurvr'r(r"rrsNN D4     ---......,,,000,,,111-----r(rc$eZdZdZdZdZdZdS)BaseFileInputGlobalMethodsTestzQBase class for unit tests for the global function of
       the fileinput module.cltj|_tj|_t
t_dSr,)	fileinput_state_orig_stater_orig_FileInputrr/s r"setUpz$BaseFileInputGlobalMethodsTest.setUp's&$+(2+	r(cJ|jt_|jt_dSr,)r9r6rr8r7r/s r"tearDownz'BaseFileInputGlobalMethodsTest.tearDown,s"2	+	r(c|j|}||d|t|j}||ddS)NrO)r%rqrD)rmock_file_inputmethod_nameactual_countactual_total_counts     r"assertExactlyOneInvocationz9BaseFileInputGlobalMethodsTest.assertExactlyOneInvocation0sU&8Eq+666 !BCC+Q/////r(N)r$r%r&r2r:r<rBr'r(r"r4r4#sK  ,,,
,,,00000r(r4c*eZdZdZdZdZdZdZdS)Test_fileinput_inputz Unit tests for fileinput.input()clt}t|_|t_|t5}tjdddn#1swxYwY|d|j	j
||tjddS)zTests 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 activefileinput._state)robjectr
r6r7rRuntimeErrorinputrq	exceptionrassertIs)rinstancecms   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															4bl6GHHH

h	 02DEEEEEsA((A,/A,cpt}d|_|t_|dS)a\Tests invoking fileinput.input() when fileinput._state is not None
           but its _file attribute *is* None.  Expect it to create and return
           a new fileinput.FileInput object with all method parameters passed
           explicitly to the __init__() method; also ensure that
           fileinput._state is set to the returned instance.N)rr
r6r7do_test_call_inputrrLs  r"-test_state_is_not_None_and_state_file_is_NonezBTest_fileinput_input.test_state_is_not_None_and_state_file_is_NoneHs4!??#	!!!!!r(cFdt_|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)r6r7rPr/s r"test_state_is_Nonez'Test_fileinput_input.test_state_is_NoneSs$ 	!!!!!r(c<t}t}t}t}t}t}tj||||||}||tjd|||jd|||jd|||jd|||jd|||j	ddS)	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().)r]rir"rr9rrFr]rir"rr9N)
rGr6rIrKr7r]rir"rr9)rr]rir"rr9rrs        r"rPz'Test_fileinput_input.do_test_call_input\s
((xx8888ugf8===	


fi.0BCCC	


eV\7333

gv~y999

ffmX666

dFK000

h<<<<<r(N)r$r%r&r2rNrRrTrPr'r(r"rDrD8sY**FFF	"	"	""""=====r(rDceZdZdZdZdZdS)Test_fileinput_closez Unit tests for fileinput.close()cdt_tj|tjdS)zPTests that fileinput.close() does nothing if fileinput._state
           is NoneN)r6r7rIassertIsNoner/s r"rTz'Test_fileinput_close.test_state_is_Nonezs7 	)*+++++r(ct}|t_tj||d|tjdS)z`Tests that fileinput.close() invokes close() on fileinput._state
           and sets _state=NonerIN)rr6r7rIrBrYrQs  r"test_state_is_not_Nonez+Test_fileinput_close.test_state_is_not_NonesV!??#	''':::)*+++++r(Nr$r%r&r2rTr[r'r(r"rWrWws8**,,,,,,,,r(rWceZdZdZdZdZdS)Test_fileinput_nextfilez#Unit tests for fileinput.nextfile()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.nextfile() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNzno active input())	r6r7rrHrwrqrJrrYrrMs  r"rTz*Test_fileinput_nextfile.test_state_is_None 	


|
,
,	!   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!/1BCCC)*+++++AAAc(t}t}||jd<|t_tj}||d||||tj|dS)aTests fileinput.nextfile() when fileinput._state is not None.
           Ensure that it invokes fileinput._state.nextfile() exactly once,
           returns whatever it returns, and does not modify fileinput._state
           to point to a different object.rwN)rGrr&r6r7rwrBrK)rnextfile_retvalrLretvals    r"r[z.Test_fileinput_nextfile.test_state_is_not_None
!(( ??-<z*#	#%%''*===

fo...

i&11111r(Nr\r'r(r"r^r^8--,,,22222r(r^ceZdZdZdZdZdS)Test_fileinput_filenamez#Unit tests for fileinput.filename()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.filename() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHr8rqrJrrYras  r"rTz*Test_fileinput_filename.test_state_is_Nonerbrcc(t}t}||jd<|t_tj}||d||||tj|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.r8N)rGrr&r6r7r8rBrK)rfilename_retvalrLrfs    r"r[z.Test_fileinput_filename.test_state_is_not_Nonergr(Nr\r'r(r"rjrjrhr(rjceZdZdZdZdZdS)Test_fileinput_linenoz!Unit tests for fileinput.lineno()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.lineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHrrrqrJrrYras  r"rTz(Test_fileinput_lineno.test_state_is_None 	


|
,
,																/1BCCC)*+++++rcc(t}t}||jd<|t_tj}||d||||tj|dS)zTests 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.rrN)rGrr&r6r7rrrBrK)r
lineno_retvalrLrfs    r"r[z,Test_fileinput_lineno.test_state_is_not_Nones

 ??+8x(#	!##''(;;;

fm,,,

i&11111r(Nr\r'r(r"roros8++,,,22222r(roceZdZdZdZdZdS)Test_fileinput_filelinenoz%Unit tests for fileinput.filelineno()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.filelineno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHrsrqrJrrYras  r"rTz,Test_fileinput_filelineno.test_state_is_Nones 	


|
,
,	# """	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#/1BCCC)*+++++rcc(t}t}||jd<|t_tj}||d||||tj|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.rsN)rGrr&r6r7rsrBrK)rfilelineno_retvalrLrfs    r"r[z0Test_fileinput_filelineno.test_state_is_not_Nones
#HH ??/@|,#	%'''',???

f/000

i&11111r(Nr\r'r(r"rurus8//,,,22222r(ruceZdZdZdZdZdS)Test_fileinput_filenoz!Unit tests for fileinput.fileno()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.fileno() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHrrqrJrrYras  r"rTz(Test_fileinput_fileno.test_state_is_Nonerqrcc6t}t}||jd<||_|t_t	j}||d||||tj|dS)zTests 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.rN)	rGrr&
fileno_retvalr6r7rrBrK)rr}rLrfs    r"r[z,Test_fileinput_fileno.test_state_is_not_Nones

 ??+8x(!.#	!##''(;;;

fm,,,

i&11111r(Nr\r'r(r"rzrzs8++,,,
2
2
2
2
2r(rzceZdZdZdZdZdS)Test_fileinput_isfirstlinez&Unit tests for fileinput.isfirstline()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.isfirstline() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHrurqrJrrYras  r"rTz-Test_fileinput_isfirstline.test_state_is_Nones 	


|
,
,	$!###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$/1BCCC)*+++++rcc(t}t}||jd<|t_tj}||d||||tj|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.ruN)rGrr&r6r7rurBrK)risfirstline_retvalrLrfs    r"r[z1Test_fileinput_isfirstline.test_state_is_not_Nones
$XX ??0B}-#	&((''-@@@

f0111

i&11111r(Nr\r'r(r"rrs800,,,22222r(rceZdZdZdZdZdS)Test_fileinput_isstdinz"Unit tests for fileinput.isstdin()c&dt_|t5}tjdddn#1swxYwY|d|jj|tjdS)zTests fileinput.isstdin() when fileinput._state is None.
           Ensure that it raises RuntimeError with a meaningful error message
           and does not modify fileinput._stateNr`)	r6r7rrHrvrqrJrrYras  r"rTz)Test_fileinput_isstdin.test_state_is_None0s 	


|
,
,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 /1BCCC)*+++++rcc(t}t}||jd<|t_tj}||d||||tj|dS)zTests 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.rvN)rGrr&r6r7rvrBrK)risstdin_retvalrLrfs    r"r[z-Test_fileinput_isstdin.test_state_is_not_None:s
  ??,:y)#	"$$'')<<<

fn---

i&11111r(Nr\r'r(r"rr-s8,,,,,22222r(rceZdZdZdZdS)InvocationRecordercd|_dSrC)invocation_countr/s r"r0zInvocationRecorder.__init__Js !r(c\|xjdz
c_||f|_tjdS)NrOs
some bytes)rlast_invocationrrrs   r"rzInvocationRecorder.__call__Ms2" $f~z-(((r(Nrr'r(r"rrHs2""")))))r(rceZdZdZdZdZdZeje	ddZ
eje	ddZejedd	Z
d
ZdZdZd
ZdZdZdZedZdS)Test_hook_compressedz*Unit tests for fileinput.hook_compressed()c,t|_dSr,)r	fake_openr/s r"r:zTest_hook_compressed.setUpVs+--r(c2|dddS)Nr;rdo_test_use_builtin_open_textr/s r"test_empty_stringz&Test_hook_compressed.test_empty_stringYs**2s33333r(c2|dddSNabcdrrr/s r"test_no_extz Test_hook_compressed.test_no_ext\**6377777r(zRequires gzip and zlibc,tj}|jt_	tjdd}|t_n#|t_wxYw||jjd||jjdifdS)Ntest.gzrrO)rr)gziprrr6hook_compressedrqrrr
original_openrs   r"test_gz_ext_fakez%Test_hook_compressed.test_gz_ext_fake_s	
N		&.y#>>F%DII
DI%%%%8!<<<7:JB9OPPPPPAActj}dt_	tjddd}|t_n#|t_wxYw|t|dgdS)Nc*tjdS)NsEx-binary string)rrrs  r"rzATest_hook_compressed.test_gz_with_encoding_fake.<locals>.<lambda>ns2:6I+J+Jr(rrrrzEx-binary string)rrr6rrqrprs   r"test_gz_with_encoding_fakez/Test_hook_compressed.test_gz_with_encoding_fakeksq	
JJ		&.y#PPPF%DII
DI%%%%f(:';<<<<<s	?A
zRequires bz2c,tj}|jt_	tjdd}|t_n#|t_wxYw||jjd||jjdifdS)Ntest.bz2rrO)rr)bz2BZ2Filerr6rrqrrrs   r"test_bz2_ext_fakez&Test_hook_compressed.test_bz2_ext_fakeus
n	(.z3??F'CKK-CK''''8!<<<7:KR9PQQQQQrc2|dddS)Nz	abcd.blahrdo_test_use_builtin_open_binaryr/s r"
test_blah_extz"Test_hook_compressed.test_blah_exts,,[$?????r(c2|dddS)Nzabcd.Gzrrr/s r"test_gz_ext_builtinz(Test_hook_compressed.test_gz_ext_builtins,,Y=====r(c2|dddS)Nzabcd.Bz2rrr/s r"test_bz2_ext_builtinz)Test_hook_compressed.test_bz2_ext_builtins,,Z>>>>>r(c2|dddS)Nrrrr/s r"test_binary_mode_encodingz.Test_hook_compressed.test_binary_mode_encodings,,VT:::::r(c2|dddSrrr/s r"test_text_mode_encodingz,Test_hook_compressed.test_text_mode_encodingrr(cT||j}	tj||}||n#||wxYw||jjd||jj||fdddfdS)NrOrrreplace_builtin_openrr6rrqrrrr8rrrs     r"rz4Test_hook_compressed.do_test_use_builtin_open_binarys11$.AA
	5.x>>F%%m4444D%%m44448!<<<7#T*,N,NO	Q	Q	Q	Q	QAAcT||j}	tj||}||n#||wxYw||jjd||jj||fdddfdS)NrOlocalerrrs     r"rz2Test_hook_compressed.do_test_use_builtin_open_texts11$.AA
	5.x>>F%%m4444D%%m44448!<<<7#T*T,R,RS	U	U	U	U	Urc6tj}|t_|Sr,)builtinsr)
new_open_funcrs  r"rz)Test_hook_compressed.replace_builtin_opens 

%
r(N)r$r%r&r2r:rrunittest
skipUnlessrrrrrrrrrrrrstaticmethodrr'r(r"rrSs]44...444888X788	Q	Q98	QX788==98=Xn--	R	R.-	R@@@>>>???;;;888	Q	Q	Q	U	U	U\r(rc$eZdZdZdZdZdZdS)Test_hook_encodedz'Unit tests for fileinput.hook_encoded()ct}t}tj||}t}tj}|t_	t}t}|||}|t_n#|t_wxYw||jd|j\}	}
|	|	d||	|	d||	|

d||	|

d|||
dS)NrrOrrr)rGr6rrrrrqrrrKpoprt)rrrrrrr8ropen_resultrrs           r"testzTest_hook_encoded.tests588'@@@&((	 

!
	*xxH88D &400K)HMMMHM))))3Q777 0f

d1gx(((

d1gt$$$

fjj,,h777

fjj**F333     s(BBcttd5}|ddddn#1swxYwYttfd}|ddgt5|ddgdddn#1swxYwY|ddg|d	d
gdS)Nrsabccttdtd|5}t|}dddn#1swxYwY||dS)Nrrrr]rr9rr	rrprq)rexpected_linesrrFrs    r"checkz,Test_hook_encoded.test_errors.<locals>.checksc$0$H$H$HJJJ
!MOR
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
UN33333sAAAignoreabcstrictru�abcbackslashreplacez\x80abc)rr	rrrrrrr!rs`  r"test_errorszTest_hook_encoded.test_errorssg
&$

	 1
GGJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 V,,,	4	4	4	4	4	h   


1
2
2	%	%E(UG$$$	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%
i+'''
 :,/////s9==B**B.1B.ctttd5}|ddddn#1swxYwYttfd}|dgdt5|dgdddddS#1swxYwYdS)Nrs
A
B
C
D+IKw-ctt|td5}t|}dddn#1swxYwY||dS)Nzutf-7rr)rrrrFrs    r"rz+Test_hook_encoded.test_modes.<locals>.checksd$0$9$9;;;
!>@R
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
UN33333sAA	Ar)rrrD€r)rzB
zC
r)rr	rrrrrrs`  r"
test_modeszTest_hook_encoded.test_modessS
&$

	*1
GG()))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	
V,,,	4	4	4	4	4	c333444


z
*
*	<	<E$:::;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<s9==B--B14B1N)r$r%r&r2rrrr'r(r"rrsG11!!!0000"<<<<<r(rceZdZdZdS)MiscTestc:tj|tdSr,)rcheck__all__r6r/s r"test_allzMiscTest.test_allsT9-----r(N)r$r%r&rr'r(r"rrs#.....r(r__main__)4r2rrrxrmr6r#rrrrImportErrorrrrrrpathlibrtest.supportrtest.support.os_helperr	r
rrrrr
rr*TestCaserLrrrr4rDrWr^rjrorurzrrrrrrr$mainr'r(r"<module>rs*
							



				JJJJ
CCCKKKKDDD!       --------      ))))))888888""""""								"
"
"
"
"
"
"
"
HQQQQQy("3QQQf$$$$$$$$CCCCCY 1CCCD
----------------^00000X%6000*==========9======~,,,,,9,,,&22222<222622222<222622222:222622222 >222622222:222822222!?222622222;2226))))))))WWWWW8,WWWr:<:<:<:<:<):<:<:<z.....x ...zHMOOOOOs-77AA
	A