
    <e                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d dl"m#Z# 	 d dl$Z$n# e%$ r dZ$Y nw xY w	 d dl&Z&n# e%$ r dZ&Y nw xY w	 d dl'Z'n# e%$ r dZ'Y nw xY w	 d dl(Z(d  e(j)                    D             Z*n# e%e+f$ r g Z*Y nw xY w	 d d	l,m-Z-m.Z. n# e%$ r ej/        xZ-Z.Y nw xY w	 d dl0Z0n# e%$ r dZ0Y nw xY wd d
l1m2Z2 d dlm3Z3 d dl4m5Z5 dZ6 e7e	d          r e	j8                    d k    Z6 e7ed          r,ej9        j:        r ej9        j:        ;                    d          Z<ndZ<ej"        ;                    d          o e	j=                    d k    Z>d Z?ddZ@ ejA        ej"        ;                    d          d          ZBd ZC G d dejD                  ZE G d dejD                  ZF G d dejD                  ZG G d dejD                  ZHd d lmIZI  G d! d"eIjJ                  ZK G d# d$ejD                  ZL ejM         e7e	d%          d&           G d' d(eL                      ZN G d) d*eL          ZO ejM         e7e	d%          d&           G d+ d,eN                      ZP G d- d.ejD                  ZQejR         G d/ d0ejD                              ZS G d1 d2ejD                  ZT ejA        ejU        d3           G d4 d5ejD                              ZV G d6 d7ejD                  ZW ejM         e7e	d8          d9           G d: d;ejD                              ZX ejY        d<          d=k    p' ejY        d>          d=k    p ejY        d?          d=k    ZZ ejA        eZd@           ejA        ej"        dAk    dB           G dC dDejD                                          Z[ej\        ddE            Z] ejM         e7e	dF          dG           G dH dIejD                              Z^ ejM        ej"        dJk    dK           G dL dMejD                              Z_ ejA        ejU        dN           G dO dPejD                              Z` ejM         e7e	dQ          dR           G dS dTejD                              Za ejA        ej"        dJk    dU           G dV dWejD                              Zb ejA        ej"        dJk    dU           G dX dYejD                              Zc ejM        ej"        dJk    dK           G dZ d[ejD                              Zd ejM        ej"        dJk    dK           G d\ d]ejD                              Ze ejM         e7e	d^          d_           G d` daejD                              Zf ejM        ej"        dJk    dK          ejg         G db dcejD                                          Zh ejM        ej"        dJk    dK           G dd deejD                              Zi ejM        ej"        dJk    dK           G df dgejD                              Zjejg         G dh diejD                              Zk G dj dkejD                  Zl G dl dmejD                  Zm ejn                     G dn doejD                              Zo ejn                     G dp dqejD                              Zp ejq        dr           ejM         e7e	ds          dt           G du dvejD                                          Zr ejM         e7e	dw          o e7e	dx          dy           G dz d{ejD                              Zs ejM         e7e	d|          d}           G d~ dejt                              Zud Zv ejM         ev            d           ejw        ddd           G d dejD                                          Zx ejM         e7e	d          d           G d dejD                              Zy ejM         e7e	d          d           ejw        dd           G d dejD                                          Zz ejM         e7e	d          d           ejw        ddd           G d dejD                                          Z{ G d dejD                  Z| G d dejD                  Z} ejn                     G d dejD                              Z~ G d dejD                  Z ejM         e7e	d          d           ejA        ej        d           G d dejD                                          Z G d dejD                  Z G d dejD                  Z G d dejD                  Z G d dejD                  Z G d dejD                  Z ej                     G d dejD                              Z e7e	d          r G d de          Zedk    r ej                     dS dS )    N)support)import_helper)	os_helper)socket_helper)warnings_helper)win32_is_iotc                     g | ]	}|j         
S  )pw_uid).0us     #/usr/lib/python3.11/test/test_os.py
<listcomp>r   5   s    222a222    )INT_MAXPY_SSIZE_T_MAXassert_python_ok)
unix_shell)FakePathFgeteuidthread_infolinuxthreadsfreebsdc                 X    t          j        t          t          |           d| z            S )Nzrequires os.%s)unittest
skipUnlesshasattrosnames    r   requires_os_funcr"   X   s%    wr4002BT2IJJJr      contentc                     t          | dd          5 }|                    |           d d d            d S # 1 swxY w Y   d S )Nxbr   )openwrite)filenamecontentfps      r   create_filer+   \   s    	ha	 	  B
                 s   599aixz%on AIX, splice() only accepts socketsc                  .    t          j        d            d S N)asyncioset_event_loop_policyr
   r   r   tearDownModuler1   f   s    !$'''''r   c                        e Zd Zd Zd Zd ZdS )	MiscTestsc                 b    t          j                    }|                     |t                     d S r.   )r   getcwdassertIsInstancestrselfcwds     r   test_getcwdzMiscTests.test_getcwdk   s)    ikkc3'''''r   c                    d}t           j        dk    rd}d}d}|d|t          |          z
  z  z   }t          j                    5 }t          j        |          5 }|}	 t          j                    }| 	                    ||           |t          |          t          t          j
        j                  z   z
  }|dk    rnt          |          |k    r|dk    r
|d |         }t          j
                            ||          }	 t          j        |           t          j        |           n8# t          $ r Y n0t           $ r }	|	j        t"          j        k    rY d }	~	n d }	~	ww xY w|}
t&          j        rt+          d	t          |                      d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )
Ni  vxworks     python_test_dir_aTr   z!Tested current directory length: )sysplatformlentempfileTemporaryDirectoryr   
change_cwdr   r5   assertEqualpathsepjoinmkdirchdirFileNotFoundErrorOSErrorerrnoENAMETOOLONGr   verboseprint)
r9   min_lendirlendirnametmpdirrI   expectedr:   needexcs
             r   test_getcwd_long_pathzMiscTests.test_getcwd_long_patho   sz     <9$$G$SFS\\$9:;(** "	Jf%f-- !J$)++C$$S(333"c#hhRW[1A1A&ABDqyy7||d**taxx")%4%.7<<g66D" ,    " " " "9(:::!EEEE!	"  $H7$: ? JHc#hhHHIIIC!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 "	Jss   F6B(F(D+*F+
E 5F7	E  EFEE  2FF6F"	"F6%F"	&F66F:=F:c                     t          j                    }|                     |t                     |                     t          j        |          t          j                               d S r.   )r   getcwdbr6   bytesrH   fsdecoder5   r8   s     r   test_getcwdbzMiscTests.test_getcwdb   sO    jllc5)))S))29;;77777r   N)__name__
__module____qualname__r;   r[   r`   r
   r   r   r3   r3   j   sE        ( ( (7J 7J 7Jr8 8 8 8 8r   r3   c                      e Zd Zd ZeZd Z ej        ej	        d           ej        ej
        d          d                         Zej        d             Zd Zej         ej        eek     d           ej        ed	z   d
d          d                                     Zd Zd Z ej        ej        dk    d          d             Zd Zd Zd Zd Zd Z ej         eed          d          d             Z  ej         eed          d          d             Z! ej         eed          d          d             Z" ej         eed          d          d             Z# ej         eed          d          e$d                          Z% ej         eed          d          e$d!                         Z& ej         eed          d          e$d"                         Z'd#S )$	FileTestsc                     t           j                            t          j                  r t          j        t          j                   d S d S r.   )r   rI   lexistsr   TESTFNunlinkr9   s    r   setUpzFileTests.setUp   s>    7??9+,, 	(Ii&'''''	( 	(r   c                    t          j        t          j        t           j        t           j        z            }t          j        |           |                     t          j        t          j        t           j	                             d S r.   )
r   r&   r   rh   O_CREATO_RDWRclose
assertTrueaccessW_OKr9   fs     r   test_accesszFileTests.test_access   sU    GI$bj&:;;
	)"2BG<<=====r   z"Test is unstable under Emscripten.zWASI does not support dup.c                 2   t          j        t          j        t           j        t           j        z            }t          j        |          }	 d}||dz   k    rSt          j        |           |dz  }|dk    r|                     d           |t          j        |          }}||dz   k    St          j        |           n# t          j        |           w xY wt          j	        ||dz              | 
                    t          t           j        |d           d S )Nr      
   z%couldn't allocate two consecutive fds      a)r   r&   r   rh   rm   rn   dupro   skipTest
closerangeassertRaisesrO   r'   )r9   firstsecondretriess       r   test_closerangezFileTests.test_closerange   s     	("*RY*>?? 
	GEAI%%1R<<MM"IJJJ &vv EAI%% HVBHV
eUQY''''28UD99999s   AB? ?Cc                     t           j        }t          j        |          }|                     t
          t          j        |d           t          j        |          }|                     ||           d S Nr   )	r   rh   rB   getrefcountr~   	TypeErrorr   renamerH   )r9   rI   oldnews       r   test_renamezFileTests.test_rename   s`    od##)RYa888od##c"""""r   c                    t          t          j        d          5 }|                    d           |                                 |                                }t          j        |dd           t          j        |d          }| 	                    t          |          t                     | 	                    |d           d d d            d S # 1 swxY w Y   d S )Nw+b   spamr      )r&   r   rh   r'   flushfilenor   lseekreadrH   typer^   )r9   fobjfdss       r   	test_readzFileTests.test_read   s    )"E** 	)dJJwJJLLLBHRAAAT!WWe,,,Q(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   B'CCCzneeds INT_MAX < PY_SSIZE_T_MAXrx   rw   F)sizememusedry_runc                 l   |                      t          j        t          j                   t	          t          j        d           t          t          j        d          5 }t          j        |                                |          }d d d            n# 1 swxY w Y   | 	                    |d           d S )Ns   testrb)

addCleanupr   ri   rh   r+   r&   r   r   r   rH   )r9   r   r*   datas       r   test_large_readzFileTests.test_large_read   s     		()*:;;;I$g... )"D)) 	.R7299;;--D	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.
 	w'''''s   (BBBc                 x   t          j        t          j        t           j        t           j        z            }|                     t          t           j        |d           t          j        |d           t          j        |t          d                     t          j        |t          d                     t          j        |           t          t          j        d          5 }|                     |                                                                g d           d d d            d S # 1 swxY w Y   d S )Nbeanss   bacon
s   eggs
s   spam
r   )s   bacons   eggsr   )r   r&   r   rh   rm   O_WRONLYr~   r   r'   	bytearray
memoryviewro   rH   r   
splitlines)r9   r   r   s      r   
test_writezFileTests.test_write   s9   WY%rzBK'?@@)RXr7;;;
Z   
Yy))***
Z	**+++
)"D)) 	.TTYY[[3355,,,. . .	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   %=D//D36D3c                 t    t          j        |t           j        d          }|                     |d           d S )NT)creationflagsshellr   )
subprocesscallCREATE_NEW_CONSOLErH   )r9   argsretcodes      r   write_windows_consolezFileTests.write_windows_console  sA    /$$7	  
 	!$$$$$r   win32z$test specific to the Windows consolec                     d}|                      t          j        d|           |                      t          j        dd|           d S )Nzprint('x' * 100000)-cz-u)r   rB   
executabler9   codes     r   test_write_windows_consolez$FileTests.test_write_windows_console  sE     %""3>4>>>""3>4tDDDDDr   c                     t          j        t          j        t           j                  }t          j        |g|R ddi}|                                 d S )Nencodingutf-8)r   r&   r   rh   O_RDONLYfdopenro   )r9   r   r   rt   s       r   fdopen_helperzFileTests.fdopen_helper  sH    WY%r{33Ib24222'22						r   c                    t          j        t          j        t           j        t           j        z            }t          j        |           |                                  |                     d           |                     dd           d S )Nrd   )r   r&   r   rh   rm   rn   ro   r   r9   r   s     r   test_fdopenzFileTests.test_fdopen  sn    WY%rz")';<<
33$$$$$r   c                 P   t           j        dz   }|                     t           j        t           j                   |                     t           j        |           t	          t           j        d           t	          |d           t          j        t           j        |           |                     t          t
          j	        t           j                   t          |dd          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Nz.2   1   2r   r   r   1)r   rh   r   ri   r+   r   replacer~   rN   statr&   rH   r   )r9   TESTFN2rt   s      r   test_replacezFileTests.test_replace&  s*   "T)	()*:;;;	('222I$d+++GT"""

9#W---+RWi6FGGG'3111 	,QQVVXXs+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   %)DD"Dc                 |    t          j        t          t           j        dd           }t          j        |           d S )N  )rI   flagsmodedir_fd)r   r&   __file__r   ro   rs   s     r   test_open_keywordszFileTests.test_open_keywords3  s4    G5  
r   c                     t          j        t          d          }	  |dt          j        dd            d S # t
          t          f$ r Y d S w xY w)NsymlinktargetF)srcdsttarget_is_directoryr   )r   get_attributer   r   rh   NotImplementedErrorrO   )r9   r   s     r   test_symlink_keywordszFileTests.test_symlink_keywords8  so    'I66	Gi&6$)$8 8 8 8 8 8#W- 	 	 	DD	s   7 AAcopy_file_rangeztest needs os.copy_file_range()c                     |                      t                    5  t          j        ddd           d d d            d S # 1 swxY w Y   d S Nr   rw   i)r~   
ValueErrorr   r   rj   s    r   #test_copy_file_range_invalid_valuesz-FileTests.test_copy_file_range_invalid_values@  s    z** 	* 	*q!S)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*   ?AAc                    t           j        dz   }d}t          t           j        |           |                     t           j        t           j                   t          t           j        d          }|                     |j                   |                                }t          |d          }|                     t           j        |           |                     |j                   |                                }	 t          j	        ||d          }| 
                    |t          dd                     t          |d          5 }|                     |                                |d |                    d d d            d S # 1 swxY w Y   d S # t          $ r6}|j        t          j        k    r |                     |           Y d }~d S d }~ww xY w)N.3
   0123456789r   r      r      )r   rh   r+   r   ri   r&   ro   r   r   r   assertInrangerH   r   rO   rP   ENOSYSr|   )	r9   r   r   in_filein_fdout_fileout_fdies	            r   test_copy_file_rangezFileTests.test_copy_file_rangeE  s   "T)I$d+++	()*:;;;y'..&&&  ''	('222'''""	;"5&!44A MM!U1a[[)))gt$$ ;  bqb:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;  	 	 	 w%,&&MM!	s*   =F 1FF	F	
G+GGc                    t           j        dz   }d}d}d}d}t          t           j        |           |                     t           j        t           j                   t          t           j        d          }|                     |j                   |                                }t          |d          }|                     t           j        |           |                     |j                   |                                }		 t          j	        ||	|||          }
| 
                    |
t          d	|d
z                        t          |d          5 }|                                }d d d            n# 1 swxY w Y   |                     |d |         d|z             |                     ||d          ||||
z                       d S # t          $ r6}|j        t          j        k    r |                     |           Y d }~d S d }~ww xY w)N.4r   r      r   r   r   )
offset_src
offset_dstr   rw       )r   rh   r+   r   ri   r&   ro   r   r   r   r   r   r   rH   rO   rP   r   r|   )r9   TESTFN4r   bytes_to_copyin_skipout_seekr   r   r   r   r   r   r   s                r   test_copy_file_range_offsetz%FileTests.test_copy_file_range_offsetg  sF   "T)I$d+++	()*:;;;y'..&&&  ''	('222'''""	6"5&-.5.68 8 8A MM!U1mAo66777gt$$ &||~~& & & & & & & & & & & & & & & T)8)_gh.>??? T())_!''!)"346 6 6 6 6%  	 	 	 w%,&&MM!	s*   G E44E8;E8
H+HHspliceztest needs os.splice()c                     |                      t                    5  t          j        ddd           d d d            d S # 1 swxY w Y   d S r   )r~   r   r   r   rj   s    r   test_splice_invalid_valuesz$FileTests.test_splice_invalid_values  s    z** 	! 	!IaC   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!r   c                 .   t           j        dz   }d}t          t           j        |           |                     t           j        t           j                   t          t           j        d          }|                     |j                   |                                }t          j	                    \  |                     fd           |                     fd           	 t          j
        |d          }|                     |t          dd                     |                     t          j        d	          |d |                    d S # t          $ r6}|j        t           j        k    r |                     |           Y d }~d S d }~ww xY w)
Nr   r   r   c                  ,    t          j                   S r.   r   ro   read_fds   r   <lambda>z'FileTests.test_splice.<locals>.<lambda>       1 1 r   c                  ,    t          j                   S r.   r   write_fds   r   r  z'FileTests.test_splice.<locals>.<lambda>       2 2 r   r   r   r   r   )r   rh   r+   r   ri   r&   ro   r   r   piper   r   r   rH   r   rO   rP   r   r|   )	r9   r   r   r   r   r   r   r  r  s	          @@r   test_splicezFileTests.test_splice  s    "T)I$d+++	()*:;;;y'..&&&  GII11112222222333	>	%1--A MM!U1a[[)))RWWc22D!H=====  	 	 	 w%,&&MM!	s   'E 
F+FFc                 J  
 t           j        dz   }d}d}d}t          t           j        |           |                     t           j        t           j                   t          t           j        d          }|                     |j                   |                                }t          j	                    \  
|                     
fd           |                     fd           	 t          j
        |||          }|                     |t          d	|d
z                        t          j        
d          }|                     |||||z                       d S # t          $ r6}	|	j        t           j        k    r |                     |	           Y d }	~	d S d }	~	ww xY w)Nr   r   r   r   r   c                  ,    t          j                   S r.   r   r  s   r   r  z1FileTests.test_splice_offset_in.<locals>.<lambda>  r  r   c                  ,    t          j                   S r.   r   r  s   r   r  z1FileTests.test_splice_offset_in.<locals>.<lambda>  r  r   )r   r   rw   r   )r   rh   r+   r   ri   r&   ro   r   r   r	  r   r   r   r   rH   rO   rP   r   r|   )r9   r   r   r   r   r   r   r   r   r   r  r  s             @@r   test_splice_offset_inzFileTests.test_splice_offset_in  s    "T)I$d+++	()*:;;;y'..&&&  GII11112222222333	<	%=WMMMA MM!U1mAo6677777C((D T4	(9#:;;;;;  	 	 	 w%,&&MM!	s   +E" "
F",+FF"c                 :   t           j        dz   }d}d}d}t          t           j        |           |                     t           j        t           j                   t          j                    \  |                     fd           |                     fd           t          j        |           t          |d          }|                     t           j        |           |                     |j	                   |
                                }	 t          j        |||          }|                     |t          d	|d
z                        t          |d          5 }|                                }	d d d            n# 1 swxY w Y   |                     |	d |         d|z             |                     |	|d          |d |                    d S # t           $ r6}
|
j        t"          j        k    r |                     |
           Y d }
~
d S d }
~
ww xY w)Nr   r   r   r   c                  ,    t          j                   S r.   r   r  s   r   r  z2FileTests.test_splice_offset_out.<locals>.<lambda>  r  r   c                  ,    t          j                   S r.   r   r  s   r   r  z2FileTests.test_splice_offset_out.<locals>.<lambda>  r  r   r   )r   r   rw   r   r   )r   rh   r+   r   ri   r   r	  r'   r&   ro   r   r   r   r   r   rH   rO   rP   r   r|   )r9   r   r   r   r   r   r   r   r   r   r   r  r  s              @@r   test_splice_offset_outz FileTests.test_splice_offset_out  sN    "T)I$d+++	()*:;;;GII11112222222333
4   ''	('222'''""	8	'6=XNNNA MM!U1mAo66777gt$$ &||~~& & & & & & & & & & & & & & & T)8)_gh.>??? T())_d2A2h77777%  	 	 	 w%,&&MM!	s*   G %FF
F

H$+HHN)(ra   rb   rc   rk   tearDownru   r   skipIfr   is_emscriptenis_wasir   cpython_onlyr   r   r   r   r   
bigmemtestr   r   r   rB   rC   r   r   r   r   r   r   r   r   r   r   r   r   requires_splice_piper
  r  r  r
   r   r   re   re      s       ( ( ( H> > >
 X_C  X_5 : :  :* # # #) ) )  X>19; ;WWr\!UCCC( ( DC; ; (
. 
. 
.% % % X0?A AE EA AE  
% % %, , ,  
   X%6779Z[[* * \[* X%6779Z[[; ; \[;B X%6779Z[[*6 *6 \[*6X XX..0HII! ! JI! XX..0HII> >  JI>> XX..0HII"< "<  JI"<H XX..0HII'8 '8  JI'8 '8 '8r   re   c                   b   e Zd Zd Zd Zd Zd Zd Z ej	         e
ed          d          d             Z ej	         e
ed          d	          d
             Z ej	        ej        dk    d          d             Z ej	        ej        dk    d           ej	         e
ed          d          d                         Zd Z ej	        ej        dk    d          d             Z ej	        ej        dk    d          d             Z ej	        ej        dk    d          d             ZdS )StatAttributeTestsc                     t           j        | _        |                     t           j        | j                   t          | j        d           d S )N   ABC)r   rh   fnamer   ri   r+   rj   s    r   rk   zStatAttributeTests.setUp  s=    %
	($*555DJ'''''r   c           	      <   t          j        |          }|                     |t          j                 d           |                     |j        d           t          |          }t          t                    D ]}|d d         dk    r|                                }|                    d          rd }nd }|                      |t          ||                    |t          t          |                              | 	                    ||           d
                                D ]P}t          t          ||          dz            }t          ||dz             d	z  }|                     ||d
           Q	 |d          |                     d           n# t          $ r Y nw xY w	 d|_        |                     d           n# t           $ r Y nw xY w	 d|_        |                     d           n# t           t$          f$ r Y nw xY w	 d|_        |                     d           n# t           $ r Y nw xY w	 t          j        d          }	|                     d           n# t$          $ r Y nw xY w	 t          j        d          }	d S # t$          $ r Y d S w xY w)Nr   ST_TIMEc                      t          |           S r.   )intxs    r   truncz7StatAttributeTests.check_stat_attributes.<locals>.trunc   s    Q-r   c                     | S r.   r
   r$  s    r   r&  z7StatAttributeTests.check_stat_attributes.<locals>.trunc"  s    (r   zst_atime st_mtime st_ctimei _nsi'  ry   deltar?   No exception raisedrw   rx   r   rw   ry   r   r   r   r         	   rx               )r   r   rH   ST_SIZEst_sizedirlowerendswithgetattrr   splitr#  assertAlmostEqualfail
IndexErrorst_modeAttributeErrorst_rdevr   parrotstat_result)
r9   r  resultmembersr!   attrr&  floatynanosecondyresult2s
             r   check_stat_attributesz(StatAttributeTests.check_stat_attributes  s    	-q111+++ f++II 		- 		-DBQBx5  zz||==(( +////***  wvt'<'<!=!="(t)<)<"=? ? ?dG,,, 16688 	A 	AD..788F!&$,775@K""6;a"@@@@	3KKII+,,,, 	 	 	D		FNII+,,,, 	 	 	D		FNII+,,,,	* 	 	 	D		FMII+,,,, 	 	 	D		nU++GII+,,,, 	 	 	D		n%IJJGGG 	 	 	DD	sl   <F 
F'&F'+G 
GGG6 6H
	H
H+ +
H87H8<)I& &
I32I37J 
JJc                 :    |                      | j                   d S r.   )rJ  r  rj   s    r   test_stat_attributesz'StatAttributeTests.test_stat_attributesT  s    ""4:.....r   c                     	 | j                             t          j                              }n-# t          $ r  |                     d| j         z             Y nw xY w|                     |           d S )Nz#cannot encode %a for the filesystem)r  encoderB   getfilesystemencodingUnicodeEncodeErrorr|   rJ  )r9   r  s     r   test_stat_attributes_bytesz-StatAttributeTests.test_stat_attributes_bytesW  s    	NJ%%c&?&A&ABBEE! 	N 	N 	NMM?$*LMMMMM	N""5)))))s   +. 'AAc                 X   t          j        | j                  }t          t          j        dz             D ]s}t	          j        ||          }|                     d|           |dk     r|                     d|           t	          j        |          }| 	                    ||           td S )Nrw   s   stat_resultr   s   cos
stat_result
)
r   r   r  r   pickleHIGHEST_PROTOCOLdumpsr   loadsrH   r9   rD  protop	unpickleds        r   test_stat_result_picklez*StatAttributeTests.test_stat_result_pickle^  s    $$62Q677 	0 	0EVU++AMM.!,,,qyy3Q777QIVY////	0 	0r   statvfsztest needs os.statvfs()c                    t          j        | j                  }|                     |j        |d                    d}t          |          D ]2\  }}|                     t          |d|z             ||                    3|                     t          |j	        t                               |                     t          |          d           	 d|_        |                     d           n# t          $ r Y nw xY w	 d|_        |                     d           n# t          $ r Y nw xY w	 t          j        d          }|                     d           n# t           $ r Y nw xY w	 t          j        d          }d S # t           $ r Y d S w xY w)	Nr   )
bsizefrsizeblocksbfreebavailfilesffreefavailflagnamemaxf_rx   rw   r+  r,  r-  )r   r\  r  rH   f_bfree	enumerater:  rp   
isinstancef_fsidr#  rD   r=  r@  rB  statvfs_resultr   )r9   rD  rE  valuememberrI  s         r   test_statvfs_attributesz*StatAttributeTests.test_statvfs_attributesh  s   DJ'' 	333:&w// 	L 	LME6WVTF];;VE]KKKK
6=#66777 	Vb)))	FNII+,,,, 	 	 	D		FMII+,,,, 	 	 	D		'..GII+,,,, 	 	 	D		'(LMMGGG 	 	 	DD	sH   C- -
C:9C:>D 
D('D(,)E 
E#"E#'E= =
F
Fneed os.statvfs()c                 X   t          j        | j                  }t          t          j        dz             D ]s}t	          j        ||          }|                     d|           |dk     r|                     d|           t	          j        |          }| 	                    ||           td S )Nrw   s   statvfs_resultr   s   cos
statvfs_result
)
r   r\  r  r   rS  rT  rU  r   rV  rH   rW  s        r   test_statvfs_result_picklez-StatAttributeTests.test_statvfs_result_pickle  s     DJ''62Q677 	0 	0EVU++AMM+Q///qyy6:::QIVY////	0 	0r   r   Win32 specific testsc                     	 t          j        d           d S # t          $ r |                     d           Y d S t          $ r }|                     d           Y d }~d S d }~ww xY w)Nzc:\pagefile.syszc:\pagefile.sys does not existzCould not stat pagefile.sys)r   r   rN   r|   rO   r=  r9   r   s     r   test_1686475zStatAttributeTests.test_1686475  s    	5G&'''''  	= 	= 	=MM;<<<<<< 	5 	5 	5II3444444444	5s    A#	A#AA#r	  zrequires os.pipe()c                    t          j                    \  }}	 t          j        |           t          j        |           t          j        |           n-# t          j        |           t          j        |           w xY w|                     t
                    5 }t          j        |           d d d            n# 1 swxY w Y   |                     |j        j        t          j	                   d S r.   )
r   r	  r   ro   r~   rO   rH   	exceptionrP   EBADF)r9   r   wctxs       r   
test_15261zStatAttributeTests.test_15261  s     wyy1	GAJJJHQKKKHQKKKK HQKKKHQKKKKw'' 	3GAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	,ek:::::s   A *A?B==CCc                     |                      t          |d                     |                      t          |j        t                               |                      d|j        cxk    odk    nc            d S )Nst_file_attributesr       )rp   r   rk  r  r#  )r9   rD  s     r   check_file_attributesz(StatAttributeTests.check_file_attributes  su    (<==>>>
6#<cBBCCCV6DDDD*DDDDEEEEEr   z$st_file_attributes is Win32 specificc                    t          j        | j                  }|                     |           |                     |j        t          j        z  d           t          j        dz   }t          j	        |           | 
                    t           j        |           t          j        |          }|                     |           |                     |j        t          j        z  t          j                   d S )Nr   r7  )r   r   r  r  rH   r  FILE_ATTRIBUTE_DIRECTORYr   rh   rL   r   rmdir)r9   rD  rV   s      r   test_file_attributesz'StatAttributeTests.test_file_attributes  s     $$""6***%(EE	 	 	
 "U*
'***!!""6***%(EE)	+ 	+ 	+ 	+ 	+r   c                 f   t           j                            t           j        d         | j                  }|                     t          j        |           t          |d           d}t          j
        d|ddg|           t          j        |          }|                     |j        d           d S )	NTEMPr  r/  z
icacls.exez/denyz*S-1-5-32-545:(S)r   r   )r   rI   rK   environr  r   r   ri   r+   r   
check_callr   assertNotEqualr6  )r9   r  DETACHED_PROCESSrD  s       r   test_access_deniedz%StatAttributeTests.test_access_denied  s     RZ/<<	(%000E6"""  5'+>?*		
 	
 	
 	
 FNA.....r   c                     dt           j                            t          j                              d         z   }t          j        |          }|                     |j        t          j                   d S )Nz//./r   )r   rI   
splitdriver5   r   rH   r?  S_IFBLK)r9   r  rD  s      r   test_stat_block_devicez)StatAttributeTests.test_stat_block_device  sV     ++BIKK88;;66666r   N)ra   rb   rc   rk   rJ  rL  rQ  r[  r   r   r   r   rp  rs  rB   rC   rw  r}  r  r  r  r  r
   r   r   r  r    s       ( ( (
? ? ?B/ / /* * *0 0 0 XY//1JKK) ) LK)V XY//,. .	0 	0. .	0 X02HII5 5 JI5 X02HIIXV,,.BCC
; 
; DC JI
;F F F
 X0?A A+ +A A+& X02HII/ / JI/( X02HII7 7 JI7 7 7r   r  c                   x   e Zd Zd Zd ZddZd Zed             Zd Z	d Z
 ej        ej        ej        v d	          d
             Z ej        ej        ej        v d          d             Z ej        ej        ej        v d          d             Zd Zd Zd Zd Zd Zd Zd Zej        d             ZdS )
UtimeTestsc                     t           j        | _        t          j                            | j        d          | _        |                     t           j        | j                   t          j	        | j                   t          | j                   d S )Nf1)r   rh   rV   r   rI   rK   r  r   rmtreerL   r+   rj   s    r   rk   zUtimeTests.setUp  sf     'W\\$,55
	($,777
DJr   c                     t          j        |          }|j        |d         k    p!|j        |d         k    p|j        |d         k    S )Nr.  r/  r0  )r   r   st_atimest_mtimest_ctime)r9   r(   sts      r   support_subsecondzUtimeTests.support_subsecond  sL     WX1% *K2a5(*K2a5(	+r   Nc                    |s| j         }|                     |          }|rd}d}nd}d} ||||f           t          j        |          }|rA|                     |j        |dz  d           |                     |j        |dz  d           n<|                     |j        |dz             |                     |j        |dz             |                     |j        |           |                     |j	        |           d S )Ni8Z;l   
o]     rT l    P9 &.>gư>r)  )
r  r  r   r   r<  r  r  rH   st_atime_nsst_mtime_ns)r9   set_timer(   r  atime_nsmtime_nsr  s          r   _test_utimezUtimeTests._test_utime  s(    	"zH 228<< 	! "H!HH !H HHh/000WX 	;""2;4t"LLL""2;4t"LLLLR[(T/:::R[(T/:::22222222r   c                 6    d }|                      |           d S )Nc                 2    t          j        | |           d S Nnsr   utimer(   r  s     r   r  z'UtimeTests.test_utime.<locals>.set_time"      HX"%%%%%%r   r  r9   r  s     r   
test_utimezUtimeTests.test_utime!  s-    	& 	& 	& 	"""""r   c                     | dz  dz   S )Nr  g&.>r
   r  s    r   	ns_to_seczUtimeTests.ns_to_sec'  s    
 T	V##r   c                 <      fd}                      |           d S )Nc                     |\  }}                     |          }                     |          }t          j        | ||f           d S r.   r  r   r  r(   r  r  r  atimemtimer9   s         r   r  z2UtimeTests.test_utime_by_indexed.<locals>.set_time0  sM    !#HhNN8,,ENN8,,E HXu~.....r   r  r  s   ` r   test_utime_by_indexedz UtimeTests.test_utime_by_indexed.  s8    	/ 	/ 	/ 	/ 	/ 	"""""r   c                 <      fd}                      |           d S )Nc                     |\  }}                     |          }                     |          }t          j        | ||f           d S )N)timesr  r  s         r   r  z0UtimeTests.test_utime_by_times.<locals>.set_time:  sN    !#HhNN8,,ENN8,,EHXeU^444444r   r  r  s   ` r   test_utime_by_timeszUtimeTests.test_utime_by_times9  s8    	5 	5 	5 	5 	5 	"""""r   z9follow_symlinks support for utime required for this test.c                 6    d }|                      |           d S )Nc                 4    t          j        | |d           d S )NF)r  follow_symlinksr  r  s     r   r  z9UtimeTests.test_utime_nofollow_symlinks.<locals>.set_timeF  s!     HX"e<<<<<<r   r  r  s     r   test_utime_nofollow_symlinksz'UtimeTests.test_utime_nofollow_symlinksB  s-    	= 	= 	= 	"""""r   z,fd support for utime required for this test.c                 6    d }|                      |           d S )Nc                     t          | dd          5 }t          j        |                                |           d d d            d S # 1 swxY w Y   d S )Nwbr   r  )r&   r   r  r   )r(   r  r*   s      r   r  z*UtimeTests.test_utime_fd.<locals>.set_timeO  s    ha(( -B ,,,,- - - - - - - - - - - - - - - - - -s   )AAAr  r  s     r   test_utime_fdzUtimeTests.test_utime_fdL  s-    	- 	- 	-
 	"""""r   z0dir_fd support for utime required for this test.c                 6    d }|                      |           d S )Nc                     t           j                            |           \  }}t          j        |          5 }t          j        |||           d d d            d S # 1 swxY w Y   d S )N)r   r  )r   rI   r;  r   open_dir_fdr  )r(   r  rV   r!   dirfds        r   r  z.UtimeTests.test_utime_dir_fd.<locals>.set_timeY  s    GMM(33MGT&w// 45e33334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s   AA #A r  r  s     r   test_utime_dir_fdzUtimeTests.test_utime_dir_fdV  s-    	4 	4 	4
 	"""""r   c                 D    d }|                      || j                   d S )Nc                 2    t          j        | |           d S r  r  r  s     r   r  z1UtimeTests.test_utime_directory.<locals>.set_timea  r  r   )r(   )r  rV   r  s     r   test_utime_directoryzUtimeTests.test_utime_directory`  s4    	& 	& 	& 	DL99999r   c                 (   t          j                     } || j                   |                     | j                  sd}nd}t          j        | j                  }d|j        d|d|j        |z
  }|                     |j        |||           d S )Ng      ?g?zst_time=z
, current=z, dt=)r*  msg)timer  r  r   r   r  r<  )r9   r  currentr*  r  r  s         r   _test_utime_currentzUtimeTests._test_utime_currentf  s    )++ 	%%dj11 	EE EWTZ  +++wwwg(=(=?r{G%* 	 	5 	5 	5 	5 	5r   c                 <      fd}                      |           d S )Nc                 :    t          j        j                   d S r.   r   r  r  r(   r9   s    r   r  z/UtimeTests.test_utime_current.<locals>.set_time}  s    HTZ     r   r  r  s   ` r   test_utime_currentzUtimeTests.test_utime_current|  s8    	! 	! 	! 	! 	! 	  *****r   c                 <      fd}                      |           d S )Nc                 <    t          j        j        d            d S r.   r  r  s    r   r  z3UtimeTests.test_utime_current_old.<locals>.set_time  s    HTZ&&&&&r   r  r  s   ` r   test_utime_current_oldz!UtimeTests.test_utime_current_old  s8    	' 	' 	' 	' 	' 	  *****r   c                 d   t           j        dk    rt          j                            t          j                            |                    d         dz   }dd l}|j        j        }|	                    dd          }|
                    |d dd d d |t          |                    }|r	|j        S d S d S )Nr   r   \ r   )rB   rC   r   rI   r  abspathctypeswindllkernel32create_unicode_bufferGetVolumeInformationWrD   rn  )r9   rI   rootr  r  bufoks          r   get_file_systemzUtimeTests.get_file_system  s    <7""7%%bgood&;&;<<Q?$FDMMM}-H..r377C//dA04dD03SXX? ?B  !y  #"! !r   c                    |                      | j                  dk    r|                     d           d}t          j        | j        ||f           |                     t          j        | j                  j        |           d S )NNTFSzrequires NTFSr  )	r  rV   r|   r   r  r  rH   r   r  )r9   larges     r   test_large_timezUtimeTests.test_large_time  sy     --77MM/***
eU^,,,,,5u=====r   c                    |                      t                    5  t          j        | j        dd           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        ddg           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        d           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        d           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        ddg           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        d           d d d            n# 1 swxY w Y   |                      t
                    5  t          j        | j        d           d d d            n# 1 swxY w Y   t          j        t          j        vrN|                      t                    5  t          j        | j        dd           d d d            n# 1 swxY w Y   t          j        t          j        vrt          | j        dd	          5 }|                      t
                    5  t          j        |
                                d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        t          j        vrQ|                      t                    5  t          j        | j        dd	
           d d d            d S # 1 swxY w Y   d S d S )N)r   r   r  r   )r   )r   r   r   Fr  r  r   r   )r~   r   r   r  r  r   supports_follow_symlinksr   supports_fdr&   r   supports_dir_fd)r9   r*   s     r   test_utime_invalid_argumentsz'UtimeTests.test_utime_invalid_arguments  s   z** 	4 	4HTZF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)) 	, 	,HTZQF++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,y)) 	* 	*HTZD))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*y)) 	/ 	/HTZI....	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 82666""#677 D DVUCCCCD D D D D D D D D D D D D D D82>))dj$** 2b&&y11 2 2HRYY[[&1112 2 2 2 2 2 2 2 2 2 2 2 2 2 22 2 2 2 2 2 2 2 2 2 2 2 2 2 2 82---""#677 7 7VA66667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 .-s   AAA)BBB7CC"%C"D**D.1D.E99E= E=GG
G
+HHHI99I= I=2L(L5LL	LL		LLLM??NNc                    d }|                      t                    5  t          j        | j         |d          df           d d d            n# 1 swxY w Y   |                      t                    5  t          j        | j         |d          df           d d d            n# 1 swxY w Y   |                      t                    5  t          j        | j         |d          df           d d d            d S # 1 swxY w Y   d S )Nc                 6      G  fdd          } |            S )Nc                       e Zd Z fdZdS )?UtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadIntc                      S r.   r
   )r   divmod_ret_vals    r   
__divmod__zJUtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadInt.__divmod__  s	    ))r   N)ra   rb   rc   r  )r  s   r   BadIntr    s.        * * * * * * *r   r  r
   )r  r  s   ` r   get_bad_intz/UtimeTests.test_issue31577.<locals>.get_bad_int  sB    * * * * * * * * * * 688Or   *   rw   r  r
   )rw   ry   r   )r~   r   r   r  r  )r9   r  s     r   test_issue31577zUtimeTests.test_issue31577  s   	 	 	
 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 	As5   'AAA6'B))B-0B-'DD	Dr.   )ra   rb   rc   rk   r  r  r  staticmethodr  r  r  r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r
   r   r   r  r    s            + + +3 3 3 3># # # $ $ \$	# 	# 	## # # XR%@@*+ +# #+ +# XR^3GI I# #I I# XR%77KM M# #M M#: : :5 5 5,+ + ++ + +
! 
! 
!> > >7 7 78 A A A A Ar   r  )mapping_testsc                      e Zd Z	 dZd Zd Zd Zd Z ej	        e
oej                            e
          d           ej	         eed          d           ej                    d	                                     Z ej	        e
oej                            e
          d           ej	         eed          d           ej                    d
                                     Zd Zd Zd Zd Z ej	        ej        d          d             Z ej                    d             Z ej        dd          d             Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&dS ) EnvironTestsNc                    t          t          j                  | _        t          j        rt          t          j                  | _        |                                                                 D ]\  }}|t          j        |<   d S r.   )	dictr   r  _EnvironTests__savesupports_bytes_environenvironb_EnvironTests__saveb
_referenceitemsr9   keyrn  s      r   rk   zEnvironTests.setUp  so    2:&&$ 	-,,DL//++1133 	$ 	$JC#BJsOO	$ 	$r   c                 *   t           j                                         t           j                            | j                   t           j        rDt           j                                         t           j                            | j                   d S d S r.   )r   r  clearupdater  r  r  r	  rj   s    r   r  zEnvironTests.tearDown  su    



$+&&&$ 	-KKt|,,,,,	- 	-r   c                     ddddS )NVALUE1VALUE2VALUE3)KEY1KEY2KEY3r
   rj   s    r   r
  zEnvironTests._reference  s    BBBr   c                 V    t           j                                         t           j        S r.   )r   r  r  rj   s    r   _empty_mappingzEnvironTests._empty_mapping  s    

zr   zrequires a shellpopenzneeds os.popen()c                 d   t           j                                         t           j                            d           t          j        dt
          z            5 }|                                                                }|                     |d           d d d            d S # 1 swxY w Y   d S )NWorld)HELLOz%s -c 'echo $HELLO')	r   r  r  r  r  r   r   striprH   )r9   r  rn  s      r   test_update2zEnvironTests.test_update2  s    
 	


(((X+j899 	-UJJLL&&((EUG,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   =B%%B),B)c                    t          j        dt          z            5 }t          |          }|                     t          |          d           |                     t          |          d           |                     t          |          d           |                     t          t
          |           d d d            d S # 1 swxY w Y   d S )Nz %s -c 'echo "line1
line2
line3"'zline1
zline2
zline3
)r   r  r   iterrH   nextr~   StopIteration)r9   r  its      r   test_os_popen_iterzEnvironTests.test_os_popen_iter  s    
 X<"# $ $ 	7',eB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 	7s   BCCCc                     t           j                                        D ]U\  }}|                     t	          |          t
                     |                     t	          |          t
                     Vd S r.   )r   r  r  rH   r   r7   )r9   r  vals      r   test_keyvalue_typesz EnvironTests.test_keyvalue_types  sh    
((** 	- 	-HCT#YY,,,T#YY,,,,	- 	-r   c                     |                                                                  D ]8\  }}|                     t          j                            |          |           9d S r.   )r
  r  rH   r   r  getr  s      r   
test_itemszEnvironTests.test_items  s\    //++1133 	9 	9JCRZ^^C00%8888	9 	9r   c                     	 t           j        }d                    d |                                D                       }|                     t          |          d| d           d S )Nz, c              3   *   K   | ]\  }}|d |V  dS )z: Nr
   )r   r  rn  s      r   	<genexpr>z-EnvironTests.test___repr__.<locals>.<genexpr>  sH       $
 $
U !!!!$
 $
 $
 $
 $
 $
r   z	environ({z}))r   r  rK   r  rH   repr)r9   envformatted_itemss      r   test___repr__zEnvironTests.test___repr__  ss    Lj)) $
 $
!iikk$
 $
 $
 
 
 	c$E$E$E$EFFFFFr   c                    t           j                            t           j                  }g d}dt           j                            |          i}t           j        }	 t          |          t           _        |                     |t          j                               |                     |t          j        d                      |t           _        n# |t           _        w xY w|                     |t          j        i                      |                     dt          j        ddi                     |                     |t          j        |                     t           j	        r	 t          j        d          5  dd	d
}d d d            n# 1 swxY w Y   |                     t          t           j        |           n# t          $ r Y nw xY w|                     t          j        ddi          dg           |                     t          j        ddi          dg           |                     t          j        ddi          dg           d S d S )N)z/montyz/pythonr  z/flying/circusPATHr0  r  r  T)recordr   r   )r4     PATHr8     abcabc)r   defpathr;  pathseprK   r  r  assertSequenceEqualget_exec_pathr  warningscatch_warningsr~   r   BytesWarning)r9   defpath_list	test_pathtest_envsaved_environ	mixed_envs         r   test_get_exec_pathzEnvironTests.test_get_exec_path  s   z''
33???	BJOOI667
	'hBJ$$Y0@0B0BCCC$$Y0@T0J0J0JKKK&BJJBJ&&&& 	  r/?/C/CDDD  (8&(E(EFFF  B,<X,F,FGGG$ 	K,D999 = =),t < <I= = = = = = = = = = = = = = = !!*b.>	JJJJ	      $$R%5w6G%H%H  $$R%5w6F%G%G  $$R%5vv6F%G%G    #	 	sC   A)C C *G ?FG FG FG 
GGz#os.environb required for this test.c                    d}	 |                     t          j                    d          }n;# t          $ r. dt          j                    }|                     |           Y nw xY w|t
          j        d<   |                     t
          j        d         |           |                     t
          j        d         |           d}|t
          j        d<   |                     t
          j        d         |           |	                    t          j                    d          }|                     t
          j        d         |           d S )	Nu   euro€surrogateescapez%U+20AC character is not encodable to unicodes   unicode   s   bytesr^   )
rN  rB   rO  rP  r|   r   r  rH   r  decode)r9   rn  value_bytesr  	value_strs        r   test_environbzEnvironTests.test_environb>  s7    	,,s'@'B'B'8: :KK! 	 	 	 	)+++.CMM#	 !&
9I.666Z0+>>>  %HX.666LL!:!<!<>OPP	G,i88888s   ', 5A$#A$c                    d}d}d|d}t          j                    5 }|                    |d            t          j        ||           t          j        t          j        d|gdt
          j	        d          }| 
                    |j                                        t          |                     t          j        |           t          j        t          j        d|gdt
          j	        d          }| 
                    |j                                        t          d                      d d d            d S # 1 swxY w Y   d S )NPYTHONTESTVAR	testvaluez%import os; print(repr(os.environ.get(z)))r   T)checkstdouttext)r   EnvironmentVarGuardpopr   putenvr   runrB   r   PIPErH   rT  rstripr/  unsetenv)r9   r!   rn  r   r0  procs         r   test_putenv_unsetenvz!EnvironTests.test_putenv_unsetenvU  sp   BtBBB*,, 	?GGD$IdE""">3>4">d)3tE E EDT[//114;;???K>3>4">d)3tE E EDT[//114::>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   DD==EErx   r   c                    dD ]]}|                      t          t          ft          j        |d           |                      t          t          ft          j        |           ^t          j        dk    r{ddz  }|                      t          t          j        |d           |                      t          t          j        d|           |                      t          t          j        |           d S d S )N)r  z=namezna=mezname=zname zna mern  r   r%     r   X)r~   rO   r   r   rX  r\  rB   rC   )r9   r!   longstrs      r   test_putenv_unsetenv_errorz'EnvironTests.test_putenv_unsetenv_errori  s     H 	H 	HDw
3RYgNNNw
3R[$GGGG<7"" FlGj")WcBBBj")S'BBBj"+w????? #"r   c                 d   d}|                      |t          j                   |                     t                    5 }t          j        |          d d d            n# 1 swxY w Y   |                     |j        j        d         |           |                     |j        j	                   |                     t                    5 }t          j        |= d d d            n# 1 swxY w Y   |                     |j        j        d         |           |                     |j        j	                   d S )N
missingkeyr   )
assertNotInr   r  r~   KeyErrorassertIsry  r   rp   __suppress_context__)r9   missingcms      r   test_key_typezEnvironTests.test_key_typey  sr   "*---x(( 	 BJw	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 bl'*G4449:::x(( 	$B
7#	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$bl'*G4449:::::s#   AA #A C  C$'C$c                    t          |          }d}t          |           dt          j        |<   	 t          |           |                     t          j        |         d           t          j        |= d S # t          j        |= w xY w)N__new_key__test_environ_iteration)r!  r"  r   r  rH   )r9   
collectioniteratornew_keys       r   _test_environ_iterationz$EnvironTests._test_environ_iteration  s    
##X 7
7	$NNNRZ02JKKK
7###
7#####s   5A5 5Bc                 D    |                      t          j                   d S r.   )rs  r   r  rj   s    r   (test_iter_error_when_changing_os_environz5EnvironTests.test_iter_error_when_changing_os_environ  s    $$RZ00000r   c                 h    |                      t          j                                                   d S r.   )rs  r   r  r  rj   s    r   .test_iter_error_when_changing_os_environ_itemsz;EnvironTests.test_iter_error_when_changing_os_environ_items  s*    $$RZ%5%5%7%788888r   c                 h    |                      t          j                                                   d S r.   )rs  r   r  valuesrj   s    r   /test_iter_error_when_changing_os_environ_valuesz<EnvironTests.test_iter_error_when_changing_os_environ_values  s*    $$RZ%6%6%8%899999r   c                 b   t           r$t          j                            t                     sd S t          j        sd S t          j        t            d| d          5 }|                                                                }d d d            n# 1 swxY w Y   | 	                    ||           d S )Nz -c 'echo $')
r   r   rI   existsr   has_subprocess_supportr  r   r  rH   )r9   varrX   r  rn  s        r   _test_underlying_process_envz)EnvironTests._test_underlying_process_env  s     	rw~~j99 	F/ 	FX6666677 	)5JJLL&&((E	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	5)))))s   'BBBc                 
   d}d}|t           j        |<   dddd|di}t          t           j                  }|                    |           t           j        |z  }|                     ||           |                     d||                    |                                }|                     t          t           j        	                    |                     | 
                    dd           | 
                    ||           d S 	N
_TEST_VAR_original_value_A_r   _B_23r  )r   r  r  r  assertDictEqualrH   r  rh  NotImplemented__or__r  r9   overridden_keyr  new_vars_dictrX   actualnew_vars_itemss          r   test_or_operatorzEnvironTests.test_or_operator  s    %)%3
>"UCE
##&&&m+Xv...f^4555&,,..nbj&7&7&G&GHHH))%444))..IIIIIr   c                    d}dt           j        |<   dddd|di}t          t           j                  }|                    |           t           xj        |z  c_        |                     |t           j                   |                     dt           j        |                    |                     dd           |                     |d           d S )Nr  r  r  r   r  r  r  r   r  r  r  rH   r  )r9   r  r  rX   s       r   test_ior_operatorzEnvironTests.test_ior_operator  s    %%5
>"UCE
##&&&


m#

2:...bj8999))%555)).#>>>>>r   c                    t           j                                        }|                     t                    5  ddi}t           xj        |z  c_        d d d            n# 1 swxY w Y   |                     t                    5  ddi}t           xj        |z  c_        d d d            n# 1 swxY w Y   |                     |t           j                   d S )Nrw   r  )r   r  copyr~   r   rH   )r9   os_environ_copydict_with_bad_keydict_with_bad_vals       r   test_ior_operator_invalid_dictsz,EnvironTests.test_ior_operator_invalid_dicts  s=   *//++y)) 	, 	,!"E
JJ++JJ	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, y)) 	, 	,!&
JJ++JJ	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,
 	"*55555s#   AA#&A#B**B.1B.c                    d}dt           j        |<   dd|dff}t          t           j                  }|                    |           t           xj        |z  c_        |                     |t           j                   |                     dt           j        |                    |                     dd           |                     |d           d S )Nr  r  )r  r   )r  r  r  r  r   r  )r9   r  r  rX   s       r   $test_ior_operator_key_value_iterablez1EnvironTests.test_ior_operator_key_value_iterable  s    %%5
>"&~s6KL
##'''


n$

2:...bj8999))%555)).#>>>>>r   c                 
   d}d}|t           j        |<   dddd|di}t          |          }|                    t           j                   |t           j        z  }|                     ||           |                     |||                    |                                }|                     t          t           j        	                    |                     | 
                    dd           | 
                    ||           d S r  )r   r  r  r  r  rH   r  rh  r  __ror__r  r  s          r   test_ror_operatorzEnvironTests.test_ror_operator  s    %)%3
>"UCE&&
###+Xv...)?@@@&,,..nbj&8&8&H&HIII))%444))..IIIIIr   )'ra   rb   rc   	type2testrk   r  r
  r  r   r   r   r   rI   r}  r   r   requires_subprocessr  r%  r(  r+  r2  rG  r  rO  r^  requires_mac_verrc  rl  rs  ru  rw  rz  r  r  r  r  r  r  r
   r   r   r  r    s       BI$ $ $- - -C C C  
 XBz(B(B+- -XW--/ABB W ""- - #" CB- -- XBz(B(B+- -XW--/ABB W ""7 7 #" CB- -7- - -
9 9 9
G G G' ' 'R X2>@ @9 9@ @9* !W ""? ? #"?& Wb!$$@ @ %$@; ; ;$ $ $1 1 19 9 9: : :	* 	* 	*J J J&? ? ?6 6 6? ? ?J J J J Jr   r  c                   H    e Zd Z	 d Zd Zd ZddZd Zd Zd Z	d	 Z
d
 ZdS )	WalkTestsc                 ^    d|v r|                     d          |d<   t          j        |fi |S Nr  followlinks)rW  r   walk)r9   topkwargss      r   r  zWalkTests.walk  s<    &&$*JJ/@$A$AF=!ws%%f%%%r   c                    t           j        j        }|                     t          j        t          j                    |t          j        d          | _         || j        d          | _         || j        d          | _	         || j        d          } ||d          } || j        d          } || j        d          } ||d          } ||d          } ||d	          | _
         |t          j        d
          } |t          j        d
d          }	 ||d          }
 ||d          } ||d          }t          j        | j	                   t          j        |           t          j        |           t          j        |           ||||	|fD ]G}t          |dd          5 }|                    d|z   dz              d d d            n# 1 swxY w Y   Ht	          j                    rt          j        t           j                            |          | j
                   t          j        d|
d           t          j         |dd          |d           t          j         |dd          |d           |dd	gg df| _        n|dgdgf| _        t$          j        st          j        |d           	 t          j        |           t          j        |t,          j                   t          j        |           t          j        |           | j        d         d d= d S # t4          $ r/ |                     t           j        |t,          j                   Y d S w xY w)NTEST1SUB1SUB11SUB2SUB21tmp1tmp2tmp3linkTEST2tmp4broken_linkbroken_link2broken_link3r%  r   r   zI'm z" and proud of it.  Blame test_os.
brokenTtmp5)r  r  r  r  r   rw   )r   rI   rK   r   r   r  rh   	walk_path	sub1_path
sub11_path	link_pathmakedirsr&   r'   can_symlinkr   r  	sub2_treer   r  chmodlistdirr   S_IRWXUri   r  PermissionError)r9   rK   	sub2_path
sub21_path	tmp1_path	tmp2_path	tmp3_path	tmp5_patht2_path	tmp4_pathbroken_link_pathbroken_link2_pathbroken_link3_pathrI   rt   s                  r   rk   zWalkTests.setUp  s   w|	()*:;;;& i.88dnf55$t~w77D00	T)W--
D00	D00	DF++	DV,,	i00$y'11D)7F;;	4	=99 DN;; DN;; 	DO$$$
I
J
Gy)Y	I 	O 	ODdC'222 Oa(MMNNNO O O O O O O O O O O O O O O  "" 		>Jrww//@@@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$   ,GG	G	=L* *5M#"M#c                    t          |                     | j                            }|                     t	          |          d           |d         d         d         dk    }|d         d                                          |dd|z  z
           d                                          |dd|z  z
           d                                          |                     |d         | j        ddgd	gf           |                     |d|z            | j        d
gdgf           |                     |d|z            | j        g g f           |                     |dd|z  z
           | j                   d S )Nr   r   rw   r  r   ry   r  r  r  r  )	listr  r  rH   rD   sortr  r  r  r9   allflippeds      r   test_walk_topdownzWalkTests.test_walk_topdownM  sZ   499T^,,--S1%%% a&)A,&(Aq	AGOR %%'''AGOQ$$&&&Q$.662BVH!MNNNQ[)DNWIx+PQQQQ[)DOR+DEEEQW_-t~>>>>>r   Nc                 
   || j         }g }|                     |          D ]7\  }}}|                    |||f           d|v r|                    d           8|                     t          |          d           |                     |d         | j         dgdgf           |d         d                                          |d         d                                          |                     |d         | j                   d S )Nr  ry   r   r  r  rw   r  )r  r  appendremoverH   rD   r  r  )r9   r  r  r  dirsrc  s         r   test_walk_prunezWalkTests.test_walk_prune^  s    I!%9!5!5 	$ 	$D$JJdE*+++~~F###S1%%%Q$.6(VH!EFFFAr
Aq	Q00000r   c                 T    |                      t          | j                             d S r.   )r  r   r  rj   s    r   test_file_like_pathzWalkTests.test_file_like_pathq  s&    Xdn5566666r   c                    t          |                     | j        d                    }|                     t	          |          d|           |d         d         d         dk    }|d         d                                          |dd|z  z
           d	                                          |dd|z  z
           d                                          |                     |d         | j        dd
gdgf           |                     ||         | j        g g f           |                     ||dz            | j        dgdgf           |                     |dd|z  z
           | j                   d S )NFtopdownr   r   rw   r   r  ry   r  r  r  r  r  )	r  r  r  rH   rD   r  r  r  r  r  s      r   test_walk_bottom_upzWalkTests.test_walk_bottom_upt  s   499T^U9;;<<S1c*** a&)A,&(Aq	AGOR %%'''AGOQ$$&&&Q.66*:VHE	G 	G 	GW/2r2	4 	4 	4Wq[).7)fX>	@ 	@ 	@QW_-	) 	) 	) 	) 	)r   c                 @   t          j                    s|                     d           |                     | j        d          }|D ]A\  }}}|| j        k    r0|                     |g            |                     |dg            d S B|                     d           d S )Nzneed symlink supportTr  r  z+Didn't follow symlink with followlinks=True)r   r  r|   r  r  r  rH   r=  )r9   walk_itr  r  rc  s        r   test_walk_symlinkzWalkTests.test_walk_symlink  s    $&& 	2MM0111 ))DND)AA!( 	E 	ED$t~%%  r***  111 &
 IICDDDDDr   c                    g }|                      | j        |j                  }t          |          \  }}}|                     |g            d}t
          j                            ||          }t
          j                            ||dz             }t          j        ||           	 d |D             }	| 	                    |           | 
                    ||	           | 
                    ||	           |D ]<}
|
|k    r4|                     t
          j                            ||
          |	           =	 t          j        ||           d S # t          j        ||           w xY w)N)onerrorr  z.newc                     g | ]\  }}}|	S r
   r
   )r   r   drt   s       r   r   z/WalkTests.test_walk_bad_dir.<locals>.<listcomp>  s    ...71aQ...r   )r  r  r  r"  rH   r   rI   rK   r   rp   rf  r   )r9   errorsr  r  r  rc  dir1path1path1newrootsdir2s              r   test_walk_bad_dirzWalkTests.test_walk_bad_dir  sZ   ))DNFM)BB MMdE$$$T4((7<<dVm44
	%"""		'..g...EOOF###UE***Xu--- C C4<<MM"',,tT":":EBBBC Ih&&&&&BIh&&&&s   (BE E#c                     d}t           j                            t          j        d          t          j        j        gdg|z  R  }t          j        |            fdt          d          D             }t          |dz             D ]S}||rdgng g f}|D ]%}                     t          |          |           &t           j        	                    |          }T fdt          d          D             }}t          |dz             D ]X}|||k     rdgng g f}|D ]%}                     t          |          |           &t           j                            |d          }Yd S )N   deepr  c                 >    g | ]}                     d           S )Fr  r  r   jbaser9   s     r   r   z7WalkTests.test_walk_many_open_files.<locals>.<listcomp>  s)    DDDA4//DDDr   r   rw   c                 >    g | ]}                     d           S )Tr  r  r  s     r   r   z7WalkTests.test_walk_many_open_files.<locals>.<listcomp>  s)    CCC14..CCCr   )
r   rI   rK   r   rh   r  r   rH   r"  rV   )r9   depthrY  itersr   rX   r$  r  s   `      @r   test_walk_many_open_filesz#WalkTests.test_walk_many_open_files  s   w||I,f55GL.#u...
ADDDDDsDDDuqy!! 	# 	#AA-C552r2H 5 5  b84444""AACCCCCc

CCCuqy!! 	% 	%AAIIC552r:H 5 5  b84444Q$$AA		% 	%r   r.   )ra   rb   rc   r  rk   r  r  r  r  r  r  r  r
   r   r   r  r    s        & & &
E& E& E&N? ? ?"1 1 1 1&7 7 7) ) )*E E E' ' '*% % % % %r   r  fwalkzTest needs os.fwalk()c                   v    e Zd Z	 d Zd Zd Zd Zd Zd Z e	j
        ej        d          d             Zd	Zd	S )

FwalkTestsc              +   D   K    | j         |fi |D ]\  }}}}|||fV  d S r.   )r  )r9   r  r  r  r  rc  root_fds          r   r  zFwalkTests.walk  sR      *4$*S*C*CF*C*C 	& 	&&D$wu%%%%%	& 	&r   c                 $    t          j        |i |S r.   )r   r  r9   r   r  s      r   r  zFwalkTests.fwalk  s    x((((r   c           	      (   	 |                                 }|                                 }t          j        dd          D ]\  }}|                    ||           |                    ||           i }t	          j        di |D ]'\  }}}t          |          t          |          f||<   ( | j        di |D ]U\  }}}}	|                     ||           | 	                    ||         t          |          t          |          f           Vd S )NTFry   repeat)r  r  )r  r  r
   )
r  	itertoolsproductr  r   r  setr  r   rH   )
r9   walk_kwargsfwalk_kwargsr  r  rX   r  r  rc  rootfds
             r   _compare_to_walkzFwalkTests._compare_to_walk  sK   	 "&&((#((**(1(9-PQ(R(R(R 
	J 
	J$G_wOLLLQQQH%'W%;%;{%;%; 9 9!dE"%d))SZZ!8-7TZ-G-G,-G-G J J)dE6dH---  $#d))SZZ1HIIIIJ
	J 
	Jr   c                 N    dt           j        i}|                     ||           d S )Nr  )r   rh   r  )r9   r  s     r   test_compare_to_walkzFwalkTests.test_compare_to_walk  s+    )*ff-----r   c                    	 t          j        dt           j                  }dt          j        i}|                                }||d<   |                     ||           t          j        |           d S # t          j        |           w xY w)N.r  r   )r   r&   r   r   rh   r  r  ro   )r9   r   r  r  s       r   test_dir_fdzFwalkTests.test_dir_fd  s{    	bk**B )"23K&++--L%'L"!!+|<<<HRLLLLLBHRLLLLs   AA4 4B
c           	      z   t          j        dd          D ]\  }}t          j        |d f} | j        |d|iD ]\  }}}}t          j        |           t          j        |           |                     t          t          j
        |                    t          |          t          |          z             d S )Nr  ry   r  r  )r
  r  r   rh   r  r   fstatr   rH   r  r  )r9   r  r  r   r  r  rc  r  s           r   test_yields_correct_dir_fdz%FwalkTests.test_yields_correct_dir_fd  s    (1(9-PQ(R(R(R 	R 	R$G_#Wd2D-7TZ-_-_-_ R R)dE6     RZ%7%7!8!8#d))c%jj:PQQQQR	R 	Rr   zCannot dup stdout on Emscriptenc                 R   t          j        d          }t          j        |           t          d          D ]$}|                     t
          j                  D ]}%t          j        d          }|                     t           j        |           |                     ||           d S )Nrw      )	r   r{   ro   r   r  r   rh   r   rH   )r9   minfdr   r%  newfds        r   test_fd_leakzFwalkTests.test_fd_leak  s     q		
s 	 	AZZ	 011  q		%(((&&&&&r   N)ra   rb   rc   r  r  r  r  r  r  r   r  r   r  r  r  r
   r   r   r  r    s        & & &) ) )J J J$. . .  
R 
R 
R X_@ ' ' ' !%r   r  c                       e Zd Z	 d ZdS )BytesWalkTestsc              +     K   d|v r|                     d          |d<   t          j        t          j        |          fi |D ]\  }}}t          j        |          }t          t          t          j        |                    }t          t          t          j        |                    }|||fV  t          t          t          j        |                    |d d <   t          t          t          j        |                    |d d <   d S r  )rW  r   r  fsencoder_   r  map)	r9   r  r  brootbdirsbfilesr  r  rc  s	            r   r  zBytesWalkTests.walk  s      &&$*JJ/@$A$AF=!$&GBK,<,<$G$G$G$G 	6 	6 E5&;u%%DBK//00DR[&1122Eu%%%%CT2233E!!!HSe4455F111II	6 	6r   N)ra   rb   rc   r  r
   r   r   r  r    s&        )	6 	6 	6 	6 	6r   r  c                       e Zd Z	 ddZdS )BytesFwalkTestsr  c              /     K   t          j        t          j        |          g|R i |D ]\  }}}}t          j        |          }t	          t          t           j        |                    }	t	          t          t           j        |                    }
||	|
|fV  t	          t          t           j        |	                    |d d <   t	          t          t           j        |
                    |d d <   d S r.   )r   r  r!  r_   r  r"  )r9   r  r   r  r#  r$  r%  topfdr  r  rc  s              r   r  zBytesFwalkTests.fwalk  s      +-8BK4D4D+Vt+V+V+Vv+V+V 	6 	6'E5&%;u%%DBK//00DR[&1122Eue,,,,CT2233E!!!HSe4455F111II	6 	6r   N)r  )ra   rb   rc   r  r
   r   r   r'  r'    s+        )6 6 6 6 6 6r   r'  c                   
   e Zd Zd Zd Z ej        ej        pej	        d          d             Z
 ej        ej        pej	        d          d             Z ej        ej        pej	        d          d             Zd Zd Zd	S )
MakedirTestsc                 B    t          j        t          j                   d S r.   r   rL   r   rh   rj   s    r   rk   zMakedirTests.setUp(  s    
!"""""r   c           
      f   t           j        }t          j                            |ddd          }t          j        |           t          j                            |dddd          }t          j        |           |                     t          t          j        t          j                   t          j                            |dddddt          j                  }t          j        |           t          j                            |dt          j        ddddd          }t          j        |           d S Nr  r  dir3dir4dir5dir6)	r   rh   r   rI   rK   r  r~   rO   curdir)r9   r  rI   s      r   test_makedirzMakedirTests.test_makedir+  s    w||D&&&99
Dw||D&&&&AA
D 	'2;	:::w||D&&&&&")TT
Dw||D&")VVV"F, ,
Dr   z$Emscripten's/WASI's umask is a stub.c                    t          j        d          5  t           j        }t          j                            |d          }t          j                            |d          }t          j        |d           |                     t          j                            |                     |                     t          j        	                    |                     t          j
        dk    r`|                     t          j        |          j        dz  d           |                     t          j        |          j        dz  d           d d d            d S # 1 swxY w Y   d S )Nry   r  r  im  ntr   i  )r   
temp_umaskrh   r   rI   rK   r  rp   r}  isdirr!   rH   r   r?  )r9   r  parentrI   s       r   	test_modezMakedirTests.test_mode:  sh   
 !%(( 		I 		I#DW\\$//F7<<//DKe$$$OOBGNN400111OOBGMM$//000w$  !6!>FFF  !85!@%HHH		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		I 		Is   D6EEEc                 :   t           j                            t          j        d          }d}t          j        d          }t          j        ||           |                     t          t           j        ||           |                     t          t           j        ||d           t          j        |dd           t          j        ||d           t          j        |           t          j        t           j        	                    d	          d           d S )
Nr  r      Fexist_oki  T)r   r?  /)
r   rI   rK   r   rh   umaskr  r~   rO   r  )r9   rI   r   old_masks       r    test_exist_ok_existing_directoryz-MakedirTests.test_exist_ok_existing_directoryJ  s    
 w||I,f558E??
D$'2;d;;;'2;dUKKK
D%$////
Dtd3333
 	BGOOC((4888888r   c                    t           j                            t          j        d          }t
          j        }d}t          j        d          }	 t          j        t          j	        t          j                  j
                  }	 t          j        t          j        ||z             n"# t          $ r t          j        d          w xY wt          j	        t          j                  j
        |z  |k    rt          j        d          t          j        |||z             t          j        ||d           t          j        |t          j        t          j	        |          j
                  | z             t          j        |||z  d           t          j        |           d S # t          j        |           w xY w)Nr  r   r=  zCannot set S_ISGID for dir.z No support for S_ISGID dir mode.Tr>  )r   rI   rK   r   rh   r   S_ISGIDrA  S_IMODElstatr?  r  r  r   SkipTestr  )r9   rI   rE  r   rB  existing_testfn_modes         r   test_exist_ok_s_isgid_directoryz,MakedirTests.test_exist_ok_s_isgid_directory\  s   
 w||I,f55,8E??	#'<HY-..6$8 $8 G)+?'+IJJJJ" G G G'(EFFFG)**2W<GG'(JKKK KdWn--- KdT2222HT4<(>??7(JKKKKdWnt<<<<HXBHXs%   5F( "B' &F( 'CCF( (F>c                    t           j        }t          j                            t           j        d          }t          |dd          5 }|                    d           d d d            n# 1 swxY w Y   |                     t          t          j	        |           |                     t          t          j	        |d           |                     t          t          j	        |d           t          j
        |           d S )	Nr  r{  r   r   r:  Fr>  T)r   rh   r   rI   rK   r&   r'   r~   rO   r  r  )r9   r  rI   rt   s       r   #test_exist_ok_existing_regular_filez0MakedirTests.test_exist_ok_existing_regular_file{  s   w||I,f55$g... 	!GGENNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	'2;555'2;uEEE'2;tDDD
	$s   	A++A/2A/c           	         t           j                            t          j        dddddd          }t           j                            |          s^|t          j        k    rNt           j                            |          }t           j                            |          s|t          j        k    Nt          j        |           d S r/  )r   rI   rK   r   rh   r}  rV   
removedirsr9   rI   s     r   r  zMakedirTests.tearDown  s    w||I,fff"FF4 4
 '..&& 	)493C+C+C7??4((D '..&& 	)493C+C+C 	dr   N)ra   rb   rc   rk   r5  r   r  r   r  r  r;  rC  rJ  rL  r  r
   r   r   r+  r+  '  s       # # #   X_0. 
I 
I	 
I X_0. 9 9	 9 X_0.  	 6  	 	 	 	 	r   r+  c                   .   e Zd Zed             Zd Z ej         ee	d          d          d             Z
 ej        eo ee          dk    d          d             Z ej        e o ee          dk    d	          d
             Zed             ZdS )ChownFileTestsc                 B    t          j        t          j                   d S r.   r-  clss    r   
setUpClasszChownFileTests.setUpClass      
!"""""r   c                 N   t          j        t          j                  }|j        }|j        }ddt          j        d          t          j	        dd          fD ]f}| 
                    t          t           j        t          j        ||           | 
                    t          t           j        t          j        ||           g|                     t          j        t          j        ||                     |                     t          j        t          j        dd                     d S )Ng      y             r  ry   )r   r   r   rh   st_uidst_giddecimalDecimal	fractionsFractionr~   r   chownassertIsNone)r9   r   uidgidrn  s        r   *test_chown_uid_gid_arguments_must_be_indexz9ChownFileTests.test_chown_uid_gid_arguments_must_be_index  s    wy'((kkC!4!4i6HQ6O6OP 	Q 	QEi93CUCPPPi93CS%PPPP"(9#3S#>>???"(9#3R<<=====r   	getgroupszneed os.getgroupsc                 @   t          j                    }t          |          dk     r|                     d           |d d         \  }}t          j        t
          j                  j        }t          j        t
          j        ||           t          j        t
          j                  j	        }| 
                    ||           t          j        t
          j        ||           t          j        t
          j                  j	        }| 
                    ||           d S )Nry   ztest needs at least 2 groups)r   rd  rD   r|   r   r   rh   rY  r_  rZ  rH   )r9   groupsgid_1gid_2ra  rb  s         r   test_chown_gidzChownFileTests.test_chown_gid  s    v;;??MM8999bqbzugi&''.
!3...gi&''.e$$$
!3...gi&''.e$$$$$r   rw   z0test needs root privilege and more than one userc                    t           d d         \  }}t          j        t          j                  j        }t          j        t          j        ||           t          j        t          j                  j        }|                     ||           t          j        t          j        ||           t          j        t          j                  j        }|                     ||           d S Nry   )		all_usersr   r   r   rh   rZ  r_  rY  rH   )r9   uid_1uid_2rb  ra  s        r   test_chown_with_rootz#ChownFileTests.test_chown_with_root  s     !!}ugi&''.
!5#...gi&''.e$$$
!5#...gi&''.e$$$$$r   z2test needs non-root account and more than one userc                 V   t           d d         \  }}t          j        t          j                  j        }|                     t                    5  t          j        t          j        ||           t          j        t          j        ||           d d d            d S # 1 swxY w Y   d S rk  )	rl  r   r   r   rh   rZ  r~   r  r_  )r9   rm  rn  rb  s       r   test_chown_without_permissionz,ChownFileTests.test_chown_without_permission  s     !!}ugi&''.// 	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 	3s   ABB"%B"c                 B    t          j        t          j                   d S r.   )r   r  r   rh   rS  s    r   tearDownClasszChownFileTests.tearDownClass  rV  r   N)ra   rb   rc   classmethodrU  rc  r   r   r   r   ri  root_in_posixrD   rl  ro  rq  rs  r
   r   r   rQ  rQ    s%        # # [#> > > X[113FGG% % HG%  X=33y>>A+=KM M% %M M% X]*Ass9~~/AMO O3 3O O3 # # [# # #r   rQ  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )RemoveDirsTestsc                 B    t          j        t          j                   d S r.   )r   r  r   rh   rj   s    r   rk   zRemoveDirsTests.setUp  s    
I$%%%%%r   c                 B    t          j        t           j                   d S r.   )r   r  rh   rj   s    r   r  zRemoveDirsTests.tearDown  s    )*****r   c                 R   t           j                            t          j        d          }t          j        |           t           j                            |d          }t          j        |           t          j        |           |                     t           j                            |                     |                     t           j                            |                     |                     t           j                            t          j                             d S )Ndiradirb)	r   rI   rK   r   rh   rL   rN  assertFalser}  r9   r{  r|  s      r   test_remove_allzRemoveDirsTests.test_remove_all  s    w||I,f55
w||D&))

d--...--...	(899:::::r   c                    t           j                            t          j        d          }t          j        |           t           j                            |d          }t          j        |           t          t           j                            |d                     t          j        |           |                     t           j        	                    |                     | 
                    t           j        	                    |                     | 
                    t           j        	                    t          j                             d S Nr{  r|  file.txt)r   rI   rK   r   rh   rL   r+   rN  r}  r}  rp   r~  s      r   test_remove_partialz#RemoveDirsTests.test_remove_partial  s    w||I,f55
w||D&))
BGLLz22333
d--...t,,---y'78899999r   c                    t           j                            t          j        d          }t          j        |           t           j                            |d          }t          j        |           t          t           j                            |d                     |                     t                    5  t          j	        |           d d d            n# 1 swxY w Y   | 
                    t           j                            |                     | 
                    t           j                            |                     | 
                    t           j                            t          j                             d S r  )r   rI   rK   r   rh   rL   r+   r~   rO   rN  rp   r}  r~  s      r   test_remove_nothingz#RemoveDirsTests.test_remove_nothing  sI   w||I,f55
w||D&))
BGLLz22333w'' 	  	 M$	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 t,,---t,,---y'78899999s   :CC"CN)ra   rb   rc   rk   r  r  r  r  r
   r   r   rw  rw    s_        & & &+ + +; ; ;	: 	: 	:
: 
: 
: 
: 
:r   rw  zWASI has no /dev/nullc                       e Zd Zd ZdS )DevNullTestsc                 t   t          t          j        dd          5 }|                    d           |                                 d d d            n# 1 swxY w Y   t          t          j        d          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr  r      hellor   r   )r&   r   devnullr'   ro   rH   r   rs   s     r   test_devnullzDevNullTests.test_devnull  s   "*dA&& 	!GGHGGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 "*d## 	,qQVVXXs+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s#   *AAA7)B--B14B1N)ra   rb   rc   r  r
   r   r   r  r    s#        , , , , ,r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )URandomTestsc                    |                      t          t          j        d                    d           |                      t          t          j        d                    d           |                      t          t          j        d                    d           |                      t          t          j        d                    d           |                      t          t          j        d                    d           d S )Nr   rw   rx   r   r>   )rH   rD   r   urandomrj   s    r   test_urandom_lengthz URandomTests.test_urandom_length  s    RZ]]++Q///RZ]]++Q///RZ^^,,b111RZ__--s333RZ--..55555r   c                     t          j        d          }|                     |t                     t          j        d          }|                     ||           d S N   )r   r  r6   r^   r  r9   data1data2s      r   test_urandom_valuezURandomTests.test_urandom_value  sN    
2eU+++
2E5)))))r   c                     d                     dd|z  ddf          }t          d|          }|d         }|                     t          |          |           |S )N
zimport os, syszdata = os.urandom(%s)zsys.stdout.buffer.write(data)zsys.stdout.buffer.flush()r   rw   )rK   r   rH   rD   )r9   countr   outrT  s        r   get_urandom_subprocessz#URandomTests.get_urandom_subprocess  sf    yy#e++'	) * *
 tT**QVe,,,r   c                     |                      d          }|                      d          }|                     ||           d S r  )r  r  r  s      r   test_urandom_subprocessz$URandomTests.test_urandom_subprocess  sD    ++B//++B//E5)))))r   N)ra   rb   rc   r  r  r  r  r
   r   r   r  r     sP        6 6 6* * *	 	 	* * * * *r   r  	getrandomzneed os.getrandom()c                   B    e Zd Zed             Zd Zd Zd Zd Zd Z	dS )GetRandomTestsc                     	 t          j        d           d S # t          $ r/}|j        t          j        k    rt          j        d           d }~ww xY w)Nrw   z%getrandom() syscall fails with ENOSYS)r   r  rO   rP   r   r   rH  )rT  rZ   s     r   rU  zGetRandomTests.setUpClass!  s]    	LOOOOO 	 	 	yEL(( '(OPPP	s    
A*AAc                     t          j        d          }|                     |t                     |                     t          |          d           d S r  )r   r  r6   r^   rH   rD   )r9   r   s     r   test_getrandom_typez"GetRandomTests.test_getrandom_type-  sI    |BdE***TB'''''r   c                 Z    t          j        d          }|                     |d           d S )Nr   r   )r   r  rH   )r9   emptys     r   test_getrandom0zGetRandomTests.test_getrandom02  s+    Q$$$$$r   c                 V    |                      t          t          d                     d S )NGRND_RANDOM)rp   r   r   rj   s    r   test_getrandom_randomz$GetRandomTests.test_getrandom_random6  s$    M2233333r   c                 h    	 t          j        dt           j                   d S # t          $ r Y d S w xY wNrw   )r   r  GRND_NONBLOCKBlockingIOErrorrj   s    r   test_getrandom_nonblockz&GetRandomTests.test_getrandom_nonblock<  sD    	LB,----- 	 	 	DD	s   # 
11c                     t          j        d          }t          j        d          }|                     ||           d S r  )r   r  r  r  s      r   test_getrandom_valuez#GetRandomTests.test_getrandom_valueD  s<    R  R  E5)))))r   N)
ra   rb   rc   rt  rU  r  r  r  r  r  r
   r   r   r  r    sx        	 	 [	( ( (
% % %4 4 4  * * * * *r   r  HAVE_GETENTROPYrw   HAVE_GETRANDOMHAVE_GETRANDOM_SYSCALLz*os.random() does not use a file descriptorr=   z$VxWorks can't set RLIMIT_NOFILE to 1c                   N    e Zd Z ej        ed          d             Zd Zd ZdS )URandomFDTestsz!test requires the resource modulec                 *    d}t          d|           d S )Na  if 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")
            r   r   r   s     r   test_urandom_failurez#URandomFDTests.test_urandom_failureV  s!     	t$$$$$r   c                 2    d}t          d|          \  }}}d S )Na  if 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   )r9   r   rcr  errs        r   test_urandom_fd_closedz%URandomFDTests.test_urandom_fd_closedm  s$     (t44Cr   c                 "   |                      t          j        t          j                   t	          t          j        d           d                    t          j                  }t          d|          \  }}}|                     t          |          d           | 	                    |dd         |dd                    t          d|          \  }}}|                     t          |          d           | 	                    ||           d S )Ns   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa  if 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))
            )rh   r  r/  r   r   )
r   r   ri   rh   r+   formatr   rH   rD   r  )r9   r   r  r  r  out2err2s          r   test_urandom_fd_reopenedz'URandomFDTests.test_urandom_fd_reopened{  s     		()*:;;;I$j1110 i.//1 	2 (t44CS1%%%C!Hc!A#h///)%66D$TA&&&D#&&&&&r   N)	ra   rb   rc   r   r   resourcer  r  r  r
   r   r   r  r  Q  s_        
 X#FGG% % HG%,5 5 5$' $' $' $' $'r   r  c              #   ^  K   	 g fd}fd}	 t           j        }t           j        }t           j        }|t           _        |t           _        | | t           _        V  |t           _        |t           _        |t           _        d S # |t           _        |t           _        |t           _        w xY w)Nc                 R                         d| |f           t          d          )Nexecvzexecv called)r  RuntimeErrorr!   r   callss     r   
mock_execvz#_execvpe_mockup.<locals>.mock_execv  s*    gtT*+++>***r   c                 h                         d| |f           t          t          j        d          )Nexecvezexecve called)r  rO   rP   ENOTDIRr  s     r   mock_execvez$_execvpe_mockup.<locals>.mock_execve  s.    hd+,,,em_555r   )r   r  r  r;  )r;  r  r  
orig_execvorig_execveorig_defpathr  s         @r   _execvpe_mockupr    s       E+ + + + +6 6 6 6 6"X
iz	 BJ	!


 	!
!!!!s   AB &B,r  zneed os.execv()c                       e Zd Z ej        ed          d             Zd Zd Z ej	         e
ed          d          d             Zd Zd	 Z ej	        ej        d
k    d          d             ZdS )	ExecTestsz4avoid triggering a linuxthreads bug: see issue #4970c                 X    |                      t          t          j        ddgd            d S )Nzno such app-)r~   rO   r   execvperj   s    r   test_execvpe_with_bad_programz'ExecTests.test_execvpe_with_bad_program  s6     	'2:~)*D	2 	2 	2 	2 	2r   c                 @   |                      t          t          j        dd           |                      t          t          j        dg            |                      t          t          j        dd           |                      t          t          j        ddg           d S )Nnotepadr
   r6  r  )r~   r   r   r  rj   s    r   test_execv_with_bad_arglistz%ExecTests.test_execv_with_bad_arglist  sz    *bh	2>>>*bh	2>>>*bh	5AAA*bh	B4@@@@@r   c                     |                      t          t          j        dg d            |                      t          t          j        dg i            |                      t          t          j        ddgi            d S )Nr  r  )r~   r   r   r  rj   s    r   test_execvpe_with_bad_arglistz'ExecTests.test_execvpe_with_bad_arglist  sd    *bj)RFFF*bj)RDDD*bj)bT2FFFFFr   _execvpez)No internal os._execvpe function to test.c                    t           j        dz   }|t          u r;d}t           j                            t          j        |          |          }|}g d}nMd}g d}t           j                            ||          }t           j        dk    rt          j        |          }n|}ddi}t                      5 }|                     t          t           j
        ||           |                     t          |          d	           |                     |d
         d||ff           d d d            n# 1 swxY w Y   t          |          5 }|                     t          t           j
        |||           |                     t          |          d	           |                     |d
         d|||ff           d d d            n# 1 swxY w Y   t                      5 }|                                }	|t          u r||	d<   n||	d<   |                     t          t           j
        |||	           |                     t          |          d	           |                     |d
         d|||	ff           d d d            d S # 1 swxY w Y   d S )Nabsolutepaths
   executable)s   prognamearg1arg2r   )prognamer  r  r7  spamr   rw   r   r  )r;  r5  r  r8  r4  )r   rJ   r^   rI   rK   r!  r!   r  r~   r  r  rH   rD   rO   r=  r  )
r9   	test_typeprogram_pathprogramfullpathnative_fullpath	argumentsr0  r  env_paths
             r   _test_internal_execvpez ExecTests._test_internal_execvpe  sr    v.#Gw||BK$=$=wGGH&O555II"G444Iw||L'::Hw$"$+h"7"7"*w  	J%lXy2 2 2SZZ+++U1XI<'HIII		J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J \222 	?egWiS  : : :SZZ+++$$U1X?Y,<=? ? ?		? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?  
	D%xxzzHE!!$0!!#/ gWiX  ? ? ?SZZ+++$$U1X?Y,ABD D D
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	D 
	Ds9   3A+D**D.1D.A.F??GGBI;;I?I?c                     |                      t                     t          j        dk    r|                      t                     d S d S )Nr7  )r  r7   r   r!   r^   rj   s    r   test_internal_execvpe_strz#ExecTests.test_internal_execvpe_str  sB    ##C(((7d??''..... ?r   c                    t           j        ddg}t          j                                        }d|d<   |                     t                    5  t          j        |d         ||           d d d            n# 1 swxY w Y   t          j                                        }d|d<   |                     t                    5  t          j        |d         ||           d d d            n# 1 swxY w Y   t          j                                        }d|d	<   |                     t                    5  t          j        |d         ||           d d d            d S # 1 swxY w Y   d S )
Nr   passcabbageFRUIT VEGETABLEr   orange VEGETABLE=cabbageFRUITlemonFRUIT=ORANGE)rB   r   r   r  r  r~   r   r  )r9   r   newenvs      r   test_execve_invalid_envz!ExecTests.test_execve_invalid_env  s   f- ""%.!"z** 	- 	-Id1gtV,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- ""5wz** 	- 	-Id1gtV,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- ""!(~z** 	- 	-Id1gtV,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s6   A66A:=A:>C''C+.C+/EE Er   zWin32-specific testc                     	 t          j        ddgi            |                     d           d S # t          $ r2}|                     |j        d u p
|j        dk               Y d }~d S d }~ww xY w)Nr  argzNo OSError raisedr   )r   r  r=  rO   rp   winerrorrv  s     r   test_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	Cs   0 
A,'A''A,N)ra   rb   rc   r   r  USING_LINUXTHREADSr  r  r  r   r   r   r  r  r  rB   rC   r  r
   r   r   r  r    s        X_'KM M2 2M M2A A AG G G
 XZ00DF F-D -DF F-D^/ / /
- - -* X02GHH+ + IH+ + +r   r  r   rt  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	Win32ErrorTestsc                 "   	 t          j        t          j                   |                     dt          j        z             d S # t
          $ r d}Y d S t          $ r2}d}|                     dt          j        d|           Y d }~d S d }~ww xY w)Nzfile %s must not existFTzfile z% must not exist; os.stat failed with )r   r   r   rh   r=  rN   rO   )r9   r}  rZ   s      r   rk   zWin32ErrorTests.setUp/  s    		CGI$%%% II.1AABBBBB ! 	 	 	FFFF 	1 	1 	1FIII")))330 1 1 1 1 1 1 1 1 1	1s   A B	B'B		Bc                     |                      t          t          j        t          j        t          j        dz              d S )Nz.bak)r~   rO   r   r   r   rh   rj   s    r   r   zWin32ErrorTests.test_rename;  s0    '29i.>	@PQW@WXXXXXr   c                 f    |                      t          t          j        t          j                   d S r.   )r~   rO   r   r  r   rh   rj   s    r   test_removezWin32ErrorTests.test_remove>  s%    '29i.>?????r   c                 f    |                      t          t          j        t          j                   d S r.   )r~   rO   r   rM   r   rh   rj   s    r   
test_chdirzWin32ErrorTests.test_chdirA  s%    '28Y-=>>>>>r   c                     |                      t          j        t          j                   t	          t          j        d          5 }|                     t          t          j        t          j                   d d d            d S # 1 swxY w Y   d S )Nr%  )	r   r   ri   rh   r&   r~   rO   r   rL   rs   s     r   
test_mkdirzWin32ErrorTests.test_mkdirD  s    	()*:;;;)"C(( 	CAgrx1ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs   1BB
Bc                 h    |                      t          t          j        t          j        d            d S r.   )r~   rO   r   r  r   rh   rj   s    r   r  zWin32ErrorTests.test_utimeJ  s'    '28Y-=tDDDDDr   c                 h    |                      t          t          j        t          j        d           d S r   )r~   rO   r   r  r   rh   rj   s    r   
test_chmodzWin32ErrorTests.test_chmodM  s'    '28Y-=qAAAAAr   N)
ra   rb   rc   rk   r   r  r  r  r  r	  r
   r   r   r  r  -  s        
C 
C 
CY Y Y@ @ @? ? ?C C CE E EB B B B Br   r  z!Cannot create invalid FD on WASI.c                   J   e Zd Zg dZd ZeD ]Z ee           e            dez   <   d Zd Z e	j
         eed          d          d             Z e	j
         eed	          d
          d             Z e	j
         eed          d          d             Z e	j
         eed          d           e	j        ej        d          d                         Z e	j
         eed          d          d             Z e	j
         eed          d          d             Z e	j
         eed          d           e	j        ej        pej        d          d                         Z e	j
         eed          d          d             Z e	j
         eed          d          d              Z e	j
         eed!          d"          d#             Z e	j
         eed$          d%          d&             Z e	j
         eed'          d(          d)             Z e	j
         eed*          d+          d,             Z e	j
         eed-          d.          d/             Z ej                    d0             Z  e	j
         eed1          d2          d3             Z!d4S )5TestInvalidFD)fchdirr{   	fdatasyncr  fstatvfsfsync	tcgetpgrpttynamec                       fd}|S )Nc                     t          t                    r*|                     t          t                               d S d S r.   )r   r   rS  r:  rs   s    r   helperz(TestInvalidFD.get_single.<locals>.helperX  s=    A +

72q>>*****+ +r   r
   )rt   r  s   ` r   
get_singlezTestInvalidFD.get_singleW  s#    	+ 	+ 	+ 	+ 	+ r   test_c                     	  |t          j                    g|R i | |                     d|z             d S # t          $ r0}|                     |j        t
          j                   Y d }~d S d }~ww xY w)Nz5%r didn't raise an OSError with a bad file descriptor)r   make_bad_fdr=  rO   rH   rP   rz  )r9   rt   r   r  r   s        r   rS  zTestInvalidFD.check_  s    	Ai#%%7777777 IIM       	3 	3 	3QWek222222222	3s   9 
A3%A..A3c                 H    |                      t          j        d           d S )Nr   r   )rS  r   r   rj   s    r   r   zTestInvalidFD.test_fdopenh  s     

29w
/////r   isattyztest needs os.isatty()c                 x    |                      t          j        t          j                              d           d S NF)rH   r   r  r   r  rj   s    r   test_isattyzTestInvalidFD.test_isattyk  s1    9#8#:#:;;UCCCCCr   r}   ztest needs os.closerange()c                 2   t          j                    }t          d          D ]*}t          j        ||z               n# t
          $ r Y 'w xY w|dk     rt          j        d          |                     t          j	        |||z   dz
            d            d S )Nrx   ry   z5Unable to acquire a range of invalid file descriptorsrw   )
r   r  r   r   r  rO   r   rH  rH   r}   )r9   r   r   s      r   r   zTestInvalidFD.test_closerangeo  s    "$$ r 	 	A"Q$      q55#GI I Ir26!844d;;;;;s   >
A
Adup2ztest needs os.dup2()c                 F    |                      t          j        d           d S )N   )rS  r   r  rj   s    r   	test_dup2zTestInvalidFD.test_dup2  s    

27Br   z@dup2() with negative fds is broken on Emscripten (see gh-102179)c                    t          j        t          t           j                  }|                     t           j        |           |ddg}t          j        |d          D ]\  }}||k    r|                     ||          5  | 	                    t                    5 }t          j        ||           d d d            n# 1 swxY w Y   |                     |j        j        t          j                   d d d            n# 1 swxY w Y   d S )Nr  i   ry   r  )r   fd2)r   r&   r   r   r   ro   r
  r  subTestr~   rO   r  rH   ry  rP   rz  )r9   valid_fdfdsr   r$  r|  s         r   test_dup2_negative_fdz#TestInvalidFD.test_dup2_negative_fd  s    78R[11(+++

 !(Q777 	G 	GGBSyy\\RS\11 G G**733 )sC((() ) ) ) ) ) ) ) ) ) ) ) ) ) )$$S]%8%+FFFG G G G G G G G G G G G G G G	G 	Gs6   D B?3D ?CD C-D  D	D	fchmodztest needs os.fchmod()c                 F    |                      t          j        d           d S r   )rS  r   r)  rj   s    r   test_fchmodzTestInvalidFD.test_fchmod  s    

29a     r   fchownztest needs os.fchown()c                 H    |                      t          j        dd           d S )Nr  )rS  r   r,  rj   s    r   test_fchownzTestInvalidFD.test_fchown  s     

29b"%%%%%r   	fpathconfztest needs os.fpathconf()z-musl libc issue on Emscripten/WASI, bpo-46390c                     |                      t          j        d           |                      t          j        d           d S )NPC_NAME_MAX)rS  r   pathconfr/  rj   s    r   test_fpathconfzTestInvalidFD.test_fpathconf  s6     	

2;...

2</////r   	ftruncateztest needs os.ftruncate()c                     |                      t          j        d           |                      t          j        d           d S r   )rS  r   truncater4  rj   s    r   test_ftruncatezTestInvalidFD.test_ftruncate  s4    

2;"""

2<#####r   r   ztest needs os.lseek()c                 H    |                      t          j        dd           d S r   )rS  r   r   rj   s    r   
test_lseekzTestInvalidFD.test_lseek  s     

28Q"""""r   r   ztest needs os.read()c                 F    |                      t          j        d           d S r  )rS  r   r   rj   s    r   r   zTestInvalidFD.test_read  s    

27Ar   readvztest needs os.readv()c                 f    t          d          }|                     t          j        |g           d S )Nrx   )r   rS  r   r;  )r9   r  s     r   
test_readvzTestInvalidFD.test_readv  s+    mm

28cU#####r   	tcsetpgrpztest needs os.tcsetpgrp()c                 F    |                      t          j        d           d S r   )rS  r   r>  rj   s    r   test_tcsetpgrptzTestInvalidFD.test_tcsetpgrpt  s    

2<#####r   r'   ztest needs os.write()c                 F    |                      t          j        d           d S )N    )rS  r   r'   rj   s    r   r   zTestInvalidFD.test_write  s    

28T"""""r   writevztest needs os.writev()c                 H    |                      t          j        dg           d S )Nr9  )rS  r   rC  rj   s    r   test_writevzTestInvalidFD.test_writev  s     

29vh'''''r   c                     |                      t          j                   |                      t          j        d           d S NT)rS  r   get_inheritableset_inheritablerj   s    r   test_inheritablezTestInvalidFD.test_inheritable  s4    

2%&&&

2%t,,,,,r   get_blocking-needs os.get_blocking() and os.set_blocking()c                     |                      t          j                   |                      t          j        d           d S rG  )rS  r   rK  set_blockingrj   s    r   test_blockingzTestInvalidFD.test_blocking  s4     	

2?###

2?D)))))r   N)"ra   rb   rc   singlesr  rt   localsrS  r   r   r   r   r   r  r   r"  r  r   r  r(  r+  r.  r  r3  r7  r9  r   r=  r@  r   rE  r  rJ  rO  r
   r   r   r  r  Q  s^       < < <G  
  , ,(jmm  0 0 0 XX..0HIID D JID X\224PQQ< < RQ< XV,,.DEE    FE  XV,,.DEEX_J G G	  FE
G XX..0HII! ! JI! XX..0HII& & JI& X[113NOOX_07 0 0	  PO
0 X[113NOO$ $ PO$ XW--/FGG# # HG# XV,,.DEE  FE XW--/FGG$ $ HG$ X[113NOO$ $ PO$ XW--/FGG# # HG# XX..0HII( ( JI( !W ""- - #"- X^44HJ J* *J J* * *r   r  r  zrequires os.linkc                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )	LinkTestsc                     t           j        | _        t          j                            t           j        dz             | _        d S )Nr  )r   rh   file1r   rI   rK   file2rj   s    r   rk   zLinkTests.setUp  s-    %
W\\)"2S"899


r   c                     | j         | j        fD ]5}t          j                            |          rt          j        |           6d S r.   )rU  rV  r   rI   r}  ri   )r9   files     r   r  zLinkTests.tearDown  sH    Z, 	  	 Dw~~d##  	$	  	 r   c           	          t          |           	 t          j        ||           n/# t          $ r"}|                     d|z             Y d }~nd }~ww xY wt          |d          5 }t          |d          5 }|                     t          j                            |	                                |	                                                     d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nos.link(): %sr   )
r+   r   r  r  r|   r&   rp   rI   sameopenfiler   )r9   rU  rV  r   r  f2s         r   
_test_linkzLinkTests._test_link  s   E	/GE5!!!! 	/ 	/ 	/MM/A-........	/% 	L"d5$&7&7 	L2OOBG00biikkJJ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 	LsK   ' 
AAA&C37ACC3C	C3"C	#C33C7:C7c                 F    |                      | j        | j                   d S r.   )r]  rU  rV  rj   s    r   	test_linkzLinkTests.test_link  s     
DJ/////r   c                     |                      t          | j        t          j                              t          | j        t          j                                         d S r.   )r]  r^   rU  rB   rO  rV  rj   s    r   test_link_byteszLinkTests.test_link_bytes  sV    dj#*C*E*EFFdj#*C*E*EFF	H 	H 	H 	H 	Hr   c                     	 t          j        d           n"# t          $ r t          j        d          w xY w| xj        dz  c_        | j        dz   | _        |                     | j        | j                   d S )N   ñz#Unable to encode for this platform.r  )r   r!  UnicodeErrorr   rH  rU  rV  r]  rj   s    r   test_unicode_namezLinkTests.test_unicode_name  s    	KK 	K 	K 	K#$IJJJ	K 	

f

Z#%

DJ/////s    6N)	ra   rb   rc   rk   r  r]  r_  ra  re  r
   r   r   rS  rS    st        : : :     
L L L0 0 0H H H0 0 0 0 0r   rS  zPosix specific testsc                      e Zd ZdZdZ ej         eed          d          d             Z	 ej         eed          d          d             Z
 ej         eed          d	          d
             Z ej         eed          d          d             Z ej         eed          d          d             Z ej         eed          d           ej                    d                         Z ej         eed          d           ej                    d                         Z ej         eed          d           ej                    d                         ZdS )PosixUidGidTests        setuidztest needs os.setuid()c                 "   t          j                    dk    r&|                     t          t           j        d           |                     t
          t           j        d           |                     t          t           j        | j                   d S Nr   z
not an int)r   getuidr~   rO   ri  r   OverflowErrorUID_OVERFLOWrj   s    r   test_setuidzPosixUidGidTests.test_setuid  sj    9;;!gry!444)RY===-D4EFFFFFr   setgidztest needs os.setgid()c                 0   t          j                    dk    r-t          s&|                     t          t           j        d           |                     t          t           j        d           |                     t          t           j        | j                   d S rk  )	r   rl  HAVE_WHEEL_GROUPr~   rO   rp  r   rm  GID_OVERFLOWrj   s    r   test_setgidzPosixUidGidTests.test_setgid	  sp    9;;!$4gry!444)RY===-D4EFFFFFr   seteuidztest needs os.seteuid()c                 "   t          j                    dk    r&|                     t          t           j        d           |                     t
          t           j        d           |                     t          t           j        | j                   d S rk  )	r   rl  r~   rO   ru  r   setegidrm  rn  rj   s    r   test_seteuidzPosixUidGidTests.test_seteuid	  sj    9;;!grz1555)RZ>>>-T5FGGGGGr   rw  ztest needs os.setegid()c                 0   t          j                    dk    r-t          s&|                     t          t           j        d           |                     t          t           j        d           |                     t          t           j        | j                   d S rk  )	r   rl  rr  r~   rO   rw  r   rm  rs  rj   s    r   test_setegidzPosixUidGidTests.test_setegid	  sp    9;;!$4grz1555)RZ>>>-T5FGGGGGr   setreuidztest needs os.setreuid()c                    t          j                    dk    r'|                     t          t           j        dd           |                     t
          t           j        dd           |                     t
          t           j        dd           |                     t          t           j        | j        d           |                     t          t           j        d| j                   d S rk  )r   rl  r~   rO   r{  r   rm  rn  rj   s    r   test_setreuidzPosixUidGidTests.test_setreuid	  s    9;;!gr{Aq999)R[,BBB)R[!\BBB-d6GKKK-a9JKKKKKr   c                 H    t          j        t          j        ddg           d S )Nr   z,import os,sys;os.setreuid(-1,-1);sys.exit(0)r   r  rB   r   rj   s    r   test_setreuid_neg1z#PosixUidGidTests.test_setreuid_neg1#	  8    
 	>@ 	A 	A 	A 	A 	Ar   setregidztest needs os.setregid()c                    t          j                    dk    r.t          s'|                     t          t           j        dd           |                     t          t           j        dd           |                     t          t           j        dd           |                     t          t           j        | j        d           |                     t          t           j        d| j                   d S rk  )	r   rl  rr  r~   rO   r  r   rm  rs  rj   s    r   test_setregidzPosixUidGidTests.test_setregid,	  s     9;;!$4gr{Aq999)R[,BBB)R[!\BBB-d6GKKK-a9JKKKKKr   c                 H    t          j        t          j        ddg           d S )Nr   z,import os,sys;os.setregid(-1,-1);sys.exit(0)r  rj   s    r   test_setregid_neg1z#PosixUidGidTests.test_setregid_neg16	  r  r   N)ra   rb   rc   rn  rs  r   r   r   r   ro  rt  rx  rz  r}  r   r  r  r  r  r
   r   r   rg  rg    sB        LLXX..0HIIG G JIG XX..0HIIG G JIG XY//1JKKH H LKH XY//1JKKH H LKH XZ002LMML L NML XZ002LMM W ""A A #" NMA XZ002LMM W ""L L #" NML XZ002LMM W ""A A #" NMA A Ar   rg  c                   t    e Zd Zd Zd Zd Zd Z ej         e	e
d          d          d             Zd Zd	S )
Pep383Testsc                 d   t           j        rt           j        | _        n/t           j        rt           j        | _        nt           j        | _        t          j        | j                  | _        g fd} |t           j                   t           j        r |t           j                   t           j        r |t           j                   s| 	                    d           t                      | _        t          j        | j                   	 D ]}t          j        t
          j                            | j        |                     t          j        |          }|| j        v rt#          d          | j                            |           d S #  t'          j        | j                    xY w)Nc                     	 t          j        |           } n# t          $ r Y d S w xY w                    |            d S r.   )r   r!  rP  r  )fnbytesfns    r   add_filenamez'Pep383Tests.setUp.<locals>.add_filenameK	  sQ    [__%   NN2s    
&&z&couldn't create any non-ascii filenamezduplicate filename)r   TESTFN_UNENCODABLEr7  TESTFN_NONASCIIrh   r   r!  bdirTESTFN_UNICODEr|   r  	unicodefnrL   create_empty_filerI   rK   r_   r   addshutilr  )r9   r  r  r  s      @r   rk   zPep383Tests.setUpA	  s   ' 	( 3DHH& 	( 0DHH 'DHK))		 	 	 	 	 	Y-...' 	7L5666$ 	4L2333 	DMMBCCC
		 ' '+BGLLB,G,GHHH[__''$%9:::""2&&&&' '	M$(###s   BF F/c                 8    t          j        | j                   d S r.   )r  r  r7  rj   s    r   r  zPep383Tests.tearDownf	  s    dhr   c                    | j         }t          t          j        | j                            }|                     ||           t          j                    }	 t          j        t          j                   |                     t          t          j                              t          t          j        t          j                                       t          j        |           d S # t          j        |           w xY wr.   )	r  r  r   r  r7  rH   r5   rM   rJ   )r9   rX   foundcurrent_directorys       r   test_listdirzPep383Tests.test_listdiri	  s    >BJtx(()))))IKK	(HRVS..BJrv4F4F0G0GHHHH&'''''BH&''''s   A;C) )C?c                     | j         D ]I}t          t          j                            | j        |          d          }|                                 Jd S Nr   )r  r&   r   rI   rK   r7  ro   )r9   r  rt   s      r   	test_openzPep383Tests.test_openu	  sM    . 	 	BRW\\$(B//66AGGIIII	 	r   r\  rq  c                     | j         D ];}t          j                            | j        |          }t          j        |           <d S r.   )r  r   rI   rK   r7  r\  )r9   r  fullnames      r   test_statvfszPep383Tests.test_statvfsz	  sI     . 	! 	!Bw||DHb11HJx    	! 	!r   c                     | j         D ]9}t          j        t          j                            | j        |                     :d S r.   )r  r   r   rI   rK   r7  )r9   r  s     r   	test_statzPep383Tests.test_stat	  sB    . 	0 	0BGBGLL2..////	0 	0r   N)ra   rb   rc   rk   r  r  r  r   r   r   r   r  r  r
   r   r   r  r  ?	  s        # # #J     
( 
( 
(  
 XY///1 1! !1 1!0 0 0 0 0r   r  c                       e Zd Zd Zd Zd Z ej        edu d          d             Z	 ej
        d           ej                    d                         Z ej                    d	             ZdS )
Win32KillTestsc                 ~   dd l }ddl m} dd l}|j        j        j        }|j        |_        |j        |	                    |j
                  |j        |	                    |j                  |	                    |j                  |	                    |j                  f|_        d}t          j        t          j        dd                    |          gt          j        t          j        t          j                  }|                     |j        j                   |                     |j        j                   |                     |j        j                   d\  }}	||	k     r|                                |                    t5          |                    }
 ||                    |j                                                  |
|                    |
          d d d           }|                     |dd           |
j        r.|                      ||
j        !                                           nHtE          j#        d	           |d
z  }||	k     r|                                | $                    d           tK          j&        |j'        |           |                      |(                                |           d S )Nr   wintypesrunningr   z<import sys;sys.stdout.write('{}');sys.stdout.flush();input())rT  stderrstdinr   r   zPeekNamedPipe failed皙?rw   z1Did not receive communication from the subprocess))r  r  msvcrtr  r  PeekNamedPipeBOOLrestypeHANDLEPOINTERc_charDWORDargtypesr   PopenrB   r   r  rZ  r   rT  ro   r  r  pollcreate_string_bufferrD   get_osfhandler   sizeofr  rn  rH   rL  r  sleepr=  r   killpidwait)r9   sigr  r  r  r  r  r]  r  maxr  rslts               r   _killzWin32KillTests._kill	  st   
 	###### .< ("*/"(.."?"?"*."(.."@"@"(.."@"@"(.."@"@"B "+ ,26#;;	!8
 (2'1&0o7 7 7 	)***)***
()))
sckkdiikk1--c#hh77C !=!5!5dk6H6H6J6J!K!K!$fmmC&8&8$dL LDa)?@@@y   ci&6&6&8&8999JsOOOQJE ckkdiikk1 IIIJJJ
#c*****r   c                 D    |                      t          j                   d S r.   )r  signalSIGTERMrj   s    r   test_kill_sigtermz Win32KillTests.test_kill_sigterm	  s    

6>"""""r   c                 0    |                      d           d S )Nr   )r  rj   s    r   test_kill_intzWin32KillTests.test_kill_int	  s    

3r   Nzrequires mmapc                    dt          j                    z  }t          j        dd|          }d|d<   t          j        t
          j        t          j        	                    t          j        
                    t                    d          |gt          j                  }d\  }}||k     rT|                                @|d         dk    rnlt          j        d           |dz  }||k     r|                                @t          j        |j        t$          j                   |                     d	           t          j        |j        |           t          j        d
           |                                sNt          j        |j        t$          j                   |                     d                    |                     d S d S )Nz
test_os_%sr  rw   r   zwin_console_handler.pyr  r  r  z'Subprocess didn't finish initializationg      ?zsubprocess did not stop on {})uuiduuid1mmapr   r  rB   r   r   rI   rK   rV   r   CREATE_NEW_PROCESS_GROUPr  r  r  r  r  r  SIGINTr=  r  )r9   eventr!   tagnamemr]  r  r  s           r   _kill_with_eventzWin32KillTests._kill_with_event	  s   -Ib!W%%!7<< 9 9 8: :;B!D ",!DF F F
 
sckkdiikk1tqyyJsOOOQJE	 ckkdiikk1 GDHfm,,,II?@@@
%    	
3yy{{ 	DGDHfm,,,II5<<TBBCCCCC	D 	Dr   z.subprocesses aren't inheriting Ctrl+C propertyc                 <   ddl m} dd l } |                    |j                              }|j        j        j        }|                    |j                  |j        f|_        |j        |_	         ||d           | 
                    t          j        d           d S )Nr   r  CTRL_C_EVENT)r  r  r  c_intr  r  SetConsoleCtrlHandlerr  r  r  r  r  r  )r9   r  r  NULLr  s        r   test_CTRL_C_EVENTz Win32KillTests.test_CTRL_C_EVENT	  s     	$##### ,v~~fl++-- & 6 L*0..*F*F*2-*9&(0%
 	dA&&&f1>BBBBBr   c                 F    |                      t          j        d           d S )NCTRL_BREAK_EVENT)r  r  r  rj   s    r   test_CTRL_BREAK_EVENTz$Win32KillTests.test_CTRL_BREAK_EVENT	  s"    f57IJJJJJr   )ra   rb   rc   r  r  r  r   r  r  r  skipr   r  r  r  r
   r   r   r  r  	  s        4+ 4+ 4+l# # #   X_TT\?33D D 43D: X]CDD W ""C C #" EDC$ !W ""K K #"K K Kr   r  c                   (    e Zd Z	 d Zd Zd Zd ZdS )Win32ListdirTestsc                 
   g | _         t          d          D ]}d|z  }t          j                            t
          j        |          }d|z  }t          j                            t
          j        |          }t          j        |           t          |dd          5 }|	                    d|z             d d d            n# 1 swxY w Y   | j         
                    ||g           | j                                          d S )Nry   zSUB%dzFILE%dr{  r   r   z'I'm %s and proud of it. Blame test_os.
)created_pathsr   r   rI   rK   r   rh   r  r&   r'   extendr  )r9   r   dir_namedir_path	file_name	file_pathrt   s          r   rk   zWin32ListdirTests.setUp
  s:   q 	= 	=A{Hw||I$4h??H 1IY%5yAAIK!!!iw777 P1BYNOOOP P P P P P P P P P P P P P P%%x&;<<<<!!!!!s   CC		C	c                 B    t          j        t          j                   d S r.   )r  r  r   rh   rj   s    r   r  zWin32ListdirTests.tearDown
  s    i&'''''r   c           	      P   	 |                      t          t          j        t          j                            | j                   |                      t          t          j        t          j        t          j                                      d | j        D                        d S )Nc                 6    g | ]}t          j        |          S r
   r   r!  r   rI   s     r   r   zCWin32ListdirTests.test_listdir_no_extended_path.<locals>.<listcomp>
  "    BBBtT""BBBr   )rH   sortedr   r  r   rh   r  r!  rj   s    r   test_listdir_no_extended_pathz/Win32ListdirTests.test_listdir_no_extended_path
  s    ;rz)"23344"	$ 	$ 	$
 	rz"+i.>"?"?@@AABBt/ABBB	D 	D 	D 	D 	Dr   c                    	 dt           j                            t          j                  z   }|                     t          t          j        |                    | j                   dt          j	        t           j                            t          j                            z   }|                     t          t          j        |                    d | j        D                        d S )N\\?\   \\?\c                 6    g | ]}t          j        |          S r
   r  r  s     r   r   z@Win32ListdirTests.test_listdir_extended_path.<locals>.<listcomp>+
  r  r   )
r   rI   r  r   rh   rH   r  r  r  r!  rO  s     r   test_listdir_extended_pathz,Win32ListdirTests.test_listdir_extended_path
  s    7 27??9+;<<<rz$''(("	$ 	$ 	$
 BK	8H(I(IJJJrz$''((BBt/ABBB	D 	D 	D 	D 	Dr   N)ra   rb   rc   rk   r  r  r  r
   r   r   r  r  	  s[        "" " "( ( (
D 
D 
DD D D D Dr   r  readlinkzneeds os.readlink()c                       e Zd ZdZej                            e          Z ej	        e          Z
 ej	        e          Zd Zd Zd Zd Zej        d             Zej        d             Zej        d             Zd	S )
ReadlinkTestsreadlinktestc                 (   t           j                            |          }t           j                            |          }t          j        dk    r-d } ||          r
|dd          } ||          r
|dd          }|                     ||           d S )Nr   c                 Z    |                      t          | t                    rdnd          S )Nr  r  )
startswithrk  r^   )rY  s    r   r  z/ReadlinkTests.assertPathEqual.<locals>.<lambda>;
  s,    1<<(E22A

	$C $C r   r   )r   rI   normcaserB   rC   rH   )r9   leftright
has_prefixs       r   assertPathEqualzReadlinkTests.assertPathEqual5
  s    w%%  ''<7""C CJz$  ABBxz%   "abb	u%%%%%r   c                    |                      t          j                            | j                             |                      t          j                            | j                             |                     t          j                            | j                             |                     t          j                            | j                             d S r.   )	rp   r   rI   r}  filelink_targetfilelinkb_targetr}  filelink	filelinkbrj   s    r   rk   zReadlinkTests.setUpC
  s    t';<<===t'<==>>>667777788888r   c                     t          | j                  }|                     t          t          j        | j                   |                     t          t          j        |           d S r.   )r   r   r~   rO   r   r  )r9   r   s     r   test_not_symlinkzReadlinkTests.test_not_symlinkI
  sO    "4#788'2;0DEEE'2;@@@@@r   c                     |                      t          t          j        d           |                      t          t          j        t	          d                     d S )Nzmissing-link)r~   rN   r   r  r   rj   s    r   test_missing_linkzReadlinkTests.test_missing_linkN
  sQ    +R[.III+R[">22	4 	4 	4 	4 	4r   c                    t          j        | j        | j                   |                     t
          j        | j                   t          | j                  }|                     t          j	        |          | j                   d S r.   )
r   r   r   r  r   r   ri   r   r  r  )r9   r  s     r   test_pathlikezReadlinkTests.test_pathlikeS
  sj    

4'777	($-888DM**R[22D4HIIIIIr   c                 F   t          j        | j        | j                   |                     t
          j        | j                   t          j        t          | j                            }| 	                    || j                   | 
                    |t                     d S r.   )r   r   r  r  r   r   ri   r  r   r  r6   r^   rO  s     r   test_pathlike_bytesz!ReadlinkTests.test_pathlike_bytesZ
  s    

4($.999	($.999{8DN3344T4#8999dE*****r   c                 ,   t          j        | j        | j                   |                     t
          j        | j                   t          j        | j                  }|                     || j                   | 	                    |t                     d S r.   )r   r   r  r  r   r   ri   r  r  r6   r^   rO  s     r   
test_byteszReadlinkTests.test_bytesb
  sx    

4($.999	($.999{4>**T4#8999dE*****r   N)ra   rb   rc   r  r   rI   r  r   r   r!  r  r  r  rk   r  r  r   skip_unless_symlinkr	  r  r  r
   r   r   r  r  .
  s        Hgooh//OH%%I"r{?33& & &9 9 9A A A
4 4 4
 "J J #"J "+ + #"+ "+ + #"+ + +r   r  c                   b   e Zd ZdZej                            e          ZdZ	ej        
                    e          ZdZd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Z ej        ej                            d          oej                            d          d          d             Zd Zd ZdS )Win32SymlinkTestsfilelinktestdirlinktestzmissing linkc                     d S r.   r
   rj   s    r   rk   zWin32SymlinkTests.setUpt
        r   c                 x   t           j                            | j                  rt          j        | j                   t           j                            | j                  rt          j        | j                   t           j                            | j                  rt          j        | j                   d S d S r.   )	r   rI   r}  r  r  dirlinkr  rg   missing_linkrj   s    r   r  zWin32SymlinkTests.tearDown{
  s    7>>$-(( 	%Idm$$$7>>$,'' 	#HT\"""7??4,-- 	)Id'(((((	) 	)r   c                    t          j        | j        | j                   |                     t           j                            | j                             |                     t           j                            | j                             |                     t           j                            | j                             | 	                    | j        | j                   d S r.   )
r   r   dirlink_targetr  rp   rI   r}  r9  islink
check_statrj   s    r   test_directory_linkz%Win32SymlinkTests.test_directory_link
  s    

4&555t|44555dl33444t|44555d&9:::::r   c                    t          j        | j        | j                   |                     t           j                            | j                             |                     t           j                            | j                             |                     t           j                            | j                             | 	                    | j        | j                   d S r.   )
r   r   r   r  rp   rI   r}  isfiler  r  rj   s    r   test_file_linkz Win32SymlinkTests.test_file_link
  s    

4'777t}55666t}55666t}55666t';<<<<<r   c                     	 | j         }t          j                            |          rt          j        |           d}d}t          j        |||           d S )Nz"c:\\target does not exist.29r3c740T)r  r   rI   rg   r  r   )r9   linknamer   target_is_dirs       r   _create_missing_dir_linkz*Win32SymlinkTests._create_missing_dir_link
  sW    <$7??8$$ 	 Ih6

68]33333r   c                 `    |                                   t          j        | j                   d S r.   )r#  r   r  r  rj   s    r   ,test_remove_directory_link_to_missing_targetz>Win32SymlinkTests.test_remove_directory_link_to_missing_target
  s/    %%''' 		$#$$$$$r   c                     |                                   |                     t          j                            | j                             d S r.   )r#  r}  r   rI   r9  r  rj   s    r   .test_isdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_isdir_on_directory_link_to_missing_target
  s?    %%'''t'899:::::r   c                 `    |                                   t          j        | j                   d S r.   )r#  r   r  r  rj   s    r   .test_rmdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_rmdir_on_directory_link_to_missing_target
  s-    %%'''
"#####r   c                    |                      t          j        |          t          j        |                     |                     t          j        |          t          j        |                     t          j        |          }|                      t          j        |          t          j        |                     |                     t          j        |          t          j        |                     d S r.   )rH   r   r   r  rG  r!  )r9   r  r   
bytes_links       r   r  zWin32SymlinkTests.check_stat
  s    888BHTNNBGDMM:::[&&
,,bgfoo>>>BHZ00"'*2E2EFFFFFr   c                    t           j                            t          j                  }t           j                            |d          }t           j                            |d          }|                     t          j        |           t          j        |           t          j        |           t          j        |           t           j                            t           j                            |d                    }t          |           t          j
                    }	 t          j        |           t           j                            |d          }t          j        t           j                            |          d           |                     dt          j        t          j
                                         |                     t          j        |          t          j        d                     t          j        |           |                     t          j        |          t          j        t           j                            |                               t          j        |           |                     t          j        |          t          j        t           j                            |                               t          j        |           d S # t          j        |           w xY w)Nlevel2level3rU  r  )r   rI   r  r   rh   rK   r   r  rL   r+   r5   rM   r   relpathr   r  rH   r   )r9   level1r-  r.  rU  orig_dirr  s          r   
test_12084zWin32SymlinkTests.test_12084
  s'   !122fh//fh//	(&111


VW = =>>E9;;	HV7<<//DJrwu--v666MM&"*RY[["9"9::: RWU^^RWV__=== HVRWU^^WRW__T%:%:;;= = = HVRWU^^WRW__T%:%:;;= = = HXBHXs   &F/K+ +LC:\Users\All UsersC:\ProgramDatazTest directories not foundc                     t          j        d          }|                     t           j                            |d                     d S )Nr3  r4  )r   r  rp   rI   samefile)r9   r   s     r   
test_29248zWin32SymlinkTests.test_29248
  s?     233((1BCCDDDDDr   c                    d}t          j        j        |gdz   }d|z   |f||f|d d         |d d         fg}|D ]\  }}	 t          j        ||           	 t          j        |           n # t
          $ r Y nw xY w# t          $ r Y nw xY w	 t          j        t          j        |          t          j        |                     	 t          j        |           # t
          $ r Y w xY w# t          $ r Y w xY wd S )NXXXXXXXXXXXXXXXXXXXXXXXXXXXrx   r     )r   rI   rK   r   r  rO   rN   r!  )r9   segmentrI   
test_casesr   dests         r   test_buffer_overflowz&Win32SymlinkTests.test_buffer_overflow
  s^    w|gY^, D['"dO$3$Zdsd$

 $ 	 	IC
3%%%IdOOOO   D %   
2;s++R[->->???IdOOOO   D %   	 	sH    A;A++
A87A8;
BB9C+C
C('C(+
C87C8c                    t           j                            d          t           j                                      s|                     d           fdt          j        t          j                  d          D             }|D ]}t          j	        rt                       t          d|           t          j        |          }|                     |t          j        |                     |                     t          j        |j                             |                     |j        t          j                    d S |                     d           d S )Nz$%LOCALAPPDATA%\Microsoft\WindowsAppsz%test requires a WindowsApps directoryc                 P    g | ]"}t           j                            |          #S r
   )r   rI   rK   )r   rA   r  s     r   r   z6Win32SymlinkTests.test_appexeclink.<locals>.<listcomp>  s?     G G G 7<<a(( G G Gr   z*.exezTesting withz$test requires an app execution alias)r   rI   
expandvarsr9  r|   fnmatchfilterr  r   rR   rS   rG  rH   r   r}  S_ISLNKr?  st_reparse_tagIO_REPARSE_TAG_APPEXECLINK)r9   aliasesaliasr  r  s       @r   test_appexeclinkz"Win32SymlinkTests.test_appexeclink  sE   w!!"IJJw}}T"" 	CMMABBBG G G G#N2:d+;+;WEEG G G  	B 	BE -ne,,,%BR000T\"*55666R.0OPPPEEMM@AAAAAr   N)ra   rb   rc   r  r   rI   r  r   r   r  rV   r  r  rk   r  r  r  r#  r%  r'  r)  r  r2  r   r   rg   r}  r7  r>  rI  r
   r   r   r  r  k
  se        Hgooh//OGW___55N!L5 5 5) ) ); ; ;= = =4 4 4% % %; ; ;$ $ $G G G! ! !F X)>?? B "/@ A A8: :
E 
E: :
E! ! !FB B B B Br   r  c                       e Zd ZdZej                            ej                            e                    Z	d Z
d Zd Zd ZdS )Win32JunctionTestsjunctiontestc                     d S r.   r
   rj   s    r   rk   zWin32JunctionTests.setUp!  r  r   c                     t           j                            | j                  rt          j        | j                   d S d S r.   )r   rI   rg   junctionri   rj   s    r   r  zWin32JunctionTests.tearDown%  s<    7??4=)) 	%Idm$$$$$	% 	%r   c                    t          j        | j        | j                   |                     t
          j                            | j                             |                     t
          j                            | j                             |                     t
          j        	                    | j                             | 
                    t          j        | j                  t          j        | j                             |                     t          j        | j                  t          j        | j                             |                     t
          j                            | j                             |                     t
          j                            d| j        z             t
          j                            t          j        | j                                       d S )Nr  )_winapiCreateJunctionjunction_targetrO  rp   r   rI   rg   r}  r9  r  r   rG  rH   r}  r  r  r  rj   s    r   test_create_junctionz'Win32JunctionTests.test_create_junction)  sc   t3T]CCC66777t}55666dm44555BGDM22BHT]4K4KLLL//9M1N1NOOO 	66777)))d6J*JKK))"+dm*D*DEE	G 	G 	G 	G 	Gr   c                    t          j        | j        | j                   |                     t
          j                            | j                             |                     t
          j                            | j                             t          j	        | j                   | 
                    t
          j                            | j                             d S r.   )rQ  rR  rS  rO  rp   r   rI   r}  rg   ri   r}  rj   s    r   test_unlink_removes_junctionz/Win32JunctionTests.test_unlink_removes_junction6  s    t3T]CCCt}5566666777
	$-   6677777r   N)ra   rb   rc   rO  r   rI   rV   r  r   rS  rk   r  rT  rV  r
   r   r   rK  rK    sy        Hgoobgooh&?&?@@O2 2 2% % %G G G8 8 8 8 8r   rK  c                   D    e Zd Zd Z ej                    d             ZdS )Win32NtTestsc                    t          j        d          }t          j        d          }dd l}|                    dd          }|j        j        |j        _        |j        j        |j	        _        |j        j        |j        j
        f|j	        _        |                                }|j                                        }|	                    ||                    |                    }|                     d|           |j        }dd	d
t           g}t#          d          D ]S}	|D ]N}
	 |                    |
           n# t&          $ r Y nw xY w	 t)          j        |
           ?# t&          $ r Y Kw xY wT|	                    ||                    |                    }|                     d|           |j        |z
  }|                     d|           d S )Nr7  r  r   zKernel32.dllT)use_last_errorrw   z\\?\C:z\\?\NULz	\\?\CONINrx   )r   import_modulectypes.wintypesWinDLLr  r  GetCurrentProcessr  r  GetProcessHandleCountLPDWORDr  r  byrefrH   rn  r   r   _getfinalpathname	Exceptionr   r   )r9   r7  r  kernelhprochandle_countr  before_count	filenames_r!   handle_deltas               r   test_getfinalpathname_handlesz*Win32NtTests.test_getfinalpathname_handles@  s   (..,X66~dCC+1?+A (/5/C$,171G171H1J$- ((**,,..))%l1K1KLLB#) 	
	 r 
	 
	A! 	 	((....    DGDMMMM    D	 ))%l1K1KLLB#)L8L)))))s$   &D<<
E	E	E""
E/.E/c           	      z   t           j        }|                     t           j        |           t	          j                    dz   }t          j        d          }t          j        t          j
        d||t          |          g          5 }t	          j                    |k     rD	 t          j        |           n# t          $ r
}Y d }~nd }~ww xY wt	          j                    |k     D	 |                    d           n)# t          j        $ r |                                 Y nw xY wd d d            d S # 1 swxY w Y   d S )Nr   a              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
            r   rw   )r   rh   r   ri   r  textwrapdedentr   r  rB   r   r7   r   r   rN   r  TimeoutExpired	terminate)r9   r(   deadlinecommandr]  r   s         r   test_stat_unlink_racez"Win32NtTests.test_stat_unlink_racep  s    $	((3339;;?/ #  ( s~tWhHVWW 		![_)++((+GH%%%%( + + + + + + + + + )++((
!		!, ! ! !     !		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		! 		!sZ   D0 B54D05
C	?D0C		D0$C:9D0:#D D0D  D00D47D4N)ra   rb   rc   rk  r   r  rs  r
   r   r   rX  rX  >  sK        .* .* .*` !W ""'! '! #"'! '! '!r   rX  c                        e Zd Zd Zd Zd ZdS )NonLocalSymlinkTestsc                 0    	 t          j        d           d S )Nzbase/some_dir)r   r  rj   s    r   rk   zNonLocalSymlinkTests.setUp  s    	 	O$$$$$r   c                 .    t          j        d           d S )Nr  )r  r  rj   s    r   r  zNonLocalSymlinkTests.tearDown  s    fr   c                 r    	 t           j                            dd          }t          j        d|           d S )Nr  	some_linksome_dir)r   rI   rK   r   )r9   r   s     r   test_directory_link_nonlocalz1NonLocalSymlinkTests.test_directory_link_nonlocal  s6    
	 gll6;//

:s#####r   N)ra   rb   rc   rk   r  r{  r
   r   r   ru  ru    sA        % % %  " " " " "r   ru  c                       e Zd Zd Zd ZdS )FSEncodingTestsc                     |                      t          j        d          d           |                      t          j        d          d           d S )Ns   abcu   abcŁ)rH   r   r!  r_   rj   s    r   test_nopzFSEncodingTests.test_nop  sH    Z00*===[11;?????r   c                     dD ]P}	 t          j        |          }n# t          $ r Y $w xY w|                     t          j        |          |           Qd S )N)u	   unicodeŁu   latinéascii)r   r!  rP  rH   r_   )r9   r  r  s      r   test_identityzFSEncodingTests.test_identity  sr    9 	7 	7B+b//%   R[1126666	7 	7s   
((N)ra   rb   rc   r  r  r
   r   r   r}  r}    s5        @ @ @7 7 7 7 7r   r}  c                      e Zd Zd Z ej         ej        d          o< e             o1e	j
                            d          p eed          o eed          d           ej        ej        d          d                         Zd	S )
DeviceEncodingTestsc                 T    |                      t          j        d                     d S )Ni@ )r`  r   device_encodingrj   s    r   test_bad_fdzDeviceEncodingTests.test_bad_fd  s'    ",V4455555r   r   winnl_langinfoCODESETz>test requires a tty and either Windows or nl_langinfo(CODESET)z*Cannot get encoding of stdin on Emscriptenc                     t          j        d          }|                     |           |                     t	          j        |                     d S r   )r   r  assertIsNotNonerp   codecslookup)r9   r   s     r   test_device_encodingz(DeviceEncodingTests.test_device_encoding  sJ     %a((X&&&h//00000r   N)ra   rb   rc   r  r   r   r   r  r   rB   rC   r  r   localer  r   r  r  r
   r   r   r  r    s        6 6 6 X1 Mllnn*< M#,BYBYZ_B`B` CLWV]++J	0J0JLN N X_K 1 1 N N1 1 1r   r  c                   >   e Zd Z ej         eed          d          d             ZddZd Z	d Z
 ej        ej        dk    d	          d
             Z ej        ej        dk    d	          d             Z ej         eed          d          d             ZdS )PidTestsgetppidztest needs os.getppidc                     t          j        t          j        ddgt           j                  }|                                \  }}|                     t          |          t          j	                               d S )Nr   zimport os; print(os.getppid()))rT  )
r   r  rB   r   rZ  communicaterH   r#  r   getpid)r9   rY  rT  ri  s       r   test_getppidzPidTests.test_getppid  sh    cnd>@$.O5 5 5 MMOO	Vbikk22222r   Nc                    t           j        dk    rdt           j         ddd| dg}nt           j        d|g}t          j        t          j        t           j        |          }| ||           t          j        |d          \  }}|                     t          j        |          |           |                     ||           d S )Nr   "r   r   )	rB   rC   r   r   spawnvP_NOWAITwaitpidrH   waitstatus_to_exitcode)r9   r   exitcodecallbackr   r  pid2statuss           r   check_waitpidzPidTests.check_waitpid  s    <7"" *)))4T=DDND$/DiS^T::HSMMM z#q))f26::HEEEs#####r   c                 4    |                      dd           d S )Nr  r   )r   r  r  rj   s    r   test_waitpidzPidTests.test_waitpid  s!    33333r   c                     d}d| d}|                      ||           |                     t                    5  t          j        d           d d d            d S # 1 swxY w Y   d S )N   zimport sys; sys.exit()r  g        )r  r~   r   r   r  )r9   r  r   s      r   test_waitstatus_to_exitcodez$PidTests.test_waitstatus_to_exitcode  s    2x2224(333y)) 	+ 	+%c***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   AA #A r   win32-specific testc                 D    d}d| d}|                      ||           d S )Nl   :   z$import _winapi; _winapi.ExitProcess(r  r  r  )r9   STATUS_CONTROL_C_EXITr   s      r   test_waitpid_windowszPidTests.test_waitpid_windows  s;     !+N6KNNN4*?@@@@@r   c                    d}ddd|fD ]-}|                      t          j        |dz            |           .|                     t                    5  t          j        |dz   dz             d d d            n# 1 swxY w Y   |                     t
                    5  t          j        d           d d d            d S # 1 swxY w Y   d S )Nr  r   rw   r   r/  r  )rH   r   r  r~   r   rm  )r9   max_exitcoder  s      r   #test_waitstatus_to_exitcode_windowsz,PidTests.test_waitstatus_to_exitcode_windows  s_   "Aq,/ 	' 	'HR6x1}EE%' ' ' ' z** 	? 	?%|a'7A&=>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?}-- 	* 	*%b)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s$   A88A<?A<B??CCSIGKILLzneed signal.SIGKILLc                 |    dt           j         d}t          j        fd}|                     | |           d S )Nzimport time; time.sleep(r  c                 2    t          j        |            d S r.   )r   r  )r  signums    r   kill_processz?PidTests.test_waitstatus_to_exitcode_kill.<locals>.kill_process   s    GC     r   )r  r  )r   LONG_TIMEOUTr  r  r  )r9   r   r  r  s      @r    test_waitstatus_to_exitcode_killz)PidTests.test_waitstatus_to_exitcode_kill  s[    A'*>AAA	! 	! 	! 	! 	! 	46'LIIIIIr   r.   )ra   rb   rc   r   r   r   r   r  r  r  r  rB   rC   r  r  r  r  r
   r   r   r  r    s&       XY//1HII3 3 JI3$ $ $ $$4 4 4+ + + X02GHHA A IHA X02GHH
* 
* IH
* X335JKKJ J LKJ J Jr   r  c                      e Zd Zed             ZddddZ ed          d             Z ed          d             Z ed	          d
             Z	 ed          d             Z
 ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Z ed          d             Zd Z ed          d             Z ed          d             ZdS )
SpawnTestsc                 >    t           j        dk    r| S d | D             S )Nr7  c                 J    g | ] }d |                                 v rd| dn|!S ) r  )r  )r   r  s     r   r   z)SpawnTests.quote_args.<locals>.<listcomp>.  s6    JJJccSYY[[00
C



cJJJr   )r   r!   )r   s    r   
quote_argszSpawnTests.quote_args(  s(     7d??KJJTJJJJr   Fwith_env	use_bytesc                   d| _         t          j        }|                     t          j        |           |sd| j         z  }njt          t          j                  | _        t          t          j                              | _        | j        | j        | j        <   d| j        d| j         d}t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   t          j        }|                     ||g          }|rHt          j        |          }d	 |D             }d
 | j                                        D             | _        ||fS )N   zimport sys; sys.exit(%s)z#import sys, os; magic = os.environ[z]; sys.exit(r  r{  r   r   c                 6    g | ]}t          j        |          S r
   r  )r   rA   s     r   r   z*SpawnTests.create_args.<locals>.<listcomp>H  s     111qBKNN111r   c                 b    i | ],\  }}t          j        |          t          j        |          -S r
   r  )r   kvs      r   
<dictcomp>z*SpawnTests.create_args.<locals>.<dictcomp>I  s>     6 6 6 Aq AA 6 6 6r   )r  r   rh   r   ri   r  r   r  r0  r7   r  uuid4r  r&   r'   rB   r   r  r!  r  )r9   r  r  r(   r   r*   r  r   s           r   create_argszSpawnTests.create_args0  s   #	((333 		1-=DDBJ''DH4:<<((DH!%DHTX xxx0D (C'222 	bHHTNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 .233 	6k'**G11D111D6 6$(HNN$4$46 6 6DH }s   =CC#&C#spawnlc                     |                                  \  }}t          j        t          j        |g|R  }|                     || j                   d S r.   )r  r   r  P_WAITrH   r  r9   r  r   r  s       r   test_spawnlzSpawnTests.test_spawnlN  sP    ((**9RY7$7774=11111r   spawnlec                     |                      d          \  }}t          j        t          j        |g|| j        R  }|                     || j                   d S NT)r  )r  r   r  r  r0  rH   r  r  s       r   test_spawnlezSpawnTests.test_spawnleT  s\    (($(77:biB4BBBB4=11111r   spawnlpc                     |                                  \  }}t          j        t          j        |g|R  }|                     || j                   d S r.   )r  r   r  r  rH   r  r  s       r   test_spawnlpzSpawnTests.test_spawnlpZ  sP    ((**:bi848884=11111r   spawnlpec                     |                      d          \  }}t          j        t          j        |g|| j        R  }|                     || j                   d S r  )r  r   r  r  r0  rH   r  r  s       r   test_spawnlpezSpawnTests.test_spawnlpe`  s\    (($(77;ry'CDC$(CCC4=11111r   r  c                 :   |                                  \  }}t          j        t          j        ||          }|                     || j                   t          j        t          j        t          |          |          }|                     || j                   d S r.   )r  r   r  r  rH   r  r   r  s       r   test_spawnvzSpawnTests.test_spawnvf  s    ((**9RY664=111 9RY(9(94@@4=11111r   spawnvec                     |                      d          \  }}t          j        t          j        ||| j                  }|                     || j                   d S r  r  r   r  r  r0  rH   r  r  s       r   test_spawnvezSpawnTests.test_spawnvep  sS    (($(77:bi$AA4=11111r   spawnvpc                     |                                  \  }}t          j        t          j        ||          }|                     || j                   d S r.   )r  r   r  r  rH   r  r  s       r   test_spawnvpzSpawnTests.test_spawnvpv  sJ    ((**:bi$774=11111r   spawnvpec                     |                      d          \  }}t          j        t          j        ||| j                  }|                     || j                   d S r  )r  r   r  r  r0  rH   r  r  s       r   test_spawnvpezSpawnTests.test_spawnvpe|  sS    (($(77;ry'4BB4=11111r   c                     |                                  \  }}t          j        t          j        ||          }t	          j        || j                   d S )Nr  )r  r   r  r  r   wait_processr  )r9   r  r   r  s       r   test_nowaitzSpawnTests.test_nowait  sJ    ((**iWd33S4=999999r   c                     |                      dd          \  }}t          j        t          j        ||| j                  }|                     || j                   d S )NTr  r  r  s       r   test_spawnve_byteszSpawnTests.test_spawnve_bytes  sW     (($$(GG:bi$AA4=11111r   c                     |                                  \  }}|                     t          t          j        t          j        |           |                     t          t          j        t          j        |d           d S Nr  )r  r~   r   r   r  r  r9   r  __s      r   test_spawnl_noargszSpawnTests.test_spawnl_noargs  s[    &&((*bigFFF*bigrJJJJJr   c                     |                                  \  }}|                     t          t          j        t          j        |i            |                     t          t          j        t          j        |di            d S r  )r  r~   r   r   r  r  r  s      r   test_spawnle_noargszSpawnTests.test_spawnle_noargs  s_    &&((*bj"+wKKK*bj"+wBOOOOOr   c                    |                                  \  }}|                     t          t          j        t          j        |d           |                     t          t          j        t          j        |g            |                     t          t          j        t          j        |d           |                     t          t          j        t          j        |dg           d S Nr
   r6  r  )r  r~   r   r   r  r  r  s      r   test_spawnv_noargszSpawnTests.test_spawnv_noargs  s    &&((*bigrJJJ*bigrJJJ*biguMMM*bigtLLLLLr   c                    |                                  \  }}|                     t          t          j        t          j        |di            |                     t          t          j        t          j        |g i            |                     t          t          j        t          j        |di            |                     t          t          j        t          j        |dgi            d S r  )r  r~   r   r   r  r  r  s      r   test_spawnve_noargszSpawnTests.test_spawnve_noargs  s    &&((*bj"+wBOOO*bj"+wBOOO*bj"+wrRRR*bj"+wbQQQQQr   c                 F   t           j        }|                     |ddg          }t          j                                        }d|d<   	  |t          j        |||          }|                     |d           n# t          $ r Y nw xY wt          j                                        }d|d<   	  |t          j        |||          }|                     |d           n# t          $ r Y nw xY wt          j                                        }d|d	<   	  |t          j        |||          }|                     |d           n# t          $ r Y nw xY wt          j
        }|                     t          j        |           t          |d
d          5 }|                    d           d d d            n# 1 swxY w Y   |                     ||g          }t          j                                        }d|d<    |t          j        |||          }|                     |d           d S )Nr   r  r  r     r  r  r  r  r{  r   r   zPimport sys, os
if os.getenv("FRUIT") != "orange=lemon":
    raise AssertionErrorzorange=lemonr   )rB   r   r  r   r  r  r  rH   r   r   rh   r   ri   r&   r'   )r9   spawnr  r   r  r  r(   r*   s           r   _test_invalid_envzSpawnTests._test_invalid_env  s   .v677 ""%.!"	,uRYv>>H Xs++++  	 	 	D	 ""5w	,uRYv>>H Xs++++  	 	 	D	 ""!(~	,uRYv>>H Xs++++  	 	 	D	 #	((333(C'222 	1bHH 0 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1
 233""(w5GT6::1%%%%%sH   	A8 8
BB,C 
C('C(D> >
E
EF..F25F2c                 D    |                      t          j                   d S r.   )r  r   r  rj   s    r   test_spawnve_invalid_envz#SpawnTests.test_spawnve_invalid_env  s    rz*****r   c                 D    |                      t          j                   d S r.   )r  r   r  rj   s    r   test_spawnvpe_invalid_envz$SpawnTests.test_spawnvpe_invalid_env  s    r{+++++r   N)ra   rb   rc   r   r  r  r"   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
   r   r   r  r  &  s       K K \K ',u     < h2 2  2
 i  2 2 ! 2
 i  2 2 ! 2
 j!!2 2 "!2
 h2 2  2 i  2 2 ! 2
 i  2 2 ! 2
 j!!2 2 "!2
 h: :  :
 i  2 2 ! 2 hK K  K
 i  P P ! P
 hM M  M i  R R ! R.& .& .&` i  + + ! + j!!, , "!, , ,r   r  z>Skip due to platform/environment differences on *NIX buildbotsgetloginztest needs os.getloginc                       e Zd Zd ZdS )
LoginTestsc                 r    t          j                    }|                     t          |          d           d S r   )r   r  r  rD   )r9   	user_names     r   test_getloginzLoginTests.test_getlogin  s/    KMM	C	NNA.....r   N)ra   rb   rc   r  r
   r   r   r  r    s#        / / / / /r   r  getprioritysetpriorityz'needs os.getpriority and os.setpriorityc                       e Zd Z	 d ZdS )ProgramPriorityTestsc                 2   t          j        t           j        t          j                              }t          j        t           j        t          j                    |dz              	 t          j        t           j        t          j                              }|dk    r|dk    rt          j        d|z            |                     ||dz              	 	 t          j        t           j        t          j                    |           d S # t          $ r!}|j	        t          j
        k    r Y d }~d S d }~ww xY w# 	 t          j        t           j        t          j                    |           w # t          $ r }|j	        t          j
        k    r Y d }~w d }~ww xY wxY w)Nrw      z?unable to reliably test setpriority at current nice level of %s)r   r  PRIO_PROCESSr  r  r   rH  rH   rO   rP   EACCES)r9   r  new_prior  s       r   test_set_get_priorityz*ProgramPriorityTests.test_set_get_priority  s   ~bory{{;;
r	TAX>>>	~bory{{CCHrzzh"nn' )FHL)M N N N   4!84444r	TBBBBB   9,, -,,,,,r	TBBBB   9,, -,,,,sO   &A,D5 1D 
D2D--D25F71E)(F)
F3F	FFFN)ra   rb   rc   r  r
   r   r   r  r    s(         ;    r   r  sendfileztest needs os.sendfile()c                   ~   e Zd Zddz  Zej                            d           o5ej                            d           oej                            d           Z ej	        ed          Z
 ej	        ej        dk     d          Zed	             Zed
             Zed             Zd Zd Zd Zed             Zed             Zd Zd Zd Zd Zd Ze
d             Ze
d             Ze
ed                         Ze
ed                         Ze
 ej	         e e!d          d          d                         Z"dS )TestSendfiles   12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdei   linuxsolarissunosz%requires headers and trailers supportrh  z(test is only meaningful on 32-bit buildsc                 D    t          t          j        | j                   d S r.   )r+   r   rh   DATArS  s    r   rU  zTestSendfile.setUpClass  s    I$ch/////r   c                 B    t          j        t           j                   d S r.   )r   ri   rh   rS  s    r   rs  zTestSendfile.tearDownClass  s    )*****r   c                   K   |                                  s3|                                  d {V W V  |                                  1d S d S r.   )at_eofr   )readers    r   chunkszTestSendfile.chunks  se      --// 	&%%%%%%%%%% --// 	& 	& 	& 	& 	&r   c                    K   d                     d |                     |          2              d {V           | _        |                                 | j                                         d S )Nr   c                 "   K   g | 3 d {V }|
6 S r.   r
   )r   r%  s     r   r   z2TestSendfile.handle_new_client.<locals>.<listcomp>   s.      &L&L&L&L&L&L&L&L1q&L&L&L&Ls   )rK   r  server_bufferro   server)r9   r  writers      r   handle_new_clientzTestSendfile.handle_new_client  sn       XX&L&LF8K8K&L&L&L&L&L&L&L&L&LMMr   c                 <  K   d| _         t          j        | j        t          j                   d {V | _        | j        j        d                                         }t          j	                    | _
        | j
                            d           t          j                                        | j
        |           d {V  | j
                                        | _        t!          t"          j        d          | _        | j                                        | _        d S )Nr   r   Fr   )r  r/   start_serverr!  r   HOSTv4r  socketsgetsocknamesocketclientsetblockingget_running_loopsock_connectr   socknor&   r   rh   rX  )r9   server_names     r   
asyncSetUpzTestSendfile.asyncSetUp$  s      #01G1>1EG G G G G G G Gk)!,88::moo&&&&((55dk;OOOOOOOOOk((**)400	i&&((r   c                    K   | j                                          | j                                         | j                                         d {V  d S r.   )rX  ro   r(  r  wait_closedrj   s    r   asyncTearDownzTestSendfile.asyncTearDown0  sX      	k%%'''''''''''r   c                  P   K   t          j        t          j        g| R i | d {V S r.   )r/   	to_threadr   r  )r   r  s     r   async_sendfilezTestSendfile.async_sendfile6  s;      &r{DTDDDVDDDDDDDDDr   c                     K   	 	 	 t          j        | i | d {V S # t          $ r@}|j        t          j        k    r |j        t          j        t          j        fv rY d }~] d }~ww xY wr.   )r  r4  rO   rP   
ECONNRESETEAGAINEBUSY)r   r  r  s      r   sendfile_wrapperzTestSendfile.sendfile_wrapper:  s      		
)8$I&IIIIIIIII   9 000Y5<"===HHHHs    
A'5A"!A""A'c                   K   d}d}d}|t          | j                  k     r|                     | j        | j        ||           d {V }|dk    rnQ||z  }||z  }|                     ||k               |                     ||           |t          | j                  k     |                     |t          | j                             | j                            t          j
                   | j                                         | j                                         d {V  |                     t          | j                  t          | j                             |                     | j        | j                   d S )Nr      )rD   r  r9  r,  r   rp   rH   r(  shutdownr'  	SHUT_RDWRro   r  r0  r  )r9   
total_sentoffsetnbytessents        r   test_send_whole_filez!TestSendfile.test_send_whole_fileL  s     
3ty>>))..t{DK/5v? ? ? ? ? ? ? ?DqyydNF$JOODFN+++VZ000 3ty>>)) 	S^^444V-...k%%'''''''''T/00#di..AAA+TY77777r   c                   K   d}t          | j                  dz  }t          | j                  |z
  }d}||k     rX|                     | j        | j        ||           d {V }|dk    rn)||z  }||z  }|                     ||k               ||k     X| j                            t          j	                   | j        
                                 | j                                         d {V  | j        t          | j                  dz  d          }|                     |t          |                     |                     t          | j                  t          |                     |                     | j        |           d S )Nr   ry   r;  )rD   r  r9  r,  r   rp   r(  r<  r'  r=  ro   r  r0  rH   r  )r9   r>  r?  	must_sendr@  rA  rX   s          r   test_send_at_certain_offsetz(TestSendfile.test_send_at_certain_offsetb  s     
TY1$	NNV+	9$$..t{DK/5v? ? ? ? ? ? ? ?DqyydNF$JOODFN+++ 9$$ 	V-...k%%'''''''''9S^^q0112S]]333T/00#h--@@@+X66666r   c                    K   t          | j                  dz   }	 |                     | j        | j        |d           d {V }|                     |d           n-# t          $ r }|j        t          j        k    r Y d }~nd }~ww xY w| j	        
                    t          j                   | j	                                         | j                                         d {V  |                     | j        d           d S )Nr;  r   r   )rD   r  r4  r,  r   rH   rO   rP   EINVALr(  r<  r'  r=  ro   r  r0  r  )r9   r?  rA  r   s       r   test_offset_overflowz!TestSendfile.test_offset_overflowy  s0     TY$&	&,,T[$+-3T; ; ; ; ; ; ; ;D T1%%%%  	 	 	w%,&& '&&&&	 	V-...k%%'''''''''+S11111s   (A 
B$A??Bc                   K   |                      t                    5 }|                     | j        | j        dd           d {V  d d d            n# 1 swxY w Y   |                     |j        j        t          j                   d S )Nr  r;  )	r~   rO   r4  r,  r   rH   ry  rP   rG  r9   rk  s     r   test_invalid_offsetz TestSendfile.test_invalid_offset  s      w'' 	J2%%dk4;DIIIIIIIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J+U\:::::s   )AAAc           	         K   |                      | j        | j        dd           d {V  | j        r.|                      | j        | j        ddddd           d {V  d S d S )Nr   r;  )r   r   r?  r  r
   )r   r   r?  r  headerstrailersr   )r4  r,  r   SUPPORT_HEADERS_TRAILERSrj   s    r   test_keywordszTestSendfile.test_keywords  s      !!DK)*$ " 8 8 	8 	8 	8 	8 	8 	8 	8( 	H%%T[-.d.02Q & H H H H H H H H H H H	H 	Hr   c                   K   d}d| j         d d         z   }|                     | j        | j        ddddg           d {V }|                     |d           ||z  }d}|t          |          k     rt          t          |          |z
  d          }|                     | j        | j        ||           d {V }|dk    rn3|                     ||           ||z  }||z  }|t          |          k     |                     |t          |                     | j	        
                                 | j                                         d {V  |                     t          | j                  t          |                     d S )	Nr   s   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyr  r;  s   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxs   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyrM  i   )r  r4  r,  r   assertLessEqualrD   minr9  rH   r(  ro   r  r0  hashr  )r9   r>  expected_datarA  r?  r@  s         r   test_headerszTestSendfile.test_headers  s     
/$)CRC.@((dk1d2<j1I ) K K K K K K K KT#3444d
3}----]++j8$??F..t{DK/5v? ? ? ? ? ? ? ?Dqyy  v...$JdNF 3}---- 	S%7%7888k%%'''''''''d01143F3FGGGGGr   c           	        K   t           j        dz   }d}|                     t           j        |           t	          ||           t          |d          5 }|                     | j        |                                ddddg           d {V  | j	        
                                 | j                                         d {V  |                     | j        d	           d d d            d S # 1 swxY w Y   d S )
Nr  s   abcdefr   r   r   s   123456s   789rN  s   abcde123456789)r   rh   r   ri   r+   r&   r4  r,  r   r(  ro   r  r0  rH   r  )r9   r   	file_datart   s       r   test_trailerszTestSendfile.test_trailers  su     "S(		('222GY''''4   	DA%%dk188::q!096/B & D D 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 	Ds   BC..C25C2c           	      F  K   d| j         j        _        |                     t                    5 }|                     | j        | j        ddddz  gdz             d {V  d d d            n# 1 swxY w Y   |                     |j	        j
        t          j                   d S )NFr      x   r`  rR  r  handler_instance
accumulater~   rO   r4  r,  r   rH   ry  rP   rG  rJ  s     r   test_headers_overflow_32bitsz)TestSendfile.test_headers_overflow_32bits  s      38$/w'' 	F2%%dk4;1/3e|nu.D & F F F F F F F F F	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	+U\:::::   2A,,A03A0c           	      F  K   d| j         j        _        |                     t                    5 }|                     | j        | j        ddddz  gdz             d {V  d d d            n# 1 swxY w Y   |                     |j	        j
        t          j                   d S )NFr   r]  r^  r`  rY  r_  rJ  s     r   test_trailers_overflow_32bitsz*TestSendfile.test_trailers_overflow_32bits  s      38$/w'' 	G2%%dk4;104u~/E & G G G G G G G G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	+U\:::::rc  SF_NODISKIOztest needs os.SF_NODISKIOc                    K   	 |                      | j        | j        ddt          j                   d {V  d S # t
          $ r+}|j        t          j        t          j        fvr Y d }~d S d }~ww xY w)Nr   r;  )r   )	r4  r,  r   r   rf  rO   rP   r8  r7  )r9   r  s     r   
test_flagszTestSendfile.test_flags  s      	%%dk4;4,.N & < < < < < < < < < < < 	 	 	yel ;;; <;;;;;	s   4: 
A/ A**A/N)#ra   rb   rc   r  rB   rC   r  rO  r   r   requires_headers_trailersmaxsizerequires_32brt  rU  rs  r   r  r!  r.  r1  r4  r9  rB  rE  rH  rK  rP  rW  r[  rb  re  r   r   rh  r
   r   r   r  r    s        $D#&<#:#:7#C#CC  D#&<#:#:9#E#EE D#&<#:#:7#C#CC  !4 34L3!5 !5&8&s{U':68 8L 0 0 [0 + + [+ & & \&  

) 
) 
)( ( ( E E \E   \"8 8 8,7 7 7.2 2 2"; ; ;
H H H H H H. D D D ; ; \ ; ; ; \ ; X]3346 6 6 6   r   r  c                     t          t          d          sdS 	 t          t          j        dd          5 } 	 t          j        |                                 dd           n:# t          $ r- Y d d d            t          j        t          j                   dS w xY w	 d d d            n# 1 swxY w Y   t          j        t          j                   n## t          j        t          j                   w xY wdS )NsetxattrFr%   r   	   user.testr   T)	r   r   r&   r   rh   rm  r   rO   ri   )r*   s    r   supports_extended_attributesro    s>   2z"" u+)"D!,, 	BIIKKs;;;;   		 	 	 	 	 	 	)***** <	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	)****	)****4sW   C B&(AB&
B)B&*C BB&C &B**C -B*.C  C0z(no non-broken extended attribute supportry   r   '   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ExtendedAttributeTestsc                 >	   t           j        }|                     t           j        |           t	          |           |                     t                    5 } || |d          fi | d d d            n# 1 swxY w Y   |                     |j        j	        t          j
                    ||          }	|                     |	t                      || |d          dfi | t          |	          }
|
                    d           |                     t           ||                    |
           |                      ||dfi |d            || |d          dt          j        fi | |                      ||dfi |d           |                     t                    5 } || |d          dt          j        fi | d d d            n# 1 swxY w Y   |                     |j        j	        t          j                   |                     t                    5 } || |d          dt          j        fi | d d d            n# 1 swxY w Y   |                     |j        j	        t          j
                    || |d          dt          j        fi | |
                    d           |                     t           ||                    |
            || |d          fi | |                     t                    5 } || |d          fi | d d d            n# 1 swxY w Y   |                     |j        j	        t          j
                   |
                    d           |                     t           ||                    |
           |                      || |d          fi |d            || |d          dfi | |                      || |d          fi |d            || |d          fi | t)          d	 t+          d
          D                       }|D ]} |||dfi | |                     t           ||                    t          |	          t          |          z             d S )N	user.testr   rn  r  s   byez
user.test2s   foos   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac              3   @   K   | ]}d                      |          V  dS )zuser.test{}N)r  )r   r   s     r   r.  z;ExtendedAttributeTests._check_xattrs_str.<locals>.<genexpr>   s0      BB!m**1--BBBBBBr   r   r]  )r   rh   r   ri   r+   r~   rO   rH   ry  rP   ENODATAr6   r  r  r  r   XATTR_REPLACEXATTR_CREATEEEXISTr  r  r   )r9   r   getxattrrm  removexattr	listxattrr  r  rk  
init_xattrxattrmanythings                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{^^S33F333J		+YYr]]++U333"l==f==sCCCQQ{^^Xr/?JJ6JJJ"l==f==xHHHw'' 	L2HR;KKFKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L+U\:::w'' 	N2HR<&"2BMMfMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N+U];;;QQ|__fboHHHHH		,YYr]]++U333B+11&111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]]++U333"aaoo@@@@&IIIQQ{^^Y99&999"aann????KKKB+11&111BBuSzzBBBBB 	0 	0EHR//////YYr]]++S__s4yy-HIIIIIsH   A66A:=A:* GGG% IIIL33L7:L7c                      | j         t          g|R i | t          j        t          j                    | j         t
          j        g|R i | t          j        t          j                   d S r.   )r  r7   r   ri   rh   r   r!  r  s      r   _check_xattrsz$ExtendedAttributeTests._check_xattrs%  sx    s4T444V444)***r{<T<<<V<<<)*****r   c                     |                      t          j        t          j        t          j        t          j                   d S r.   r  r   rz  rm  r{  r|  rj   s    r   test_simplez"ExtendedAttributeTests.test_simple,  s5    2;R^<	) 	) 	) 	) 	)r   c                     |                      t          j        t          j        t          j        t          j        d           d S )NFr  r  rj   s    r   
test_lpathz!ExtendedAttributeTests.test_lpath0  sA    2;R^< 	 	@ 	@ 	@ 	@ 	@r   c                 N    d }d }d }d }|                      ||||           d S )Nc                     t          | d          5 }t          j        |                                g|R  cd d d            S # 1 swxY w Y   d S r  )r&   r   rz  r   rI   r   r*   s      r   rz  z1ExtendedAttributeTests.test_fds.<locals>.getxattr5  s    dD!! 7R{299;;66667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7   $AA	Ac                     t          | dd          5 }t          j        |                                g|R   d d d            d S # 1 swxY w Y   d S Nr  r   )r&   r   rm  r   r  s      r   rm  z1ExtendedAttributeTests.test_fds.<locals>.setxattr8  s    dD!$$ 0BIIKK/$////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   %AAAc                     t          | dd          5 }t          j        |                                g|R   d d d            d S # 1 swxY w Y   d S r  )r&   r   r{  r   r  s      r   r{  z4ExtendedAttributeTests.test_fds.<locals>.removexattr;  s    dD!$$ 3ryy{{2T22223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3r  c                     t          | d          5 }t          j        |                                g|R  cd d d            S # 1 swxY w Y   d S r  )r&   r   r|  r   r  s      r   r|  z2ExtendedAttributeTests.test_fds.<locals>.listxattr>  s    dD!! 8R|BIIKK7$7778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8r  )r  )r9   rz  rm  r{  r|  s        r   test_fdszExtendedAttributeTests.test_fds4  s`    	7 	7 	7	0 	0 	0	3 	3 	3	8 	8 	8 	8X{IFFFFFr   N)ra   rb   rc   r  r  r  r  r  r
   r   r   rr  rr    sk        .J .J .J`+ + +) ) )@ @ @G G G G Gr   rr  get_terminal_sizezrequires os.get_terminal_sizec                       e Zd Zd Zd ZdS )TermsizeTestsc                 L   	 	 t          j                    }nW# t          $ rJ}t          j        dk    s|j        t
          j        t
          j        fv r|                     d            d }~ww xY w| 	                    |j
        d           | 	                    |j        d           d S )Nr   failed to query terminal sizer   )r   r  rO   rB   rC   rP   rG  ENOTTYr|   assertGreaterEqualcolumnslines)r9   r   r   s      r   test_does_not_crashz!TermsizeTests.test_does_not_crashF  s    	
	'))DD 	 	 	|w&&!'elEL5Q*Q*Q =>>>	 	a000
A.....s    
A+AA&&A+c                 v   	 	 t          j        ddgt           j        d                                          }n7# t          t           j        t          f$ r |                     d           Y nw xY wt          |d                   t          |d                   f}	 t          j
        t          j                                                  }nW# t          $ rJ}t          j        dk    s|j        t           j        t           j        fv r|                     d	            d }~ww xY w|                     ||           d S )
Nsttyr   T)r  rU  zstty invocation failedrw   r   r   r  )r   check_outputDEVNULLr;  rN   CalledProcessErrorr  r|   r#  r   r  rB   	__stdin__r   rO   rC   rP   rG  r  rH   )r9   r   rX   r  r   s        r   test_stty_matchzTermsizeTests.test_stty_matchX  s?   		4'V$Z-?d  %'' D
 ":#@! 	4 	4 	4MM233333	4 QLL#d1g,,/	)#-*>*>*@*@AAFF 	 	 	|w&&!'elEL5Q*Q*Q =>>>	 	6*****s(   59 1A-,A-0C 
D ADD N)ra   rb   rc   r  r  r
   r   r   r  r  D  s2        / / /$+ + + + +r   r  memfd_createzrequires os.memfd_creater   r  c                       e Zd Zd ZdS )MemfdCreateTestsc                    t          j        dt           j                  }|                     |d           |                     t           j        |           |                     t          j        |                     t          |dd          5 }|	                    d           | 
                    |                                d           d d d            n# 1 swxY w Y   t          j        d          }|                     t           j        |           |                     t          j        |                     d S )NHir  r  F)closefds   memfd_creater2  )r   r  MFD_CLOEXECr  r   ro   r}  rH  r&   r'   rH   tell)r9   r   rt   r$  s       r   test_memfd_createz"MemfdCreateTests.test_memfd_createx  sC   _T2>22B###"%%%+B//000"dE*** 	+aGGO$$$QVVXXr***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ od###&&&+C0011111s   >CC CN)ra   rb   rc   r  r
   r   r   r  r  u  s#        2 2 2 2 2r   r  eventfdzrequires os.eventfdr  c                        e Zd Zd Zd Zd ZdS )EventfdTestsc                    d }d}d}t          j        |          }|                     |d           |                     t           j        |           |                     t          j        |                     t          j        ||          }|                     | ||                     t          j	        | |d                     t          j        ||          }|                     | |d                     t          j	        | |d                     t          j	        | |d                     t          j        ||          }|                     | |d                     t          j
        |d           t          j
        |d	           t          j        |          }|                     |d           d S )
Nc                 .    	 t          j        d|           S )Nz@Q)structpack)rn  s    r   r  z/EventfdTests.test_eventfd_initval.<locals>.pack  s    ;tU+++r   r/  r  r  r  (   ry   r!  r   )r   r  r  r   ro   r}  rH  r   rH   r'   eventfd_writeeventfd_read)r9   r  r   initvalr   ress         r   test_eventfd_initvalz!EventfdTests.test_eventfd_initval  s   	, 	, 	, Z  B###"%%%+B//000 gb$dd7mm,,,
TT"XXgb$dd2hh'''
TT"XX
TT!WWgb$dd2hh''' 	R   
Qob!!b!!!!!r   c                    d}t           j        t           j        z  t           j        z  }t          j        ||          }|                     |d           |                     t           j        |           t          j        |          }| 	                    |d           t          j        |          }| 	                    |d           | 
                    t                    5  t          j        |           d d d            n# 1 swxY w Y   | 
                    t                    5  t          j        |d           d d d            n# 1 swxY w Y   t          j        |d           t          j        |          }| 	                    |d           | 
                    t                    5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nry   r  rw   r/  )r   EFD_CLOEXECEFD_SEMAPHOREEFD_NONBLOCKr  r  r   ro   r  rH   r~   r  r   r  )r9   r  r   r   r  s        r   test_eventfd_semaphorez#EventfdTests.test_eventfd_semaphore  sY   !11BOCZ''B###"%%% ob!!a   ob!!a   // 	  	 OB	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 // 	 	GBNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Qob!!a   // 	  	 OB	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s6   "DD
D(E

EE.GGGc                    t           j        t           j        z  }t          j        d|          }|                     |d           |                     t           j        |           t          j        |g|g|gd          \  }}}|                     |||fg |gg f           t          j	        |d           t          j        |g|g|gd          \  }}}|                     |||f|g|gg f           |                     t          j
        |          d           t          j	        |d           t          j        |g|g|gd          \  }}}|                     |||f|gg g f           t          j
        |           d S )Nr   r  r  l    )r   r  r  r  r  r   ro   selectrH   r  r  )r9   r   r   rfdwfdxfds         r   test_eventfd_selectz EventfdTests.test_eventfd_select  s   0Z5!!B###"%%% rdRD2$::S##sC2tR.999 	R   rdRD2$::S##sCB4"r*:;;;,,b111 	[)))rdRD2$::S##sCB4R.999
r   N)ra   rb   rc   r  r  r  r
   r   r   r  r    sA        " " ">     4    r   r  c                       e Zd Zd Zd ZdS )OSErrorTestsc                 r    G d dt                     }g | _        g | _        t          j        t          j        }nt          j        }| j                            |           | j                             ||                     t          j        t          j        }nt          j	        t          j                  }| j                            |           | j                            t          |                     | j                            t          |                     | j        | j        z   | _        d S )Nc                       e Zd ZdS )OSErrorTests.setUp.<locals>.StrNra   rb   rc   r
   r   r   Strr            Dr   r  )r7   bytes_filenamesunicode_filenamesr   r  rh   r  TESTFN_UNDECODABLEr   r!  r   r   rh  )r9   r  decodedencodeds       r   rk   zOSErrorTests.setUp  s   	 	 	 	 	# 	 	 	  "!#'32GG&G%%g...%%cc'll333'32GGk)"233G##G,,,##Ig$6$6777##Jw$7$7888-0FFr   c           
      
   | j         t          j        f| j         t          j        f| j         t          j        t          j        f| j         t          j        f| j         t          j        f| j         t          j        fg}t          j
        dk    rt|                    | j        t          j        df| j        t          j        df| j        t          j        df| j        t          j        df| j        t          j        ff           nM|                    | j         t          j        f| j         t          j        df| j         t          j        dff           t#          j                    r'|                    | j         t          j        df           t+          t          d          r(|                    | j         t          j        ddf           t+          t          d          r(|                    | j         t          j        ddf           t+          t          d          r'|                    | j         t          j        df           t+          t          d	          r'|                    | j         t          j        df           t+          t          d
          r'|                    | j         t          j        df           t+          t          d          r&|                    | j         t          j        f           t+          t          d          rt          j
        dk    rO|                    | j        t          j        df           |                    | j        t          j        df           n'|                    | j         t          j        df           t+          t          d          ra|                    | j         t          j        f| j         t          j        df| j         t          j        ddf| j         t          j         dff           t+          t          d          r'|                    | j         t          j!        df           t+          t          d          r&|                    | j         t          j"        f           |D ]^}}}|D ]}	 tG          |tH          tJ          f          r
 ||g|R   n<| &                    tN          d          5   ||g|R   d d d            n# 1 swxY w Y   | (                    d)                    |                     # tT          $ r3}| +                    |j,        |tI          |                     Y d }~d }~wtZ          $ r Y w xY wd S )Nr   s   dstr   r   r_  r   lchownr6  chflagslchflagschrootr  r|  rt  s   userlchmodr  z	should bezNo exception thrown by {}).rh  r   rM   rG  r&   r   r  r   ri   rB   rC   r  r  r   r   r  r  r   	can_chmodr  r  r   r_  r  r6  r  r  r  r  r|  rz  rm  r{  r  r  rk  r7   r^   assertWarnsRegexDeprecationWarningr=  r  rO   rh  r(   UnicodeDecodeError)r9   funcsrh  func	func_argsr!   r  s          r   test_oserror_filenamez"OSErrorTests.test_oserror_filename  s"   ^RX'^RX'^RWbk2^RX'^RW&^RY(
 <7""LL%ry&9%rz6:'E:'U;'6     LL-E2U3   
    	<LL$."(E:;;;2w 	;LL$."(Aq9:::2x   	<LL$.")Q:;;;2z"" 	;LL$."+q9:::2y!! 	:LL$."*a89992z"" 	;LL$."+q9:::2x   	7LL$.")56662v 	?|w&&d2BGVDEEEd4bguEFFFFdnbgu=>>>2{## 	LL/k:k7C=	    2x   	=LL$.")U;<<<2z"" 	9LL$."+7888 ,1 	H 	H'Iti! H HH!$e55 3T.I.....!223E{SS 3 3 D2	22223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 II9@@FFGGGG  A A AMM#,c$ii@@@@@@@@)   DH	H 	HsC   AT
STST S!T
U)UUUN)ra   rb   rc   rk   r  r
   r   r   r  r    s?        G G G,EH EH EH EH EHr   r  c                       e Zd Zd ZdS )CPUCountTestsc                     t          j                    }|3|                     |t                     |                     |d           d S |                     d           d S )Nr   z&Could not determine the number of CPUs)r   	cpu_countr6   r#  assertGreaterr|   )r9   cpuss     r   test_cpu_countzCPUCountTests.test_cpu_count8  s^    |~~!!$,,,tQ'''''MMBCCCCCr   N)ra   rb   rc   r  r
   r   r   r  r  7  s(        D D D D Dr   r  c                      e Zd Zd Z ej        edu d          d             Z ej        edu d          d             Z ej	         e
ed          d          d             Zd	 Zd
 Z ej	         e
ed          d          d             Zd Zd Z ej	        ej        dk    d          d             Z ej	         e
ed          d          d             Z ej	         e
ed          d          d             ZdS )FDInheritanceTestsc                 X   t          j        t          t           j                  }|                     t           j        |           |                     t          j        |          d           t          j        |d           |                     t          j        |          d           d S NFT)	r   r&   r   r   r   ro   rH   rH  rI  r   s     r   test_get_set_inheritablez+FDInheritanceTests.test_get_set_inheritableD  s    WXr{++"%%%+B//777
2t$$$+B//66666r   Nz
need fcntlc                    t          j        t          t           j                  }|                     t           j        |           |                     t          j        |          d           t          j        |t          j	                  }|t          j
         z  }t          j        |t          j        |           |                     t          j        |          d           d S r  )r   r&   r   r   r   ro   rH   rH  fcntlF_GETFD
FD_CLOEXECF_SETFD)r9   r   r   s      r   test_get_inheritable_cloexecz/FDInheritanceTests.test_get_inheritable_cloexecL  s    WXr{++"%%%+B//777 B..%"""Bu---+B//66666r   c                    t          j        t          t           j                  }|                     t           j        |           |                     t          j        |t          j                  t          j	        z  t          j	                   t          j
        |d           |                     t          j        |t          j                  t          j	        z  d           d S )NTr   )r   r&   r   r   r   ro   rH   r  r  r  rI  r   s     r   test_set_inheritable_cloexecz/FDInheritanceTests.test_set_inheritable_cloexecY  s    WXr{++"%%%R77%:JJ)	+ 	+ 	+ 	2t$$$R77%:JJ	 	 	 	 	r   O_PATHzneed os.O_PATHc                    t          j        t          t           j                  }|                     t           j        |           |                     t          j        |          d           t          j        |d           |                     t          j        |          d           t          j        |d           |                     t          j        |          d           d S r  )	r   r&   r   r  r   ro   rH   rH  rI  r   s     r   test_get_set_inheritable_o_pathz2FDInheritanceTests.test_get_set_inheritable_o_pathd  s    WXry))"%%%+B//777
2t$$$+B//666
2u%%%+B//77777r   c                    t          j                    }|                     t                    5 }t	          j        |           d d d            n# 1 swxY w Y   |                     |j        j        t          j	                   |                     t                    5 }t	          j
        |d           d d d            n# 1 swxY w Y   |                     |j        j        t          j	                   |                     t                    5 }t	          j
        |d           d d d            n# 1 swxY w Y   |                     |j        j        t          j	                   d S NTF)r   r  r~   rO   r   rH  rH   ry  rP   rz  rI  )r9   r   r|  s      r   test_get_set_inheritable_badfz0FDInheritanceTests.test_get_set_inheritable_badfp  s   "$$w'' 	#3r"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#,ek:::w'' 	)3r4(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	),ek:::w'' 	*3r5)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*,ek:::::s5   AAAC  CCD11D58D5c                     t          j        t          t           j                  }|                     t           j        |           |                     t          j        |          d           d S r  )r   r&   r   r   r   ro   rH   rH  r   s     r   r  zFDInheritanceTests.test_open  sR    WXr{++"%%%+B//77777r   r	  zneed os.pipe()c                 R   t          j                    \  }}|                     t           j        |           |                     t           j        |           |                     t          j        |          d           |                     t          j        |          d           d S r  )r   r	  r   ro   rH   rH  )r9   r  r  s      r   	test_pipezFDInheritanceTests.test_pipe  s    799S#&&&#&&&+C00%888+C00%88888r   c                 F   t          j        t          t           j                  }|                     t           j        |           t          j        |          }|                     t           j        |           |                     t          j        |          d           d S r  )	r   r&   r   r   r   ro   r{   rH   rH  r9   fd1r$  s      r   test_dupzFDInheritanceTests.test_dup  su    gh,,#&&&fSkk#&&&+C00%88888r   c                     t          j        d          }|                     t           j        |           |                     |d           d S Nrw   r   )r   r{   r   ro   r  r   s     r   test_dup_standard_streamz+FDInheritanceTests.test_dup_standard_stream  sA    VAYY"%%%2q!!!!!r   r   r  c                 :   t          j        dt           j                  }|                     t           j        |           t          j        |          }|                     t           j        |           |                     t          j        |                     d S )NNUL)r   r&   r   r   ro   r{   r}  rH  r  s      r   test_dup_nulzFDInheritanceTests.test_dup_nul  su     geR[))#&&&fSkk#&&&+C0011111r   r  zneed os.dup2()c                    t          j        t          t           j                  }|                     t           j        |           t          j        t          t           j                  }|                     t           j        |           |                     t          j        ||          |           |                     t          j	        |                     t          j        t          t           j                  }|                     t           j        |           |                     t          j        ||d          |           | 
                    t          j	        |                     d S )NF)inheritable)r   r&   r   r   r   ro   rH   r  rp   rH  r}  )r9   r   r$  fd3s       r   r"  zFDInheritanceTests.test_dup2  s   WXr{++"%%% gh,,#&&&S))3///*3//000 gh,,#&&&Se<<<cBBB+C0011111r   openptyzneed os.openpty()c                 R   t          j                    \  }}|                     t           j        |           |                     t           j        |           |                     t          j        |          d           |                     t          j        |          d           d S r  )r   r
  r   ro   rH   rH  )r9   	master_fdslave_fds      r   test_openptyzFDInheritanceTests.test_openpty  s     jll	8),,,(++++I66>>>+H55u=====r   )ra   rb   rc   r  r   r  r  r  r  r   r   r   r  r  r  r  r   r  rB   rC   r  r"  r  r
   r   r   r  r  B  s       7 7 7 X_Ud]L11
7 
7 21
7 X_Ud]L11  21 XX..0@AA	8 	8 BA	8; ; ;8 8 8
 XV,,.>??9 9 @?99 9 9" " "
 X02GHH2 2 IH2 XV,,.>??2 2 @?2  XY//1DEE> > FE> > >r   r  c                   h    e Zd Zddddej        fdfddddej        f eed	d          fgZd
 Zd Z	dS )PathTConverterTests)r   Tr
   N)rG  Fr
   Nrq   FN)r  Fr   N)r  Fr  Nr&   ro   c           	         t           j        }t          j        dk    rd x}}n-t          j        t           j                  }t          |          }t          j        t          |          t          j        t          j        z            }| 	                    t           j
        t           j                   | 	                    t          j        |           t          |          }t          |          }| j        D ]J\  }}}	}
|                     |          5  	 t          t          |          }n# t          $ r Y d d d            Mw xY w||||fD ]J}||                     ||          5   ||g|	R  }|
 |
|           d d d            n# 1 swxY w Y   K|                     t"          d          5   ||g|	R   d d d            n# 1 swxY w Y   |r ||g|	R  }|
 |
|           n<|                     t"          d          5   ||g|	R   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   Ld S )Nr7  r    )r!   rI   zto return str or byteszos.PathLike)r   rh   r   r!   r!  r   r&   r   rm   r   ri   ro   	functionsr%  r:  r@  assertRaisesRegexr   )r9   str_filenamebytes_fspathbytes_filenamer   
int_fspath
str_fspathr!   allow_fd
extra_args
cleanup_fnr  rI   rD  s                 r   test_path_t_converterz)PathTConverterTests.test_path_t_converter  s    '7d??,00L>>[)9::N#N33LWXl++R[-CDD	()*:;;;"%%%b\\
l++
6:n 	, 	,2D(J
4(( , , T**BB%   	, , , , , , , *>:)+ / /D| 4d;; / /!#D!6:!6!6!6%1&Jv.../ / / / / / / / / / / / / / /
 ++!#;= = 0 0Bz/J////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  ,R0Z000F!-"
6***//%)+ + , , 2+
++++, , , , , , , , , , , , , , ,1, , , , , , , , , , , , , , ,	, 	,s   H6D-,H6-
E7H6E%H6*F	H6FH6FH64
G
>H6
GH6G7H6	
HH6H##H6&H#'H66H:	=H:	c                 .   d}|                      t          |dz            5  t          j        t	          d                     d d d            n# 1 swxY w Y   |                      t          |dz            5  t          j        t	          d                     d d d            n# 1 swxY w Y   |                      t          |dz            5  t          j        t	          t                                           d d d            d S # 1 swxY w Y   d S )Nz-__fspath__\(\) to return str or bytes, not %sr#  ry   floatgQ@object)r  r   r   r   r   r   )r9   r  s     r   &test_path_t_converter_and_custom_classz:PathTConverterTests.test_path_t_converter_and_custom_class  s   >##IsV|<< 	! 	!GHQKK   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!##IsX~>> 	$ 	$GHTNN###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$##IsY?? 	( 	(GHVXX&&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s5   "AAA8"B&&B*-B*.D

DD)
ra   rb   rc   r   F_OKr   r:  r  r  r!  r
   r   r   r  r    sv         	!"	527*d+&'	GT(B(BCI*, *, *,X( ( ( ( (r   r  rK  rL  zCannot unset blocking flagc                       e Zd Zd ZdS )BlockingTestsc                    t          j        t          t           j                  }|                     t           j        |           |                     t          j        |          d           t          j        |d           |                     t          j        |          d           t          j        |d           |                     t          j        |          d           d S r  )	r   r&   r   r   r   ro   rH   rK  rN  r   s     r   rO  zBlockingTests.test_blocking  s    WXr{++"%%%,,d333
E""",,e444
D!!!,,d33333r   N)ra   rb   rc   rO  r
   r   r   r$  r$    s#        	4 	4 	4 	4 	4r   r$  c                       e Zd Zd ZdS )ExportsTestsc                     |                      dt          j                   |                      dt          j                   d S )Nr&   r  )r   r   __all__rj   s    r   test_os_allzExportsTests.test_os_all  s4    fbj)))fbj)))))r   N)ra   rb   rc   r*  r
   r   r   r'  r'    s#        * * * * *r   r'  c                        e Zd Zd Zd Zd ZdS )TestDirEntryc                     t           j                            t          j                  | _        |                     t          j        | j                   t          j        | j                   d S r.   )r   rI   realpathr   rh   r   r  rL   rj   s    r   rk   zTestDirEntry.setUp  sM    G$$Y%566		($)444
r   c                 P    |                      t          t          j                   d S r.   )r~   r   r   DirEntryrj   s    r   test_uninstantiablez TestDirEntry.test_uninstantiable  s     )R[11111r   c                    t          t          j                            | j        d          d          }d t          j        | j                  D                                             }|                     |t          j                   |                     |j	        d           dd l
}|                     t          |j        ||           d S )Nr     pythonc                     g | ]}|S r
   r
   r   entrys     r   r   z0TestDirEntry.test_unpickable.<locals>.<listcomp>   s    :::5:::r   r   )r+   r   rI   rK   scandirrW  r6   r0  rH   r!   rS  r~   r   rU  )r9   r(   r6  rS  s       r   test_unpickablezTestDirEntry.test_unpickable  s    rw||DIzBBINN::BJty$9$9:::>>@@eR[111Z000)V\5(CCCCCr   N)ra   rb   rc   rk   r1  r8  r
   r   r   r,  r,    sF          
2 2 2D D D D Dr   r,  c                   F   e Zd Zej        Zd Zd!dZd Zd Zd Z	d Z
d Zd	 Zd
 Zd!dZd Zd Zd Zd Zd Zd Zd Zd Zd Z ej        ej        ej        v d          d             Z ej        ej         d          d             Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d S )"TestScandirc                    t           j                            t          j                  | _        t          j        | j                  | _        |                     t          j        | j                   t          j	        | j                   d S r.   )
r   rI   r.  r   rh   r!  
bytes_pathr   r  rL   rj   s    r   rk   zTestScandir.setUp*  s`    G$$Y%566	+di00	($)444
r   r  c                     t          |t                    r| j        n| j        }t          j                            ||          }t          |d           |S )Nr3  )rk  r^   r<  rI   r   rK   r+   )r9   r!   rI   r(   s       r   r+   zTestScandir.create_file0  sH    ",T5"9"9Htty7<<d++Hi(((r   c                     t          d t          j        | j                  D                       }|                     t          |                                          |           |S )Nc              3   (   K   | ]}|j         |fV  d S r.   r    r5  s     r   r.  z*TestScandir.get_entries.<locals>.<genexpr>7  s=       ; ;  
E* ; ; ; ; ; ;r   )r  r   r7  rI   rH   r  keys)r9   namesentriess      r   get_entrieszTestScandir.get_entries6  sd     ; ;$&Jty$9$9; ; ; ; ;//777r   c                     |ret          |          D ]S}|                    d          s|dv r|                     t          ||          t          ||          |||f           Td S |                     ||           d S )Nst_)st_devst_inost_nlink)r7  r  rH   r:  )r9   stat1stat2skip_fieldsrF  s        r   assert_stat_equalzTestScandir.assert_stat_equal<  s     
	+E

 7 7u-- ;;;  !5!5!(!5!5"'!57 7 7 77 7 UE*****r   c                     t          j        | j                  }|                     t          t          |                     |                                 d S r.   )r   r7  rI   r~   r   r   ro   )r9   scandir_iters     r   r1  zTestScandir.test_uninstantiableI  sI    z$),,)T,%7%7888r   c                     |                      d          }t          j        | j                  }dd l}|                     t          |j        ||           |                                 d S )Nr  r   )	r+   r   r7  rI   rS  r~   r   rU  ro   )r9   r(   rN  rS  s       r   r8  zTestScandir.test_unpickableN  sc    ##J//z$),,)V\<JJJr   c                 f   |                      |t          j                   |                     |j        |           |                     |j        t          j                            | j        |                     |                     |                                t          j        |j        d          j	                   t          j        |j                  }|                     |
                                t          j        |j                             |                     |                                t          j        |j                             |                     |                                t          j                            |j                             t          j        |j        d          }|                     |
                    d          t          j        |j                             |                     |                    d          t          j        |j                             |                     |                                |t          j        dk    o|            |                     |                    d          |t          j        dk               d S )NFr  r7  )r6   r   r0  rH   r!   rI   rK   inoder   rG  is_dirS_ISDIRr?  is_fileS_ISREG
is_symlinkr  rL  )r9   r6  r!   rR  rT  rV  
entry_statentry_lstats           r   check_entryzTestScandir.check_entryU  sJ   eR[111T***RW\\$)T%B%BCCCUCCCJ	L 	L 	L WUZ((
j&899	; 	; 	;j&899	; 	; 	;))++
33	5 	5 	5 gej%@@@e<<k&9::	< 	< 	<u==k&9::	< 	< 	< 	uzz||)!w$Az>	C 	C 	C 	uzz%z@@*!w$	0 	0 	0 	0 	0r   c                    t          t          d          }t          j                    }t          j                            | j        d          }t          j        |           |                     d          }|ri	 t          j        |t          j                            | j        d                     n/# t          $ r"}| 
                    d|z             Y d }~nd }~ww xY w|rrt          j        |t          j                            | j        d          d           t          j        |t          j                            | j        d	                     ddg}|r|                    d           |r|                    d
           |                     |          }|d         }|                     |dddd           |d         }|                     |dddd           |r!|d         }|                     |dddd           |rD|d         }|                     |dddd           |d	         }|                     |d	ddd           d S d S )Nr  r7  r  zlink_file.txtrZ  symlink_dirT)r   symlink_file.txt)r[  r\  F)r   r   r   r  rI   rK   rL   r+   r  r  r|   r   r  r  rC  rY  )	r9   r  r   rV   r(   r   rA  rB  r6  s	            r   test_attributeszTestScandir.test_attributesq  sg   r6""'))',,ty%00
##J// 	33"',,ty/"J"JKKKK" 3 3 3o1222222223 	NJwTY F F+/1 1 1 1Jxdi9K!L!LMMM
# 	*LL))) 	>LL<===""5))tUE:::
#
E4??? 	IO,EUOUD%HHH 	KM*EUM4EEE./EU$6tTJJJJJ	K 	Ks   :8B3 3
C=CCc                    t          |t                    r| j        n| j        }t	          t          j        |                    }|                     t          |          d           |d         }|                     |j	        |           |S r  )
rk  r^   r<  rI   r  r   r7  rH   rD   r!   )r9   r!   rI   rB  r6  s        r   	get_entryzTestScandir.get_entry  sw    ",T5"9"9Httyrz$''((Wq)))
T***r   c                     |                      |          }|                     t          j                            |                    S )Nr    )r+   r_  r   rI   basename)r9   r!   r(   s      r   create_file_entryzTestScandir.create_file_entry  s:    ###..~~bg..x88999r   c                    |                                  }t          j                    }	 t          j        | j                   t          d t          j                    D                       }|                     t          |	                                          t          j        
                    |          g           t          j        |           d S # t          j        |           w xY w)Nc              3   (   K   | ]}|j         |fV  d S r.   r    r5  s     r   r.  z5TestScandir.test_current_directory.<locals>.<genexpr>  s)      II5EJ.IIIIIIr   )r+   r   r5   rM   rI   r  r7  rH   r  r@  ra  )r9   r(   old_dirrB  s       r   test_current_directoryz"TestScandir.test_current_directory  s    ##%%)++		HTY IIBJLLIIIIIGVGLLNN33 g..x889; ; ; HWBHWs   BC C+c                 t    |                                  }|                     t          |          d           d S )Nz<DirEntry 'file.txt'>)rb  rH   r/  r9   r6  s     r   	test_reprzTestScandir.test_repr  s6    &&((e&=>>>>>r   c                     |                                  }|                     t          j        |          t          j                            | j        d                     d S )Nr  )rb  rH   r   fspathrI   rK   rh  s     r   test_fspath_protocolz TestScandir.test_fspath_protocol  sK    &&((5))27<<	:+N+NOOOOOr   c                 N   t          j        d          }|                     |          }t          j        |          }|                     |t
                     |                     |t           j                            t          j        | j                  |                     d S )Nzbytesfile.txtr    )	r   r!  rb  rk  r6   r^   rH   rI   rK   )r9   r  bytes_entryrk  s       r   test_fspath_protocol_bytesz&TestScandir.test_fspath_protocol_bytes  s    _55,,.,AA;''fe,,,bk$)&<&<^LL	N 	N 	N 	N 	Nr   c                 `   t           j                            | j        d          }t          j        |           |                     d          }t          j        |           t           j        dk    r'|                     |                                           | 	                    |
                                           | 	                    |                                           t           j        dk    rL|                     t          |j                   |                                 |                    d           d S |                     |                                d           |                     t          |j                   |                     t          |j        d           d S )Nr7  r7  Fr  r   )r   rI   rK   rL   r_  r  r!   rp   rR  r}  rT  rV  r~   rN   rQ  r   r  )r9   rI   r6  s      r   test_removed_dirzTestScandir.test_removed_dir  sM   w||DIu--
u%%
 7d??OOELLNN+++)))))++,,,7d??/===JJLLLJJuJ-----u{{}}a000/<<</USSSSSr   c                    |                                  }t          j        |j                   |                     |                                           t          j        dk    r'|                     |                                           |                     |	                                           t          j        dk    rL| 
                    t          |j                   |                                 |                    d           d S |                     |                                d           | 
                    t          |j                   | 
                    t          |j        d           d S )Nr7  Fr  r   )rb  r   ri   rI   r}  rR  r!   rp   rT  rV  r~   rN   rQ  r   r  rh  s     r   test_removed_filezTestScandir.test_removed_file  s,   &&((
	%*(((7d??OOEMMOO,,,))++,,,7d??/===JJLLLJJuJ-----u{{}}a000/<<</USSSSSr   c                    t          j                    s|                     d          S |                     d          }t	          j        |t          j                            | j        d                     |                     ddg          }|d         }t	          j	        |           | 
                    |                                d           |                     |                                           |                     |                                           |                     |                    d                     |                     |                    d                     |                     |                                           |                     t$          |j                   |                    d           d S )Nzcannot create symbolic linkr  zsymlink.txtr   Fr  )r   r  r|   r+   r   r   rI   rK   rC  ri   r  rQ  r}  rR  rT  rp   rV  r~   rN   r   )r9   r(   rB  r6  s       r   test_broken_symlinkzTestScandir.test_broken_symlink  s   $&& 	@==!>???##J//

87<<	=99	; 	; 	;""J#>??&
	(5;;==!,,,((()))e<<===u==>>>((**++++UZ888

5
)))))r   c           	         |                      d           t          j        | j                  }t	          t          j        |                    }|                     t          |          d|           |d         }|                     |j        d           |                     |j        t          j        t          j        	                    | j        d                               d S Nr  rw   r   s   file.txt)
r+   r   r!  rI   r  r7  rH   rD   r!   rK   )r9   
path_bytesrB  r6  s       r   r  zTestScandir.test_bytes  s    $$$[++
rz*--..Wq'222
[111RW\\$)Z%H%HII	K 	K 	K 	K 	Kr   c           
      "   |                      d           t          t          fD ]i} |t          j        | j                            }|                     t                    5  t          t          j	        |                    }d d d            n# 1 swxY w Y   | 
                    t          |          d|           |d         }| 
                    |j        d           | 
                    |j        t          j        t          j                            | j        d                               |                     t          |j                  t                      |                     t          |j                  t                      kd S rw  )r+   r   r   r   r!  rI   assertWarnsr  r  r7  rH   rD   r!   rK   rh  r   r^   )r9   rT  rx  rB  r6  s        r   test_bytes_likezTestScandir.test_bytes_like  s   $$$j( 	3 	3CR[3344J!!"455 7 7rz*55667 7 7 7 7 7 7 7 7 7 7 7 7 7 7S\\1g666AJEUZ555UZ[di)L)LMMO O OMM$uz**E222MM$uz**E2222	3 	3s   #"BB	B	z.fd support for listdir required for this test.c                     |                      t          j        t          j                   |                     d           dg}t          j                    rMt          j        dt          j        	                    | j        d                     |
                    d           t          j        | j                  5 }t          j        |          5 }t          |          }d d d            n# 1 swxY w Y   d |D             }|                     t          |          |           |                     |t          j        |                     |D ]"}|                     |j        |j                   |                     t          j        |          |j                   |                     |                                |j        dk               t          j        t          j        v rt          j        |j        |          }|                     |                                |           t          j        |j        |d          }|                     |                    d          |           $	 d d d            d S # 1 swxY w Y   d S )Nr  r  c                     g | ]	}|j         
S r
   r    r5  s     r   r   z'TestScandir.test_fd.<locals>.<listcomp>,  s    555EUZ555r   r  F)r   r  r  )r   r   r7  r  r+   r   r  r   rI   rK   r  r  r  rH   r  r  r!   rk  rV  r   r  )r9   expected_namesr   r$  rB  rA  r6  r  s           r   test_fdzTestScandir.test_fd  s    	bj".111$$$$ "" 	*Jz27<<	6#B#BCCC!!&)))"49-- 	LB #2r((# # # # # # # # # # # # # # #55W555EVE]]N;;;UBJrNN333  L L  UZ888  5!1!15:>>>  !1!1!3!3UZ65IJJJ7b000B777B$$UZZ\\2666BNNNB$$UZZZ%F%FKKKL	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls7   <JC-!J-C1	1J4C1	5F JJ
JzWASI maps '' to cwdc                 R    |                      t          t          j        d           d S r  )r~   rN   r   r7  rj   s    r   test_empty_pathzTestScandir.test_empty_path9  s#    +RZ<<<<<r   c                 .   |                      d           t          j        | j                  }t	          |          }|                     t          |          d|           t	          |          }|                     t          |          d|           d S )Nr  rw   r   )r+   r   r7  rI   r  rH   rD   )r9   rq  rB  entries2s       r   test_consume_iterator_twicez'TestScandir.test_consume_iterator_twice=  s    $$$:di((x..Wq'222 >>X844444r   c                 b    di g fD ](}|                      t          t          j        |           )d S )NgX9v?)r~   r   r   r7  )r9   objs     r   test_bad_path_typezTestScandir.test_bad_path_typeH  s>    2r? 	: 	:CiS9999	: 	:r   c                 V   |                      d           |                      d           t          j        | j                  }t	          |           |                                 |                                 |                                 5  ~d d d            d S # 1 swxY w Y   d S Nr  	file2.txt)r+   r   r7  rI   r"  ro   check_no_resource_warningr9   rq  s     r   
test_closezTestScandir.test_closeL  s    $$$%%%:di((X++-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BB"%B"c                 6   |                      d           |                      d           t          j        | j                  5 }t	          |           d d d            n# 1 swxY w Y   |                                 5  ~d d d            d S # 1 swxY w Y   d S r  )r+   r   r7  rI   r"  r  r  s     r   test_context_managerz TestScandir.test_context_managerW  s   $$$%%%Z	"" 	hNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	++-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   A  A$'A$?BBBc                    |                      d           |                      d           t          j        | j                  5 }t	          |           |                                 d d d            d S # 1 swxY w Y   d S r  )r+   r   r7  rI   r"  ro   r  s     r   test_context_manager_closez&TestScandir.test_context_manager_close_  s    $$$%%%Z	"" 	hNNNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $A55A9<A9c                    |                      d           |                      d           |                     t                    5  t          j        | j                  5 }t          |           ddz   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                                 5  ~d d d            d S # 1 swxY w Y   d S )Nr  r  rw   r   )r+   r~   ZeroDivisionErrorr   r7  rI   r"  r  r  s     r   test_context_manager_exceptionz*TestScandir.test_context_manager_exceptionf  s   $$$%%%011 	 	DI&& (X!              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ++-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sH   BB 4B B	BB	BBB6CC	C	c                    |                      d           |                      d           t          j        | j                  }t	          |           |                     t                    5  ~t          j                     d d d            n# 1 swxY w Y   t          j        | j                  }t          |           | 
                                5  ~d d d            d S # 1 swxY w Y   d S r  )r+   r   r7  rI   r"  rz  ResourceWarningr   
gc_collectr  r  r  s     r   test_resource_warningz!TestScandir.test_resource_warningp  sX   $$$%%%:di((Xo.. 	! 	!   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! :di((X++-- 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   -BBBC$$C(+C(N)r  ))ra   rb   rc   r   r  rk   r+   rC  rL  r1  r8  rY  r]  r_  rb  rf  ri  rl  ro  rq  rs  ru  r  r{  r   r   r   r  r  r  r  r   r  r  r  r  r  r  r  r  r  r
   r   r   r:  r:  '  s/        / I       + + +  
  0 0 08'K 'K 'KR  : : : :  ? ? ?P P PN N NT T T,T T T&* * **
K 
K 
K3 3 3  Xr~5IK KL LK KL0 X_W_&;<<= = =<=	5 	5 	5: : :	 	 	          r   r:  c                   d    e Zd Z eej                  Zd Zd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
S )
TestPEP519c                 b    dD ]+}|                      ||                     |                     ,d S )N)r  s   goodbyes   some/path/and/filerH   rk  )r9   bs     r   test_return_byteszTestPEP519.test_return_bytes  s>    < 	0 	0AQA////	0 	0r   c                 b    dD ]+}|                      ||                     |                     ,d S )N)hellogoodbyezsome/path/and/filer  )r9   r   s     r   test_return_stringzTestPEP519.test_return_string  s>    9 	0 	0AQA////	0 	0r   c                     dD ]}t          |          }|                     ||                     |                     |                     dt          j        |                     |                     dt          j        |                     d S )N)path/like/object   path/like/objectr  r  )r   rH   rk  r   r!  r_   )r9   rY  pathlikes      r   test_fsencode_fsdecodez!TestPEP519.test_fsencode_fsdecode  s    8 	H 	HA{{HQH 5 56660"+h2G2GHHH/X1F1FGGGG	H 	Hr   c                 J   |                      d|                     t          d                               |                     t	          t          t
          j                             |                     t          t          d          t
          j                             d S )Nz#feelthegilr%  )rH   rk  r   rp   
issubclassr   PathLikerk  rj   s    r   r	  zTestPEP519.test_pathlike  st    H]4K4K(L(LMMM
8R[99:::
8C=="+>>?????r   c                     t          ddi           }t          t           t           |            fD ]#}|                     t          | j        |           $d S )Nblahr
   )r   r#  r   r~   r   rk  )r9   vaporos      r   test_garbage_in_exception_outz(TestPEP519.test_garbage_in_exception_out  sX    VR$$dB' 	9 	9Aia8888	9 	9r   c                 F    |                      t          | j                   d S r.   )r~   r   rk  rj   s    r   test_argument_requiredz!TestPEP519.test_argument_required  s     )T[11111r   c                 X   |                      t          | j        t          d                     t	          ddi           }d|_        |                      t          | j         |                       |                      t          | j        t          t                                           d S )Nr  foor
   rw   )r~   r   rk  r   r   
__fspath__r  )r9   cs     r   test_bad_pathlikezTestPEP519.test_bad_pathlike  s    )T[(2,,???B)T[!!##666+T["#4#6#677	9 	9 	9 	9 	9r   c                      G d dt           j                  }|                     t          t          |                     |                     t          t          t           j                             d S )Nc                       e Zd ZdS )0TestPEP519.test_pathlike_subclasshook.<locals>.ANr  r
   r   r   Ar    r  r   r  )r   r  r}  r  r   rp   )r9   r  s     r   test_pathlike_subclasshookz%TestPEP519.test_pathlike_subclasshook  sp    	 	 	 	 	 	 	 	Ha00111
8R[99:::::r   c                 p    |                      t          j        t                   t          j                   d S r.   )r6   r   r  r^   typesGenericAliasrj   s    r   test_pathlike_class_getitemz&TestPEP519.test_pathlike_class_getitem  s(    bk%0%2DEEEEEr   N)ra   rb   rc   r   r   rk  r  r  r  r	  r  r  r  r  r  r
   r   r   r  r    s         \")$$F0 0 00 0 0H H H@ @ @
9 9 9
2 2 2	9 	9 	9; ; ;F F F F Fr   r  c                       e Zd Zd ZdS )
TimesTestsc                    t          j                    }|                     |t           j                   dD ]-}t	          ||          }|                     |t
                     .t           j        dk    rS|                     |j        d           |                     |j	        d           |                     |j
        d           d S d S )N)usersystemchildren_userchildren_systemelapsedr7  r   )r   r  r6   times_resultr:  r  r!   rH   r  r  r  )r9   r  fieldrn  s       r   
test_timeszTimesTests.test_times  s    

eR_555! 	0 	0EE5))E!!%////7d??U0!444U2A666U]A..... ?r   N)ra   rb   rc   r  r
   r   r   r  r    s#        / / / / /r   r  c                       e Zd Zd ZdS )	ForkTestsc                 N    d}t          d|           t          d|d           d S )Nzif 1:
            import os
            from test import support
            pid = os.fork()
            if pid != 0:
                support.wait_process(pid, exitcode=0)
        r   malloc_debug)PYTHONMALLOCr   r   s     r   	test_forkzForkTests.test_fork  s6     	t$$$t.AAAAAAr   N)ra   rb   rc   r  r
   r   r   r  r    s(        B B B B Br   r  _fspathc                   0    e Zd Z	  eej                  ZdS )TestPEP519PurePythonN)ra   rb   rc   r   r   r  rk  r
   r   r   r  r    s"        Lbj))r   r  __main__)r#   r.   )r/   r  
contextlibr[  rP   rB  r]  r
  r  r   rS  r  r  r  r'  r   r  r   rB   	sysconfigrE   rm  r  r  r   r  r?  testr   test.supportr   r   r   r   rC   r   r  ImportErrorr  rQ  pwdgetpwallrl  r@  	_testcapir   r   rj  r  test.support.script_helperr   r   test.support.os_helperr   ru  r   r   r   versionr  r  getgidrr  r"   r+   r  r  r1   TestCaser3   re   r  r  r  BasicTestMappingProtocolr  r  r   r  r  r'  r+  skip_unless_working_chmodrQ  rw  r  r  r  r  get_config_varOS_URANDOM_DONT_USE_FDr  contextmanagerr  r  r  r  rS  rg  r  r  r  r  r  r  rK  rX  ru  r}  r  r  r  r  r  r  r  IsolatedAsyncioTestCaser  ro  requires_linux_versionrr  r  r  r  r  r  r  r  r  r$  r'  r,  r:  r  r  requires_forkr  r  ra   mainr
   r   r   <module>r     s  
                   				            



                  & & & & & & " " " " " " & & & & & & ( ( ( ( ( ( ! ! ! ! ! !OOOO   HHHLLLL   EEENNNN   GGGJJJ22<3<>>222II^$   III+111111111 + + +"{*Gnnn+KKKK   DDD 8 7 7 7 7 7 # # # # # # + + + + + + 
72y (RZ\\Q&M 73 3?#: 0;;NKK <**955J)")++:J K K K    'xs|'>'>u'E'E'NP P ( ( (A8 A8 A8 A8 A8! A8 A8 A8JZ8 Z8 Z8 Z8 Z8! Z8 Z8 Z8|
a7 a7 a7 a7 a7* a7 a7 a7HXA XA XA XA XA" XA XA XAv      kJ kJ kJ kJ kJ=9 kJ kJ kJ\	C% C% C% C% C%! C% C% C%L WWR))+BCCG% G% G% G% G% G% G% DCG%T6 6 6 6 6Y 6 6 6 WWR))+BCC	6 	6 	6 	6 	6j 	6 	6 DC	6g g g g g8$ g g gT $8# 8# 8# 8# 8#X& 8# 8# %$8#v&: &: &: &: &:h' &: &: &:R "9::, , , , ,8$ , , ;:,* * * * *8$ * * *> WWR--/DEE'* '* '* '* '*X& '* '* FE'*Z I.//14 ?y 011Q6?y 899Q> 
 '=? ?*79 9J' J' J' J' J'X& J' J'9 9? ?J'Z " " " "@ WWR))&( (e+ e+ e+ e+ e+! e+ e+( (e+P S\W,.DEE B  B  B  B  Bh'  B  B FE BF "EFF}* }* }* }* }*H% }* }* GF}*@ WWR((*<==#0 #0 #0 #0 #0! #0 #0 >=#0J (*@AADA DA DA DA DAx( DA DA BADAL (*@AAE0 E0 E0 E0 E0(# E0 E0 BAE0N S\W,.DEEsK sK sK sK sKX& sK sK FEsKl S\W,.DEE,D ,D ,D ,D ,D) ,D ,D FE,D^ WWR,,.CDD9+ 9+ 9+ 9+ 9+H% 9+ 9+ ED9+x S\W,.DEE
mB mB mB mB mB) mB mB  FEmB^ S\W,.DEE8 8 8 8 8* 8 8 FE8B S\W,.DEEY! Y! Y! Y! Y!8$ Y! Y! FEY!x " " " " "8, " " ">7 7 7 7 7h' 7 7 7 1 1 1 1 1(+ 1 1 1$ EJ EJ EJ EJ EJx  EJ EJ EJP z, z, z, z, z," z, z, z,~ OPPWWR,,.FGG/ / / / /" / / HG QP/ WWR//NGGB4N4N>@ @    8,  @ @, WWR,,.HIIU U U U U83 U U JIUp    1133?A A  1b))NG NG NG NG NGX. NG NG *)A ANGb WWR!4557VWW-+ -+ -+ -+ -+H% -+ -+ XW-+` WWR002LMM2&&2 2 2 2 2x( 2 2 '& NM2 WWR++-BCC1b))N N N N N8$ N N *) DCNb\H \H \H \H \H8$ \H \H \H|D D D D DH% D D D v> v> v> v> v>* v> v> v>r?( ?( ?( ?( ?((+ ?( ?( ?(D WWR00DF F&(DEE
4 
4 
4 
4 
4H% 
4 
4 FEF F
4* * * * *8$ * * *D D D D D8$ D D D$U U U U U(# U U Up
7F 7F 7F 7F 7F" 7F 7F 7Ft/ / / / /" / / /  B B B B B! B B B" 72y ** * * * *z * * * zHMOOOOO sl   B B! B!%B* *B43B48B= =CCC) )	C54C59D DDD D&%D&