python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_file.cpython-312.pyc

͑e!/ddlZddlZddlZddlmZddlmZddlZddlZddl	m
Z
ddlmZddl	m
Z
ddl	mZddlmZGd	d
ZGddeej$ZGd
deej$ZGddZGddeej$ZGddeej$Zedk(rej2yy)N)array)proxy)
gc_collect)TESTFN)	os_helper)warnings_helper)UserListcZeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
Zy)
AutoFileTestsc:|jtd|_y)Nwb)openrfselfs B/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_file.pysetUpzAutoFileTests.setUps64(c|jr|jjtjtyN)rcloserunlinkrrs rtearDownzAutoFileTests.tearDowns$66FFLLN rcNt|j}|jd|j|jj	|j	|jjd|_t
|jtt|dy)Ns
teststringtell)
rrwriteassertEqualrrrassertRaisesReferenceErrorgetattr)rps  rtestWeakRefszAutoFileTests.testWeakRefssh$&&M	
1.'1f=rcd|j}|j|j|jyr)rnamemodeclosedrrs  rtestAttributeszAutoFileTests.testAttributes%s FF			rc8|jjd|jjtdd}|j	t
d|_|jj
|}|jd|jd|y)N12b
xxxxxxxxxxrb)	rrrrrrreadintortobytes)rans   rtestReadintozAutoFileTests.testReadinto,skU#w64(FFOOA		BQ0rctdd}|jj|jtd|_t|jdr,|j
t|jj|yy)Nr+r,zutf-8)encodingr.)	rrrrrhasattrr	TypeErrorr.)rr0s  rtestReadinto_textzAutoFileTests.testReadinto_text5s\#w6G4466:&i!<'rctddg}|jj||jj|j	t
d|_|jj
}|j|dy)N12r-r*)r	r
writelinesrrrreadr)rlbufs   rtestWritelinesUserListz$AutoFileTests.testWritelinesUserList=s`dD\"!64(ffkkme$rc^|jt|jjgdyN)rr6rr;rs rtestWritelinesIntegersz$AutoFileTests.testWritelinesIntegersFs)TVV%6%6	Brcttgd}|jt|jj|yrA)r	rr6rr;)rr=s  rtestWritelinesIntegersUserListz,AutoFileTests.testWritelinesIntegersUserListJs(W)TVV%6%6:rcGdd}|jt|jj||gy)NceZdZy)8AutoFileTests.testWritelinesNonString.<locals>.NonStringN)__name__
__module____qualname__rr	NonStringrKQsrrPrE)rrPs  rtestWritelinesNonStringz%AutoFileTests.testWritelinesNonStringOs6			
)TVV%6%6$;	4	6rc|j}|j|jt|j	|j|j	|jt|dr'|jttf|jd|j|j|jy)Nr.)rrr$rassertFalseisattyr&r5rOSErrorr6r.r
assertTruer's  r
testErrorszAutoFileTests.testErrorsWsFF($"1j!w	2AJJC		!rc
(ddddddddd	d
ddgffdg
}|jd
|jjddd|j|jj|D]3\}}t|j|}|jt|g|5|j|jjdddd	ddzy#|j|jjtjdYyxYw)N)filenorO)flushrO)rUrO)__next__rOr<rO)r)rreadlinerO	readlinesrO)seek)r)rrOr;)__iter__rO)truncaterOrBr)appendr__exit__rWr&r r
ValueErrorrsysexc_info)rmethods
methodnameargsmethods     rtestMethodszAutoFileTests.testMethodsbs! !#$#$!$ 2%(#
	'(	
dD)

& '	9JTVVZ0FDj&848	9	
tT:DA	E
aC	E_TVV__clln=tDsC=DcX|jt|jjyr)rrVrr<rs rtestReadWhenWritingz!AutoFileTests.testReadWhenWritings'466;;/rN)rLrMrNrrr"r(r2r7r?rFrHrQrXrnrprOrrrrsF)!
>1=%C;
6	" ED0rrc$eZdZejZy)CAutoFileTestsNrLrMrNiorrOrrrrrr
77Drrrc0eZdZeej
Zy)PyAutoFileTestsNrLrMrNstaticmethodpyiorrOrrrwrw		"Drrwc<eZdZdZdZdZdZdZdZdZ	dZ
y	)
OtherFileTestsc6tjtyr)rrrrs rrzOtherFileTests.tearDowns rc|jtdjdD]=}	|jt|}|j|jd|z?y#t$rYLwxYw)Nr
)rSaUzwU+zU+z+UzrU+z%r is an invalid file mode)rrrfailrg)rr%rs   rtestModeStringszOtherFileTests.testModeStringssn		&$%%'8	?D
?IIfd+			6=>	?

sA((	A43A4ctjdk(r|jdtjj	s|jd|jttf5tjjdddd|jttf5tjjdddy#1swYLxYw#1swYyxYw)Nosf1V5zE sys.stdin.seek(-1) may crash the interpreter on OSF1. Test manually.z stdin must be a TTY in this test)
rhplatformskipTeststdinrUrIOErrorrgrbrdrs r	testStdinzOtherFileTests.testStdins<<8#MM"
#yy!MM<=


4
5	IINN2	


4
5	!II 	!	!			!	!s/ C2C&C#&C/c8d}	|jt|}|j|jd|zy#t$rQ}|j
ddk7r5t
|}t|vs||vr|jd|zYd}~yYd}~yYd}~yd}~wwxYw)Nqwertyzno error for invalid mode: %srz&bad error message for invalid mode: %s)rrrrrgrlstr)rbad_modermsgss     rtestBadModeArgumentz"OtherFileTests.testBadModeArguments	B		&(+A
GGIII5@A	Lxx{aHQ;(!"3IIFJKK#4 	Ls?	B=BBc	|jtd|}|jt|j	d|j|j|jtd|}t
|jjd}|j|j|j|y#t$r)}|jd|t|fzYd}~@d}~wwxYw)Nr
asciir-z error setting buffer size %d: %s)rrrrencoderintr<decoderVrr)rrrdrs     r_checkBufferSizezOtherFileTests._checkBufferSizes
	J		&$*A
GGCFMM'*+
GGI
GGI		&$*AAFFHOOG,-A
GGI
GGI	
A	JII8As3x=HII	JsB?C	DDDcdD]8}tj|dt5|j|ddd:|j	td5|jddddy#1swYuxYw#1swYyxYw)N)rrizline buffering)messagecategoryrB)rcheck_no_warningsRuntimeWarningrassertWarnsRegex)rrs  rtestSetBufferSizez OtherFileTests.testSetBufferSizes	)A 2243C4BD
)%%a(
)
)	)
"
">3C
D	%!!!$	%	%
)
)	%	%sA/A;/A8	;Bc|jtd}	|jd|j|jtd}|j	d}|dk7r|jd|z|j
dk7r"|jd|j
z|j|j
dk7r"|jd|j
z|jtjjt}|dk7r|jd	|z|jy#|jwxYw)
Nr
s12345678901zrb+s12345z(Read on file opened for update failed %rzFile pos after read wrong %dz!File pos after ftruncate wrong %dz"File size after ftruncate wrong %d)rrrrr<rrrdospathgetsize)rrdatasizes    rtestTruncateOnWindowsz$OtherFileTests.testTruncateOnWindowss
IIfd#	
GGN#
GGI		&'A66!9Dx		DtKLvvx1}		81668CD
JJLvvx1}		=HI
GGI77??6*Dqy		>EF
GGIAGGIsD'EE"cd}d}|t|zrJd|t|z}gd}ddddtd	d
ffg}|jtd}|j	||z|j||j
|D]W\}}|jtd}	|jt|	|t|	|}
|
||	j
Y|jtd}	t|D]
}t|	|jd
}	|	j}

|k7r|jd|
d||jd
}td	dt|z}	|	j||j!}
|
|k7r|jd|
d||jd
}	|	j#t|}
|
|k7r|jd|
d|	|	j%}|k7r|jd|
d||	j
|jtd}		|	D]}
	|	j|	j||	j#|	j%|	j
y#t$r|jdYwxYw#t$r|jdY`wxYw#t$r|jdY)wxYw#t$r|jdYwxYw#t$r|jdYwxYw#|	j
wxYw)Ni@sham
z*dataoffset must be multiple of len(filler))sspam, spam and eggs
seggs, spam, ham and spam
ssaussages, spam, spam and eggs
sspam, ham, spam and eggs
s(spam, spam, spam, spam, spam, ham, spam
swonderful spaaaaaam.
r^r]r`r.r+sd                                                                                                    r
r-rzLreadline() after next() with supposedly empty iteration-buffer failed anywayz6readline() after next() with empty buffer failed. Got z, expected zLreadinto() after next() with supposedly empty iteration-buffer failed anywayz6readinto() after next() with empty buffer failed. Got zHread() after next() with supposedly empty iteration-buffer failed anywayz2read() after next() with empty buffer failed. Got zMreadlines() after next() with supposedly empty iteration-buffer failed anywayz7readlines() after next() with empty buffer failed. Got z'read* failed after next() consumed file)lenrrrrr;rrnextr rangepopr_rgrr.r/r<ra)r
dataoffsetfillernchunks	testlinesrjbagrkrlrmethitestlineliner>liness                r
testIterationzOtherFileTests.testIterationsL
F+	98	9F+
	$\3DsH!5 78:ii%		&7"#y!		 '	J		&$'AT!Wf-1j)D$K
GGI	
IIfd#w	AG	==#	:::<D8II9=xI
J==#C3x=01	:
JJsO{{}8II9=xI
J==#	:66#h-(D8II9=xI
J	:KKMEIII9=xI
J		
IIfd#	


E



3

GGIe	:II9
:	:	:II9
:	:	:II9
:	:	:II9
:	:$
E		CD
E
GGIss)J2?KK4LM AL62KKK10K14LLL32L36MMMMM(N)rLrMrNrrrrrrrrrOrrr}r}s,!
?! B %8_rr}c$eZdZejZy)COtherFileTestsNrsrOrrrrXrurrc0eZdZeej
Zy)PyOtherFileTestsNrxrOrrrr[r{rr__main__)rhrunittestrweakrefrrt_pyiorztest.supportrtest.support.os_helperrrrcollectionsr	rTestCaserrrwr}rrrLmainrOrr<module>rs
		#)"( u0u0n]H$5$5#mX%6%6#HHTnh&7&7#~x'8'8#zHMMOr