python (3.11.7)

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

eddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#	ddl$Z$n
#e%$rdZ$YnwxYw	ddl&Z&n
#e%$rdZ&YnwxYw	ddl'Z'n
#e%$rdZ'YnwxYw	ddl(Z(de(j)DZ*n#e%e+f$rgZ*YnwxYw	dd	l,m-Z-m.Z.n#e%$rej/xZ-Z.YnwxYw	ddl0Z0n
#e%$rdZ0YnwxYwdd
l1m2Z2ddlm3Z3ddl4m5Z5d
Z6e7e	dre	j8dkZ6e7edr,ej9j:r ej9j:;dZ<nd
Z<ej";doe	j=dkZ>dZ?ddZ@ejAej";ddZBdZCGddejDZEGddejDZFGddejDZGGddejDZHdd lmIZIGd!d"eIjJZKGd#d$ejDZLejMe7e	d%d&Gd'd(eLZNGd)d*eLZOejMe7e	d%d&Gd+d,eNZPGd-d.ejDZQejRGd/d0ejDZSGd1d2ejDZTejAejUd3Gd4d5ejDZVGd6d7ejDZWejMe7e	d8d9Gd:d;ejDZXejYd<d=kp'ejYd>d=kpejYd?d=kZZejAeZd@ejAej"dAkdBGdCdDejDZ[ej\ddEZ]ejMe7e	dFdGGdHdIejDZ^ejMej"dJkdKGdLdMejDZ_ejAejUdNGdOdPejDZ`ejMe7e	dQdRGdSdTejDZaejAej"dJkdUGdVdWejDZbejAej"dJkdUGdXdYejDZcejMej"dJkdKGdZd[ejDZdejMej"dJkdKGd\d]ejDZeejMe7e	d^d_Gd`daejDZfejMej"dJkdKejgGdbdcejDZhejMej"dJkdKGdddeejDZiejMej"dJkdKGdfdgejDZjejgGdhdiejDZkGdjdkejDZlGdldmejDZmejnGdndoejDZoejnGdpdqejDZpejqdrejMe7e	dsdtGdudvejDZrejMe7e	dwoe7e	dxdyGdzd{ejDZsejMe7e	d|d}Gd~dejtZudZvejMevdejwdddGddejDZxejMe7e	ddGddejDZyejMe7e	ddejwddGddejDZzejMe7e	ddejwdddGddejDZ{GddejDZ|GddejDZ}ejnGddejDZ~GddejDZejMe7e	ddejAejdGddejDZGddejDZGddejDZGddejDZGddejDZGddejDZejGddejDZe7e	drGddeZedkrejdSdS)N)support)
import_helper)	os_helper)
socket_helper)warnings_helper)win32_is_iotcg|]	}|j
S)pw_uid).0us  @/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_os.py
<listcomp>r5s222a222)INT_MAXPY_SSIZE_T_MAXassert_python_ok)
unix_shell)FakePathFgeteuidthread_infolinuxthreadsfreebsdcXtjtt|d|zS)Nzrequires os.%s)unittest
skipUnlesshasattrosnames rrequires_os_funcr"Xs%wr4002BT2IJJJrcontentct|dd5}||ddddS#1swxYwYdS)Nxbr)openwrite)filenamecontentfps   rcreate_filer+\s	
ha	 	 B
s599aixz%on AIX, splice() only accepts socketsc.tjddSN)asyncioset_event_loop_policyr
rrtearDownModuler1fs!$'''''rc eZdZdZdZdZdS)	MiscTestscbtj}||tdSr.)rgetcwdassertIsInstancestrselfcwds  rtest_getcwdzMiscTests.test_getcwdks)ikkc3'''''rcd}tjdkrd}d}d}|d|t|z
zz}tj5}tj|5}|}	tj}|	|||t|ttj
jzz
}|dkrnt||kr|dkr
|d|}tj
||}	tj
|tj|n8#t$rYn0t $r }	|	jt"jkrYd}	~	n
d}	~	wwxYw|}
t&jrt+d	t|dddn#1swxYwYddddS#1swxYwYdS)
Nivxworkspython_test_dir_aTrz!Tested current directory length: )sysplatformlentempfileTemporaryDirectoryr
change_cwdrr5assertEqualpathsepjoinmkdirchdirFileNotFoundErrorOSErrorerrnoENAMETOOLONGrverboseprint)
r9min_lendirlendirnametmpdirrIexpectedr:needexcs
          rtest_getcwd_long_pathzMiscTests.test_getcwd_long_pathosz<9$$G$SFS\\$9:;

(
*
*"	Jf%f--!
J$)++C$$S(333"c#hhRW[1A1A&ABDqyy7||d**taxx")%4%.7<<g66D",""""9(:::!EEEE!	" $H7$:?JHc#hhHHIIIC!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J!
J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	J"	JssF6B(F(D+*F+
E 5F7	E EFEE  2FF6F"	"F6%F"	&F66F:=F:ctj}||t|tj|tjdSr.)rgetcwdbr6bytesrHfsdecoder5r8s  rtest_getcwdbzMiscTests.test_getcwdbsOjllc5)))S))29;;77777rN)__name__
__module____qualname__r;r[r`r
rrr3r3jsE(((7J7J7Jr88888rr3ceZdZdZeZdZejej	dejej
ddZejdZ
dZejejeekdejed	zd
dd
ZdZdZejejdkddZdZdZdZdZdZejeedddZ ejeedddZ!ejeedddZ"ejeedddZ#ejeedde$d Z%ejeedde$d!Z&ejeedde$d"Z'd#S)$	FileTestsctjtjr tjtjdSdSr.)rrIlexistsrTESTFNunlinkr9s rsetUpzFileTests.setUps>
7??9+,,	(Ii&'''''	(	(rctjtjtjtjz}tj||tjtjtj	dSr.)
rr&rrhO_CREATO_RDWRclose
assertTrueaccessW_OKr9fs  rtest_accesszFileTests.test_accesssUGI$bj&:;;
	)"2BG<<=====rz"Test is unstable under Emscripten.zWASI does not support dup.c2tjtjtjtjz}tj|}	d}||dzkrStj||dz
}|dkr|d|tj|}}||dzkStj|n#tj|wxYwtj	||dz|
ttj|ddS)Nr
z%couldn't allocate two consecutive fdsa)
rr&rrhrmrnduproskipTest
closerangeassertRaisesrOr')r9firstsecondretriess    rtest_closerangezFileTests.test_closeranges	("*RY*>??
	GEAI%%1R<<MM"IJJJ &vv
EAI%%
HVBHV

eUQY''''28UD99999s
AB??Cctj}tj|}|t
tj|dtj|}|||dSNr)	rrhrBgetrefcountr~	TypeErrorrrenamerH)r9rIoldnews    rtest_renamezFileTests.test_renames`od##)RYa888od##c"""""rcttjd5}|d||}t
j|ddt
j|d}|	t|t|	|dddddS#1swxYwYdS)Nw+bspamr)r&rrhr'flushfilenorlseekreadrHtyper^)r9fobjfdss    r	test_readzFileTests.test_reads
)"E
*
*	)dJJwJJLLLBHRAAAT!WWe,,,Q(((	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)sB'CCCzneeds INT_MAX < PY_SSIZE_T_MAXrxrwF)sizememusedry_runcl|tjtjt	tjdttjd5}t
j||}dddn#1swxYwY|	|ddS)Nstestrb)

addCleanuprrirhr+r&rrrrH)r9rr*datas    rtest_large_readzFileTests.test_large_reads	
	()*:;;;I$g...)"D
)
)	.R7299;;--D	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.
	
w'''''s(BBBcxtjtjtjtjz}|ttj|dtj|dtj|tdtj|tdtj|ttjd5}||
gdddddS#1swxYwYdS)Nbeanssbacon
seggs
sspam
r)sbaconseggsr)rr&rrhrmO_WRONLYr~rr'	bytearray
memoryviewrorHr
splitlines)r9rrs   r
test_writezFileTests.test_writes9
WY%rzBK'?
@
@)RXr7;;;
Z   
Yy))***
Z	**+++

)"D
)
)	.TTYY[[3355,,,
.
.
.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.s%=D//D36D3cttj|tjd}||ddS)NT)
creationflagsshellr)
subprocesscallCREATE_NEW_CONSOLErH)r9argsretcodes   rwrite_windows_consolezFileTests.write_windows_consolesA/$$7	
	
!$$$$$rwin32z$test specific to the Windows consolecd}|tjd||tjdd|dS)Nzprint('x' * 100000)-cz-u)rrB
executabler9codes  rtest_write_windows_consolez$FileTests.test_write_windows_consolesE%""3>4>>>""3>4tDDDDDrctjtjtj}tj|g|Rddi}|dS)Nencodingutf-8)rr&rrhO_RDONLYfdopenro)r9rrrts    r
fdopen_helperzFileTests.fdopen_helpersH
WY%r{
3
3Ib24222'22						rctjtjtjtjz}tj|||d|dddS)Nrd)rr&rrhrmrnrorr9rs  rtest_fdopenzFileTests.test_fdopensn
WY%rz")';
<
<
33$$$$$rcPtjdz}|tjtj|tj|t	tjdt	|dtjtj||tt
j	tjt|dd5}||dddddS#1swxYwYdS)Nz.212rrr1)
rrhrrir+rreplacer~rNstatr&rHr)r9TESTFN2rts   rtest_replacezFileTests.test_replace&s*"T)	()*:;;;	('222I$d+++GT"""

9#W---+RWi6FGGG
'3
1
1
1	,QQVVXXs+++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,s%)DD"Dc|tjttjdd}tj|dS)N)rIflagsmodedir_fd)rr&__file__rrorss  rtest_open_keywordszFileTests.test_open_keywords3s4G5



rctjtd}	|dtjdddS#t
tf$rYdSwxYw)NsymlinktargetF)srcdsttarget_is_directoryr)r
get_attributerrrhNotImplementedErrorrO)r9rs  rtest_symlink_keywordszFileTests.test_symlink_keywords8so'I66	Gi&6$)$
8
8
8
8
8
8#W-			DD	s7AAcopy_file_rangeztest needs os.copy_file_range()c|t5tjdddddddS#1swxYwYdSNrrwi)r~
ValueErrorrrrjs r#test_copy_file_range_invalid_valuesz-FileTests.test_copy_file_range_invalid_values@s


z
*
*	*	*q!S)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*?AActjdz}d}ttj||tjtjttjd}||j|}t|d}|tj|||j|}	tj	||d}|
|tddt|d5}||
|d|ddddS#1swxYwYdS#t$r6}|jtjkr||Yd}~dSd}~wwxYw)N.3
0123456789rrr)rrhr+rrir&rorrrassertInrangerHrrOrPENOSYSr|)	r9rrin_filein_fdout_fileout_fdies	         rtest_copy_file_rangezFileTests.test_copy_file_rangeEs"T)I$d+++	()*:;;;y'..
&&&  ''	('222'''""	;"5&!44A
MM!U1a[[)))gt$$
;  bqb:::
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;			w%,&&MM!
	s*=F1FF	F	
G+G

Gctjdz}d}d}d}d}ttj||tjtjttjd}||j|}t|d}|tj|||j|}		tj	||	|||}
|
|
td	|d
zt|d5}|}dddn#1swxYwY|
|d|d|z|
||d||||
zdS#t$r6}|jtjkr||Yd}~dSd}~wwxYw)N.4rrrrr)
offset_src
offset_dstrrw)rrhr+rrir&rorrrrrrrHrOrPrr|)
r9TESTFN4r
bytes_to_copyin_skipout_seekrrrrrrrs
             rtest_copy_file_range_offsetz%FileTests.test_copy_file_range_offsetgsF"T)
I$d+++	()*:;;;y'..
&&&  ''	('222'''""	6"5&-.5.6888A
MM!U1mAo66777gt$$
&||~~
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
T)8)_gh.>???
T())_!''!)"34
6
6
6
6
6%			w%,&&MM!
	s*GE44E8;E8
H+HHspliceztest needs os.splice()c|t5tjdddddddS#1swxYwYdSr)r~rrrrjs rtest_splice_invalid_valuesz$FileTests.test_splice_invalid_valuess


z
*
*	!	!IaC   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!rc.tjdz}d}ttj||tjtjttjd}||j|}tj	\|fd|fd	tj
|d}||tdd|
tjd	|d|dS#t$r6}|jt jkr||Yd}~dSd}~wwxYw)
Nrrrc,tjSr.rroread_fdsr<lambda>z'FileTests.test_splice.<locals>.<lambda> 1 1rc,tjSr.rwrite_fdsrrz'FileTests.test_splice.<locals>.<lambda> 2 2rrrrr)rrhr+rrir&rorrpiperrrrHrrOrPrr|)	r9rrrrrrrrs	       @@rtest_splicezFileTests.test_splices"T)I$d+++	()*:;;;y'..
&&&  GII11112222222333	>	%1--A
MM!U1a[[)))RWWc22D!H=====			w%,&&MM!
	s'E
F+FFcJ
tjdz}d}d}d}ttj||tjtjttjd}||j|}tj	\
|
fd|fd	tj
|||}||td	|d
ztj

d}||||||zdS#t$r6}	|	jt jkr||	Yd}	~	dSd}	~	wwxYw)Nrrrrrc,tjSr.rrsrrz1FileTests.test_splice_offset_in.<locals>.<lambda>rrc,tjSr.rrsrrz1FileTests.test_splice_offset_in.<locals>.<lambda>rr)rrrwr)rrhr+rrir&rorrr	rrrrrHrOrPrr|)r9rrrrrrrrrrrs          @@rtest_splice_offset_inzFileTests.test_splice_offset_ins"T)
I$d+++	()*:;;;y'..
&&&  GII11112222222333	<	%=WMMMA
MM!U1mAo6677777C((D
T4	(9#:;;;;;			w%,&&MM!
	s+E""
F",+FF"c:tjdz}d}d}d}ttj||tjtjtj\|fd|fdtj|t|d}|tj|||j	|
}	tj|||}||td	|d
zt|d5}|}	dddn#1swxYwY||	d|d|z||	|d|d|dS#t $r6}
|
jt"jkr||
Yd}
~
dSd}
~
wwxYw)
Nrrrrc,tjSr.rrsrrz2FileTests.test_splice_offset_out.<locals>.<lambda>rrc,tjSr.rrsrrz2FileTests.test_splice_offset_out.<locals>.<lambda>rrr)rrrwrr)rrhr+rrirr	r'r&rorrrrrrHrOrPrr|)
r9rrrrrrrrrrrrs
           @@rtest_splice_offset_outz FileTests.test_splice_offset_outsN"T)
I$d+++	()*:;;;GII11112222222333
4   ''	('222'''""	8	'6=XNNNA
MM!U1mAo66777gt$$
&||~~
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
T)8)_gh.>???
T())_d2A2h77777%			w%,&&MM!
	s*G%FF

F

H$+HHN)(rarbrcrktearDownrurskipIfr
is_emscriptenis_wasircpython_onlyrrrrr
bigmemtestrrrrBrCrrrrrrrrrrrrrequires_splice_piper
rrr
rrreres(((H>>>
X_CX_5:::*
###)))
X>19;;WWr\!UCCC((DC;;(
.
.
.%%%X0?AAEEAAE
%%%,,,
X%6779Z[[**\[*X%6779Z[[;;\[;BX%6779Z[[*6*6\[*6XXX..0HII!!JI!XX..0HII>>JI>>XX..0HII"<"<JI"<HXX..0HII'8'8JI'8'8'8rrecbeZdZdZdZdZdZdZej	e
edddZej	e
edd	d
Z
ej	ejdkdd
Zej	ejdkdej	e
edddZdZej	ejdkddZej	ejdkddZej	ejdkddZdS)StatAttributeTestsctj|_|tj|jt|jddS)NABC)rrhfnamerrir+rjs rrkzStatAttributeTests.setUps=%
	($*555DJ'''''rc	<tj|}||tjd||jdt|}ttD]}|dddkr|}|drd}nd}||t|||tt||	||d
D]P}tt||dz}t||dzd	z}|||d
Q	|d|
d
n#t$rYnwxYw	d|_|
d
n#t $rYnwxYw	d|_|
d
n#t t$f$rYnwxYw	d|_|
d
n#t $rYnwxYw	tjd}	|
d
n#t$$rYnwxYw	tjd}	dS#t$$rYdSwxYw)NrST_TIMEc t|Sr.)intxs rtruncz7StatAttributeTests.check_stat_attributes.<locals>.trunc sQ-rc|Sr.r
r$s rr&z7StatAttributeTests.check_stat_attributes.<locals>.trunc"s(rzst_atime st_mtime st_ctimei_nsi'rydeltar?No exception raisedrwrxrrwryrrrr	rx
)rrrHST_SIZEst_sizedirlowerendswithgetattrrsplitr#assertAlmostEqualfail
IndexErrorst_modeAttributeErrorst_rdevrparrotstat_result)
r9rresultmembersr!attrr&floatynanosecondyresult2s
          rcheck_stat_attributesz(StatAttributeTests.check_stat_attributess	
-q111+++f++II		-		-DBQBx5  zz||==((+////***  wvt'<'<!=!="(t)<)<"=???

dG,,,16688	A	AD..788F!&$,775@K""6;a"@@@@	3KKII+,,,,			D		FNII+,,,,			D		FNII+,,,,	*			D		FMII+,,,,			D		nU++GII+,,,,			D		n%IJJGGG			DD	sl<F
F'&F'+G
GGG66H
	H
H++
H87H8<)I&&
I32I37J

JJc:||jdSr.)rJrrjs rtest_stat_attributesz'StatAttributeTests.test_stat_attributesTs""4:.....rc	|jtj}n-#t$r |d|jzYnwxYw||dS)Nz#cannot encode %a for the filesystem)rencoderBgetfilesystemencodingUnicodeEncodeErrorr|rJ)r9rs  rtest_stat_attributes_bytesz-StatAttributeTests.test_stat_attributes_bytesWs	NJ%%c&?&A&ABBEE!	N	N	NMM?$*LMMMMM	N""5)))))s+.'AAcXtj|j}ttjdzD]s}t	j||}|d||dkr|d|t	j|}|	||tdS)Nrwsstat_resultrscos
stat_result
)
rrrrpickleHIGHEST_PROTOCOLdumpsrloadsrHr9rDprotop	unpickleds     rtest_stat_result_picklez*StatAttributeTests.test_stat_result_pickle^s$$62Q677	0	0EVU++AMM.!,,,qyy

3Q777QIVY////
	0	0rstatvfsztest needs os.statvfs()ctj|j}||j|dd}t|D]2\}}|t
|d|z||3|t|j	t|t|d	d|_|dn#t$rYnwxYw	d|_|dn#t$rYnwxYw	tjd}|dn#t $rYnwxYw	tjd}dS#t $rYdSwxYw)	Nr)
bsizefrsizeblocksbfreebavailfilesffreefavailflagnamemaxf_rxrwr+r,r-)rr\rrHf_bfree	enumerater:rp
isinstancef_fsidr#rDr=r@rBstatvfs_resultr)r9rDrEvaluememberrIs      rtest_statvfs_attributesz*StatAttributeTests.test_statvfs_attributeshsDJ''	
333:&w//	L	LME6WVTF];;VE]KKKK
6=#66777	
Vb)))	FNII+,,,,			D		FMII+,,,,			D		'..GII+,,,,			D		'(LMMGGG			DD	sHC--
C:9C:>D
D('D(,)E
E#"E#'E==
F
Fneed os.statvfs()cXtj|j}ttjdzD]s}t	j||}|d||dkr|d|t	j|}|	||tdS)Nrwsstatvfs_resultrscos
statvfs_result
)
rr\rrrSrTrUrrVrHrWs     rtest_statvfs_result_picklez-StatAttributeTests.test_statvfs_result_picklesDJ''62Q677	0	0EVU++AMM+Q///qyy

6:::QIVY////
	0	0rrWin32 specific testsc	tjddS#t$r|dYdSt$r }|dYd}~dSd}~wwxYw)Nzc:\pagefile.syszc:\pagefile.sys does not existzCould not stat pagefile.sys)rrrNr|rOr=r9rs  rtest_1686475zStatAttributeTests.test_1686475s	5G&''''' 	=	=	=MM;<<<<<<	5	5	5II3444444444	5sA#	A#AA#r	zrequires os.pipe()ctj\}}	tj|tj|tj|n-#tj|tj|wxYw|t
5}tj|dddn#1swxYwY||jjtj	dSr.)
rr	rror~rOrH	exceptionrPEBADF)r9rwctxs    r
test_15261zStatAttributeTests.test_15261swyy1	GAJJJHQKKKHQKKKK
HQKKKHQKKKK


w
'
'	3GAJJJ															,ek:::::sA*A?B==CCc|t|d|t|jt|d|jcxkodkncdS)Nst_file_attributesr)rprrkrr#)r9rDs  rcheck_file_attributesz(StatAttributeTests.check_file_attributessu(<==>>>
6#<cBBCCCV6DDDD*DDDDEEEEErz$st_file_attributes is Win32 specificctj|j}||||jtjzdtjdz}tj	||
tj|tj|}||||jtjztjdS)Nrr7)rrrrrHrFILE_ATTRIBUTE_DIRECTORYrrhrLrrmdir)r9rDrVs   rtest_file_attributesz'StatAttributeTests.test_file_attributess$$""6***%(EE
			
"U*
'***!!""6***%(EE)	+	+	+	+	+rcltjtjd|jdz}|tj|t|dd}tj
d|ddg|tj|}||j
d	dS)
NTEMP_accessrr/z
icacls.exez/denyz*S-1-5-32-545:(S)rr)rrIrKenvironrrrrir+r
check_callrassertNotEqualr6)r9rDETACHED_PROCESSrDs    rtest_access_deniedz%StatAttributeTests.test_access_deniedsRZ/i1GHH	(%000E6"""5'+>?*		
	
	
	
FNA.....rcdtjtjdz}tj|}||jtjdS)Nz//./r)rrI
splitdriver5rrHr?S_IFBLK)r9rrDs   rtest_stat_block_devicez)StatAttributeTests.test_stat_block_devicesV++BIKK88;;66666rN)rarbrcrkrJrLrQr[rrrrrprsrBrCrwr}rrrrr
rrrr
s(((
???B///***000XY//1JKK))LK)VXY//,..	0	0..	0X02HII55JI5X02HIIXV,,.BCC
;
;DCJI
;FFF
X0?AA++AA+&X02HII//JI/(X02HII77JI777rrcxeZdZdZdZddZdZedZdZ	dZ
eje
je
jvd	d
Zeje
je
jvddZeje
je
jvd
dZdZdZdZdZdZdZdZejdZdS)
UtimeTestsc tj|_tj|jd|_|tj|jtj	|jt|jdS)Nf1)rrhrVrrIrKrrrmtreerLr+rjs rrkzUtimeTests.setUpsf 'W\\$,55
	($,777
DJrctj|}|j|dkp!|j|dkp|j|dkS)Nr.r/r0)rrst_atimest_mtimest_ctime)r9r(sts   rsupport_subsecondzUtimeTests.support_subsecondsLWX

1%*K2a5(*K2a5(	+rNc|s|j}||}|rd}d}nd}d}||||ftj|}|rA||j|dzd||j|dzdn<||j|dz||j|dz||j|||j	|dS)Ni8Z;l
o]rTlP9&.>gư>r))
rrrrr<rrrHst_atime_nsst_mtime_ns)r9set_timer(ratime_nsmtime_nsrs       r_test_utimezUtimeTests._test_utimes(	"zH 228<<	!"H!HH!H HHh/000
WX

	;""2;4t"LLL""2;4t"LLLLR[(T/:::R[(T/:::22222222rc6d}||dS)Nc2tj||dSNnsrutimer(rs  rrz'UtimeTests.test_utime.<locals>.set_time"HX"%%%%%%rrr9rs  r
test_utimezUtimeTests.test_utime!s-	&	&	&	
"""""rc|dzdzS)Nrg&.>r
rs r	ns_to_seczUtimeTests.ns_to_sec's
T	V##rc<fd}|dS)Nc|\}}|}|}tj|||fdSr.rrrr(rrratimemtimer9s      rrz2UtimeTests.test_utime_by_indexed.<locals>.set_time0sM!#HhNN8,,ENN8,,E
HXu~.....rrrs` rtest_utime_by_indexedz UtimeTests.test_utime_by_indexed.s8	/	/	/	/	/	
"""""rc<fd}|dS)Nc|\}}|}|}tj|||fdS)N)timesrrs      rrz0UtimeTests.test_utime_by_times.<locals>.set_time:sN!#HhNN8,,ENN8,,EHXeU^444444rrrs` rtest_utime_by_timeszUtimeTests.test_utime_by_times9s8	5	5	5	5	5	
"""""rz9follow_symlinks support for utime required for this test.c6d}||dS)Nc4tj||ddS)NF)rfollow_symlinksrrs  rrz9UtimeTests.test_utime_nofollow_symlinks.<locals>.set_timeFs!
HX"e<<<<<<rrrs  rtest_utime_nofollow_symlinksz'UtimeTests.test_utime_nofollow_symlinksBs-	=	=	=	
"""""rz,fd support for utime required for this test.c6d}||dS)Nct|dd5}tj||ddddS#1swxYwYdS)Nwbrr)r&rrr)r(rr*s   rrz*UtimeTests.test_utime_fd.<locals>.set_timeOsha((
-B,,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-s)AAArrs  r
test_utime_fdzUtimeTests.test_utime_fdLs-	-	-	-
	
"""""rz0dir_fd support for utime required for this test.c6d}||dS)Nctj|\}}tj|5}tj|||ddddS#1swxYwYdS)N)rr)rrIr;ropen_dir_fdr)r(rrVr!dirfds     rrz.UtimeTests.test_utime_dir_fd.<locals>.set_timeYsGMM(33MGT&w//
45e3333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4sAA #A rrs  rtest_utime_dir_fdzUtimeTests.test_utime_dir_fdVs-	4	4	4
	
"""""rcDd}|||jdS)Nc2tj||dSrrrs  rrz1UtimeTests.test_utime_directory.<locals>.set_timearr)r()rrVrs  rtest_utime_directoryzUtimeTests.test_utime_directory`s4	&	&	&	
DL99999rc(tj}||j||jsd}nd}tj|j}d|jd|d|j|z
}||j|||dS)Ng?g?zst_time=z
, current=z, dt=)r*msg)timerrrrrr<)r9rcurrentr*rrs      r_test_utime_currentzUtimeTests._test_utime_currentfs)++	%%dj11	EEE
WTZ
 
 +++wwwg(=(=?r{G%*		5	5	5	5	5rc<fd}|dS)Nc:tjjdSr.rrrr(r9s rrz/UtimeTests.test_utime_current.<locals>.set_time}sHTZ     rrrs` rtest_utime_currentzUtimeTests.test_utime_current|s8	!	!	!	!	!	
  *****rc<fd}|dS)Nc<tjjddSr.rrs rrz3UtimeTests.test_utime_current_old.<locals>.set_timesHTZ&&&&&rrrs` rtest_utime_current_oldz!UtimeTests.test_utime_current_olds8	'	'	'	'	'	
  *****rcdtjdkrtjtj|ddz}ddl}|jj}|	dd}|
|ddddd|t|}|r	|jSdSdS)Nrr\r)
rBrCrrIrabspathctypeswindllkernel32create_unicode_bufferGetVolumeInformationWrDrn)r9rIrootrrbufoks       rget_file_systemzUtimeTests.get_file_systems<7""7%%bgood&;&;<<Q?$FDMMM}-H..r377C//dA04dD03SXX??B
!y #"
!
!rc||jdkr|dd}tj|j||f|tj|jj|dS)NNTFSz
requires NTFSr)	rrVr|rrrrHrr)r9larges  rtest_large_timezUtimeTests.test_large_timesy--77MM/***
eU^,,,,,5u=====rc|t5tj|jdddddn#1swxYwY|t
5tj|jddgdddn#1swxYwY|t
5tj|jddddn#1swxYwY|t
5tj|jddddn#1swxYwY|t
5tj|jddgdddn#1swxYwY|t
5tj|jddddn#1swxYwY|t
5tj|jddddn#1swxYwYtjtjvrN|t5tj|jdddddn#1swxYwYtjtjvrt|jdd	5}|t
5tj|
ddddn#1swxYwYdddn#1swxYwYtjtjvrQ|t5tj|jdd	
ddddS#1swxYwYdSdS)N)rrrr)r)rrrFrrrr)r~rrrrrsupports_follow_symlinksrsupports_fdr&rsupports_dir_fd)r9r*s  rtest_utime_invalid_argumentsz'UtimeTests.test_utime_invalid_argumentss


z
*
*	4	4HTZF3333	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4


y
)
)	)	)HTZ!Q(((	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)


y
)
)	'	'HTZ&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'


y
)
)	,	,HTZ+++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,


y
)
)	,	,HTZQF++++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,


y
)
)	*	*HTZD))))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*


y
)
)	/	/HTZI....	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/82666""#677
D
DVUCCCC
D
D
D
D
D
D
D
D
D
D
D
D
D
D
D
82>))dj$**
2b&&y1122HRYY[[&111222222222222222
2
2
2
2
2
2
2
2
2
2
2
2
2
2
282---""#677
7
7VA6666
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7.-sAAA)BBB7CC"%C"D**D.1D.E99E=E=GG

G
+HHHI99I=I=2L
(L5LL	LL		LLLM??NNcd}|t5tj|j|ddfdddn#1swxYwY|t5tj|j|ddfdddn#1swxYwY|t5tj|j|ddfddddS#1swxYwYdS)Nc6Gfdd}|S)NceZdZfdZdS)?UtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadIntcSr.r
)rdivmod_ret_vals r
__divmod__zJUtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadInt.__divmod__s	))rN)rarbrcr)rsrBadIntrs.*******rrr
)rrs` rget_bad_intz/UtimeTests.test_issue31577.<locals>.get_bad_intsB
*
*
*
*
*
*
*
*
*
*688Or*rwrr
)rwryr)r~rrrr)r9rs  rtest_issue31577zUtimeTests.test_issue31577s			


y
)
)	:	:HTZ[[__a$89999	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:


y
)
)	:	:HTZ[[__a$89999	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:


y
)
)	A	AHTZ[[%;%;Q$?@@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	As5'AAA6'B))B-0B-'DD	Dr.)rarbrcrkrrrstaticmethodrrrrrrrrrrrrrrrrrrrrrrrr
rrrrs   +++3333>###$$\$	#	#	####XR%@@*++##++#XR^3GII##II#XR%77KMM##MM#:::555,++++++
!
!
!>>>7778

A
A
A
A
Arr)
mapping_testsceZdZdZdZdZdZdZdZe	j
eoej
ede	j
eedd	ejd
Ze	j
eoej
ede	j
eedd	ejdZdZd
ZdZdZe	j
ejddZejdZejdddZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&d Z'dS)!EnvironTestsz8check that os.environ object conform to mapping protocolNcttj|_tjrttj|_|D]\}}|tj|<dSr.)	dictrr_EnvironTests__savesupports_bytes_environenvironb_EnvironTests__saveb
_referenceitemsr9keyrns   rrkzEnvironTests.setUpso2:&&
$	-,,DL//++1133	$	$JC#BJsOO	$	$rc*tjtj|jtjrDtjtj|jdSdSr.)rrclearupdaterrr	r
rjs rrzEnvironTests.tearDownsu



$+&&&
$	-KKt|,,,,,	-	-rcddddS)NVALUE1VALUE2VALUE3)KEY1KEY2KEY3r
rjs rrzEnvironTests._referencesBBBrcVtjtjSr.)rrrrjs r_empty_mappingzEnvironTests._empty_mappings

zrzrequires a shellpopenzneeds os.popen()cdtjtjdtjdt
z5}|}||dddddS#1swxYwYdS)NWorld)HELLOz%s -c 'echo $HELLO')	rrrrrrrstriprH)r9rrns   rtest_update2zEnvironTests.test_update2s
	


(((
X+j8
9
9	-UJJLL&&((EUG,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-s=B%%B),B)ctjdtz5}t|}|t|d|t|d|t|d|tt
|ddddS#1swxYwYdS)Nz %s -c 'echo "line1
line2
line3"'zline1
zline2
zline3
)rrriterrHnextr~
StopIteration)r9rits   rtest_os_popen_iterzEnvironTests.test_os_popen_iters
X<"#$$	7',eBT"XXy111T"XXy111T"XXy111mT2666
	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7sBCCCctjD]U\}}|t	|t
|t	|t
VdSr.)rrrrHrr7)r9rvals   rtest_keyvalue_typesz EnvironTests.test_keyvalue_typessh
((**	-	-HCT#YY,,,T#YY,,,,	-	-rc|D]8\}}|tj||9dSr.)rrrHrrgetr
s   r
test_itemszEnvironTests.test_itemss\//++1133	9	9JCRZ^^C00%8888	9	9rctj}dd|D}|t|d|ddS)z>Check that the repr() of os.environ looks like environ({...}).z, c3*K|]\}}|d|VdS)z: Nr
)rrrns   r	<genexpr>z-EnvironTests.test___repr__.<locals>.<genexpr>sH$
$
U!!!!$
$
$
$
$
$
rz	environ({z})N)rrrKrrHrepr)r9envformatted_itemss   r
test___repr__zEnvironTests.test___repr__spj))$
$
!iikk$
$
$


	
c$E$E$E$EFFFFFrctjtj}gd}dtj|i}tj}	t
|t_||tj||tjd|t_n#|t_wxYw||tji|dtjddi||tj|tj	r	tjd5dd	d
}dddn#1swxYwY|ttj|n#t$rYnwxYw|tjddid
g|tjdd
id
g|tjddid
gdSdS)N)z/montyz/pythonrz/flying/circusPATHr1rrT)recordrr)r5PATHr9abcabc)rdefpathr;pathseprKrrassertSequenceEqual
get_exec_pathrwarningscatch_warningsr~rBytesWarning)r9defpath_list	test_pathtest_env
saved_environ	mixed_envs      rtest_get_exec_pathzEnvironTests.test_get_exec_pathsz''
33???	BJOOI667

	'hBJ$$Y0@0B0BCCC$$Y0@T0J0J0JKKK&BJJBJ&&&&	
  r/?/C/CDDD  (8&(E(EFFF  B,<X,F,FGGG
$	
K,D999==),t < <I===============!!*b.>	JJJJ	 




$$R%5w6G%H%H


$$R%5w6F%G%G


$$R%5vv6F%G%G




#		sCA)CC *G?FGFGFG
GGz#os.environb required for this test.cd}	|tjd}n;#t$r.dtj}||YnwxYw|t
jd<|t
jd||t
jd|d}|t
jd<|t
jd||	tjd}|t
jd|dS)	Nueuro€surrogateescapez%U+20AC character is not encodable to unicodesunicodesbytesr^)
rNrBrOrPr|rrrHr	decode)r9rnvalue_bytesr	value_strs     r
test_environbzEnvironTests.test_environb>s7	,,s'@'B'B'8::KK!				)+++.CMM#	!&
9I.666Z0+>>> %HX.666LL!:!<!<>OPP	G,i88888s',5A$#A$cd}d}d|d}tj5}||dtj||tjtjd|gdt
j	d}|
|jt|tj|tjtjd|gdt
j	d}|
|jtdddddS#1swxYwYdS)N
PYTHONTESTVAR	testvaluez%import os; print(repr(os.environ.get(z)))rT)checkstdouttext)rEnvironmentVarGuardpoprputenvrrunrBrPIPErHrUrstripr0unsetenv)r9r!rnrr1procs      rtest_putenv_unsetenvz!EnvironTests.test_putenv_unsetenvUspBtBBB

*
,
,	?GGD$IdE""">3>4">d)3tEEEDT[//114;;???K>3>4">d)3tEEEDT[//114::>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?sDD==EErxrcdD]]}|ttftj|d|ttftj|^dD]O}|ttj|d|ttj|Ptjdkr{ddz}|ttj|d|ttjd||ttj|dSdS)	N)rz=namezna=mezname=rn)znameznamerr%rX)r~rOrrrYr]rBrC)r9r!longstrs   rtest_putenv_unsetenv_errorz'EnvironTests.test_putenv_unsetenv_erroris4	H	HDw
3RYgNNNw
3R[$GGGG(	=	=Dj")T7CCCj"+t<<<<<7""FlGj")WcBBBj")S'BBBj"+w?????
#"rcdd}||tj|t5}tj|dddn#1swxYwY||jjd|||jj	|t5}tj|=dddn#1swxYwY||jjd|||jj	dS)N
missingkeyr)
assertNotInrrr~KeyErrorassertIsryrrp__suppress_context__)r9missingcms   r
test_key_typezEnvironTests.test_key_type|sr"*---


x
(
(	 BJw	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 

bl'*G4449:::


x
(
(	$B
7#	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$

bl'*G4449:::::s#AA #A C  C$'C$ct|}d}t|dtj|<	t||tj|dtj|=dS#tj|=wxYw)N__new_key__test_environ_iteration)r"r#rrrH)r9
collectioniteratornew_keys    r_test_environ_iterationz$EnvironTests._test_environ_iterations
##X7
7	$NNNRZ02JKKK
7###
7#####s5A55BcD|tjdSr.)rtrrrjs r(test_iter_error_when_changing_os_environz5EnvironTests.test_iter_error_when_changing_os_environs$$RZ00000rch|tjdSr.)rtrrrrjs r.test_iter_error_when_changing_os_environ_itemsz;EnvironTests.test_iter_error_when_changing_os_environ_itemss*$$RZ%5%5%7%788888rch|tjdSr.)rtrrvaluesrjs r/test_iter_error_when_changing_os_environ_valuesz<EnvironTests.test_iter_error_when_changing_os_environ_valuess*$$RZ%6%6%8%899999rcbtr$tjtsdStjsdStjtd|d5}|}dddn#1swxYwY|	||dS)Nz -c 'echo $')
rrrIexistsrhas_subprocess_supportrrrrH)r9varrXrrns     r_test_underlying_process_envz)EnvironTests._test_underlying_process_envs	rw~~j99	F/	F
X66666
7
7	)5JJLL&&((E	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	
5)))))s'BBBc
d}d}|tj|<dddd|di}ttj}||tj|z}||||d|||}|ttj	||
dd|
||dS	N
_TEST_VAR_original_value_A_r_B_23r)rrrrassertDictEqualrHrriNotImplemented__or__rr9overridden_keyr
new_vars_dictrXactualnew_vars_itemss       rtest_or_operatorzEnvironTests.test_or_operators%)%3
>"UCE

##
&&&m+Xv...f^4555&,,..

nbj&7&7&G&GHHH))%444))..IIIIIrcd}dtj|<dddd|di}ttj}||txj|zc_||tj|dtj||dd||ddS)NrrrrrrrrrrrrHr)r9rrrXs    rtest_ior_operatorzEnvironTests.test_ior_operators%%5
>"UCE

##
&&&


m#

2:...bj8999))%555)).#>>>>>rctj}|t5ddi}txj|zc_dddn#1swxYwY|t5ddi}txj|zc_dddn#1swxYwY||tjdS)Nrwr)rrcopyr~rrH)r9os_environ_copydict_with_bad_keydict_with_bad_vals    rtest_ior_operator_invalid_dictsz,EnvironTests.test_ior_operator_invalid_dictss=*//++


y
)
)	,	,!"E
JJ++JJ	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,

y
)
)	,	,!&
JJ++JJ	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,
	
"*55555s#AA#&A#B**B.1B.cd}dtj|<dd|dff}ttj}||txj|zc_||tj|dtj||dd||ddS)Nrr)rr)rrrrrr)r9rrrXs    r$test_ior_operator_key_value_iterablez1EnvironTests.test_ior_operator_key_value_iterables%%5
>"&~s6KL
##'''


n$

2:...bj8999))%555)).#>>>>>rc
d}d}|tj|<dddd|di}t|}|tj|tjz}||||||||}|ttj	||
dd|
||dSr)rrrrrrHrrir__ror__rrs       rtest_ror_operatorzEnvironTests.test_ror_operators%)%3
>"UCE

&&
###+Xv...)?@@@&,,..

nbj&8&8&H&HIII))%444))..IIIIIr)(rarbrc__doc__	type2testrkrrrrrrrrIr~rrrequires_subprocessr r&r)r,r3rHrrPr_requires_mac_verrdrmrtrvrxr{rrrrrrr
rrrrsBBI$$$---CCC
XBz(B(B+--XW--/ABB W ""--#"CB---XBz(B(B+--XW--/ABB W ""77#"CB--7---
999
GGG'''RX2>@@99@@9*!W ""??#"?&Wb!$$@@%$@$;;;
$
$
$111999:::	*	*	*JJJ&
?
?
?666
?
?
?JJJJJrrcJeZdZdZdZdZdZddZdZdZ	d	Z
d
ZdZdS)
	WalkTestszTests for os.walk().c^d|vr|d|d<tj|fi|SNrfollowlinks)rXrwalk)r9topkwargss   rrzWalkTests.walks<&&$*JJ/@$A$AF=!ws%%f%%%rctjj}|tjtj|tjd|_||jd|_||jd|_	||jd}||d}||jd}||jd}||d}||d}||d	|_
|tjd
}|tjd
d}	||d}
||d
}||d}tj|j	tj|tj|tj|||||	|fD]G}
t|
dd5}|
d|
zdzdddn#1swxYwYHt	jrtjtj||j
tjd|
dtj|dd|dtj|dd|d|dd	ggdf|_n|dgdgf|_t$jstj|d	tj|tj|t,jtj|tj||jddd=dS#t4$r/|tj|t,jYdSwxYw)NTEST1SUB1SUB11SUB2SUB21tmp1tmp2tmp3linkTEST2tmp4broken_linkbroken_link2broken_link3r%rrzI'm z" and proud of it.  Blame test_os.
brokenTtmp5)rrrrrrw)rrIrKrrrrh	walk_path	sub1_path
sub11_path	link_pathmakedirsr&r'can_symlinkrr	sub2_treerrchmodlistdirrS_IRWXUrirPermissionError)r9rK	sub2_path
sub21_path	tmp1_path	tmp2_path	tmp3_path	tmp5_patht2_path	tmp4_pathbroken_link_pathbroken_link2_pathbroken_link3_pathrIrts               rrkzWalkTests.setUp	sw|	()*:;;;&i.88dnf55$t~w77D00	T)W--
D00	D00	DF++	DV,,	i00$y'11D)7F;;	4	=99 DN;; DN;;	DO$$$
I
J
Gy)Y	I	O	ODdC'222
Oa
(MMNNN
O
O
O
O
O
O
O
O
O
O
O
O
O
O
O ""		>Jrww//@@@Jx!14888JttFH--/@$GGGJttGV,,.?FFF''6):'''(DNN('VH=DN$	$HZ###	&Jz"""
HZ...Ii   HZ   q!"1"%%%
	@	@	@OOBHj$,??????	@s$,GG	G	=L**5M#"M#ct||j}|t	|d|ddddk}|dd|dd|zz
d|dd|zz
d||d|jddgd	gf||d|z|jd
gdgf||d|z|jggf||dd|zz
|jdS)Nrrrwrrryrrrr)	listrrrHrDsortrrrr9allflippeds   rtest_walk_topdownzWalkTests.test_walk_topdownPsZ499T^,,--S1%%%a&)A,&(Aq	AGOR %%'''AGOQ$$&&&Q$.662BVH!MNNNQ[)DNWIx+PQQQQ[)DOR+DEEEQW_-t~>>>>>rNc
||j}g}||D]7\}}}||||fd|vr|d8|t|d||d|jdgdgf|dd|dd||d|jdS)Nrryrrrrwr)rrappendremoverHrDrr)r9rrrdirsrcs      rtest_walk_prunezWalkTests.test_walk_pruneasI!%9!5!5	$	$D$JJdE*+++~~F###S1%%%Q$.6(VH!EFFFAr
Aq	Q00000rcT|t|jdSr.)rrrrjs rtest_file_like_pathzWalkTests.test_file_like_pathts&Xdn5566666rct||jd}|t	|d||ddddk}|dd|dd|zz
d	|dd|zz
d||d|jdd
gdgf||||jggf|||dz|jdgd
gf||dd|zz
|jdS)NFtopdownrrrwrrryrrrrr)	rrrrHrDrrrrrs   rtest_walk_bottom_upzWalkTests.test_walk_bottom_upws499T^U9;;<<S1c***a&)A,&(Aq	AGOR %%'''AGOQ$$&&&Q.66*:VHE	G	G	GW/2r2	4	4	4Wq[).7)fX>	@	@	@QW_-	)	)	)	)	)rc@tjs|d||jd}|D]A\}}}||jkr0||g||dgdSB|ddS)Nzneed symlink supportTrrz+Didn't follow symlink with followlinks=True)rrr|rrrrHr=)r9walk_itrrrcs     rtest_walk_symlinkzWalkTests.test_walk_symlinks$&&	2MM0111))DND)AA!(	E	ED$t~%%  r***  111&

IICDDDDDrcg}||j|j}t|\}}}||gd}t
j||}t
j||dz}tj||	d|D}	|	||
||	|
||	|D]<}
|
|kr4|t
j||
|	=	tj||dS#tj||wxYw)N)onerrorrz.newcg|]\}}}|	Sr
r
)rrdrts    rrz/WalkTests.test_walk_bad_dir.<locals>.<listcomp>s...71aQ...r)rrrr#rHrrIrKrrprgr)r9errorsrrrrcdir1path1path1newrootsdir2s           rtest_walk_bad_dirzWalkTests.test_walk_bad_dirsZ))DNFM)BB MMdE$$$T4((7<<dVm44
	%"""		'..g...EOOF###UE***Xu---
C
C4<<MM"',,tT":":EBBB
C
Ih&&&&&BIh&&&&s
(BEE#cd}tjtjdtjjgdg|zR}tj|fdt
dD}t
|dzD]S}||rdgnggf}|D]%}t||&tj	|}Tfdt
dD}}t
|dzD]X}|||krdgnggf}|D]%}t||&tj|d}YdS)Ndeeprc>g|]}dS)Frrrjbaser9s  rrz7WalkTests.test_walk_many_open_files.<locals>.<listcomp>s)DDDA4//DDDrrrwc>g|]}dS)Trrrs  rrz7WalkTests.test_walk_many_open_files.<locals>.<listcomp>s)CCC14..CCCr)
rrIrKrrhrrrHr#rV)r9depthrYitersrrXr%rs`      @rtest_walk_many_open_filesz#WalkTests.test_walk_many_open_filessw||I,f55GL.#u...
ADDDDDsDDDuqy!!	#	#AA-C552r2H
5
5  b84444""AACCCCCc

CCCuqy!!	%	%AAIIC552r:H
5
5  b84444Q$$AA		%	%rr.)
rarbrcrrrkrrrrrrrr
rrrrs&&&
E&E&E&N???"1111&777)))*EEE'''*%%%%%rrfwalkzTest needs os.fwalk()cxeZdZdZdZdZdZdZdZdZ	e
jej
dd	Zd
Zd
S)
FwalkTestszTests for os.fwalk().c+DK|j|fi|D]\}}}}|||fVdSr.)r)r9rrrrrcroot_fds       rrzFwalkTests.walksR*4$*S*C*CF*C*C	&	&&D$wu%%%%%	&	&rc$tj|i|Sr.)rrr9rrs   rrzFwalkTests.fwalksx((((rc	&|}|}tjddD]\}}||||||i}t	jdi|D]'\}}}t
|t
|f||<(|jdi|D]U\}}}}	||||	||t
|t
|fVdS)z.
        compare with walk() results.
        TFryrepeat)rr)rrNr
)
r	itertoolsproductrrrsetrrrH)
r9walk_kwargsfwalk_kwargsrrrXrrrcrootfds
          r_compare_to_walkzFwalkTests._compare_to_walksF"&&((#((**(1(9-PQ(R(R(R
	J
	J$G_wOLLLQQQH%'W%;%;{%;%;
9
9!dE"%d))SZZ!8-7TZ-G-G,-G-G
J
J)dE6

dH---  $#d))SZZ1HIIII
J
	J
	JrcNdtji}|||dS)Nr)rrhr)r9rs  rtest_compare_to_walkzFwalkTests.test_compare_to_walks+)*ff-----rc	tjdtj}dtji}|}||d<|||tj|dS#tj|wxYw)N.rr)rr&rrrhrrro)r9rrrs    rtest_dir_fdzFwalkTests.test_dir_fds{	bk**B )"23K&++--L%'L"!!+|<<<HRLLLLLBHRLLLLsAA44B
c	ztjddD]\}}tj|df}|j|d|iD]\}}}}tj|tj||ttj
|t|t|zdS)Nr	ryr
r)rr
rrhrrfstatrrHrr)r9rrrrrrcrs        rtest_yields_correct_dir_fdz%FwalkTests.test_yields_correct_dir_fds(1(9-PQ(R(R(R	R	R$G_#Wd2D-7TZ-_-_-_
R
R)dE6     RZ%7%7!8!8#d))c%jj:PQQQQ

R	R	RrzCannot dup stdout on EmscriptencRtjd}tj|tdD]$}|t
jD]}%tjd}|tj||||dS)Nrw)	rr{rorrrrhrrH)r9minfdrr%newfds     rtest_fd_leakzFwalkTests.test_fd_leaksq		
s		AZZ	 011


q		%(((&&&&&rN)rarbrcrrrrrrrrrrrrrr
rrrrs&&&)))JJJ$...
R
R
RX_@'''!%rrceZdZdZdZdS)BytesWalkTestsTests for os.walk() with bytes.c+Kd|vr|d|d<tjtj|fi|D]\}}}tj|}tt
tj|}tt
tj|}|||fVtt
tj||dd<tt
tj||dd<dSr)rXrrfsencoder_rmap)	r9rrbrootbdirsbfilesrrrcs	         rrzBytesWalkTests.walks&&$*JJ/@$A$AF=!$&GBK,<,<$G$G$G$G	6	6 E5&;u%%DBK//00DR[&1122Eu%%%%CT2233E!!!HSe4455F111II
	6	6rN)rarbrcrrr
rrr!r!s)))	6	6	6	6	6rr!ceZdZdZddZdS)BytesFwalkTestsr"rc/Ktjtj|g|Ri|D]\}}}}tj|}t	ttj|}	t	ttj|}
||	|
|fVt	ttj|	|dd<t	ttj|
|dd<dSr.)rrr$r_rr%)r9rrrr&r'r(topfdrrrcs           rrzBytesFwalkTests.fwalk s+-8BK4D4D+Vt+V+V+Vv+V+V	6	6'E5&%;u%%DBK//00DR[&1122Eue,,,,CT2233E!!!HSe4455F111II
	6	6rN)r)rarbrcrrr
rrr*r*s.))666666rr*c
eZdZdZdZejejpej	ddZ
ejejpej	ddZejejpej	ddZdZ
dZd	S)
MakedirTestscBtjtjdSr.rrLrrhrjs rrkzMakedirTests.setUp+s
!"""""rc
ftj}tj|ddd}tj|tj|dddd}tj||ttjtjtj|dddddtj}tj|tj|dtjddddd}tj|dSNrrdir3dir4dir5dir6)	rrhrrIrKrr~rOcurdir)r9rrIs   rtest_makedirzMakedirTests.test_makedir.sw||D&&&99
Dw||D&&&&AA
D	
'2;	:::w||D&&&&&")TT
Dw||D&")VVV"F,,
Drz$Emscripten's/WASI's umask is a stub.ctjd5tj}tj|d}tj|d}tj|d|tj||tj	|tj
dkr`|tj|j
dzd|tj|j
dzdddddS#1swxYwYdS)Nryrrimntri)r
temp_umaskrhrrIrKrrpr~isdirr!rHrr?)r9rparentrIs    r	test_modezMakedirTests.test_mode=sh

!%
(
(		I		I#DW\\$//F7<<//DKe$$$OOBGNN400111OOBGMM$//000w$  !6!>FFF  !85!@%HHH		I		I		I		I		I		I		I		I		I		I		I		I		I		I		I		I		I		IsD6EEEc:tjtjd}d}tjd}tj|||ttj|||ttj||dtj|ddtj||dtj|tjtj	d	ddS)
NrrFexist_okiT)rrB/)
rrIrKrrhumaskrr~rOr)r9rIrold_masks    r test_exist_ok_existing_directoryz-MakedirTests.test_exist_ok_existing_directoryMs
w||I,f558E??
D$'2;d;;;'2;dUKKK
D%$////
Dtd3333
	BGOOC((4888888rctjtjd}t
j}d}tjd}	tjtj	tjj
}	tjtj||zn"#t$rtjdwxYwtj	tjj
|z|krtjdtj|||ztj||dtj|tjtj	|j
|ztj|||zdtj|dS#tj|wxYw)Nrrr@zCannot set S_ISGID for dir.z No support for S_ISGID dir mode.TrA)rrIrKrrhrS_ISGIDrDS_IMODElstatr?rrrSkipTestr)r9rIrHrrEexisting_testfn_modes      rtest_exist_ok_s_isgid_directoryz,MakedirTests.test_exist_ok_s_isgid_directory_s
w||I,f55,8E??	#'<HY-..6$8$8 
G)+?'+IJJJJ"
G
G
G'(EFFF
G)**2W<GG'(JKKK
KdWn---
KdT2222HT4<(>??7(JKKKKdWnt<<<<HXBHXs%5F("B'&F('CCF((F>ctj}tjtjd}t|dd5}|ddddn#1swxYwY|ttj	||ttj	|d|ttj	|dtj
|dS)	Nrr{rrr;FrAT)rrhrrIrKr&r'r~rOrr)r9rrIrts    r#test_exist_ok_existing_regular_filez0MakedirTests.test_exist_ok_existing_regular_file~sw||I,f55
$g
.
.
.	!
GGENNN															'2;555'2;uEEE'2;tDDD
	$s	A++A/2A/c	tjtjdddddd}tj|s^|tjkrNtj|}tj|s|tjkNtj|dSr2)rrIrKrrhr~rV
removedirsr9rIs  rrzMakedirTests.tearDownsw||I,fff"FF44
'..&&	)493C+C+C7??4((D'..&&	)493C+C+C	
drN)rarbrcrkr8rrrrrr>rFrMrOrr
rrr.r.*s###


X_0.
I
I	
IX_0.99	9X_0.	6					rr.c.eZdZedZdZejee	dddZ
ejeoee
dkddZejeoee
dkd	d
ZedZdS)
ChownFileTestscBtjtjdSr.r0clss r
setUpClasszChownFileTests.setUpClass
!"""""rcNtjtj}|j}|j}ddt
jdtj	ddfD]f}|
ttjtj|||
ttjtj||g|
tjtj|||
tjtjdddS)Ngyrry)rrrrhst_uidst_giddecimalDecimal	fractionsFractionr~rchownassertIsNone)r9ruidgidrns     r*test_chown_uid_gid_arguments_must_be_indexz9ChownFileTests.test_chown_uid_gid_arguments_must_be_indexswy'((kkC!4!4i6HQ6O6OP	Q	QEi93CUCPPPi93CS%PPPP"(9#3S#>>???"(9#3R<<=====r	getgroupszneed os.getgroupsc@tj}t|dkr|d|dd\}}tjt
jj}tjt
j||tjt
jj	}|
||tjt
j||tjt
jj	}|
||dS)Nryztest needs at least 2 groups)rrgrDr|rrrhr\rbr]rH)r9groupsgid_1gid_2rdres      rtest_chown_gidzChownFileTests.test_chown_gidsv;;??MM8999bqbzugi&''.
!3...gi&''.e$$$
!3...gi&''.e$$$$$rrwz0test needs root privilege and more than one userctdd\}}tjtjj}tjtj||tjtjj}|||tjtj||tjtjj}|||dSNry)		all_usersrrrrhr]rbr\rH)r9uid_1uid_2rerds     rtest_chown_with_rootz#ChownFileTests.test_chown_with_roots!!}ugi&''.
!5#...gi&''.e$$$
!5#...gi&''.e$$$$$rz2test needs non-root account and more than one usercVtdd\}}tjtjj}|t5tjtj||tjtj||ddddS#1swxYwYdSrn)	rorrrrhr]r~rrb)r9rprqres    rtest_chown_without_permissionz,ChownFileTests.test_chown_without_permissions!!}ugi&''.



/
/	3	3HY%uc222HY%uc222	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3sABB"%B"cBtjtjdSr.)rrrrhrVs r
tearDownClasszChownFileTests.tearDownClassrYrN)rarbrcclassmethodrXrfrrrrrl
root_in_posixrDrorrrtrvr
rrrTrTs%##[#>>>X[113FGG%%HG% X=33y>>A+=KMM%%MM%X]*Ass9~~/AMOO33OO3##[###rrTc,eZdZdZdZdZdZdZdS)RemoveDirsTestscBtjtjdSr.)rrrrhrjs rrkzRemoveDirsTests.setUps
I$%%%%%rcBtjtjdSr.)rrrhrjs rrzRemoveDirsTests.tearDowns)*****rcRtjtjd}tj|tj|d}tj|tj||tj||tj||tjtjdS)Ndiradirb)	rrIrKrrhrLrQassertFalser~r9r~rs   rtest_remove_allzRemoveDirsTests.test_remove_allsw||I,f55
w||D&))


d--...--...	(899:::::rctjtjd}tj|tj|d}tj|t
tj|dtj||tj	||
tj	||
tj	tjdSNr~rfile.txt)rrIrKrrhrLr+rQrr~rprs   rtest_remove_partialz#RemoveDirsTests.test_remove_partialsw||I,f55
w||D&))
BGLLz22333

d--...t,,---y'78899999rctjtjd}tj|tj|d}tj|t
tj|d|t5tj	|dddn#1swxYwY|
tj||
tj||
tjtjdSr)rrIrKrrhrLr+r~rOrQrpr~rs   rtest_remove_nothingz#RemoveDirsTests.test_remove_nothingsIw||I,f55
w||D&))
BGLLz22333


w
'
'	 	 M$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 t,,---t,,---y'78899999s:CC"CN)rarbrcrkrrrrr
rrrzrzs_&&&+++;;;	:	:	:
:
:
:
:
:rrzzWASI has no /dev/nullceZdZdZdS)DevNullTestsctttjdd5}|d|dddn#1swxYwYttjd5}||dddddS#1swxYwYdS)Nrrhellorr)r&rdevnullr'rorHrrss  rtest_devnullzDevNullTests.test_devnulls
"*dA
&
&	!
GGH
GGIII															"*d
#
#	,qQVVXXs+++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,s#*AAA7)B--B14B1N)rarbrcrr
rrrrs#,,,,,rrc&eZdZdZdZdZdZdS)URandomTestsc|ttjdd|ttjdd|ttjdd|ttjdd|ttjdddS)Nrrwrxrr>)rHrDrurandomrjs rtest_urandom_lengthz URandomTests.test_urandom_lengthsRZ]]++Q///RZ]]++Q///RZ^^,,b111RZ__--s333RZ--..55555rctjd}||ttjd}|||dSN)rrr6r^rr9data1data2s   rtest_urandom_valuezURandomTests.test_urandom_valuesN
2eU+++
2E5)))))rcddd|zddf}td|}|d}|t|||S)N
zimport os, syszdata = os.urandom(%s)zsys.stdout.buffer.write(data)zsys.stdout.buffer.flush()rrw)rKrrHrD)r9countroutrUs     rget_urandom_subprocessz#URandomTests.get_urandom_subprocesssfyy#e++'	)**
tT**QVe,,,
rc|d}|d}|||dSr)rrrs   rtest_urandom_subprocessz$URandomTests.test_urandom_subprocesssD++B//++B//E5)))))rN)rarbrcrrrrr
rrrrsP666***			*****rr	getrandomzneed os.getrandom()cBeZdZedZdZdZdZdZdZ	dS)GetRandomTestsc	tjddS#t$r/}|jtjkrtjdd}~wwxYw)Nrwz%getrandom() syscall fails with ENOSYS)rrrOrPrrrK)rWrZs  rrXzGetRandomTests.setUpClass$s]	LOOOOO			yEL(('(OPPP
	s
A*AActjd}||t|t|ddSr)rrr6r^rHrD)r9rs  rtest_getrandom_typez"GetRandomTests.test_getrandom_type0sI|BdE***TB'''''rcZtjd}||ddS)Nrr)rrrH)r9emptys  rtest_getrandom0zGetRandomTests.test_getrandom05s+Q$$$$$rcV|ttddS)NGRND_RANDOM)rprrrjs rtest_getrandom_randomz$GetRandomTests.test_getrandom_random9s$M2233333rch	tjdtjdS#t$rYdSwxYwNrw)rr
GRND_NONBLOCKBlockingIOErrorrjs rtest_getrandom_nonblockz&GetRandomTests.test_getrandom_nonblock?sD	LB,-----			DD	s#
11ctjd}tjd}|||dSr)rrrrs   rtest_getrandom_valuez#GetRandomTests.test_getrandom_valueGs<R  R  E5)))))rN)
rarbrcrwrXrrrrrr
rrrr"sx		[	(((
%%%444*****rrHAVE_GETENTROPYrwHAVE_GETRANDOMHAVE_GETRANDOM_SYSCALLz*os.random() does not use a file descriptorr=z$VxWorks can't set RLIMIT_NOFILE to 1cNeZdZejeddZdZdZdS)URandomFDTestsz!test requires the resource modulec*d}td|dS)Naif 1:
            import errno
            import os
            import resource

            soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
            resource.setrlimit(resource.RLIMIT_NOFILE, (1, hard_limit))
            try:
                os.urandom(16)
            except OSError as e:
                assert e.errno == errno.EMFILE, e.errno
            else:
                raise AssertionError("OSError not raised")
            rrrs  rtest_urandom_failurez#URandomFDTests.test_urandom_failureYs!
	t$$$$$rc2d}td|\}}}dS)Naif 1:
            import os
            import sys
            import test.support
            os.urandom(4)
            with test.support.SuppressCrashReport():
                os.closerange(3, 256)
            sys.stdout.buffer.write(os.urandom(4))
            -Scr)r9rrcrerrs     rtest_urandom_fd_closedz%URandomFDTests.test_urandom_fd_closedps$(t44Crc"|tjtjt	tjddtj}t
d|\}}}|t|d|	|dd|ddt
d|\}}}|t|d|	||dS)Nsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaif 1:
            import os
            import sys
            import test.support
            os.urandom(4)
            with test.support.SuppressCrashReport():
                for fd in range(3, 256):
                    try:
                        os.close(fd)
                    except OSError:
                        pass
                    else:
                        # Found the urandom fd (XXX hopefully)
                        break
                os.closerange(3, 256)
            with open({TESTFN!r}, 'rb') as f:
                new_fd = f.fileno()
                # Issue #26935: posix allows new_fd and fd to be equal but
                # some libc implementations have dup2 return an error in this
                # case.
                if new_fd != fd:
                    os.dup2(new_fd, fd)
                sys.stdout.buffer.write(os.urandom(4))
                sys.stdout.buffer.write(os.urandom(4))
            )rhrr/rr)
rrrirhr+formatrrHrDr)r9rrrrout2err2s       rtest_urandom_fd_reopenedz'URandomFDTests.test_urandom_fd_reopened~s	
	()*:;;;I$j1110i.//1	
2(t44CS1%%%C!Hc!A#h///)%66D$TA&&&D#&&&&&rN)	rarbrcrrresourcerrrr
rrrrTs_
X#FGG%%HG%,555$'$'$'$'$'rrc#\Kgfd}fd}	tj}tj}tj}|t_|t_||t_V|t_|t_|t_dS#|t_|t_|t_wxYw)z
    Stubs out execv and execve functions when used as context manager.
    Records exec calls. The mock execv and execve functions always raise an
    exception as they would normally never return.
    cRd||ftd)Nexecvzexecv called)rRuntimeErrorr!rcallss  r
mock_execvz#_execvpe_mockup.<locals>.mock_execvs*
gtT*+++>***rchd||fttjd)Nexecvez
execve called)rrOrPENOTDIRrs  rmock_execvez$_execvpe_mockup.<locals>.mock_execves.
hd+,,,em_555rN)rrrr<)r<rr
orig_execvorig_execveorig_defpathrs      @r_execvpe_mockuprs
E+++++66666"X
iz	 BJ	!


	!
!!!!sAB&B+rzneed os.execv()ceZdZejeddZdZdZej	e
edddZdZ
d	Zej	ejd
kddZd
S)	ExecTestsz4avoid triggering a linuxthreads bug: see issue #4970cX|ttjddgddS)Nzno such app-)r~rOrexecvperjs rtest_execvpe_with_bad_programz'ExecTests.test_execvpe_with_bad_programs6	
'2:~)*D	2	2	2	2	2rc@|ttjdd|ttjdg|ttjdd|ttjddgdS)Nnotepadr
r7r)r~rrrrjs rtest_execv_with_bad_arglistz%ExecTests.test_execv_with_bad_arglistsz*bh	2>>>*bh	2>>>*bh	5AAA*bh	B4@@@@@rc|ttjdgd|ttjdgi|ttjddgidS)Nrr)r~rrrrjs rtest_execvpe_with_bad_arglistz'ExecTests.test_execvpe_with_bad_arglistsd*bj)RFFF*bj)RDDD*bj)bT2FFFFFr_execvpez)No internal os._execvpe function to test.ctjdz}|tur;d}tjtj||}|}gd}nMd}gd}tj||}tjdkrtj|}n|}ddi}t5}|ttj
|||t|d	||d
d||ffdddn#1swxYwYt|5}|ttj
|||
|t|d	||d
d|||ffdddn#1swxYwYt5}|}	|tur||	d<n||	d<|ttj
|||	
|t|d	||d
d|||	ffddddS#1swxYwYdS)Nabsolutepaths
executable)sprognamearg1arg2r)prognamerrr:spamrrwrr)r<r6rr9r5)rrJr^rIrKr$r!rr~rrrHrDrOr>r)
r9	test_typeprogram_pathprogramfullpathnative_fullpath	argumentsr1renv_paths
          r_test_internal_execvpez ExecTests._test_internal_execvpesrv.#Gw||BK$=$=wGGH&O555II"G444Iw||L'::Hw$"$+h"7"7"*w

	J%lXy
2
2
2SZZ+++U1XI<'HIII		J	J	J	J	J	J	J	J	J	J	J	J	J	J	J\
2
2
2	?egWiS

:
:
:SZZ+++$$U1X?Y,<=
?
?
?		?	?	?	?	?	?	?	?	?	?	?	?	?	?	?


	D%xxzzHE!!$0!!#/ gWiX

?
?
?SZZ+++$$U1X?Y,AB
D
D
D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	D
	Ds93A+D**D.1D.A.F??GGBI;;I?I?c|ttjdkr|tdSdS)Nr:)rr7rr!r^rjs rtest_internal_execvpe_strz#ExecTests.test_internal_execvpe_strsB##C(((
7d??''.....?rctjddg}tj}d|d<|t5tj|d||dddn#1swxYwYtj}d|d<|t5tj|d||dddn#1swxYwYtj}d|d	<|t5tj|d||ddddS#1swxYwYdS)
NrpasscabbageFRUITVEGETABLErorangeVEGETABLE=cabbageFRUITlemonFRUIT=ORANGE)rBrrrrr~rr)r9rnewenvs   rtest_execve_invalid_envz!ExecTests.test_execve_invalid_envsf-""%.!"


z
*
*	-	-Id1gtV,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-""5w


z
*
*	-	-Id1gtV,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-""!(~


z
*
*	-	-Id1gtV,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-s6
A66A:=A:>C''C+.C+/EE ErzWin32-specific testc	tjddgi|ddS#t$r2}||jdup
|jdkYd}~dSd}~wwxYw)NrargzNo OSError raisedr)rrr=rOrpwinerrorrvs  rtest_execve_with_empty_pathz%ExecTests.test_execve_with_empty_path%s	+Ib5'2&&&
II)*****	C	C	COOAJ$.A!*/BBBBBBBBB	Cs0
A,'A''A,N)rarbrcrrUSING_LINUXTHREADSrrrrrrrrrrBrCrr
rrrrsX_'KMM22MM2AAAGGG
XZ00DFF-D-DFF-D^///
---*X02GHH++IH+++rrrrtc8eZdZdZdZdZdZdZdZdZ	dS)	Win32ErrorTestsc"	tjtj|dtjzdS#t
$rd}YdSt$r2}d}|dtjd|Yd}~dSd}~wwxYw)Nzfile %s must not existFTzfile z% must not exist; os.stat failed with )rrrrhr=rNrO)r9r~rZs   rrkzWin32ErrorTests.setUp2s		CGI$%%%
II.1AABBBBB!			FFFF	1	1	1FIII")))330
1
1
1
1
1
1
1
1
1	1sAB	B'B		Bc|ttjtjtjdzdS)Nz.bak)r~rOrrrrhrjs rrzWin32ErrorTests.test_rename>s0'29i.>	@PQW@WXXXXXrcf|ttjtjdSr.)r~rOrrrrhrjs rtest_removezWin32ErrorTests.test_removeAs%'29i.>?????rcf|ttjtjdSr.)r~rOrrMrrhrjs r
test_chdirzWin32ErrorTests.test_chdirDs%'28Y-=>>>>>rc |tjtjt	tjd5}|ttjtjddddS#1swxYwYdS)Nr%)	rrrirhr&r~rOrrLrss  r
test_mkdirzWin32ErrorTests.test_mkdirGs	()*:;;;
)"C
(
(	CAgrx1ABBB	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	Cs1BB
Bch|ttjtjddSr.)r~rOrrrrhrjs rrzWin32ErrorTests.test_utimeMs''28Y-=tDDDDDrch|ttjtjddSr)r~rOrrrrhrjs r
test_chmodzWin32ErrorTests.test_chmodPs''28Y-=qAAAAArN)
rarbrcrkrrrr	rrr
rrrr0s
C
C
CYYY@@@???CCCEEEBBBBBrrz!Cannot create invalid FD on WASI.cJeZdZgdZdZeD]Zeeedez<dZdZe	j
eedddZ
e	j
eed	d
dZe	j
eedd
dZe	j
eedd
e	jejddZe	j
eedddZe	j
eedddZe	j
eedde	jejpejddZe	j
eedddZe	j
eeddd Ze	j
eed!d"d#Ze	j
eed$d%d&Ze	j
eed'd(d)Ze	j
eed*d+d,Ze	j
eed-d.d/Zejd0Z e	j
eed1d2d3Z!d4S)5
TestInvalidFD)fchdirr{	fdatasyncrfstatvfsfsync	tcgetpgrpttynamecfd}|S)Ncttr*|ttdSdSr.)rrrTr:rss rhelperz(TestInvalidFD.get_single.<locals>.helper[s=A
+

72q>>*****
+
+rr
)rtrs` r
get_singlezTestInvalidFD.get_singleZs#	+	+	+	+	+
rtest_c	|tjg|Ri||d|zdS#t$r0}||jt
jYd}~dSd}~wwxYw)Nz5%r didn't raise an OSError with a bad file descriptor)rmake_bad_fdr=rOrHrPrz)r9rtrrrs     rrTzTestInvalidFD.checkbs	
Ai#%%7777777
IIM




	3	3	3QWek222222222	3s9
A3%A..A3cH|tjddS)Nrr)rTrrrjs rrzTestInvalidFD.test_fdopenks 

29w
/////risattyztest needs os.isatty()cx|tjtjddSNF)rHrrrrrjs rtest_isattyzTestInvalidFD.test_isattyns19#8#:#:;;UCCCCCrr}ztest needs os.closerange()c2tj}tdD]*}tj||zn#t
$rY'wxYw|dkrt
jd|tj	|||zdz
ddS)Nrxryz5Unable to acquire a range of invalid file descriptorsrw)
rrrrrrOrrKrHr})r9rrs   rrzTestInvalidFD.test_closerangers

"
$
$r		A"Q$




q55#GII
Ir26!844d;;;;;s>
A
Adup2ztest needs os.dup2()cF|tjddS)N)rTrr"rjs r	test_dup2zTestInvalidFD.test_dup2s

27Brz@dup2() with negative fds is broken on Emscripten (see gh-102179)ctjttj}|tj||ddg}t
j|dD]\}}||kr|||5|	t5}tj||dddn#1swxYwY||j
jtjdddn#1swxYwYdS)Nriryr
)rfd2)rr&rrrrorr
subTestr~rOr"rHryrPrz)r9valid_fdfdsrr'r|s      rtest_dup2_negative_fdz#TestInvalidFD.test_dup2_negative_fds78R[11(+++

!(Q777	G	GGBSyy\\RS\11GG**733)sC((()))))))))))))))$$S]%8%+FFFGGGGGGGGGGGGGGG	G	Gs6DB?3D?CDC-DD	D	fchmodztest needs os.fchmod()cF|tjddSr)rTrr,rjs rtest_fchmodzTestInvalidFD.test_fchmods

29a     rfchownztest needs os.fchown()cH|tjdddS)Nr)rTrr/rjs rtest_fchownzTestInvalidFD.test_fchowns 

29b"%%%%%r	fpathconfztest needs os.fpathconf()z-musl libc issue on Emscripten/WASI, bpo-46390c|tjd|tjddS)NPC_NAME_MAX)rTrpathconfr2rjs rtest_fpathconfzTestInvalidFD.test_fpathconfs6	

2;
...

2</////r	ftruncateztest needs os.ftruncate()c|tjd|tjddSr)rTrtruncater7rjs rtest_ftruncatezTestInvalidFD.test_ftruncates4

2;"""

2<#####rrztest needs os.lseek()cH|tjdddSr)rTrrrjs r
test_lseekzTestInvalidFD.test_lseeks 

28Q"""""rrztest needs os.read()cF|tjddSr)rTrrrjs rrzTestInvalidFD.test_reads

27Arreadvztest needs os.readv()cftd}|tj|gdS)Nrx)rrTrr>)r9rs  r
test_readvzTestInvalidFD.test_readvs+mm

28cU#####r	tcsetpgrpztest needs os.tcsetpgrp()cF|tjddSr)rTrrArjs rtest_tcsetpgrptzTestInvalidFD.test_tcsetpgrpts

2<#####rr'ztest needs os.write()cF|tjddS)N )rTrr'rjs rrzTestInvalidFD.test_writes

28T"""""rwritevztest needs os.writev()cH|tjdgdS)Nr:)rTrrFrjs rtest_writevzTestInvalidFD.test_writevs 

29vh'''''rc|tj|tjddSNT)rTrget_inheritableset_inheritablerjs rtest_inheritablezTestInvalidFD.test_inheritables4

2%&&&

2%t,,,,,rget_blocking-needs os.get_blocking() and os.set_blocking()c|tj|tjddSrJ)rTrrNset_blockingrjs r
test_blockingzTestInvalidFD.test_blockings4	

2?###

2?D)))))rN)"rarbrcsinglesrrtlocalsrTrrrrrr rr%rrrr+r.r1rr6r:r<rr@rCrrHrrMrRr
rrrrTs^<<<G
,,(jmm000XX..0HIIDDJIDX\224PQQ
<
<RQ
<XV,,.DEE  FE XV,,.DEEX_J
G
G	FE

GXX..0HII!!JI!XX..0HII&&JI&X[113NOOX_0700	PO
0X[113NOO$$PO$XW--/FGG##HG#XV,,.DEEFEXW--/FGG$$HG$X[113NOO$$PO$XW--/FGG##HG#XX..0HII((JI(!W ""--#"-X^44HJJ**JJ***rrrzrequires os.linkc2eZdZdZdZdZdZdZdZdS)	LinkTestsctj|_tjtjdz|_dS)Nr)rrhfile1rrIrKfile2rjs rrkzLinkTests.setUps-%
W\\)"2S"899


rc|j|jfD]5}tj|rtj|6dSr.)rXrYrrIr~ri)r9files  rrzLinkTests.tearDownsHZ,	 	 Dw~~d##
 	$	 	 rc	t|	tj||n/#t$r"}|d|zYd}~nd}~wwxYwt|d5}t|d5}|tj|	|	dddn#1swxYwYddddS#1swxYwYdS)N
os.link(): %sr)
r+rrrr|r&rprIsameopenfiler)r9rXrYrrf2s      r
_test_linkzLinkTests._test_linksE	/GE5!!!!	/	/	/MM/A-........	/
%

	L"d5$&7&7	L2OOBG00biikkJJKKK	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	LsK'
AAA&C37ACC3C	C3"C	#C33C7:C7cF||j|jdSr.)r`rXrYrjs r	test_linkzLinkTests.test_links 
DJ/////rc|t|jtjt|jtjdSr.)r`r^rXrBrOrYrjs rtest_link_byteszLinkTests.test_link_bytessVdj#*C*E*EFFdj#*C*E*EFF	H	H	H	H	Hrc	tjdn"#t$rtjdwxYw|xjdz
c_|jdz|_||j|jdS)Nñz#Unable to encode for this platform.r)rr$UnicodeErrorrrKrXrYr`rjs rtest_unicode_namezLinkTests.test_unicode_names	KK	K	K	K#$IJJJ	K	

f

Z#%

DJ/////s6N)	rarbrcrkrr`rbrdrhr
rrrVrVst:::   
LLL000HHH00000rrVzPosix specific testsceZdZdZdZejeedddZ	ejeedddZ
ejeedd	d
Zejeeddd
ZejeedddZ
ejeeddejdZejeeddejdZejeeddejdZdS)PosixUidGidTestssetuidztest needs os.setuid()c"tjdkr&|ttjd|t
tjd|ttj|jdSNrz
not an int)rgetuidr~rOrlr
OverflowErrorUID_OVERFLOWrjs rtest_setuidzPosixUidGidTests.test_setuid	sj
9;;!gry!444)RY===-D4EFFFFFrsetgidztest needs os.setgid()c0tjdkr-ts&|ttjd|ttjd|ttj|jdSrn)	rroHAVE_WHEEL_GROUPr~rOrsrrpGID_OVERFLOWrjs rtest_setgidzPosixUidGidTests.test_setgid	sp
9;;!$4gry!444)RY===-D4EFFFFFrseteuidztest needs os.seteuid()c"tjdkr&|ttjd|t
tjd|ttj|jdSrn)	rror~rOrxrsetegidrprqrjs rtest_seteuidzPosixUidGidTests.test_seteuid	sj
9;;!grz1555)RZ>>>-T5FGGGGGrrzztest needs os.setegid()c0tjdkr-ts&|ttjd|ttjd|ttj|jdSrn)	rrorur~rOrzrrprvrjs rtest_setegidzPosixUidGidTests.test_setegid	sp
9;;!$4grz1555)RZ>>>-T5FGGGGGrsetreuidztest needs os.setreuid()ctjdkr'|ttjdd|t
tjdd|t
tjdd|ttj|jd|ttjd|jdSrn)rror~rOr~rrprqrjs r
test_setreuidzPosixUidGidTests.test_setreuid	s
9;;!gr{Aq999)R[,BBB)R[!\BBB-d6GKKK-a9JKKKKKrcHtjtjddgdS)Nrz,import os,sys;os.setreuid(-1,-1);sys.exit(0)rrrBrrjs rtest_setreuid_neg1z#PosixUidGidTests.test_setreuid_neg1&	8
	>@	A	A	A	A	Arsetregidztest needs os.setregid()ctjdkr.ts'|ttjdd|ttjdd|ttjdd|ttj|jd|ttjd|jdSrn)	rrorur~rOrrrprvrjs r
test_setregidzPosixUidGidTests.test_setregid/	s9;;!$4gr{Aq999)R[,BBB)R[!\BBB-d6GKKK-a9JKKKKKrcHtjtjddgdS)Nrz,import os,sys;os.setregid(-1,-1);sys.exit(0)rrjs rtest_setregid_neg1z#PosixUidGidTests.test_setregid_neg19	rrN)rarbrcrqrvrrrrrrrwr{r}rrrrrrr
rrrjrjsBLLXX..0HIIGGJIGXX..0HIIGGJIGXY//1JKKHHLKHXY//1JKKHHLKHXZ002LMMLLNMLXZ002LMM W ""AA#"NMAXZ002LMM W ""LL#"NMLXZ002LMM W ""AA#"NMAAArrjcteZdZdZdZdZdZeje	e
dddZdZd	S)
Pep383Testscdtjrtj|_n/tjrtj|_ntj|_tj|j|_gfd}|tjtjr|tjtjr|tjs|	dt|_tj|j	D]}tj
t
j|j|tj|}||jvrt#d|j|dS#t'j|jxYw)Nc	tj|}n#t$rYdSwxYw|dSr.)rr$rPr)fnbytesfns radd_filenamez'Pep383Tests.setUp.<locals>.add_filenameN	sQ
[__%



NN2s
&&z&couldn't create any non-ascii filenamezduplicate filename)rTESTFN_UNENCODABLEr7TESTFN_NONASCIIrhrr$bdirTESTFN_UNICODEr|r	unicodefnrLcreate_empty_filerIrKr_raddshutilr)r9rrrs   @rrkzPep383Tests.setUpD	s'	( 3DHH

&	( 0DHH 'DHK))							Y-...'	7L5666$	4L2333	DMMBCCC
		
'
'+BGLLB,G,GHHH[__''$%9:::""2&&&&
'
'	M$(###s
BFF/c8tj|jdSr.)rrr7rjs rrzPep383Tests.tearDowni	s
dhrc|j}ttj|j}|||tj}	tjtj|ttjttjtjtj|dS#tj|wxYwr.)	rrrrr7rHr5rMrJ)r9rXfoundcurrent_directorys    rtest_listdirzPep383Tests.test_listdirl	s>BJtx(()))))IKK	(HRVS..BJrv4F4F0G0GHHHH&'''''BH&''''s
A;C))C?c|jD]I}ttj|j|d}|JdSNr)rr&rrIrKr7ro)r9rrts   r	test_openzPep383Tests.test_openx	sM.		BRW\\$(B//66A
GGIIII		rr\rqc|jD];}tj|j|}tj|<dSr.)rrrIrKr7r\)r9rfullnames   rtest_statvfszPep383Tests.test_statvfs}	sI.	!	!Bw||DHb11HJx    	!	!rc|jD]9}tjtj|j|:dSr.)rrrrIrKr7)r9rs  r	test_statzPep383Tests.test_stat	sB.	0	0BGBGLL2..////	0	0rN)
rarbrcrkrrrrrrrrrr
rrrrB	s###J   
(
(
(
XY///11!!11!00000rrceZdZdZdZdZejeduddZ	ej
dejdZ
ejd	ZdS)
Win32KillTestsc~ddl}ddlm}ddl}|jjj}|j|_|j|	|j
|j|	|j|	|j|	|jf|_d}tjtjdd|gtjtjtj}||jj||jj||jjd\}}	||	kr||t5|}
|||j|
||
ddd}||dd|
jr.| ||
j!nHtEj#d	|d
z
}||	kr||$dtKj&|j'|| |(|dS)Nrwintypesrunningrz<import sys;sys.stdout.write('{}');sys.stdout.flush();input())rUstderrstdin)rrzPeekNamedPipe failedg?rwz1Did not receive communication from the subprocess))rrmsvcrtrr
PeekNamedPipeBOOLrestypeHANDLEPOINTERc_charDWORDargtypesrPopenrBrrr[rrUrorrpollcreate_string_bufferrD
get_osfhandlersizeofrrnrHrMrsleepr=rkillpidwait)r9sigrrrrrr^rmaxrrslts            r_killzWin32KillTests._kill	st
	


######



.<
 (

"*/"(.."?"?"*."(.."@"@"(.."@"@"(.."@"@"B
"+,26#;;	!8
(2'1&0o777	
)***)***
()))
sckkdiikk1--c#hh77C!=!5!5dk6H6H6J6J!K!K!$fmmC&8&8$dLLDa)?@@@y
  ci&6&6&8&8999JsOOOQJEckkdiikk1
IIIJJJ
#c*****rcD|tjdSr.)rsignalSIGTERMrjs rtest_kill_sigtermz Win32KillTests.test_kill_sigterm	s

6>"""""rc0|ddS)Nr)rrjs r
test_kill_intzWin32KillTests.test_kill_int	s

3rNz
requires mmapcZdtjz}tjdd|}d|d<tjtjtd}tj	||g}tj|tj}|5tjtjD]}|n*||dtj|j|	|tjnQ#tj$r?||d	|YnwxYwddddS#1swxYwYdS)
Nz
test_os_%srrwrzwin_console_handler.pyrz'Subprocess didn't finish initialization)timeoutzsubprocess did not stop on {})uuiduuid1mmaprrIrKrVrrBrrrCREATE_NEW_PROCESS_GROUPrsleeping_retry
SHORT_TIMEOUTrrr=rrTimeoutExpiredr)	r9eventr!tagnamemscriptcmdr^_s	         r_kill_with_eventzWin32KillTests._kill_with_event	s-Ib!W%%!bgooh77688~vw/.8.QSSS	H	H+G,ABB
E
E99;;&E'				CDDDGDHe$$$
H		'"7	8888,
H
H
H				9@@FFGGGGG
H!	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	Hs8%A;F ! EF AF
F FF  F$'F$z.subprocesses aren't inheriting Ctrl+C propertyc<ddlm}ddl}||j}|jjj}||j|jf|_|j|_	||d|
tjddS)NrrCTRL_C_EVENT)
rrrc_intrrSetConsoleCtrlHandlerrrrrrr)r9rrNULLrs     rtest_CTRL_C_EVENTz Win32KillTests.test_CTRL_C_EVENT	s	$#####


,v~~fl++-- &
 6 L*0..*F*F*2-*9&(0
%
	dA&&&f1>BBBBBrcF|tjddS)NCTRL_BREAK_EVENT)rrrrjs rtest_CTRL_BREAK_EVENTz$Win32KillTests.test_CTRL_BREAK_EVENT
s"f57IJJJJJr)rarbrcrrrrrrrskiprrrrr
rrrr	s4+4+4+l###X_TT\?33HH43HBX]CDD W ""CC#"EDC$!W ""KK#"KKKrrc*eZdZdZdZdZdZdZdS)Win32ListdirTestszTest listdir on Windows.c
g|_tdD]}d|z}tjt
j|}d|z}tjt
j|}tj|t|dd5}|	d|zdddn#1swxYwY|j
||g|jdS)NryzSUB%dzFILE%dr{rrz'I'm %s and proud of it. Blame test_os.
)
created_pathsrrrIrKrrhrr&r'extendr)r9rdir_namedir_path	file_name	file_pathrts       rrkzWin32ListdirTests.setUp	
s:q	=	=A{Hw||I$4h??H 1IY%5yAAIK!!!iw777
P1BYNOOO
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P%%x&;<<<<!!!!!sCC		C	cBtjtjdSr.)rrrrhrjs rrzWin32ListdirTests.tearDown
s
i&'''''rc	N|ttjtj|j|ttjtjtjd|jDdS)z-Test when the path is not an "extended" path.c6g|]}tj|Sr
rr$rrIs  rrzCWin32ListdirTests.test_listdir_no_extended_path.<locals>.<listcomp>#
"BBBtT""BBBrN)rHsortedrrrrhrr$rjs rtest_listdir_no_extended_pathz/Win32ListdirTests.test_listdir_no_extended_path
s	
rz)"23344"	$	$	$
	
rz"+i.>"?"?@@AABBt/ABBB	D	D	D	D	Drcdtjtjz}|t
tj||jdtj	tjtjz}|t
tj|d|jDdS)z&Test when the path starts with '\\?\'.\\?\\\?\c6g|]}tj|Sr
rrs  rrz@Win32ListdirTests.test_listdir_extended_path.<locals>.<listcomp>2
rrN)
rrIrrrhrHrrrr$rRs  rtest_listdir_extended_pathz,Win32ListdirTests.test_listdir_extended_path%
s27??9+;<<<rz$''(("	$	$	$
BK	8H(I(IJJJrz$''((BBt/ABBB	D	D	D	D	DrN)rarbrcrrkrrrr
rrrr
s^"""""(((
D
D
D
D
D
D
D
Drrreadlinkzneeds os.readlink()ceZdZdZejeZej	eZ
ej	eZdZdZ
dZdZejdZejdZejdZd	S)

ReadlinkTestsreadlinktestc(tj|}tj|}tjdkr-d}||r
|dd}||r
|dd}|||dS)NrcZ|t|trdndS)Nrr)
startswithrkr^)rYs rrz/ReadlinkTests.assertPathEqual.<locals>.<lambda>B
s,1<<(E22A

	$C$Crr)rrInormcaserBrCrH)r9leftright
has_prefixs    rassertPathEqualzReadlinkTests.assertPathEqual<
sw%%  ''<7""CCJz$
 ABBxz%  
"abb	u%%%%%rc|tj|j|tj|j|tj|j|tj|jdSr.)	rprrIr~filelink_targetfilelinkb_targetrfilelink	filelinkbrjs rrkzReadlinkTests.setUpJ
st';<<===t'<==>>>
667777788888rct|j}|ttj|j|ttj|dSr.)rrr~rOrr)r9rs  rtest_not_symlinkzReadlinkTests.test_not_symlinkP
sO"4#788'2;0DEEE'2;@@@@@rc|ttjd|ttjt	ddS)Nzmissing-link)r~rNrrrrjs rtest_missing_linkzReadlinkTests.test_missing_linkU
sQ+R[.III+R[">22	4	4	4	4	4rctj|j|j|t
j|jt|j}|tj	||jdSr.)
rrrr	rrrirrr)r9r	s  r
test_pathlikezReadlinkTests.test_pathlikeZ
sj

4'777	($-888DM**R[22D4HIIIIIrcFtj|j|j|t
j|jtjt|j}|	||j|
|tdSr.)rrrr
rrrirrrr6r^rRs  rtest_pathlike_bytesz!ReadlinkTests.test_pathlike_bytesa
s

4($.999	($.999{8DN3344T4#8999dE*****rc,tj|j|j|t
j|jtj|j}|||j|	|tdSr.)rrrr
rrrirrr6r^rRs  r
test_byteszReadlinkTests.test_bytesi
sx

4($.999	($.999{4>**T4#8999dE*****rN)rarbrcr	rrIrrrr$r
rrrkrrrskip_unless_symlinkrrrr
rrrr5
sHgooh//OH%%I"r{?33&&&999AAA
444
"JJ#"J"++#"+"++#"+++rrcbeZdZdZejeZdZ	ej
eZdZdZ
dZdZdZdZd	Zd
ZdZdZd
ZejejdoejdddZdZdZdS)Win32SymlinkTestsfilelinktestdirlinktestzmissing linkcdSr.r
rjs rrkzWin32SymlinkTests.setUp{
rcxtj|jrtj|jtj|jrtj|jtj|jrtj|jdSdSr.)	rrIr~r	rdirlinkrrgmissing_linkrjs rrzWin32SymlinkTests.tearDown
s
7>>$-((	%Idm$$$
7>>$,''	#HT\"""
7??4,--	)Id'(((((	)	)rctj|j|j|tj|j|tj|j|tj|j|	|j|jdSr.)
rrdirlink_targetrrprIr~r<islink
check_statrjs rtest_directory_linkz%Win32SymlinkTests.test_directory_link
s

4&555t|44555

dl33444t|44555d&9:::::rctj|j|j|tj|j|tj|j|tj|j|	|j|jdSr.)
rrrr	rprIr~isfiler!r"rjs rtest_file_linkz Win32SymlinkTests.test_file_link
s

4'777t}55666t}55666t}55666
t';<<<<<rc|j}tj|rtj|d}d}tj|||dS)z2Create a "directory" link to a non-existent targetz"c:\\target does not exist.29r3c740TN)rrrIrgrr)r9linknamer
target_is_dirs    r_create_missing_dir_linkz*Win32SymlinkTests._create_missing_dir_link
sT$
7??8$$	 Ih6


68]33333rc`|tj|jdSr.)r*rrrrjs r,test_remove_directory_link_to_missing_targetz>Win32SymlinkTests.test_remove_directory_link_to_missing_target
s/%%'''		$#$$$$$rc||tj|jdSr.)r*rrrIr<rrjs r.test_isdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_isdir_on_directory_link_to_missing_target
s?%%'''t'899:::::rc`|tj|jdSr.)r*rrrrjs r.test_rmdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_rmdir_on_directory_link_to_missing_target
s-%%'''
"#####rc|tj|tj||tj|tj|tj|}|tj|tj||tj|tj|dSr.)rHrrrrJr$)r9rr
bytes_links    rr"zWin32SymlinkTests.check_stat
s888BHTNNBGDMM:::[&&
,,bgfoo>>>BHZ00"'*2E2EFFFFFrctjtj}tj|d}tj|d}|tj|tj|tj|tj|tjtj|d}t|tj
}	tj|tj|d}tjtj
|d|dtjtj
|tj|tjdtj||tj|tjtj
|tj||tj|tjtj
|tj|dS#tj|wxYw)Nlevel2level3rXr)rrIrrrhrKrrrLr+r5rMrrelpathrrrHr)r9level1r4r5rXorig_dirrs       r
test_12084zWin32SymlinkTests.test_12084
s'!122fh//fh//	(&111


VW = =>>E9;;	HV7<<//DJrwu--v666MM&"*RY[["9"9:::
RWU^^RWV__===
HVRWU^^WRW__T%:%:;;
=
=
=
HVRWU^^WRW__T%:%:;;
=
=
=
HXBHXs
&F/K++LC:\Users\All UsersC:\ProgramDatazTest directories not foundctjd}|tj|ddS)Nr:r;)rrrprIsamefile)r9rs  r
test_29248zWin32SymlinkTests.test_29248
s?233((1BCCDDDDDrcd}tjj|gdz}d|z|f||f|dd|ddfg}|D]\}}	tj||	tj|n #t
$rYnwxYw#t$rYnwxYw	tjtj|tj|	tj|#t
$rYwxYw#t$rYwxYwdS)NXXXXXXXXXXXXXXXXXXXXXXXXXXXrxr)rrIrKrrrOrNr$)r9segmentrI
test_casesrdests      rtest_buffer_overflowz&Win32SymlinkTests.test_buffer_overflow
s^w|gY^,D['"
dO
$3$Zdsd$


$		IC

3%%%IdOOOOD%





2;s++R[->->???IdOOOOD%



		sHA;A++
A87A8;
BB9C+C
C('C(+
C87C8ctjdtjs|dfdtjtjdD}|D]}tj	rttd|tj|}||tj
||tj|j||jtjdS|ddS)Nz$%LOCALAPPDATA%\Microsoft\WindowsAppsz%test requires a WindowsApps directorycPg|]"}tj|#Sr
)rrIrK)rrArs  rrz6Win32SymlinkTests.test_appexeclink.<locals>.<listcomp>s?GGG7<<a((GGGrz*.exezTesting withz$test requires an app execution alias)rrI
expandvarsr<r|fnmatchfilterrrrRrSrJrHrrS_ISLNKr?st_reparse_tagIO_REPARSE_TAG_APPEXECLINK)r9aliasesaliasrrs    @rtest_appexeclinkz"Win32SymlinkTests.test_appexeclinksEw!!"IJJw}}T""	CMMABBBGGGG#N2:d+;+;WEEGGG	B	BE
-ne,,,%BR000T\"*55666R.0OPPPEEMM@AAAAArN)rarbrcr	rrIrrrrrVr rrkrr#r&r*r,r.r0r"r9rrrgr~r>rErPr
rrrrr
seHgooh//OGW___55N!L555)));;;===444%%%;;;$$$GGG!!!FX)>??B "/@ A A8::
E
E::
E!!!FBBBBBrrceZdZdZejejeZ	dZ
dZdZdZ
dS)Win32JunctionTestsjunctiontestcdSr.r
rjs rrkzWin32JunctionTests.setUp(rrctj|jrtj|jdSdSr.)rrIrgjunctionrirjs rrzWin32JunctionTests.tearDown,s<
7??4=))	%Idm$$$$$	%	%rctj|j|j|t
j|j|t
j|j|t
j	|j|
tj|jtj|j|
tj|jtj|j|t
j|j|
t
jd|jzt
jtj|jdS)Nr)_winapiCreateJunctionjunction_targetrVrprrIrgr~r<rrrJrHrr!rrrjs rtest_create_junctionz'Win32JunctionTests.test_create_junction0sct3T]CCC
66777t}55666

dm44555BGDM22BHT]4K4KLLL//9M1N1NOOO	

66777)))d6J*JKK))"+dm*D*DEE	G	G	G	G	Grctj|j|j|t
j|j|t
j|jtj	|j|
t
j|jdSr.)rXrYrZrVrprrIr~rgrirrjs rtest_unlink_removes_junctionz/Win32JunctionTests.test_unlink_removes_junction=st3T]CCCt}55666
66777
	$-   
6677777rN)rarbrcrVrrIrVrrrZrkrr[r]r
rrrRrR#syHgoobgooh&?&?@@O222%%%GGG88888rrRcDeZdZdZejdZdS)Win32NtTestsctjd}tjd}ddl}|dd}|jj|j_|jj|j	_|jj|jj
f|j	_|}|j}|	||
|}|d||j}dd	d
t g}t#dD]S}	|D]N}
	||
n#t&$rYnwxYw	t)j|
?#t&$rYKwxYwT|	||
|}|d||j|z
}|d|dS)Nr:rrzKernel32.dllT)use_last_errorrwz\\?\C:z\\?\NULz	\\?\CONINrx)r
import_modulectypes.wintypesWinDLLrrGetCurrentProcessrrGetProcessHandleCountLPDWORDrrbyrefrHrnrr_getfinalpathname	Exceptionrr)r9r:rkernelhprochandle_countrbefore_count	filenamesrr!handle_deltas            rtest_getfinalpathname_handlesz*Win32NtTests.test_getfinalpathname_handlesGs

(
.
.,X66~dCC+1?+A (/5/C$,171G171H1J$-((**,,..

)
)%l1K1K
L
LB#)
	
	r
	
	A!	
	
((.... DGDMMMM D	

)
)%l1K1K
L
LB#)L8L)))))s$&D<<
E	E	
E""
E/.E/c	ztj}|tj|t	jdz}tjd}tjtj
d||t|g5}t	j|krD	tj
|n#t$r
}Yd}~nd}~wwxYwt	j|kD	|dn)#tj$r|YnwxYwddddS#1swxYwYdS)Nra            import os
            import sys
            import time

            filename = sys.argv[1]
            deadline = float(sys.argv[2])

            while time.time() < deadline:
                try:
                    with open(filename, "w") as f:
                        pass
                except OSError:
                    pass
                try:
                    os.remove(filename)
                except OSError:
                    pass
            rrw)rrhrrirtextwrapdedentrrrBrr7rrrNrr	terminate)r9r(deadlinecommandr^rs      rtest_stat_unlink_racez"Win32NtTests.test_stat_unlink_racews$	((3339;;?/#(
s~tWhH

V
W
W		![_)++((+GH%%%%(+++++++++)++((

!		!,
!
!
!     
!		!		!		!		!		!		!		!		!		!		!		!		!		!		!		!		!		!		!sZD0 B54D05
C	?D0C		D0$C:9D0:#D D0D  D00D47D4N)rarbrcrqrrrxr
rrr_r_EsK.*.*.*`!W ""'!'!#"'!'!'!rr_c eZdZdZdZdZdS)NonLocalSymlinkTestsc.tjddS)zM
        Create this structure:

        base
         \___ some_dir
        z
base/some_dirN)rrrjs rrkzNonLocalSymlinkTests.setUps	O$$$$$rc.tjddS)Nr)rrrjs rrzNonLocalSymlinkTests.tearDowns
frcptjdd}tjd|dS)a
        The symlink target should resolve relative to the link, not relative
        to the current directory.

        Then, link base/some_link -> base/some_dir and ensure that some_link
        is resolved as a directory.

        In issue13772, it was discovered that directory detection failed if
        the symlink target was not specified relative to the current
        directory, which was a defect in the implementation.
        r	some_linksome_dirN)rrIrKr)r9rs  rtest_directory_link_nonlocalz1NonLocalSymlinkTests.test_directory_link_nonlocals1gll6;//

:s#####rN)rarbrcrkrrr
rrrzrzsA%%%"""""rrzceZdZdZdZdS)FSEncodingTestsc|tjdd|tjdddS)NsabcuabcŁ)rHrr$r_rjs rtest_nopzFSEncodingTests.test_nopsHZ00*===[11;?????rcdD]P}	tj|}n#t$rY$wxYw|tj||QdS)N)u	unicodeŁulatinéascii)rr$rPrHr_)r9rrs   r
test_identityzFSEncodingTests.test_identitysr9	7	7B
+b//%



R[1126666	7	7s
((N)rarbrcrrr
rrrrs5@@@77777rrceZdZdZejejdo<eo1e	j
dpee
doee
ddejejddZd	S)
DeviceEncodingTestscT|tjddS)Ni@)rcrdevice_encodingrjs rtest_bad_fdzDeviceEncodingTests.test_bad_fds'",V4455555rrwinnl_langinfoCODESETz>test requires a tty and either Windows or nl_langinfo(CODESET)z*Cannot get encoding of stdin on Emscriptenctjd}|||t	j|dSr)rrassertIsNotNonerpcodecslookup)r9rs  rtest_device_encodingz(DeviceEncodingTests.test_device_encodingsJ%a((X&&&
h//00000rN)rarbrcrrrrrrrBrCrrlocalerrrrr
rrrrs666X1Mllnn*<M#,BYBYZ_B`B`CL
WV]
+
+
J	0J0JLNNX_K11NN111rrc>eZdZejeedddZddZdZ	dZ
ejejdkd	d
Z
ejejdkd	dZejeedd
dZdS)PidTestsgetppidztest needs os.getppidctjtjddgtj}|\}}|t|tj	dS)Nrzimport os; print(os.getppid()))rU)
rrrBrr[communicaterHr#rgetpid)r9rYrUrs    rtest_getppidzPidTests.test_getppidshcnd>@$.O
5
5
5MMOO	Vbikk22222rNctjdkrdtjddd|dg}ntjd|g}tjtjtj|}|||tj|d\}}|tj|||||dS)Nr"rr)	rBrCrrspawnvP_NOWAITwaitpidrHwaitstatus_to_exitcode)r9rexitcodecallbackrrpid2statuss        r
check_waitpidzPidTests.check_waitpids<7""*)))4T=DDND$/DiS^T::HSMMMz#q))f26::HEEEs#####rc4|dddS)Nrr)rrrrjs rtest_waitpidzPidTests.test_waitpids!33333rcd}d|d}||||t5tjdddddS#1swxYwYdS)Nzimport sys; sys.exit()rg)rr~rrr)r9rrs   rtest_waitstatus_to_exitcodez$PidTests.test_waitstatus_to_exitcodes2x2224(333


y
)
)	+	+%c***	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+sAA #A rwin32-specific testcDd}d|d}|||dS)Nl:z$import _winapi; _winapi.ExitProcess(rrr)r9STATUS_CONTROL_C_EXITrs   rtest_waitpid_windowszPidTests.test_waitpid_windowss;!+N6KNNN4*?@@@@@rcd}ddd|fD]-}|tj|dz|.|t5tj|dzdzdddn#1swxYwY|t
5tjdddddS#1swxYwYdS)Nrrrwrr/r)rHrrr~rrp)r9max_exitcoders   r#test_waitstatus_to_exitcode_windowsz,PidTests.test_waitstatus_to_exitcode_windowss_"Aq,/	'	'HR6x1}EE%
'
'
'
'

z
*
*	?	?%|a'7A&=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?


}
-
-	*	*%b)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*s$A88A<?A<B??CCSIGKILLzneed signal.SIGKILLc|dtjd}tjfd}|||dS)Nzimport time; time.sleep(rc2tj|dSr.)rr)rsignums rkill_processz?PidTests.test_waitstatus_to_exitcode_kill.<locals>.kill_process'sGC     r)rr)rLONG_TIMEOUTrrr)r9rrrs   @r test_waitstatus_to_exitcode_killz)PidTests.test_waitstatus_to_exitcode_kill"s[A'*>AAA	!	!	!	!	!	
46'LIIIIIrr.)rarbrcrrrrrrrrrBrCrrrrr
rrrrs&XY//1HII33JI3$$$$$444+++X02GHHAAIHAX02GHH
*
*IH
*X335JKKJJLKJJJrrceZdZedZddddZeddZeddZed	d
Z	eddZ
ed
dZeddZeddZ
eddZed
dZeddZeddZeddZed
dZeddZdZeddZeddZdS)
SpawnTestsc>tjdkr|Sd|DS)Nr:cJg|] }d|vrd|dn|!S) r)r)rrs  rrz)SpawnTests.quote_args.<locals>.<listcomp>5s6JJJccSYY[[00
C



cJJJr)rr!)rs r
quote_argszSpawnTests.quote_args/s(7d??KJJTJJJJrFwith_env	use_bytescd|_tj}|tj||sd|jz}njttj|_ttj|_|j|j|j<d|jd|jd}t|dd5}||dddn#1swxYwYtj}|||g}|rHt
j|}d	|D}d
|jD|_||fS)Nzimport sys; sys.exit(%s)z#import sys, os; magic = os.environ[z]; sys.exit(rr{rrc6g|]}tj|Sr
r)rrAs  rrz*SpawnTests.create_args.<locals>.<listcomp>Os 111qBKNN111rcbi|],\}}tj|tj|-Sr
r)rkvs   r
<dictcomp>z*SpawnTests.create_args.<locals>.<dictcomp>Ps>666 AqAA666r)rrrhrrirrrr1r7ruuid4rr&r'rBrrr$r)r9rrr(rr*rrs        rcreate_argszSpawnTests.create_args7s
#	((333		1-
=DDBJ''DH4:<<((DH!%DHTXxxx0D(C'
2
2
2	bHHTNNN															.233	6k'**G11D111D66$(HNN$4$4666DH}s=CC#&C#spawnlc|\}}tjtj|g|R}|||jdSr.)rrrP_WAITrHrr9rrrs    rtest_spawnlzSpawnTests.test_spawnlUsP((**
9RY7$7774=11111rspawnlec|d\}}tjtj|g||jR}|||jdSNT)r)rrrrr1rHrrs    rtest_spawnlezSpawnTests.test_spawnle[s\(($(77
:biB4BBBB4=11111rspawnlpc|\}}tjtj|g|R}|||jdSr.)rrrrrHrrs    rtest_spawnlpzSpawnTests.test_spawnlpasP((**
:bi848884=11111rspawnlpec|d\}}tjtj|g||jR}|||jdSr)rrrrr1rHrrs    r
test_spawnlpezSpawnTests.test_spawnlpegs\(($(77
;ry'CDC$(CCC4=11111rrc:|\}}tjtj||}|||jtjtjt
||}|||jdSr.)rrrrrHrrrs    rtest_spawnvzSpawnTests.test_spawnvms((**
9RY664=1119RY(9(94@@4=11111rspawnvec|d\}}tjtj|||j}|||jdSrrrrrr1rHrrs    rtest_spawnvezSpawnTests.test_spawnvewsS(($(77
:bi$AA4=11111rspawnvpc|\}}tjtj||}|||jdSr.)rrrrrHrrs    rtest_spawnvpzSpawnTests.test_spawnvp}sJ((**
:bi$774=11111rspawnvpec|d\}}tjtj|||j}|||jdSr)rrrrr1rHrrs    r
test_spawnvpezSpawnTests.test_spawnvpesS(($(77
;ry'4BB4=11111rc|\}}tjtj||}t	j||jdS)Nr)rrrrrwait_processr)r9rrrs    rtest_nowaitzSpawnTests.test_nowaitsJ((**
iWd33S4=999999rc|dd\}}tjtj|||j}|||jdS)NTrrrs    rtest_spawnve_byteszSpawnTests.test_spawnve_bytessW(($$(GG
:bi$AA4=11111rc|\}}|ttjtj||ttjtj|ddSNr)rr~rrrrr9r__s   rtest_spawnl_noargszSpawnTests.test_spawnl_noargss[&&((*bigFFF*bigrJJJJJrc|\}}|ttjtj|i|ttjtj|didSr)rr~rrrrrs   rtest_spawnle_noargszSpawnTests.test_spawnle_noargss_&&((*bj"+wKKK*bj"+wBOOOOOrc|\}}|ttjtj|d|ttjtj|g|ttjtj|d|ttjtj|dgdSNr
r7r)rr~rrrrrs   rtest_spawnv_noargszSpawnTests.test_spawnv_noargss&&((*bigrJJJ*bigrJJJ*biguMMM*bigtLLLLLrc|\}}|ttjtj|di|ttjtj|gi|ttjtj|di|ttjtj|dgidSr)rr~rrrrrs   rtest_spawnve_noargszSpawnTests.test_spawnve_noargss&&((*bj"+wBOOO*bj"+wBOOO*bj"+wrRRR*bj"+wbQQQQQrcFtj}||ddg}tj}d|d<	|tj|||}||dn#t$rYnwxYwtj}d|d<	|tj|||}||dn#t$rYnwxYwtj}d|d	<	|tj|||}||dn#t$rYnwxYwtj
}|tj|t|d
d5}|d
dddn#1swxYwY|||g}tj}d|d<|tj|||}||ddS)Nrrrrrrrrr{rrzPimport sys, os
if os.getenv("FRUIT") != "orange=lemon":
    raise AssertionErrorzorange=lemonr)rBrrrrrrrHrrrhrrir&r')r9spawnrrrrr(r*s        r_test_invalid_envzSpawnTests._test_invalid_envs.v677""%.!"	,uRYv>>H
Xs++++			D	""5w	,uRYv>>H
Xs++++			D	""!(~	,uRYv>>H
Xs++++			D	#	((333
(C'
2
2
2	1bHH0
1
1
1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1
233""(w5GT6::1%%%%%sH	A88
BB,C
C('C(D>>
E
EF..F25F2cD|tjdSr.)rrrrjs rtest_spawnve_invalid_envz#SpawnTests.test_spawnve_invalid_envsrz*****rcD|tjdSr.)rrrrjs rtest_spawnvpe_invalid_envz$SpawnTests.test_spawnvpe_invalid_envsr{+++++rN)rarbrcrrrr"rrrrrrrrrrrrrrrrrr
rrrr-sKK\K',u<h22 2
i  22! 2
i  22! 2
j!!22"!2
h22 2i  22! 2
i  22! 2
j!!22"!2
h:: :
i  22! 2hKK K
i  PP! P
hMM Mi  RR! R.&.&.&`i  ++! +j!!,,"!,,,rrz>Skip due to platform/environment differences on *NIX buildbotsgetloginztest needs os.getloginceZdZdZdS)
LoginTestscrtj}|t|ddSr)rrrrD)r9	user_names  r
test_getloginzLoginTests.test_getlogins/KMM	C	NNA.....rN)rarbrcr	r
rrrrs#/////rrgetprioritysetpriorityz'needs os.getpriority and os.setpriorityceZdZdZdZdS)ProgramPriorityTestsz0Tests for os.getpriority() and os.setpriority().c2tjtjtj}tjtjtj|dz	tjtjtj}|dkr|dkrtjd|z|||dz		tjtjtj|dS#t$r!}|j	tj
krYd}~dSd}~wwxYw#	tjtjtj|w#t$r }|j	tj
krYd}~wd}~wwxYwxYw)Nrwz?unable to reliably test setpriority at current nice level of %s)rr
PRIO_PROCESSrrrrKrHrOrPEACCES)r9rnew_priors    rtest_set_get_priorityz*ProgramPriorityTests.test_set_get_prioritys~bory{{;;
r	TAX>>>	~bory{{CCHrzzh"nn')FHL)MNNN  4!84444
r	TBBBBB


9,,-,,,,,

r	TBBBB


9,,-,,,,
sO&A,D51D
D2D--D25F71E)(F)
F3F	FFFN)rarbrcrrr
rrr
r
s+;:rr
sendfileztest needs os.sendfile()c~eZdZddzZejdo5ejdoejdZej	edZ
ej	ejdkdZe
d	Ze
d
ZedZdZd
ZdZedZedZdZdZdZdZdZe
dZe
dZe
edZe
edZe
ej	e e!dddZ"dS)TestSendfiles12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdeilinuxsolarissunosz%requires headers and trailers supportrkz(test is only meaningful on 32-bit buildscDttj|jdSr.)r+rrhDATArVs rrXzTestSendfile.setUpClass
sI$ch/////rcBtjtjdSr.)rrirhrVs rrvzTestSendfile.tearDownClass
s)*****rcK|s3|d{VWV|1dSdSr.)at_eofr)readers rchunkszTestSendfile.chunks!
se--//	&

%%%%%%%%%%--//	&	&	&	&	&rcKdd||2d{V|_||jdS)Nrc"Kg|3d{V}|
6Sr.r
)rr%s  rrz2TestSendfile.handle_new_client.<locals>.<listcomp>'
s.&L&L&L&L&L&L&L&L1q&L&L&L&Ls)rKr 
server_bufferroserver)r9rwriters   rhandle_new_clientzTestSendfile.handle_new_client&
sn XX&L&LF8K8K&L&L&L&L&L&L&L&L&LMMrc<Kd|_tj|jtjd{V|_|jjd}tj	|_
|j
dtj
|j
|d{V|j
|_t!t"jd|_|j|_dS)NrrFr)r#r/start_serverr&rHOSTv4r$socketsgetsocknamesocketclientsetblockingget_running_loopsock_connectrsocknor&rrhr[)r9server_names  r
asyncSetUpzTestSendfile.asyncSetUp+
s #01G1>1EGGGGGGGGk)!,88::moo&&&&((55dk;OOOOOOOOOk((**)400	i&&((rcK|j|j|jd{VdSr.)r[ror-r$wait_closedrjs r
asyncTearDownzTestSendfile.asyncTearDown7
sX	k%%'''''''''''rcPKtjtjg|Ri|d{VSr.)r/	to_threadrr)rrs  rasync_sendfilezTestSendfile.async_sendfile=
s;&r{DTDDDVDDDDDDDDDrcK		tj|i|d{VS#t$r@}|jtjkr|jtjtjfvrYd}~]d}~wwxYw)zfA higher level wrapper representing how an application is
        supposed to use sendfile().
        TN)rr9rOrP
ECONNRESETEAGAINEBUSY)rrrs   rsendfile_wrapperzTestSendfile.sendfile_wrapperA
s
	

)8$I&IIIIIIIII


9 000Y5<"===HHHH
s
A&5A! A!!A&cKd}d}d}|t|jkr||j|j||d{V}|dkrnQ||z
}||z
}|||k||||t|jk||t|j|jtj
|j|j
d{V|t|jt|j||j|jdS)Nr)rDrr>r1rrprHr-shutdownr,	SHUT_RDWRror$r5r#)r9
total_sentoffsetnbytessents     rtest_send_whole_filez!TestSendfile.test_send_whole_fileS
s
3ty>>))..t{DK/5v????????DqyydNF$JOODFN+++VZ0003ty>>))	
S^^444V-...k%%'''''''''T/00#di..AAA+TY77777rcKd}t|jdz}t|j|z
}d}||krX||j|j||d{V}|dkrn)||z
}||z
}|||k||kX|jtj	|j
|jd{V|jt|jdzd}|
|t||
t|jt||
|j|dS)Nrryr@)rDrr>r1rrpr-rAr,rBror$r5rHr#)r9rCrD	must_sendrErFrXs       rtest_send_at_certain_offsetz(TestSendfile.test_send_at_certain_offseti
s
TY1$	NNV+	9$$..t{DK/5v????????DqyydNF$JOODFN+++9$$	
V-...k%%'''''''''9S^^q0112S]]333T/00#h--@@@+X66666rcKt|jdz}	||j|j|dd{V}||dn-#t$r }|jtjkrYd}~nd}~wwxYw|j	
tj|j	
|jd{V||jddS)Nr@rr)rDrr9r1rrHrOrPEINVALr-rAr,rBror$r5r#)r9rDrFrs    rtest_offset_overflowz!TestSendfile.test_offset_overflow
s0TY$&	&,,T[$+-3T;;;;;;;;D
T1%%%%			w%,&&'&&&&		
V-...k%%'''''''''+S11111s(A
B$A??BcK|t5}||j|jddd{Vdddn#1swxYwY||jjtjdS)Nrr@)	r~rOr9r1rrHryrPrLr9rls  rtest_invalid_offsetz TestSendfile.test_invalid_offset
s


w
'
'	J2%%dk4;DIIIIIIIII	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J+U\:::::s)AAAc	K||j|jddd{V|jr.||j|jdddddd{VdSdS)Nrr@)rrrDrr
)rrrDrheaderstrailersr)r9r1rSUPPORT_HEADERS_TRAILERSrjs r
test_keywordszTestSendfile.test_keywords
s!!DK)*$"88	8	8	8	8	8	8	8(	H%%T[-.d.02Q&HH
H
H
H
H
H
H
H
H
H	H	HrcKd}d|jddz}||j|jddddgd{V}||d||z
}d}|t|krt
t||z
d}||j|j||d{V}|dkrn3|||||z
}||z
}|t|k||t||j	
|jd{V|t|jt|dS)	Nrsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyrr@sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyrRi)rr9r1rassertLessEqualrDminr>rHr-ror$r5hashr#)r9rC
expected_datarFrDrEs      rtest_headerszTestSendfile.test_headers
s
/$)CRC.@
((dk1d2<j1I)KKKKKKKKT#3444d
3}----]++j8$??F..t{DK/5v????????Dqyy  v...$JdNF3}----	
S%7%7888k%%'''''''''d0114
3F3FGGGGGrc	Ktjdz}d}|tj|t	||t|d5}||j|ddddgd{V|j	
|jd{V|
|jd	ddddS#1swxYwYdS)
Nrsabcdefrrrs123456s789rSsabcde123456789)rrhrrir+r&r9r1rr-ror$r5rHr#)r9r	file_datarts    r
test_trailerszTestSendfile.test_trailers
su"S(		('222GY'''
'4
 
 	DA%%dk188::q!096/B&DD
D
D
D
D
D
D
DK+))+++++++++T/1BCCC	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	DsB
C..C25C2c	FKd|jj_|t5}||j|jddddzgdzd{Vdddn#1swxYwY||j	j
tjdS)NFrxrarWr$handler_instance
accumulater~rOr9r1rrHryrPrLrOs  rtest_headers_overflow_32bitsz)TestSendfile.test_headers_overflow_32bits
s38$/


w
'
'	F2%%dk4;1/3e|nu.D&FF
F
F
F
F
F
F
F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	
+U\:::::2A,,A03A0c	FKd|jj_|t5}||j|jddddzgdzd{Vdddn#1swxYwY||j	j
tjdS)NFrrbrcrar^rdrOs  rtest_trailers_overflow_32bitsz*TestSendfile.test_trailers_overflow_32bits
s38$/


w
'
'	G2%%dk4;104u~/E&GG
G
G
G
G
G
G
G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	
+U\:::::rhSF_NODISKIOztest needs os.SF_NODISKIOcK	||j|jddtjd{VdS#t
$r+}|jtjtjfvrYd}~dSd}~wwxYw)Nrr@)r)	r9r1rrrkrOrPr=r<)r9rs  r
test_flagszTestSendfile.test_flags
s	%%dk4;4,.N&<<
<
<
<
<
<
<
<
<
<			yel ;;;<;;;;;	s4:
A/ A**A/N)#rarbrcrrBrCrrTrrrequires_headers_trailersmaxsizerequires_32brwrXrvrr r&r3r6r9r>rGrJrMrPrUr\r`rgrjrrrmr
rrrr

s$D#&<#:#:7#C#CC D#&<#:#:9#E#EE D#&<#:#:7#C#CC!4 34L3!5!5&8&s{U':688L00[0++[+&&\&

)
)
)(((EE\E\"888,777.222";;;
HHHHHH.DDD;;\;;;\;X]3346666rrcttdsdS	ttjdd5}	tj|ddn:#t$r-YdddtjtjdSwxYw	dddn#1swxYwYtjtjn##tjtjwxYwdS)NsetxattrFr%r	user.testrT)	rrr&rrhrrrrOri)r*s rsupports_extended_attributesrt
s>2z""u+
)"D!
,
,	
BIIKKs;;;;


								)*****
<																)****	)****4sWCB&(AB&
B)B&*CBB&C&B**C-B*.C C0z(no non-broken extended attribute supportryr'c,eZdZdZdZdZdZdZdS)ExtendedAttributeTestsc>	tj}|tj|t	||t5}|||dfi|dddn#1swxYwY||jj	tj
||}	||	t|||ddfi|t|	}
|
d|t|||
|||dfi|d|||ddtjfi||||dfi|d|t5}|||ddtjfi|dddn#1swxYwY||jj	tj|t5}|||ddtjfi|dddn#1swxYwY||jj	tj
|||ddtjfi||
d|t|||
|||dfi||t5}|||dfi|dddn#1swxYwY||jj	tj
|
d|t|||
||||dfi|d|||ddfi|||||dfi|d|||dfi|t)d	t+d
D}|D]
}|||dfi||t||t|	t|zdS)N	user.testrrsrsbyez
user.test2sfoosaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac3@K|]}d|VdS)zuser.test{}N)r)rrs  rr/z;ExtendedAttributeTests._check_xattrs_str.<locals>.<genexpr>'s0BB!m**1--BBBBBBrrrb)rrhrrir+r~rOrHryrPENODATAr6rrrr
XATTR_REPLACEXATTR_CREATEEEXISTrrr)
r9rgetxattrrrremovexattr	listxattrrrrl
init_xattrxattrmanythings
             r_check_xattrs_strz(ExtendedAttributeTests._check_xattrs_str
s

	("---B


w
'
'	32HR;226222	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3+U];;;Yr]]
j$///QQ{^^S33F333J
		+YYr]]++U333"l==f==sCCCQQ{^^Xr/?JJ6JJJ"l==f==xHHH


w
'
'	L2HR;KKFKKK	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L+U\:::


w
'
'	N2HR<&"2BMMfMMM	N	N	N	N	N	N	N	N	N	N	N	N	N	N	N+U];;;QQ|__fboHHHHH
		,YYr]]++U333B+11&111


w
'
'	32HR;226222	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3+U];;;
[!!!YYr]]++U333"aaoo@@@@&IIIQQ{^^Y99&999"aann????KKKB+11&111BBuSzzBBBBB	0	0EHR//////YYr]]++S__s4yy-HIIIIIsHA66A:=A:* GGG% IIIL33L7:L7c|jtg|Ri|tjtj|jt
jg|Ri|tjtjdSr.)rr7rrirhrr$rs   r
_check_xattrsz$ExtendedAttributeTests._check_xattrs,sxs4T444V444)***r{<T<<<V<<<)*****rc|tjtjtjtjdSr.rrrrrrrrjs rtest_simplez"ExtendedAttributeTests.test_simple3s52;R^<	)	)	)	)	)rc|tjtjtjtjddS)NFrrrjs r
test_lpathz!ExtendedAttributeTests.test_lpath7sA2;R^<		@	@	@	@	@rcNd}d}d}d}|||||dS)Nct|d5}tj|g|RcdddS#1swxYwYdSr)r&rrrrIrr*s   rrz1ExtendedAttributeTests.test_fds.<locals>.getxattr<sdD!!
7R{299;;6666
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7$AA	Act|dd5}tj|g|RddddS#1swxYwYdSNrr)r&rrrrrs   rrrz1ExtendedAttributeTests.test_fds.<locals>.setxattr?sdD!$$
0BIIKK/$////
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0%AAAct|dd5}tj|g|RddddS#1swxYwYdSr)r&rrrrs   rrz4ExtendedAttributeTests.test_fds.<locals>.removexattrBsdD!$$
3ryy{{2T2222
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3rct|d5}tj|g|RcdddS#1swxYwYdSr)r&rrrrs   rrz2ExtendedAttributeTests.test_fds.<locals>.listxattrEsdD!!
8R|BIIKK7$777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8r)r)r9rrrrrs     rtest_fdszExtendedAttributeTests.test_fds;s`	7	7	7	0	0	0	3	3	3	8	8	8	
8X{IFFFFFrN)rarbrcrrrrrr
rrrwrw
sk.J.J.J`+++)))@@@
G
G
G
G
Grrwget_terminal_sizezrequires os.get_terminal_sizeceZdZdZdZdS)
TermsizeTestscJ	tj}nW#t$rJ}tjdks|jt
jt
jfvr|dd}~wwxYw|	|j
d|	|jddS)zCheck if get_terminal_size() returns a meaningful value.

        There's no easy portable way to actually check the size of the
        terminal, so let's check if it returns something sensible instead.
        rfailed to query terminal sizeNr)rrrOrBrCrPrLENOTTYr|assertGreaterEqualcolumnslines)r9rrs   rtest_does_not_crashz!TermsizeTests.test_does_not_crashMs	'))DD			|w&&!'elEL5Q*Q*Q

=>>>		
a000
A.....s
A*AA%%A*ct	tjddgtjd}n7#ttjtf$r|dYnwxYwt|dt|df}	tj
tj
}nW#t$rJ}tjdks|jt jt jfvr|d	d
}~wwxYw|||d
S)zCheck if stty returns the same results

        stty actually tests stdin, so get_terminal_size is invoked on
        stdin explicitly. If stty succeeded, then get_terminal_size()
        should work too.
        sttyrT)rrVzstty invocation failedrwrrrN)rcheck_outputDEVNULLr;rNCalledProcessErrorrr|r#rrrB	__stdin__rrOrCrPrLrrH)r9rrXrrs     rtest_stty_matchzTermsizeTests.test_stty_match_s:	4'V$Z-?d%''
D
":#@!	4	4	4MM233333	4QLL#d1g,,/	)#-*>*>*@*@AAFF			|w&&!'elEL5Q*Q*Q

=>>>		
6*****s(581A,+A,0C
DADDN)rarbrcrrr
rrrrKs2///$+++++rrmemfd_createzrequires os.memfd_createrrceZdZdZdS)MemfdCreateTestsctjdtj}||d|tj||tj|t|dd5}|	d|
|ddddn#1swxYwYtjd}|tj||tj|dS)NHirrF)closefdsmemfd_creater2)rrMFD_CLOEXECrrrorrKr&r'rHtell)r9rrtr's    rtest_memfd_createz"MemfdCreateTests.test_memfd_createsC
_T2>
2
2B###"%%%+B//000
"dE
*
*
*	+a
GGO$$$QVVXXr***	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+od###&&&+C0011111s>CC CN)rarbrcrr
rrrr|s#22222rreventfdzrequires os.eventfdrc eZdZdZdZdZdS)EventfdTestscd}d}d}tj|}||d|tj||tj|tj||}||||tj	||dtj||}|||dtj	||dtj	||dtj||}|||dtj
|dtj
|d	tj|}||ddS)
Nc,tjd|S)z$Pack as native uint64_t
            z@Q)structpack)rns rrz/EventfdTests.test_eventfd_initval.<locals>.packs;tU+++rr/rrr(ryr$r)rrrrrorrKrrHr'
eventfd_writeeventfd_read)r9rrinitvalrress      rtest_eventfd_initvalz!EventfdTests.test_eventfd_initvals	,	,	,
Z
 
 B###"%%%+B//000gb$dd7mm,,,
TT"XXgb$dd2hh'''
TT"XX
TT!WWgb$dd2hh'''	R   
Qob!!b!!!!!rcd}tjtjztjz}tj||}||d|tj|tj|}|	|dtj|}|	|d|
t5tj|dddn#1swxYwY|
t5tj|ddddn#1swxYwYtj
|dtj|}|	|d|
t5tj|ddddS#1swxYwYdS)Nryrrwr/)rEFD_CLOEXEC
EFD_SEMAPHOREEFD_NONBLOCKrrrrorrHr~rrr)r9rrrrs     rtest_eventfd_semaphorez#EventfdTests.test_eventfd_semaphoresY!11BOC
Z
'
'B###"%%%ob!!a   ob!!a   



/
/	 	 OB	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 



/
/		GBNNN																Qob!!a   



/
/	 	 OB	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 s6"DD
D(E

EE.GGGctjtjz}tjd|}||d|tj|tj|g|g|gd\}}}||||fg|ggftj	|dtj|g|g|gd\}}}||||f|g|ggf|tj
|dtj	|dtj|g|g|gd\}}}||||f|gggftj
|dS)Nrrrl)rrrrrrroselectrHrr)r9rrrfdwfdxfds      rtest_eventfd_selectz EventfdTests.test_eventfd_selects0
Z5
!
!B###"%%%
rdRD2$::
S##sC2tR.999	R   
rdRD2$::
S##sCB4"r*:;;;,,b111	[)))
rdRD2$::
S##sCB4R.999
rN)rarbrcrrrr
rrrrsA""">   4rrceZdZdZdZdS)OSErrorTestscrGddt}g|_g|_tj
tj}ntj}|j||j||tj
tj}ntj	tj}|j||jt||jt||j|jz|_dS)NceZdZdS)OSErrorTests.setUp.<locals>.StrNrarbrcr
rrStrrDrr)
r7bytes_filenamesunicode_filenamesrrrhrTESTFN_UNDECODABLErr$rrro)r9rdecodedencodeds    rrkzOSErrorTests.setUps					#			 "!#'32GG&G%%g...%%cc'll333'32GGk)"233G##G,,,##Ig$6$6777##Jw$7$7888-0FFrc

|jtjf|jtjf|jtjtjf|jtjf|jtjf|jtjfg}tj
dkrt||jtj
df|jtjdf|jtj
df|jtjdf|jtjffnM||jtjf|jtj
df|jtjdfft#jr'||jtjdft+tdr(||jtjddft+tdr(||jtjddft+tdr'||jtjdft+td	r'||jtjdft+td
r'||jtjdft+tdr&||jtjft+tdrtj
dkrO||jtjdf||jtjdfn'||jtjdft+td
ra||jtjf|jtjdf|jtjddf|jtj dfft+tdr'||jtj!dft+tdr&||jtj"f|D]^}}}|D]}	tG|tHtJfr
||g|Rn<|&tNd5||g|Rdddn#1swxYwY|(d)|#tT$r3}|+|j,|tI|Yd}~d}~wtZ$rYwxYwdS)Nrsdstrrrbrlchownr9chflagslchflagschrootrrrysuserlchmodrz	should bezNo exception thrown by {}).rorrMrJr&rrrrirBrCrrrrrrr	can_chmodrrrrbrr9rrrrrrrrrrrrkr7r^assertWarnsRegexDeprecationWarningr=rrOrir(UnicodeDecodeError)r9funcsrofunc	func_argsr!rs       rtest_oserror_filenamez"OSErrorTests.test_oserror_filenames"
^RX'
^RX'
^RWbk2
^RX'
^RW&
^RY(

<7""LL%ry&9%rz6:'E:'U;'6




LL-E2U3



  	<LL$."(E:;;;2w	;LL$."(Aq9:::2x  	<LL$.")Q:;;;2z""	;LL$."+q9:::2y!!	:LL$."*a89992z""	;LL$."+q9:::2x  	7LL$.")56662v	?|w&&d2BGVDEEEd4bguEFFFFdnbgu=>>>2{##	LL/k:k7C=	


2x  	=LL$.")U;<<<2z""	9LL$."+7888,1
	H
	H'Iti!
H
HH!$e553T.I.....!223E{SS33 D2	2222333333333333333II9@@FFGGGGAAAMM#,c$ii@@@@@@@@)D
H
	H
	HsCAT

S
T
ST
 S!T

U)U
UUN)rarbrcrkrr
rrrrs?GGG,EHEHEHEHEHrrceZdZdZdS)
CPUCountTestsctj}|3||t||ddS|ddS)Nrz&Could not determine the number of CPUs)r	cpu_countr6r#
assertGreaterr|)r9cpuss  rtest_cpu_countzCPUCountTests.test_cpu_count?s^|~~!!$,,,tQ'''''MMBCCCCCrN)rarbrcrr
rrrr>s(DDDDDrrceZdZdZejeduddZejeduddZej	e
edddZd	Z
d
Zej	e
eddd
ZdZdZej	ejdkddZej	e
edddZej	e
edddZdS)FDInheritanceTestscXtjttj}|tj||tj|dtj|d|tj|ddSNFT)	rr&rrrrorHrKrLrs  rtest_get_set_inheritablez+FDInheritanceTests.test_get_set_inheritableKs
WXr{
+
+"%%%+B//777
2t$$$+B//66666rNz
need fcntlctjttj}|tj||tj|dtj|tj	}|tj
z}tj|tj||tj|ddSr)rr&rrrrorHrKfcntlF_GETFD
FD_CLOEXECF_SETFD)r9rrs   rtest_get_inheritable_cloexecz/FDInheritanceTests.test_get_inheritable_cloexecSs
WXr{
+
+"%%%+B//777B
..
%"""
B
u---+B//66666rctjttj}|tj||tj|tjtj	ztj	tj
|d|tj|tjtj	zddS)NTr)rr&rrrrorHrrrrLrs  rtest_set_inheritable_cloexecz/FDInheritanceTests.test_set_inheritable_cloexec`s
WXr{
+
+"%%%R77%:JJ)	+	+	+	2t$$$R77%:JJ					rO_PATHzneed os.O_PATHctjttj}|tj||tj|dtj|d|tj|dtj|d|tj|ddSr)	rr&rrrrorHrKrLrs  rtest_get_set_inheritable_o_pathz2FDInheritanceTests.test_get_set_inheritable_o_pathks
WXry
)
)"%%%+B//777
2t$$$+B//666
2u%%%+B//77777rctj}|t5}t	j|dddn#1swxYwY||jjtj	|t5}t	j
|ddddn#1swxYwY||jjtj	|t5}t	j
|ddddn#1swxYwY||jjtj	dSNTF)rrr~rOrrKrHryrPrzrL)r9rr|s   rtest_get_set_inheritable_badfz0FDInheritanceTests.test_get_set_inheritable_badfws

"
$
$


w
'
'	#3r"""	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#,ek:::


w
'
'	)3r4(((	)	)	)	)	)	)	)	)	)	)	)	)	)	)	),ek:::


w
'
'	*3r5)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*,ek:::::s5AAACCCD11D58D5ctjttj}|tj||tj|ddSr)rr&rrrrorHrKrs  rrzFDInheritanceTests.test_opensR
WXr{
+
+"%%%+B//77777rr	zneed os.pipe()cRtj\}}|tj||tj||tj|d|tj|ddSr)rr	rrorHrK)r9rrs   r	test_pipezFDInheritanceTests.test_pipes799S#&&&#&&&+C00%888+C00%88888rcFtjttj}|tj|tj|}|tj||tj|ddSr)	rr&rrrror{rHrKr9fd1r's   rtest_dupzFDInheritanceTests.test_dupsugh,,#&&&fSkk#&&&+C00%88888rctjd}|tj|||ddSNrwr)rr{rrorrs  rtest_dup_standard_streamz+FDInheritanceTests.test_dup_standard_streamsA
VAYY"%%%2q!!!!!rrrc:tjdtj}|tj|tj|}|tj||tj|dS)NNUL)rr&rrror{rrKrs   rtest_dup_nulzFDInheritanceTests.test_dup_nulsugeR[))#&&&fSkk#&&&+C0011111rr"zneed os.dup2()ctjttj}|tj|tjttj}|tj||tj||||tj	|tjttj}|tj||tj||d||
tj	|dS)NF)inheritable)rr&rrrrorHr"rprKr)r9rr'fd3s    rr%zFDInheritanceTests.test_dup2s
WXr{
+
+"%%%gh,,#&&&S))3///*3//000gh,,#&&&Se<<<cBBB+C0011111ropenptyzneed os.openpty()cRtj\}}|tj||tj||tj|d|tj|ddSr)rrrrorHrK)r9	master_fdslave_fds   rtest_openptyzFDInheritanceTests.test_openptys jll	8),,,(++++I66>>>+H55u=====r)rarbrcrrrrrrrrrrrrrrrrBrCrr%rr
rrrrIs777X_Ud]L11
7
721
7X_Ud]L1121XX..0@AA	8	8BA	8
;
;
;888
XV,,.>??99@?9999"""
X02GHH22IH2XV,,.>??22@?2 XY//1DEE>>FE>>>rrc
heZdZddddejfdfddddejfeed	dfgZd
ZdZ	dS)PathTConverterTests)rTr
N)rJFr
NrqFN)rFrN)rFrNr&roc	tj}tjdkrdx}}n-tjtj}t|}tjt|tjtjz}|	tj
tj|	tj|t|}t|}|jD]J\}}}	}
|
|5	tt|}n#t$rYdddMwxYw||||fD]J}||
||5||g|	R}
|
|
|
dddn#1swxYwYK|t"d5||g|	Rdddn#1swxYwY|r||g|	R}
|
|
|
n<|t"d5||g|	Rdddn#1swxYwYdddn#1swxYwYLdS)Nr:r )r!rIzto return str or byteszos.PathLike)rrhrr!r$rr&rrmrriro	functionsr(r:r@assertRaisesRegexr)r9str_filenamebytes_fspathbytes_filenamer
int_fspath
str_fspathr!allow_fd
extra_args
cleanup_fnrrIrDs              rtest_path_t_converterz)PathTConverterTests.test_path_t_converters '
7d??,00L>>[)9::N#N33L
WXl++R[-C
D
D	()*:;;;"%%%b\\
l++
6:n	,	,2D(J
4((
,
, T**BB%	
,
,
,
,
,
,
,*>:)+//D| 4d;;//!#D!6:!6!6!6%1&Jv...///////////////
++!#;==00Bz/J////000000000000000,R0Z000F!-"
6***//%)++,,2+
++++,,,,,,,,,,,,,,,1
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,	,	,sH6D-,H6-
E7H6E%H6*F
	H6
F
H6F
H64
G
>H6
GH6G7H6	
HH6H##H6&H#'H66H:	=H:	c.d}|t|dz5tjt	ddddn#1swxYwY|t|dz5tjt	ddddn#1swxYwY|t|dz5tjt	tddddS#1swxYwYdS)Nz-__fspath__\(\) to return str or bytes, not %sr#ryfloatgQ@object)rrrrrr%)r9rs  r&test_path_t_converter_and_custom_classz:PathTConverterTests.test_path_t_converter_and_custom_classs>

#
#IsV|
<
<	!	!GHQKK   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!

#
#IsX~
>
>	$	$GHTNN###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$

#
#IsY
?
?	(	(GHVXX&&'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(s5"AAA8"B&&B*-B*.D

DD)
rarbrcrF_OKrr:rr"r&r
rrrrsv	!"	527*d+&'	GT(B(BC
I*,*,*,X(((((rrrNrOzCannot unset blocking flagceZdZdZdS)
BlockingTestsctjttj}|tj||tj|dtj|d|tj|dtj|d|tj|ddSr)	rr&rrrrorHrNrQrs  rrRzBlockingTests.test_blocking	s
WXr{
+
+"%%%,,d333
E""",,e444
D!!!,,d33333rN)rarbrcrRr
rrr)r)s#	4	4	4	4	4rr)ceZdZdZdS)ExportsTestsc|dtj|dtjdS)Nr&r)rr__all__rjs rtest_os_allzExportsTests.test_os_alls4

fbj)))

fbj)))))rN)rarbrcr/r
rrr,r,s#*****rr,c eZdZdZdZdZdS)TestDirEntryctjtj|_|tj|jtj|jdSr.)rrIrealpathrrhrrrLrjs rrkzTestDirEntry.setUpsMG$$Y%566		($)444
rcP|ttjdSr.)r~rrDirEntryrjs rtest_uninstantiablez TestDirEntry.test_uninstantiable"s )R[11111rcttj|jdd}dtj|jD}||tj||j	dddl
}|t|j
||dS)Nrpythoncg|]}|Sr
r
rentrys  rrz0TestDirEntry.test_unpickable.<locals>.<listcomp>'s:::5:::rr)r+rrIrKscandirrXr6r5rHr!rSr~rrU)r9r(r;rSs    rtest_unpickablezTestDirEntry.test_unpickable%srw||DIzBBINN::BJty$9$9:::>>@@eR[111Z000


)V\5(CCCCCrN)rarbrcrkr6r=r
rrr1r1sF
222DDDDDrr1cFeZdZejZdZd!dZdZdZdZ	dZ
dZd	Zd
Z
d!dZdZd
ZdZdZdZdZdZdZdZejejejvddZejej ddZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(d S)"TestScandirctjtj|_tj|j|_|tj|jtj	|jdSr.)
rrIr3rrhr$
bytes_pathrrrLrjs rrkzTestScandir.setUp1s`G$$Y%566	+di00	($)444
rrct|tr|jn|j}tj||}t
|d|S)Nr8)rkr^rArIrrKr+)r9r!rIr(s    rr+zTestScandir.create_file7sH",T5"9"9Htty7<<d++Hi(((rctdtj|jD}|t|||S)Nc3(K|]
}|j|fVdSr.r r:s  rr/z*TestScandir.get_entries.<locals>.<genexpr>>s=;; 
E*;;;;;;r)rrr<rIrHrkeys)r9namesentriess   rget_entrieszTestScandir.get_entries=sd;;$&Jty$9$9;;;;;//777rc|ret|D]S}|ds|dvr|t||t|||||fTdS|||dS)Nst_)st_devst_inost_nlink)r7rrHr:)r9stat1stat2skip_fieldsrFs     rassert_stat_equalzTestScandir.assert_stat_equalCs
	+E


7
7u--;;;  !5!5!(!5!5"'!57777
7
7
UE*****rctj|j}|tt||dSr.)rr<rIr~rrro)r9scandir_iters  rr6zTestScandir.test_uninstantiablePsIz$),,)T,%7%7888rc|d}tj|j}ddl}|t|j|||dS)Nrr)	r+rr<rIrSr~rrUro)r9r(rSrSs    rr=zTestScandir.test_unpickableUsc##J//z$),,


)V\<JJJrcf||tj||j|||jtj|j|||tj|jdj	tj|j}||
tj|j||
tj|j||tj|jtj|jd}||
dtj|j||
dtj|j|||tjdko|||d|tjdkdS)NFrr:)r6rr5rHr!rIrKinoderrLis_dirS_ISDIRr?is_fileS_ISREG
is_symlinkr!rQ)r9r;r!rWrYr[
entry_statentry_lstats        rcheck_entryzTestScandir.check_entry\sJeR[111T***RW\\$)T%B%BCCCUCCCJ	L	L	LWUZ((
j&899	;	;	;j&899	;	;	;))++
33	5	5	5gej%@@@e<<k&9::	<	<	<u==k&9::	<	<	<	
uzz||)!w$Az>	C	C	C	
uzz%z@@*!w$	0	0	0	0	0rcttd}tj}tj|jd}tj||d}|ri	tj|tj|jdn/#t$r"}|
d|zYd}~nd}~wwxYw|rrtj|tj|jddtj|tj|jd	ddg}|r|d|r|
d
||}|d}||dddd|d}||dddd|r!|d}||dddd|rD|d}||dddd|d	}||d	ddddSdS)Nrr7rz
link_file.txtr]symlink_dirT)rsymlink_file.txt)r`raF)rrrrrIrKrLr+rrr|rrrrHr^)	r9rrrVr(rrFrGr;s	         rtest_attributeszTestScandir.test_attributesxsgr6""'))',,ty%00
##J//	3
3"',,ty/"J"JKKKK"
3
3
3

o122222222
3	NJwTY
 F F+/
1
1
1
1Jxdi9K!L!LMMM
#	*LL)))	>LL<===""5))tUE:::
#
E4???	IO,EUOUD%HHH	KM*EUM4EEE./EU$6tTJJJJJ	K	Ks:8B33
C=CCct|tr|jn|j}t	tj|}|t|d|d}||j	||Sr)
rkr^rArIrrr<rHrDr!)r9r!rIrGr;s     r	get_entryzTestScandir.get_entrysw",T5"9"9Httyrz$''((Wq)))
T***rc||}|tj|S)Nr )r+rdrrIbasename)r9r!r(s   rcreate_file_entryzTestScandir.create_file_entrys:###..~~bg..x88999rc|}tj}	tj|jtdtjD}|t|	tj
|gtj|dS#tj|wxYw)Nc3(K|]
}|j|fVdSr.r r:s  rr/z5TestScandir.test_current_directory.<locals>.<genexpr>s)II5EJ.IIIIIIr)r+rr5rMrIrr<rHrrErf)r9r(old_dirrGs    rtest_current_directoryz"TestScandir.test_current_directorys##%%)++		HTYIIBJLLIIIIIGVGLLNN33 g..x889
;
;
;
HWBHWsBCC+ct|}|t|ddS)Nz<DirEntry 'file.txt'>)rgrHr0r9r;s  r	test_reprzTestScandir.test_reprs6&&((e&=>>>>>rc|}|tj|tj|jddS)Nr)rgrHrfspathrIrKrms  rtest_fspath_protocolz TestScandir.test_fspath_protocolsK&&((5))27<<	:+N+NOOOOOrcNtjd}||}tj|}||t
||tjtj|j|dS)Nz
bytesfile.txtr )	rr$rgrpr6r^rHrIrK)r9rbytes_entryrps    rtest_fspath_protocol_bytesz&TestScandir.test_fspath_protocol_bytess_55,,.,AA;''fe,,,bk$)&<&<^LL	N	N	N	N	Nrc`tj|jd}tj||d}tj|tjdkr'|||	|
|	|tjdkrL|t|j||ddS||d|t|j|t|jddS)Nr7r:Frr)rrIrKrLrdrr!rprWrrYr[r~rNrVrr)r9rIr;s   rtest_removed_dirzTestScandir.test_removed_dirsMw||DIu--
u%%
7d??OOELLNN+++)))))++,,,
7d??/===JJLLLJJuJ-----u{{}}a000/<<</USSSSSrc|}tj|j||tjdkr'||||	tjdkrL|
t|j|
|
ddS||d|
t|j
|
t|j
ddS)Nr:Frr)rgrrirIrrWr!rprYr[r~rNrVrrrms  rtest_removed_filezTestScandir.test_removed_files,&&((
	%*(((
7d??OOEMMOO,,,))++,,,
7d??/===JJLLLJJuJ-----u{{}}a000/<<</USSSSSrctjs|dS|d}t	j|tj|jd|ddg}|d}t	j	||
|d||
||||
d||d|||t$|j|ddS)Nzcannot create symbolic linkrzsymlink.txtrFr)rrr|r+rrrIrKrHrirrVrrWrYrpr[r~rNr)r9r(rGr;s    rtest_broken_symlinkzTestScandir.test_broken_symlinks$&&	@==!>???##J//

87<<	=99	;	;	;""J
#>??
&
	(5;;==!,,,((()))e<<===u==>>>((**++++UZ888

5
)))))rc	|dtj|j}t	tj|}|t|d||d}||jd||jtjtj	|jddSNrrwrsfile.txt)
r+rr$rIrr<rHrDr!rK)r9
path_bytesrGr;s    rrzTestScandir.test_bytes
s$$$[++
rz*--..Wq'222
[111RW\\$)Z%H%HII	K	K	K	K	Krc
"|dttfD]i}|tj|j}|t5ttj	|}dddn#1swxYwY|
t|d||d}|
|jd|
|jtjtj
|jd|t|jt |t|jt kdSr|)r+rrrr$rIassertWarnsrrr<rHrDr!rKrirr^)r9rWr}rGr;s     rtest_bytes_likezTestScandir.test_bytes_likes$$$j(	3	3CR[3344J!!"455
7
7rz*5566
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7S\\1g666AJEUZ555UZ[di)L)LMM
O
O
OMM$uz**E222MM$uz**E2222	3	3s#"BB	B	z.fd support for listdir required for this test.c |tjtj|ddg}tjrMtjdtj	|jd|
dtj|j5}tj|5}t|}dddn#1swxYwYd|D}|
t|||
|tj||D]"}|
|j|j|
tj||j|
||jdktjtjvrtj|j|}|
||tj|j|d}|
|d|$	ddddS#1swxYwYdS)Nrrcg|]	}|j
Sr
r r:s  rrz'TestScandir.test_fd.<locals>.<listcomp>3s555EUZ555rrF)rrr)rrr<rr+rrrrIrKrrrrHrrr!rpr[rr)r9expected_namesrr%rGrFr;rs        rtest_fdzTestScandir.test_fd&s	


bj".111$$$$ ""	*Jz27<<	6#B#BCCC!!&)))

"49
-
-	LB
#2r((
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#55W555EVE]]N;;;UBJrNN333 
L
L  UZ888  5!1!15:>>>  !1!1!3!3UZ65IJJJ7b000B777B$$UZZ\\2666BNNNB$$UZZZ%F%FKKK
L
	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	L	Ls7<JC-!J-C1	1J4C1	5FJJ
JzWASI maps '' to cwdcR|ttjddSr)r~rNrr<rjs rtest_empty_pathzTestScandir.test_empty_path@s#+RZ<<<<<rc.|dtj|j}t	|}|t
|d|t	|}|t
|d|dS)Nrrwr)r+rr<rIrrHrD)r9rrrGentries2s    rtest_consume_iterator_twicez'TestScandir.test_consume_iterator_twiceDs$$$:di((x..Wq'222>>X844444rcbdigfD](}|ttj|)dS)NgX9v?)r~rrr<)r9objs  rtest_bad_path_typezTestScandir.test_bad_path_typeOs>2r?	:	:CiS9999	:	:rcV|d|dtj|j}t	||||5~ddddS#1swxYwYdSNr	file2.txt)r+rr<rIr#rocheck_no_resource_warningr9rrs  r
test_closezTestScandir.test_closeSs$$$%%%:di((X

+
+
-
-																				sBB"%B"c6|d|dtj|j5}t	|dddn#1swxYwY|5~ddddS#1swxYwYdSr)r+rr<rIr#rrs  rtest_context_managerz TestScandir.test_context_manager^s$$$%%%
Z	
"
"	hNNN															

+
+
-
-																				s$A  A$'A$?BBBc|d|dtj|j5}t	||ddddS#1swxYwYdSr)r+rr<rIr#rors  rtest_context_manager_closez&TestScandir.test_context_manager_closefs$$$%%%
Z	
"
"	hNNNNN																		s$A55A9<A9c|d|d|t5tj|j5}t
|ddzdddn#1swxYwYdddn#1swxYwY|5~ddddS#1swxYwYdS)Nrrrwr)r+r~ZeroDivisionErrorrr<rIr#rrs  rtest_context_manager_exceptionz*TestScandir.test_context_manager_exceptionms$$$%%%


0
1
1		DI&&
(X!














															
+
+
-
-																				sHBB4BB	BB	BBB6CC	C	c|d|dtj|j}t	||t5~tjdddn#1swxYwYtj|j}t||
5~ddddS#1swxYwYdSr)r+rr<rIr#rResourceWarningr
gc_collectrrrs  rtest_resource_warningz!TestScandir.test_resource_warningwsX$$$%%%:di((X


o
.
.	!	!   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!:di((X

+
+
-
-																				s$-BBBC$$C(+C(N)r))rarbrcrrrkr+rHrQr6r=r^rbrdrgrkrnrqrtrvrxrzrrrrrrrrrrrrrrrrrrrr
rrr?r?.s/ / I+++
0008'K'K'KR::::???PPPNNNTTT,TTT&****
K
K
K333 Xr~5IKKLLKKL0X_W_&;<<===<=	5	5	5:::			rr?cdeZdZeejZdZdZdZdZ	dZ
dZdZdZ
d	Zd
S)
TestPEP519cbdD]+}||||,dS)N)rsgoodbyessome/path/and/filerHrp)r9bs  rtest_return_byteszTestPEP519.test_return_bytess><	0	0AQA////	0	0rcbdD]+}||||,dS)N)hellogoodbyezsome/path/and/filer)r9rs  rtest_return_stringzTestPEP519.test_return_strings>9	0	0AQA////	0	0rc dD]}t|}|||||dtj||dtj|dS)N)path/like/objectpath/like/objectrr)rrHrprr$r_)r9rYpathlikes   rtest_fsencode_fsdecodez!TestPEP519.test_fsencode_fsdecodes8	H	HA{{HQH 5 56660"+h2G2GHHH/X1F1FGGGG	H	HrcJ|d|td|t	tt
j|ttdt
jdS)Nz#feelthegilr%)rHrprrp
issubclassrPathLikerkrjs rrzTestPEP519.test_pathlikestH]4K4K(L(LMMM
8R[99:::
8C=="+>>?????rctddi}ttt|fD]#}|t|j|$dS)Nblahr
)rr#rr~rrp)r9vaporos   rtest_garbage_in_exception_outz(TestPEP519.test_garbage_in_exception_outsXVR$$dB'	9	9Aia8888	9	9rcF|t|jdSr.)r~rrprjs rtest_argument_requiredz!TestPEP519.test_argument_requireds )T[11111rcX|t|jtdt	ddi}d|_|t|j||t|jtt
dS)Nrfoor
rw)r~rrprr
__fspath__r)r9cs  rtest_bad_pathlikezTestPEP519.test_bad_pathlikes)T[(2,,???B)T[!!##666+T["#4#6#677	9	9	9	9	9rcGddtj}|tt||tttjdS)NceZdZdS)0TestPEP519.test_pathlike_subclasshook.<locals>.ANrr
rrArrrr)rrrrrrp)r9rs  rtest_pathlike_subclasshookz%TestPEP519.test_pathlike_subclasshooksp								Ha00111
8R[99:::::rcp|tjttjdSr.)r6rrr^typesGenericAliasrjs rtest_pathlike_class_getitemz&TestPEP519.test_pathlike_class_getitems(bk%0%2DEEEEErN)rarbrcrrrprrrrrrrrrr
rrrrs\")
$
$F000000HHH@@@
999
222	9	9	9;;;FFFFFrrceZdZdZdS)
TimesTestsctj}||tjdD]-}t	||}||t
.tjdkrS||jd||j	d||j
ddSdS)N)usersystem
children_userchildren_systemelapsedr:r)rrr6times_resultr:r$r!rHrrr)r9rfieldrns    r
test_timeszTimesTests.test_timess

eR_555!	0	0EE5))E!!%////
7d??U0!444U2A666U]A.....?rN)rarbrcrr
rrrrs#/////rrceZdZdZdS)	ForkTestscNd}td|td|ddS)Nzif 1:
            import os
            from test import support
            pid = os.fork()
            if pid != 0:
                support.wait_process(pid, exitcode=0)
        rmalloc_debug)PYTHONMALLOCrrs  r	test_forkzForkTests.test_forks6	t$$$t.AAAAAArN)rarbrcrr
rrrrs(BBBBBrr_fspathc2eZdZdZeejZdS)TestPEP519PurePythonz>Explicitly test the pure Python implementation of os.fspath().N)rarbrcrrrrrpr
rrrrs%LLbj))rr__main__)r#r.)r/r
contextlibr^rPrIr`rrrrSrrrr,rrrrB	sysconfigrErsrrrrr@testrtest.supportrrrrrCrrImportErrorrrXpwdgetpwallror@	_testcapirrrortest.support.script_helperrrtest.support.os_helperrrxrrrversionrrgetgidrur"r+rrr1TestCaser3rerrrBasicTestMappingProtocolrrrrr!r*r.skip_unless_working_chmodrTrzrrrrget_config_varOS_URANDOM_DONT_USE_FDrcontextmanagerrrrrrVrjrrrrrrrRr_rzrrrrrrrr
IsolatedAsyncioTestCaserrtrequires_linux_versionrwrrrrrrrrr)r,r1r?rr
requires_forkrrramainr
rr<module>rs








				



























&&&&&&""""""&&&&&&((((((!!!!!!OOOOHHHLLLLEEENNNNGGGJJJ22<3<>>222II^$III+111111111+++"{*Gnnn+KKKKDDD877777######++++++

72y(RZ\\Q&M73
3?#:0;;NKK<**955J)")++:JKKK'xs|'>'>u'E'E'NPP(((A8A8A8A8A8!A8A8A8JZ8Z8Z8Z8Z8!Z8Z8Z8|
a7a7a7a7a7*a7a7a7HXAXAXAXAXA"XAXAXAvnJnJnJnJnJ=9nJnJnJb	C%C%C%C%C%!C%C%C%LWWR))+BCCG%G%G%G%G%G%G%DCG%T66666Y666WWR))+BCC	6	6	6	6	6j	6	6DC	6ggggg8$gggT$8#8#8#8#8#X&8#8#%$8#v&:&:&:&:&:h'&:&:&:R"9::,,,,,8$,,;:,*****8$***>WWR--/DEE'*'*'*'*'*X&'*'*FE'*ZI.//14?y 011Q6?y 899Q>
'=??*799J'J'J'J'J'X&J'J'99??J'Z""""@WWR))&((e+e+e+e+e+!e+e+((e+PS\W,.DEE B B B B Bh' B BFE BF"EFF}*}*}*}*}*H%}*}*GF}*@WWR((*<==#0#0#0#0#0!#0#0>=#0J(*@AADADADADADAx(DADABADAL(*@AAE0E0E0E0E0(#E0E0BAE0NS\W,.DEEwKwKwKwKwKX&wKwKFEwKtS\W,.DEE,D,D,D,D,D),D,DFE,D^WWR,,.CDD9+9+9+9+9+H%9+9+ED9+xS\W,.DEE
mBmBmBmBmB)mBmBFEmB^S\W,.DEE88888*88FE8BS\W,.DEEY!Y!Y!Y!Y!8$Y!Y!FEY!x"""""8,""">77777h'777 11111(+111$EJEJEJEJEJx EJEJEJPz,z,z,z,z,"z,z,z,~OPPWWR,,.FGG/////"//HGQP/WWR//NGGB
4N4N>@@8,@@,WWR,,.HIIUUUUU83UUJIUp


 1133?AA 1b))NGNGNGNGNGX.NGNG*)AANGbWWR!4557VWW-+-+-+-+-+H%-+-+XW-+`WWR002LMM2&&22222x(22'&NM2WWR++-BCC1b))NNNNN8$NN*)DCNb\H\H\H\H\H8$\H\H\H|DDDDDH%DDDv>v>v>v>v>*v>v>v>r?(?(?(?(?((+?(?(?(DWWR00DFF&(DEE
4
4
4
4
4H%
4
4FEFF
4*****8$***DDDDD8$DDD$UUUUU(#UUUp
7F7F7F7F7F"7F7F7Ft
/
/
/
/
/"
/
/
/ BBBBB!BBB"72y******z***zHMOOOOOslBB! B!%B**B43B48B==CCC))	C54C59DDDDD&%D&