Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_os.cpython-311.pyc
�

�Ke������ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#	ddl$Z$n
#e%$rdZ$YnwxYw	ddl&Z&n
#e%$rdZ&YnwxYw	ddl'Z'n
#e%$rdZ'YnwxYw	ddl(Z(d�e(j)��D��Z*n#e%e+f$rgZ*YnwxYw	dd	l,m-Z-m.Z.n#e%$rej/xZ-Z.YnwxYw	ddl0Z0n
#e%$rdZ0YnwxYwdd
l1m2Z2ddlm3Z3ddl4m5Z5d
Z6e7e	d��re	j8��dkZ6e7ed��r,ej9j:r ej9j:�;d��Z<nd
Z<ej"�;d��oe	j=��dkZ>d�Z?d�d�Z@ejAej"�;d��d��ZBd�ZCGd�dejD��ZEGd�dejD��ZFGd�dejD��ZGGd�dejD��ZHdd lmIZIGd!�d"eIjJ��ZKGd#�d$ejD��ZLejMe7e	d%��d&��Gd'�d(eL����ZNGd)�d*eL��ZOejMe7e	d%��d&��Gd+�d,eN����ZPGd-�d.ejD��ZQejRGd/�d0ejD����ZSGd1�d2ejD��ZTejAejUd3��Gd4�d5ejD����ZVGd6�d7ejD��ZWejMe7e	d8��d9��Gd:�d;ejD����ZXejYd<��d=kp'ejYd>��d=kpejYd?��d=kZZejAeZd@��ejAej"dAkdB��GdC�dDejD������Z[ej\d�dE���Z]ejMe7e	dF��dG��GdH�dIejD����Z^ejMej"dJkdK��GdL�dMejD����Z_ejAejUdN��GdO�dPejD����Z`ejMe7e	dQ��dR��GdS�dTejD����ZaejAej"dJkdU��GdV�dWejD����ZbejAej"dJkdU��GdX�dYejD����ZcejMej"dJkdK��GdZ�d[ejD����ZdejMej"dJkdK��Gd\�d]ejD����ZeejMe7e	d^��d_��Gd`�daejD����ZfejMej"dJkdK��ejgGdb�dcejD������ZhejMej"dJkdK��Gdd�deejD����ZiejMej"dJkdK��Gdf�dgejD����ZjejgGdh�diejD����ZkGdj�dkejD��ZlGdl�dmejD��Zmejn��Gdn�doejD����Zoejn��Gdp�dqejD����Zpejqdr��ejMe7e	ds��dt��Gdu�dvejD������ZrejMe7e	dw��oe7e	dx��dy��Gdz�d{ejD����ZsejMe7e	d|��d}��Gd~�dejt����Zud��ZvejMev��d���ejwd�d�d���Gd��d�ejD������ZxejMe7e	d���d���Gd��d�ejD����ZyejMe7e	d���d���ejwd�d���Gd��d�ejD������ZzejMe7e	d���d���ejwd�d�d���Gd��d�ejD������Z{Gd��d�ejD��Z|Gd��d�ejD��Z}ejn��Gd��d�ejD����Z~Gd��d�ejD��ZejMe7e	d���d���ejAej�d���Gd��d�ejD������Z�Gd��d�ejD��Z�Gd��d�ejD��Z�Gd��d�ejD��Z�Gd��d�ejD��Z�Gd��d�ejD��Z�ej���Gd��d�ejD����Z�e7e	d���rGd��d�e���Z�e�d�krej���dSdS)��N)�support)�
import_helper)�	os_helper)�
socket_helper)�warnings_helper)�win32_is_iotc��g|]	}|j��
S�)�pw_uid)�.0�us  �6/usr/local/apps/python3/lib/python3.11/test/test_os.py�
<listcomp>r5s��2�2�2�a���2�2�2�)�INT_MAX�PY_SSIZE_T_MAX��assert_python_ok)�
unix_shell)�FakePathF�geteuid�thread_info�linuxthreads�freebsdc�X�tjtt|��d|z��S)Nzrequires os.%s)�unittest�
skipUnless�hasattr�os��names r�requires_os_funcr"Xs%����w�r�4�0�0�2B�T�2I�J�J�Jr�contentc��t|dd��5}|�|��ddd��dS#1swxYwYdS)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�.�tjd��dS�N)�asyncio�set_event_loop_policyr
rr�tearDownModuler1fs���!�$�'�'�'�'�'rc� �eZdZd�Zd�Zd�ZdS)�	MiscTestsc�b�tj��}|�|t��dSr.)r�getcwd�assertIsInstance�str��self�cwds  r�test_getcwdzMiscTests.test_getcwdks)���i�k�k�����c�3�'�'�'�'�'rc��d}tjdkrd}d}d}|d|t|��z
zz}tj��5}tj|��5}|}	tj��}|�	||��|t|��ttj
j��zz
}|dkrn�t|��|kr|dkr
|d|�}tj
�||��}	tj
|��tj|��n8#t$rYn0t $r }	|	jt"jkrYd}	~	n
�d}	~	wwxYw|}��
t&jrt+d	t|������ddd��n#1swxYwYddd��dS#1swxYwYdS)
Ni��vxworks�����python_test_dir_�aTrz!Tested current directory length: )�sys�platform�len�tempfile�TemporaryDirectoryr�
change_cwdrr5�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_pathzMiscTests.test_getcwd_long_pathosz�����<�9�$�$��G���$���S�F�S��\�\�$9�:�;��
�
(�
*�
*�"	J�f��%�f�-�-�!
J����$��)�+�+�C��$�$�S�(�3�3�3�"�c�#�h�h��R�W�[�1A�1A�&A�B�D��q�y�y���7�|�|�d�*�*�t�a�x�x�")�%�4�%�.���7�<�<��g�6�6�D�"���������������,������"�"�"�"��9��(:�:�:�!�E�E�E�E�!�����	"���� $�H�7$�:�?�J��H�c�#�h�h�H�H�I�I�I�C!
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�"	Jss�F6�B(F�(D+�*F�+
E �5F�7	E �E�F�E�E � 2F�F6�F"	�"F6�%F"	�&F6�6F:�=F:c���tj��}|�|t��|�tj|��tj����dSr.)r�getcwdbr6�bytesrH�fsdecoder5r8s  r�test_getcwdbzMiscTests.test_getcwdb�sO���j�l�l�����c�5�)�)�)������S�)�)�2�9�;�;�7�7�7�7�7rN)�__name__�
__module__�__qualname__r;r[r`r
rrr3r3jsE������(�(�(�7J�7J�7J�r8�8�8�8�8rr3c���eZdZd�ZeZd�Zejej	d��ejej
d��d�����Zejd���Z
d�Zejejeekd��ejed	zd
d���d
�������Zd�Zd�Zejejdkd��d���Zd�Zd�Zd�Zd�Zd�Zejeed��d��d���Z ejeed��d��d���Z!ejeed��d��d���Z"ejeed��d��d���Z#ejeed��d��e$d �����Z%ejeed��d��e$d!�����Z&ejeed��d��e$d"�����Z'd#S)$�	FileTestsc��tj�tj��r tjtj��dSdSr.)rrI�lexistsr�TESTFN�unlink�r9s r�setUpzFileTests.setUp�s>��
�7�?�?�9�+�,�,�	(��I�i�&�'�'�'�'�'�	(�	(rc��tjtjtjtjz��}tj|��|�tjtjtj	����dSr.)
rr&rrh�O_CREAT�O_RDWR�close�
assertTrue�access�W_OK�r9�fs  r�test_accesszFileTests.test_access�sU���G�I�$�b�j���&:�;�;��
����������	�)�"2�B�G�<�<�=�=�=�=�=rz"Test is unstable under Emscripten.zWASI does not support dup.c�2�tjtjtjtjz��}tj|��}	d}||dzkrStj|��|dz
}|dkr|�d��|tj|��}}||dzk�Stj|��n#tj|��wxYwtj	||dz��|�
ttj|d��dS)Nr��
z%couldn't allocate two consecutive fds��a)
rr&rrhrmrn�dupro�skipTest�
closerange�assertRaisesrOr')r9�first�second�retriess    r�test_closerangezFileTests.test_closerange�s����	�(�"�*�R�Y�*>�?�?��������
	��G��E�A�I�%�%��������1����R�<�<��M�M�"I�J�J�J� &���v���v��
�E�A�I�%�%�
�H�V������B�H�V��������
�
�e�U�Q�Y�'�'�'����'�2�8�U�D�9�9�9�9�9s
�AB?�?Cc���tj}tj|��}|�t
tj|d��tj|��}|�||��dS�Nr)	rrhrB�getrefcountr~�	TypeErrorr�renamerH)r9rI�old�news    r�test_renamezFileTests.test_rename�s`������o�d�#�#�����)�R�Y��a�8�8�8��o�d�#�#������c�"�"�"�"�"rc��ttjd��5}|�d��|���|���}t
j|dd��t
j|d��}|�	t|��t��|�	|d��ddd��dS#1swxYwYdS)N�w+b�spamr�)r&rrhr'�flush�filenor�lseek�readrH�typer^)r9�fobj�fd�ss    r�	test_readzFileTests.test_read�s���
�)�"�E�
*�
*�	)�d��J�J�w�����J�J�L�L�L������B��H�R��A�������A���A����T�!�W�W�e�,�,�,����Q��(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�B'C�C�Czneeds INT_MAX < PY_SSIZE_T_MAXrxrwF)�size�memuse�dry_runc�l�|�tjtj��t	tjd��ttjd��5}t
j|���|��}ddd��n#1swxYwY|�	|d��dS)Nstest�rb)
�
addCleanuprrirhr+r&rr�r�rH)r9r�r*�datas    r�test_large_readzFileTests.test_large_read�s���	
���	�(�)�*:�;�;�;��I�$�g�.�.�.��)�"�D�
)�
)�	.�R��7�2�9�9�;�;��-�-�D�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
	
����w�'�'�'�'�'s�(B�B�Bc�x�tjtjtjtjz��}|�ttj|d��tj|d��tj|td����tj|td����tj|��ttjd��5}|�|�
�����gd���ddd��dS#1swxYwYdS)N�beanssbacon
seggs
sspam
r�)sbaconseggsr�)rr&rrhrm�O_WRONLYr~r�r'�	bytearray�
memoryviewrorHr��
splitlines)r9r�r�s   r�
test_writezFileTests.test_write�s9��
�W�Y�%�r�z�B�K�'?�
@�
@�����)�R�X�r�7�;�;�;�
���Z� � � �
���Y�y�)�)�*�*�*�
���Z�	�*�*�+�+�+�
������
�)�"�D�
)�
)�	.�T����T�Y�Y�[�[�3�3�5�5�,�,�,�
.�
.�
.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.s�%=D/�/D3�6D3c�t�tj|tjd���}|�|d��dS)NT)�
creationflags�shellr)�
subprocess�call�CREATE_NEW_CONSOLErH)r9�args�retcodes   r�write_windows_consolezFileTests.write_windows_consolesA���/�$�$�7��	����
	
����!�$�$�$�$�$r�win32z$test specific to the Windows consolec��d}|�tjd|��|�tjdd|��dS)Nzprint('x' * 100000)�-cz-u)r�rB�
executable�r9�codes  r�test_write_windows_consolez$FileTests.test_write_windows_consolesE��%���"�"�3�>�4��>�>�>��"�"�3�>�4��t�D�D�D�D�Drc��tjtjtj��}tj|g|�Rddi�}|���dS)N�encoding�utf-8)rr&rrh�O_RDONLY�fdopenro)r9r�r�rts    r�
fdopen_helperzFileTests.fdopen_helpersH��
�W�Y�%�r�{�
3�
3���I�b�2�4�2�2�2�'�2�2��	���	�	�	�	�	rc��tjtjtjtjz��}tj|��|���|�d��|�dd��dS)N�r�d)rr&rrhrmrnror��r9r�s  r�test_fdopenzFileTests.test_fdopensn��
�W�Y�%�r�z�"�)�';�
<�
<��
���������������3�������3��$�$�$�$�$rc�P�tjdz}|�tjtj��|�tj|��t	tjd��t	|d��tjtj|��|�tt
j	tj��t|dd���5}|�|���d��ddd��dS#1swxYwYdS)Nz.2�1�2r�r��r��1)
rrhr�rir+r�replacer~rN�statr&rHr�)r9�TESTFN2rts   r�test_replacezFileTests.test_replace&s*���"�T�)�����	�(�)�*:�;�;�;����	�(�'�2�2�2��I�$�d�+�+�+��G�T�"�"�"�
�
�9�#�W�-�-�-����+�R�W�i�6F�G�G�G�
�'�3��
1�
1�
1�	,�Q����Q�V�V�X�X�s�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�%)D�D�"Dc�|�tjttjdd���}tj|��dS)N�)rI�flags�mode�dir_fd)rr&�__file__r�rorss  r�test_open_keywordszFileTests.test_open_keywords3s4���G����5��
�
�
��
�������rc��tjtd��}	|dtjdd���dS#t
tf$rYdSwxYw)N�symlink�targetF)�src�dst�target_is_directoryr�)r�
get_attributerrrh�NotImplementedErrorrO)r9r�s  r�test_symlink_keywordszFileTests.test_symlink_keywords8so���'��I�6�6��	��G��i�&6�$)�$�
8�
8�
8�
8�
8�
8��#�W�-�	�	�	��D�D�	���s�7�A�A�copy_file_rangeztest needs os.copy_file_range()c��|�t��5tjddd��ddd��dS#1swxYwYdS�Nrrwi����)r~�
ValueErrorrr�rjs r�#test_copy_file_range_invalid_valuesz-FileTests.test_copy_file_range_invalid_values@s���
�
�
�z�
*�
*�	*�	*���q�!�S�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*��?�A�Ac��tjdz}d}ttj|��|�tjtj��ttjd��}|�|j��|���}t|d��}|�tj|��|�|j��|���}	tj	||d��}|�
|tdd����t|d��5}|�|�
��|d|���ddd��dS#1swxYwYdS#t$r6}|jtjkr�|�|��Yd}~dSd}~wwxYw)N�.3�
0123456789r�r��r�)rrhr+r�rir&ror�rr��assertIn�rangerHr�rOrP�ENOSYSr|)	r9r�r��in_file�in_fd�out_file�out_fd�i�es	         r�test_copy_file_rangezFileTests.test_copy_file_rangeEs����"�T�)�����I�$�d�+�+�+����	�(�)�*:�;�;�;��y�'��.�.������
�&�&�&���� � �����'�'�����	�(�'�2�2�2������'�'�'����"�"��	;��"�5�&�!�4�4�A�
�M�M�!�U�1�a�[�[�)�)�)��g�t�$�$�
;��� � �������b�q�b��:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;���	�	�	��w�%�,�&�&���M�M�!��������������
	���s*�=F�1F�F	�F	�
G�+G
�
Gc��tjdz}d}d}d}d}ttj|��|�tjtj��ttjd��}|�|j��|���}t|d��}|�tj|��|�|j��|���}		tj	||	|||���}
|�
|
td	|d
z����t|d��5}|���}ddd��n#1swxYwY|�
|d|�d|z��|�
||d�||||
z���dS#t$r6}|jtjkr�|�|��Yd}~dSd}~wwxYw)N�.4r�r��r�r�r�)�
offset_src�
offset_dstrrw�)rrhr+r�rir&ror�rr�r�r�r�rHrOrPr�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_offsetgsF���"�T�)�����
������I�$�d�+�+�+����	�(�)�*:�;�;�;��y�'��.�.������
�&�&�&���� � �����'�'�����	�(�'�2�2�2������'�'�'����"�"��	6��"�5�&�-�.5�.6�8�8�8�A�
�M�M�!�U�1�m�A�o�6�6�7�7�7��g�t�$�$�
&���|�|�~�~��
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&�
���T�)�8�)�_�g�h�.>�?�?�?�
���T�(�)�)�_�!�'�'�!�)�"3�4�
6�
6�
6�
6�
6��%�	�	�	��w�%�,�&�&���M�M�!��������������
	���s*�G�E4�4E8�;E8�
H�+H�H�spliceztest needs os.splice()c��|�t��5tjddd��ddd��dS#1swxYwYdSr�)r~r�rr�rjs r�test_splice_invalid_valuesz$FileTests.test_splice_invalid_values�s���
�
�
�z�
*�
*�	!�	!��I�a��C� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!r�c�.���tjdz}d}ttj|��|�tjtj��ttjd��}|�|j��|���}tj	��\��|��fd���|��fd���	tj
|�d��}|�|tdd����|�
tj�d	��|d|���dS#t$r6}|jt jkr�|�|��Yd}~dSd}~wwxYw)
Nr�r�r�c�,��tj���Sr.�rro��read_fds�r�<lambda>z'FileTests.test_splice.<locals>.<lambda>�������� 1� 1�rc�,��tj���Sr.r��write_fds�rrz'FileTests.test_splice.<locals>.<lambda>�������� 2� 2�rr�rr�r�)rrhr+r�rir&ror�r�piper�r�r�rHr�rOrPr�r|)	r9r�r�r�r�r�r�rrs	       @@r�test_splicezFileTests.test_splice�s������"�T�)�����I�$�d�+�+�+����	�(�)�*:�;�;�;��y�'��.�.������
�&�&�&���� � ���G�I�I�������1�1�1�1�2�2�2����2�2�2�2�3�3�3�	>��	�%��1�-�-�A�
�M�M�!�U�1�a�[�[�)�)�)����R�W�W�c�2�2�D��!��H�=�=�=�=�=���	�	�	��w�%�,�&�&���M�M�!��������������
	���s�'E�
F�+F�Fc�J�
��tjdz}d}d}d}ttj|��|�tjtj��ttjd��}|�|j��|���}tj	��\�
�|��
fd���|��fd���	tj
|�||���}|�|td	|d
z����tj
�
d��}|�|||||z���dS#t$r6}	|	jt jkr�|�|	��Yd}	~	dSd}	~	wwxYw)Nr�r�r�r�r�c�,��tj���Sr.rrs�rrz1FileTests.test_splice_offset_in.<locals>.<lambda>�rrc�,��tj���Sr.rrs�rrz1FileTests.test_splice_offset_in.<locals>.<lambda>�rr)r�rrwr�)rrhr+r�rir&ror�rr	r�r�r�r�rHrOrPr�r|)r9r�r�r�r�r�r�r�r�r�rrs          @@r�test_splice_offset_inzFileTests.test_splice_offset_in�s������"�T�)�����
����I�$�d�+�+�+����	�(�)�*:�;�;�;��y�'��.�.������
�&�&�&���� � ���G�I�I�������1�1�1�1�2�2�2����2�2�2�2�3�3�3�	<��	�%��=�W�M�M�M�A�
�M�M�!�U�1�m�A�o�6�6�7�7�7��7�7�C�(�(�D�
���T�4����	�(9�#:�;�;�;�;�;���	�	�	��w�%�,�&�&���M�M�!��������������
	���s�+E"�"
F"�,+F�F"c�:���tjdz}d}d}d}ttj|��|�tjtj��tj��\��|��fd���|��fd���tj�|��t|d��}|�tj|��|�|j	��|�
��}	tj�|||���}|�|td	|d
z����t|d��5}|���}	ddd��n#1swxYwY|�|	d|�d|z��|�|	|d�|d|���dS#t $r6}
|
jt"jkr�|�|
��Yd}
~
dSd}
~
wwxYw)
Nr�r�r�r�c�,��tj���Sr.rrs�rrz2FileTests.test_splice_offset_out.<locals>.<lambda>�rrc�,��tj���Sr.rrs�rrz2FileTests.test_splice_offset_out.<locals>.<lambda>�rrr�)r�rrwr�r�)rrhr+r�rirr	r'r&ror�r�r�r�r�rHrOrPr�r|)
r9r�r�r�r�r�r�r�r�r�r�rrs
           @@r�test_splice_offset_outz FileTests.test_splice_offset_out�sN�����"�T�)�����
����I�$�d�+�+�+����	�(�)�*:�;�;�;��G�I�I�������1�1�1�1�2�2�2����2�2�2�2�3�3�3�
���4� � � ����'�'�����	�(�'�2�2�2������'�'�'����"�"��	8��	�'�6�=�X�N�N�N�A�
�M�M�!�U�1�m�A�o�6�6�7�7�7��g�t�$�$�
&���|�|�~�~��
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&�
���T�)�8�)�_�g�h�.>�?�?�?�
���T�(�)�)�_�d�2�A�2�h�7�7�7�7�7��%�	�	�	��w�%�,�&�&���M�M�!��������������
	���s*�G�%F�F
�
F
�
H�$+H�HN)(rarbrcrk�tearDownrur�skipIfr�
is_emscripten�is_wasir��cpython_onlyr�r�rrr�
bigmemtestr�r�r�rBrCr�r�r�r�r�r�rrr�r�r�r��requires_splice_piper
rrr
rrrere�s�������(�(�(��H�>�>�>�
�X�_���C����X�_���5���:�:�����:�*
��#�#���#�)�)�)�
���X���>�1�9�;�;��W��W�r�\�!�U�C�C�C�(�(�D�C�;�;���(�
.�
.�
.�%�%�%��X�����0�?�A�A�E�E�A�A�E����
%�%�%�,�,�,����
����X�����%6�7�7�9Z�[�[�*�*�\�[�*��X�����%6�7�7�9Z�[�[�;�;�\�[�;�B�X�����%6�7�7�9Z�[�[�*6�*6�\�[�*6�X�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�'8rrec�b�eZdZd�Zd�Zd�Zd�Zd�Zej	e
ed��d��d���Zej	e
ed��d	��d
���Z
ej	ejdkd��d
���Zej	ejdkd��ej	e
ed��d��d�����Zd�Zej	ejdkd��d���Zej	ejdkd��d���Zej	ejdkd��d���ZdS)�StatAttributeTestsc��tj|_|�tj|j��t|jd��dS)N�ABC)rrh�fnamer�rir+rjs rrkzStatAttributeTests.setUps=���%��
����	�(�$�*�5�5�5��D�J��'�'�'�'�'rc	�<�tj|��}|�|tjd��|�|jd��t|��}tt��D]�}|dd�dkr�|���}|�d��rd�}nd�}|�|t||����|tt|����|�	||����d�
��D]P}tt||��dz��}t||dz��d	z}|�||d
����Q	|d|�
d
��n#t$rYnwxYw	d|_|�
d
��n#t $rYnwxYw	d|_|�
d
��n#t t$f$rYnwxYw	d|_|�
d
��n#t $rYnwxYw	tjd��}	|�
d
��n#t$$rYnwxYw	tjd��}	dS#t$$rYdSwxYw)Nr��ST_�TIMEc� �t|��Sr.)�int��xs r�truncz7StatAttributeTests.check_stat_attributes.<locals>.trunc s���Q���-rc��|Sr.r
r$s rr&z7StatAttributeTests.check_stat_attributes.<locals>.trunc"s���(rzst_atime st_mtime st_ctimei���_nsi'ry��deltar?�No exception raisedrw�rx�rrwryr�r�r�r����	rx���
�)rr�rH�ST_SIZE�st_size�dir�lower�endswith�getattrr��splitr#�assertAlmostEqual�fail�
IndexError�st_mode�AttributeError�st_rdevr��parrot�stat_result)
r9r�result�membersr!�attrr&�floaty�nanosecondy�result2s
          r�check_stat_attributesz(StatAttributeTests.check_stat_attributess��������	
������-�q�1�1�1�������+�+�+��f�+�+����I�I�		-�		-�D��B�Q�B�x�5� � ��z�z�|�|���=�=��(�(�+�/�/�/�/�*�*�*�� � ���w�v�t�'<�'<�!=�!=�"(���t�)<�)<�"=�?�?�?��
�
�d�G�,�,�,��1�6�6�8�8�	A�	A�D�����.�.��7�8�8�F�!�&�$��,�7�7�5�@�K��"�"�6�;�a�"�@�@�@�@�	��3�K�K��I�I�+�,�,�,�,���	�	�	��D�	����	��F�N��I�I�+�,�,�,�,���	�	�	��D�	����	��F�N��I�I�+�,�,�,�,���	�*�	�	�	��D�	����	��F�M��I�I�+�,�,�,�,���	�	�	��D�	����	��n�U�+�+�G��I�I�+�,�,�,�,���	�	�	��D�	����	��n�%I�J�J�G�G�G���	�	�	��D�D�	���sl�<F�
F'�&F'�+G�
G�G�G6�6H
�	H
�H+�+
H8�7H8�<)I&�&
I3�2I3�7J
�
J�Jc�:�|�|j��dSr.)rJrrjs r�test_stat_attributesz'StatAttributeTests.test_stat_attributesTs���"�"�4�:�.�.�.�.�.rc���	|j�tj����}n-#t$r |�d|jz��YnwxYw|�|��dS)Nz#cannot encode %a for the filesystem)r�encoderB�getfilesystemencoding�UnicodeEncodeErrorr|rJ)r9rs  r�test_stat_attributes_bytesz-StatAttributeTests.test_stat_attributes_bytesWs���	N��J�%�%�c�&?�&A�&A�B�B�E�E��!�	N�	N�	N��M�M�?�$�*�L�M�M�M�M�M�	N�����"�"�5�)�)�)�)�)s�+.�'A�Ac�X�tj|j��}ttjdz��D]s}t	j||��}|�d|��|dkr|�d|��t	j|��}|�	||���tdS)Nrwsstat_resultr�scos
stat_result
)
rr�rr��pickle�HIGHEST_PROTOCOL�dumpsr��loadsrH�r9rD�proto�p�	unpickleds     r�test_stat_result_picklez*StatAttributeTests.test_stat_result_pickle^s�������$�$���6�2�Q�6�7�7�	0�	0�E���V�U�+�+�A��M�M�.�!�,�,�,��q�y�y��
�
�3�Q�7�7�7���Q���I����V�Y�/�/�/�/�
	0�	0r�statvfsztest needs os.statvfs()c��tj|j��}|�|j|d��d}t|��D]2\}}|�t
|d|z��||���3|�t|j	t����|�t|��d��	d|_|�d��n#t$rYnwxYw	d|_|�d��n#t$rYnwxYw	tjd��}|�d��n#t $rYnwxYw	tjd��}dS#t $rYdSwxYw)	Nr�)
�bsize�frsize�blocks�bfree�bavail�files�ffree�favail�flag�namemax�f_rxrwr+r,r-)rr\rrH�f_bfree�	enumerater:rp�
isinstance�f_fsidr#rDr=r@rB�statvfs_resultr�)r9rDrE�value�memberrIs      r�test_statvfs_attributesz*StatAttributeTests.test_statvfs_attributeshs�����D�J�'�'��	
��������3�3�3�:��&�w�/�/�	L�	L�M�E�6����W�V�T�F�]�;�;�V�E�]�K�K�K�K����
�6�=�#�6�6�7�7�7�	
����V���b�)�)�)�	��F�N��I�I�+�,�,�,�,���	�	�	��D�	����	��F�M��I�I�+�,�,�,�,���	�	�	��D�	����	��'��.�.�G��I�I�+�,�,�,�,���	�	�	��D�	����	��'�(L�M�M�G�G�G���	�	�	��D�D�	���sH�C-�-
C:�9C:�>D�
D(�'D(�,)E�
E#�"E#�'E=�=
F�
F�need os.statvfs()c�X�tj|j��}ttjdz��D]s}t	j||��}|�d|��|dkr|�d|��t	j|��}|�	||���tdS)Nrwsstatvfs_resultr�scos
statvfs_result
)
rr\rr�rSrTrUr�rVrHrWs     r�test_statvfs_result_picklez-StatAttributeTests.test_statvfs_result_pickle�s�����D�J�'�'���6�2�Q�6�7�7�	0�	0�E���V�U�+�+�A��M�M�+�Q�/�/�/��q�y�y��
�
�6��:�:�:���Q���I����V�Y�/�/�/�/�
	0�	0rr��Win32 specific testsc���	tjd��dS#t$r|�d��YdSt$r }|�d��Yd}~dSd}~wwxYw)Nzc:\pagefile.syszc:\pagefile.sys does not existzCould not stat pagefile.sys)rr�rNr|rOr=�r9r�s  r�test_1686475zStatAttributeTests.test_1686475�s���	5��G�&�'�'�'�'�'�� �	=�	=�	=��M�M�;�<�<�<�<�<�<��	5�	5�	5��I�I�3�4�4�4�4�4�4�4�4�4�����	5���s��A#�	A#�A�A#r	zrequires os.pipe()c���tj��\}}	tj|��tj|��tj|��n-#tj|��tj|��wxYw|�t
��5}tj|��ddd��n#1swxYwY|�|jjtj	��dSr.)
rr	r�ror~rOrH�	exceptionrP�EBADF)r9r��w�ctxs    r�
test_15261zStatAttributeTests.test_15261�s����w�y�y���1�	��G�A�J�J�J��H�Q�K�K�K��H�Q�K�K�K�K��
�H�Q�K�K�K��H�Q�K�K�K�K����
�
�
�w�
'�
'�	�3��G�A�J�J�J�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	������,�e�k�:�:�:�:�:s�A�*A?�B=�=C�Cc��|�t|d����|�t|jt����|�d|jcxkodknc��dS)N�st_file_attributesr���)rprrkrr#)r9rDs  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�Erz$st_file_attributes is Win32 specificc���tj|j��}|�|��|�|jtjzd��tjdz}tj	|��|�
tj|��tj|��}|�|��|�|jtjztj��dS)Nrr7)rr�rr�rHr�FILE_ATTRIBUTE_DIRECTORYrrhrLr��rmdir)r9rDrVs   r�test_file_attributesz'StatAttributeTests.test_file_attributes�s�������$�$���"�"�6�*�*�*�����%��(E�E�
�	�	�	�
�"�U�*��
�����������'�*�*�*����!�!���"�"�6�*�*�*�����%��(E�E��)�	+�	+�	+�	+�	+rc�f�tj�tjd|j��}|�tj|��t|d��d}tj
d|ddg|���tj|��}|�|j
d��dS)	N�TEMPrr/z
icacls.exez/denyz*S-1-5-32-545:(S)�r�r)rrIrK�environrr�rrir+r��
check_callr��assertNotEqualr6)r9r�DETACHED_PROCESSrDs    r�test_access_deniedz%StatAttributeTests.test_access_denied�s�������R�Z��/���<�<�����	�(�%�0�0�0��E�6�"�"�"������5�'�+>�?�*�		
�	
�	
�	
����������F�N�A�.�.�.�.�.rc���dtj�tj����dz}tj|��}|�|jtj��dS)Nz//./r)rrI�
splitdriver5r�rHr?�S_IFBLK)r9rrDs   r�test_stat_block_devicez)StatAttributeTests.test_stat_block_device�sV�����+�+�B�I�K�K�8�8��;�;���������������6�6�6�6�6rN)rarbrcrkrJrLrQr[rrrrrprsrBrCrwr}r�r�r�r�r
rrrr
s������(�(�(�
?�?�?�B/�/�/�*�*�*�0�0�0��X�����Y�/�/�1J�K�K�)�)�L�K�)�V�X�����Y�/�/�,�.�.�	0�	0�.�.�	0��X�����0�2H�I�I�5�5�J�I�5��X�����0�2H�I�I��X�����V�,�,�.B�C�C�
;�
;�D�C�J�I�
;�F�F�F�
�X�����0�?�A�A�+�+�A�A�+�&�X�����0�2H�I�I�/�/�J�I�/�(�X�����0�2H�I�I�7�7�J�I�7�7�7rrc�x�eZdZd�Zd�Zdd�Zd�Zed���Zd�Z	d�Z
eje
je
jvd	��d
���Zeje
je
jvd��d���Zeje
je
jvd
��d���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejd���ZdS)�
UtimeTestsc� �tj|_tj�|jd��|_|�tj|j��tj	|j��t|j��dS)N�f1)rrhrVrrIrKrr��rmtreerLr+rjs rrkzUtimeTests.setUp�sf�� �'����W�\�\�$�,��5�5��
����	�(�$�,�7�7�7�
��������D�J�����rc��tj|��}|j|dkp!|j|dkp|j|dkS)Nr.r/r0)rr��st_atime�st_mtime�st_ctime)r9r(�sts   r�support_subsecondzUtimeTests.support_subsecond�sL���W�X�
�
�����1��%�*��K�2�a�5�(�*��K�2�a�5�(�	+rNc��|s|j}|�|��}|rd}d}nd}d}||||f��tj|��}|rA|�|j|dzd���|�|j|dzd���n<|�|j|dz��|�|j|dz��|�|j|��|�|j	|��dS)Ni8Z�;l�
o]�rTlP�9��&�.>g���ư>r))
rr�rr�r<r�r�rH�st_atime_ns�st_mtime_ns)r9�set_timer(r��atime_ns�mtime_nsr�s       r�_test_utimezUtimeTests._test_utimes(���	"��z�H� �2�2�8�<�<���	!�"�H�!�H�H�!�H� �H����H�h�/�0�0�0�
�W�X�
�
���	;��"�"�2�;��4��t�"�L�L�L��"�"�2�;��4��t�"�L�L�L�L����R�[�(�T�/�:�:�:����R�[�(�T�/�:�:�:�������2�2�2�������2�2�2�2�2rc�6�d�}|�|��dS)Nc�2�tj||���dS�N��ns�r�utime�r(r�s  rr�z'UtimeTests.test_utime.<locals>.set_time"����H�X�"�%�%�%�%�%�%r�r��r9r�s  r�
test_utimezUtimeTests.test_utime!s-��	&�	&�	&�	
����"�"�"�"�"rc��|dzdzS)Nr�g��&�.>r
r�s r�	ns_to_seczUtimeTests.ns_to_sec's��
�T�	�V�#�#rc�<���fd�}��|��dS)Nc���|\}}��|��}��|��}tj|||f��dSr.�r�rr��r(r�r�r��atime�mtimer9s      �rr�z2UtimeTests.test_utime_by_indexed.<locals>.set_time0sM���!#��H�h��N�N�8�,�,�E��N�N�8�,�,�E�
�H�X��u�~�.�.�.�.�.rr�r�s` r�test_utime_by_indexedz UtimeTests.test_utime_by_indexed.s8���	/�	/�	/�	/�	/�	
����"�"�"�"�"rc�<���fd�}��|��dS)Nc���|\}}��|��}��|��}tj|||f���dS)N)�timesr�r�s      �rr�z0UtimeTests.test_utime_by_times.<locals>.set_time:sN���!#��H�h��N�N�8�,�,�E��N�N�8�,�,�E��H�X�e�U�^�4�4�4�4�4�4rr�r�s` r�test_utime_by_timeszUtimeTests.test_utime_by_times9s8���	5�	5�	5�	5�	5�	
����"�"�"�"�"rz9follow_symlinks support for utime required for this test.c�6�d�}|�|��dS)Nc�4�tj||d���dS)NF)r��follow_symlinksr�r�s  rr�z9UtimeTests.test_utime_nofollow_symlinks.<locals>.set_timeFs!��
�H�X�"�e�<�<�<�<�<�<rr�r�s  r�test_utime_nofollow_symlinksz'UtimeTests.test_utime_nofollow_symlinksBs-��	=�	=�	=�	
����"�"�"�"�"rz,fd support for utime required for this test.c�6�d�}|�|��dS)Nc��t|dd��5}tj|���|���ddd��dS#1swxYwYdS)N�wbrr�)r&rr�r�)r(r�r*s   rr�z*UtimeTests.test_utime_fd.<locals>.set_timeOs����h��a�(�(�
-�B���������,�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
-�
-s�)A�A�Ar�r�s  r�
test_utime_fdzUtimeTests.test_utime_fdLs-��	-�	-�	-�
	
����"�"�"�"�"rz0dir_fd support for utime required for this test.c�6�d�}|�|��dS)Nc���tj�|��\}}tj|��5}tj|||���ddd��dS#1swxYwYdS)N)r�r�)rrIr;r�open_dir_fdr�)r(r�rVr!�dirfds     rr�z.UtimeTests.test_utime_dir_fd.<locals>.set_timeYs����G�M�M�(�3�3�M�G�T��&�w�/�/�
4�5����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_fdzUtimeTests.test_utime_dir_fdVs-��	4�	4�	4�
	
����"�"�"�"�"rc�D�d�}|�||j���dS)Nc�2�tj||���dSr�r�r�s  rr�z1UtimeTests.test_utime_directory.<locals>.set_timear�r)r()r�rVr�s  r�test_utime_directoryzUtimeTests.test_utime_directory`s4��	&�	&�	&�	
����D�L��9�9�9�9�9rc�(�tj��}||j��|�|j��sd}nd}tj|j��}d|j�d|�d|j|z
��}|�|j|||���dS)Ng�?g�������?zst_time=z
, current=z, dt=)r*�msg)�timerr�rr�r�r<)r9r��currentr*r�r�s      r�_test_utime_currentzUtimeTests._test_utime_currentfs����)�+�+��	��������%�%�d�j�1�1�	��E�E��E�
�W�T�Z�
 �
 ����+�+�+�w�w�w���g�(=�(=�?�����r�{�G�%*��	�	5�	5�	5�	5�	5rc�<���fd�}��|��dS)Nc�:��tj�j��dSr.�rr�r�r(r9s �rr�z/UtimeTests.test_utime_current.<locals>.set_time}s����H�T�Z� � � � � r�r�r�s` r�test_utime_currentzUtimeTests.test_utime_current|s8���	!�	!�	!�	!�	!�	
� � ��*�*�*�*�*rc�<���fd�}��|��dS)Nc�<��tj�jd��dSr.r�r�s �rr�z3UtimeTests.test_utime_current_old.<locals>.set_time�s����H�T�Z��&�&�&�&�&rr�r�s` r�test_utime_current_oldz!UtimeTests.test_utime_current_old�s8���	'�	'�	'�	'�	'�	
� � ��*�*�*�*�*rc�d�tjdkr�tj�tj�|����ddz}ddl}|jj}|�	dd��}|�
|ddddd|t|����}|r	|jSdSdS)Nr�r�\�r�)
rBrCrrIr��abspath�ctypes�windll�kernel32�create_unicode_buffer�GetVolumeInformationWrDrn)r9rI�rootr�r��buf�oks       r�get_file_systemzUtimeTests.get_file_system�s����<�7�"�"��7�%�%�b�g�o�o�d�&;�&;�<�<�Q�?�$�F�D��M�M�M��}�-�H��.�.�r�3�7�7�C��/�/��d�A�04�d�D�03�S��X�X�?�?�B��
!��y� �#�"�
!�
!rc��|�|j��dkr|�d��d}tj|j||f��|�tj|j��j|��dS)N�NTFSz
requires NTFSr�)	r�rVr|rr�rrHr�r�)r9�larges  r�test_large_timezUtimeTests.test_large_time�sy�������-�-��7�7��M�M�/�*�*�*���
����e�U�^�,�,�,��������,�,�5�u�=�=�=�=�=rc��|�t��5tj|jdd���ddd��n#1swxYwY|�t
��5tj|jddg��ddd��n#1swxYwY|�t
��5tj|jd��ddd��n#1swxYwY|�t
��5tj|jd��ddd��n#1swxYwY|�t
��5tj|jddg���ddd��n#1swxYwY|�t
��5tj|jd���ddd��n#1swxYwY|�t
��5tj|jd���ddd��n#1swxYwYtjtjvrN|�t��5tj|jdd���ddd��n#1swxYwYtjtjvr�t|jdd	��5}|�t
��5tj|�
��d��ddd��n#1swxYwYddd��n#1swxYwYtjtjvrQ|�t��5tj|jdd	�
��ddd��dS#1swxYwYdSdS)N)r�r�r�r�)r�)r�r�r�F�r�r�r�r�)r~r�rr�rr��supports_follow_symlinksr��supports_fdr&r��supports_dir_fd)r9r*s  r�test_utime_invalid_argumentsz'UtimeTests.test_utime_invalid_arguments�s���
�
�
�z�
*�
*�	4�	4��H�T�Z��F�3�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�
�
�
�y�
)�
)�	)�	)��H�T�Z�!�Q��(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�
�
�
�y�
)�
)�	'�	'��H�T�Z��&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�
�
�
�y�
)�
)�	,�	,��H�T�Z��+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
�
�
�y�
)�
)�	,�	,��H�T�Z�Q��F�+�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
�
�
�y�
)�
)�	*�	*��H�T�Z�D�)�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
�
�
�y�
)�
)�	/�	/��H�T�Z�I�.�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/��8�2�6�6�6��"�"�#6�7�7�
D�
D�����V�U�C�C�C�C�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D����
D�
D�
D�
D�
�8�2�>�)�)��d�j�$��*�*�
2�b��&�&�y�1�1�2�2��H�R�Y�Y�[�[�&�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��8�2�-�-�-��"�"�#6�7�7�
7�
7�����V�A�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�7C�C"�%C"�D*�*D.�1D.�E9�9E=�E=�G�G
�
G
�+H�H�H�I9�9I=�I=�2L�
(L�5L�L	�L�L	�	L�L�L�M?�?N�Nc��d�}|�t��5tj|j|d��df���ddd��n#1swxYwY|�t��5tj|j|d��df���ddd��n#1swxYwY|�t��5tj|j|d��df���ddd��dS#1swxYwYdS)Nc�6��G�fd�d��}|��S)Nc���eZdZ�fd�ZdS)�?UtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadIntc����Sr.r
)r��divmod_ret_vals �r�
__divmod__zJUtimeTests.test_issue31577.<locals>.get_bad_int.<locals>.BadInt.__divmod__�s	���)�)rN)rarbrcr�)r�s�r�BadIntr��s.�������*�*�*�*�*�*�*rr�r
)r�r�s` r�get_bad_intz/UtimeTests.test_issue31577.<locals>.get_bad_int�sB���
*�
*�
*�
*�
*�
*�
*�
*�
*�
*��6�8�8�Or�*rwr�r
)rwryr�)r~r�rr�r)r9r�s  r�test_issue31577zUtimeTests.test_issue31577�s���	�	�	�
�
�
�y�
)�
)�	:�	:��H�T�Z�[�[��_�_�a�$8�9�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�
�
�
�y�
)�
)�	:�	:��H�T�Z�[�[��_�_�a�$8�9�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�
�
�
�y�
)�
)�	A�	A��H�T�Z�[�[��%;�%;�Q�$?�@�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As5�'A�A�A�6'B)�)B-�0B-�'D�D�	Dr.)rarbrcrkr�r�r��staticmethodr�r�r�rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r
rrr�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�7�8
��
A�
A���
A�
A�
Arr�)�
mapping_testsc���eZdZdZdZd�Zd�Zd�Zd�Ze	j
eoej
�e��d��e	j
eed��d	��ej��d
�������Ze	j
eoej
�e��d��e	j
eed��d	��ej��d�������Zd�Zd
�Zd�Zd�Ze	j
ejd��d���Zej��d���Zejdd��d���Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d �Z'dS)!�EnvironTestsz8check that os.environ object conform to mapping protocolNc��ttj��|_tjrttj��|_|������D]\}}|tj|<�dSr.)	�dictrr��_EnvironTests__save�supports_bytes_environ�environb�_EnvironTests__saveb�
_reference�items�r9�keyrns   rrkzEnvironTests.setUp�so���2�:�&�&���
�$�	-����,�,�D�L��/�/�+�+�1�1�3�3�	$�	$�J�C��#�B�J�s�O�O�	$�	$rc�*�tj���tj�|j��tjrDtj���tj�|j��dSdSr.)rr��clear�updaterrrr	rjs rrzEnvironTests.tearDown�su��
�
������
�
���$�+�&�&�&�
�$�	-��K�������K���t�|�,�,�,�,�,�	-�	-rc��dddd�S)N�VALUE1�VALUE2�VALUE3)�KEY1�KEY2�KEY3r
rjs rr
zEnvironTests._reference�s�����B�B�Brc�V�tj���tjSr.)rr�rrjs r�_empty_mappingzEnvironTests._empty_mapping�s��
�
�������z�rzrequires a shell�popenzneeds os.popen()c�d�tj���tj�d���tjdt
z��5}|������}|�|d��ddd��dS#1swxYwYdS)N�World)�HELLOz%s -c 'echo $HELLO')	rr�rrrrr��striprH)r9rrns   r�test_update2zEnvironTests.test_update2�s���
	�
������
�
�����(�(�(�
�X�+�j�8�
9�
9�	-�U��J�J�L�L�&�&�(�(�E����U�G�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s�=B%�%B)�,B)c��tjdtz��5}t|��}|�t|��d��|�t|��d��|�t|��d��|�tt
|��ddd��dS#1swxYwYdS)Nz %s -c 'echo "line1
line2
line3"'zline1
zline2
zline3
)rrr�iterrH�nextr~�
StopIteration)r9r�its   r�test_os_popen_iterzEnvironTests.test_os_popen_iter�s���
�X�<�"�#�$�$�	7�',��e���B����T�"�X�X�y�1�1�1����T�"�X�X�y�1�1�1����T�"�X�X�y�1�1�1����m�T�2�6�6�6�
	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s�BC�C�Cc���tj���D]U\}}|�t	|��t
��|�t	|��t
���VdSr.)rr�rrHr�r7)r9r
�vals   r�test_keyvalue_typesz EnvironTests.test_keyvalue_typessh���
�(�(�*�*�	-�	-�H�C�����T�#�Y�Y��,�,�,����T�#�Y�Y��,�,�,�,�	-�	-rc���|������D]8\}}|�tj�|��|���9dSr.)r
rrHrr��getrs   r�
test_itemszEnvironTests.test_itemss\���/�/�+�+�1�1�3�3�	9�	9�J�C�����R�Z�^�^�C�0�0�%�8�8�8�8�	9�	9rc���tj}d�d�|���D����}|�t|��d|�d���dS)z>Check that the repr() of os.environ looks like environ({...}).z, c3�*K�|]\}}|�d|��V��dS)z: Nr
)rr
rns   r�	<genexpr>z-EnvironTests.test___repr__.<locals>.<genexpr>sH����$
�$
���U��!�!��!�!�$
�$
�$
�$
�$
�$
rz	environ({z})N)rr�rKrrH�repr)r9�env�formatted_itemss   r�
test___repr__zEnvironTests.test___repr__sp���j���)�)�$
�$
�!�i�i�k�k�$
�$
�$
�
�
��	
����c���$E��$E�$E�$E�F�F�F�F�Frc��tj�tj��}gd�}dtj�|��i}tj}	t
|��t_|�|tj����|�|tjd�����|t_n#|t_wxYw|�|tji����|�dtjddi����|�|tj|����tj	r�	tjd���5dd	d
�}ddd��n#1swxYwY|�ttj|��n#t$rYnwxYw|�tjddi��d
g��|�tjdd
i��d
g��|�tjddi��d
g��dSdS)N)z/montyz/pythonr�z/flying/circus�PATH�r0�r�r�T)�recordr�r�)r4�PATHr8�abc�abc)r�defpathr;�pathseprKr�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_pathzEnvironTests.test_get_exec_paths����z�'�'��
�3�3��?�?�?�	��B�J�O�O�I�6�6�7���
�
�	'��h���B�J��$�$�Y��0@�0B�0B�C�C�C��$�$�Y��0@�T�0J�0J�0J�K�K�K�&�B�J�J���B�J�&�&�&�&�	
� � ��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�%5�w��6G�%H�%H���
�
�
��$�$�R�%5�w��6F�%G�%G���
�
�
��$�$�R�%5�v�v�6F�%G�%G���
�
�
�
�
�#	�	sC�A)C�C �*G�?F�G�F�G�F�G�
G�Gz#os.environb required for this test.c��d}	|�tj��d��}n;#t$r.dtj����}|�|��YnwxYw|t
jd<|�t
jd|��|�t
jd|��d}|t
jd<|�t
jd|��|�	tj��d��}|�t
jd|��dS)	Nueuro€�surrogateescapez%U+20AC character is not encodable to �unicodesunicode��sbytesr^)
rNrBrOrPr|rr�rHr�decode)r9rn�value_bytesr��	value_strs     r�
test_environbzEnvironTests.test_environb>s7����	��,�,�s�'@�'B�'B�'8�:�:�K�K��!�	�	�	�	��)�+�+�+�.�C��M�M�#������	����!&��
�9�������I�.��6�6�6������Z�0�+�>�>�>��� %���H�������X�.��6�6�6��L�L��!:�!<�!<�>O�P�P�	������G�,�i�8�8�8�8�8s�',�5A$�#A$c��d}d}d|�d�}tj��5}|�|d��tj||��tjtjd|gdt
j	d���}|�
|j���t|����tj|��tjtjd|gdt
j	d���}|�
|j���td����ddd��dS#1swxYwYdS)N�
PYTHONTESTVAR�	testvaluez%import os; print(repr(os.environ.get(z)))r�T)�check�stdout�text)r�EnvironmentVarGuard�popr�putenvr��runrBr��PIPErHrT�rstripr/�unsetenv)r9r!rnr�r0�procs      r�test_putenv_unsetenvz!EnvironTests.test_putenv_unsetenvUsp������B�t�B�B�B��
�
*�
,�
,�	?���G�G�D�$�����I�d�E�"�"�"��>�3�>�4��">�d�)3��t�E�E�E�D����T�[�/�/�1�1�4��;�;�?�?�?��K������>�3�>�4��">�d�)3��t�E�E�E�D����T�[�/�/�1�1�4��:�:�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s�DD=�=E�Erxr�c���dD]]}|�ttftj|d��|�ttftj|���^tjdkr{ddz}|�ttj|d��|�ttjd|��|�ttj|��dSdS)N)r�z=namezna=mezname=znameznamernr�r%��r��X)r~rOr�rrXr\rBrC)r9r!�longstrs   r�test_putenv_unsetenv_errorz'EnvironTests.test_putenv_unsetenv_erroris���H�	H�	H�D����w�
�3�R�Y��g�N�N�N����w�
�3�R�[�$�G�G�G�G��<�7�"�"��F�l�G����j�"�)�W�c�B�B�B����j�"�)�S�'�B�B�B����j�"�+�w�?�?�?�?�?�
#�"rc�d�d}|�|tj��|�t��5}tj|ddd��n#1swxYwY|�|jjd|��|�|jj	��|�t��5}tj|=ddd��n#1swxYwY|�|jjd|��|�|jj	��dS)N�
missingkeyr)
�assertNotInrr�r~�KeyError�assertIsryr�rp�__suppress_context__)r9�missing�cms   r�
test_key_typezEnvironTests.test_key_typeysr��������"�*�-�-�-�
�
�
�x�
(�
(�	 �B��J�w���	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��
�
�b�l�'��*�G�4�4�4������9�:�:�:�
�
�
�x�
(�
(�	$�B��
�7�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��
�
�b�l�'��*�G�4�4�4������9�:�:�:�:�:s#�A�A �#A �C � C$�'C$c��t|��}d}t|��dtj|<	t|��|�tj|d��tj|=dS#tj|=wxYw)N�__new_key__�test_environ_iteration)r!r"rr�rH)r9�
collection�iterator�new_keys    r�_test_environ_iterationz$EnvironTests._test_environ_iteration�s����
�#�#�����X����7��
�7��	$���N�N�N����R�Z��0�2J�K�K�K��
�7�#�#�#���
�7�#�#�#�#�#s�5A5�5Bc�D�|�tj��dSr.)rsrr�rjs r�(test_iter_error_when_changing_os_environz5EnvironTests.test_iter_error_when_changing_os_environ�s���$�$�R�Z�0�0�0�0�0rc�h�|�tj�����dSr.)rsrr�rrjs r�.test_iter_error_when_changing_os_environ_itemsz;EnvironTests.test_iter_error_when_changing_os_environ_items�s*���$�$�R�Z�%5�%5�%7�%7�8�8�8�8�8rc�h�|�tj�����dSr.)rsrr��valuesrjs r�/test_iter_error_when_changing_os_environ_valuesz<EnvironTests.test_iter_error_when_changing_os_environ_values�s*���$�$�R�Z�%6�%6�%8�%8�9�9�9�9�9rc�b�tr$tj�t��sdStjsdStjt�d|�d���5}|������}ddd��n#1swxYwY|�	||��dS)Nz -c 'echo $�')
rrrI�existsr�has_subprocess_supportrr�rrH)r9�varrXrrns     r�_test_underlying_process_envz)EnvironTests._test_underlying_process_env�s����	�r�w�~�~�j�9�9�	��F��/�	��F�
�X��6�6��6�6�6�
7�
7�	)�5��J�J�L�L�&�&�(�(�E�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
����5�)�)�)�)�)s�'B�B�Bc�
�d}d}|tj|<dddd|di}ttj��}|�|��tj|z}|�||��|�d||��|���}|�ttj�	|����|�
dd��|�
||��dS�	N�
_TEST_VAR_�original_value�_A_r��_B_�2�3r�)rr�rr�assertDictEqualrHrrh�NotImplemented�__or__r��r9�overridden_keyr��
new_vars_dictrX�actual�new_vars_itemss       r�test_or_operatorzEnvironTests.test_or_operator�s���%��)��%3��
�>�"���U�C���E�
���
�#�#�����
�&�&�&���m�+�����X�v�.�.�.�����f�^�4�5�5�5�&�,�,�.�.���
�
�n�b�j�&7�&7��&G�&G�H�H�H��)�)�%��4�4�4��)�)�.�.�I�I�I�I�Irc��d}dtj|<dddd|di}ttj��}|�|��txj|zc_|�|tj��|�dtj|��|�dd��|�|d��dS)Nr�r�r�r�r�r�r��rr�rrrHr�)r9r�r�rXs    r�test_ior_operatorzEnvironTests.test_ior_operator�s���%��%5��
�>�"���U�C���E�
���
�#�#�����
�&�&�&�
�
�
�m�#�
�
�����2�:�.�.�.�����b�j��8�9�9�9��)�)�%��5�5�5��)�)�.�#�>�>�>�>�>rc��tj���}|�t��5ddi}txj|zc_ddd��n#1swxYwY|�t��5ddi}txj|zc_ddd��n#1swxYwY|�|tj��dS)Nrwr�)rr��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�
���J�J�+�+�J�J�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,��
�
�y�
)�
)�	,�	,�!&��
���J�J�+�+�J�J�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
	
����"�*�5�5�5�5�5s#�A�A#�&A#�B*�*B.�1B.c��d}dtj|<dd|dff}ttj��}|�|��txj|zc_|�|tj��|�dtj|��|�dd��|�|d��dS)Nr�r�)r�r�)r�r�r�r�r�r�)r9r�r�rXs    r�$test_ior_operator_key_value_iterablez1EnvironTests.test_ior_operator_key_value_iterable�s���%��%5��
�>�"�&��~�s�6K�L����
�#�#������'�'�'�
�
�
�n�$�
�
�����2�:�.�.�.�����b�j��8�9�9�9��)�)�%��5�5�5��)�)�.�#�>�>�>�>�>rc�
�d}d}|tj|<dddd|di}t|��}|�tj��|tjz}|�||��|�|||��|���}|�ttj�	|����|�
dd��|�
||��dSr�)rr�rrr�rHrrhr��__ror__r�r�s       r�test_ror_operatorzEnvironTests.test_ror_operator�s���%��)��%3��
�>�"���U�C���E�
��
�&�&������
�#�#�#����+�����X�v�.�.�.�������)?�@�@�@�&�,�,�.�.���
�
�n�b�j�&8�&8��&H�&H�I�I�I��)�)�%��4�4�4��)�)�.�.�I�I�I�I�Ir)(rarbrc�__doc__�	type2testrkrr
rrrrrrIr}rr�requires_subprocessrr%r(r+r2rGrrOr^�requires_mac_verrcrlrsrurwrzr�r�r�r�r�r�r
rrrr�s�������B�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�Jrrc�J�eZdZdZd�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
�	WalkTestszTests for os.walk().c�^�d|vr|�d��|d<tj|fi|��S�Nr��followlinks)rWr�walk)r9�top�kwargss   rr�zWalkTests.walks<����&�&�$*�J�J�/@�$A�$A�F�=�!��w�s�%�%�f�%�%�%rc���tjj}|�tjtj��|tjd��|_||jd��|_||jd��|_	||jd��}||d��}||jd��}||jd��}||d��}||d��}||d	��|_
|tjd
��}|tjd
d��}	||d��}
||d
��}||d��}tj|j	��tj|��tj|��tj|��||||	|fD]G}
t|
dd���5}|�
d|
zdz��ddd��n#1swxYwY�Ht	j��r�tjtj�|��|j
��tjd|
d��tj|dd��|d��tj|dd��|d��|dd	ggd�f|_n|dgdgf|_t$jstj|d��	tj|��tj|t,j��tj|��tj|��|jddd�=dS#t4$r/|�tj|t,j��YdSwxYw)N�TEST1�SUB1�SUB11�SUB2�SUB21�tmp1�tmp2�tmp3�link�TEST2�tmp4�broken_link�broken_link2�broken_link3r%r�r�zI'm z" and proud of it.  Blame test_os.
�brokenT�tmp5)r�r�r�r�rrw)rrIrKr�rr�rh�	walk_path�	sub1_path�
sub11_path�	link_path�makedirsr&r'�can_symlinkr�r��	sub2_treerr�chmod�listdirr��S_IRWXUrir��PermissionError)r9rK�	sub2_path�
sub21_path�	tmp1_path�	tmp2_path�	tmp3_path�	tmp5_path�t2_path�	tmp4_path�broken_link_path�broken_link2_path�broken_link3_pathrIrts               rrkzWalkTests.setUps����w�|�����	�(�)�*:�;�;�;�&��i�.��8�8�����d�n�f�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��)�7�F�;�;�	��4�	�=�9�9�� �D��N�;�;�� �D��N�;�;��	��D�O�$�$�$�
��I����
��J����
��G�����y�)�Y�	�I�	O�	O�D��d�C�'�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��� �"�"�		>��J�r�w���w�/�/���@�@�@��J�x�!1�4�8�8�8��J�t�t�F�H�-�-�/@�$�G�G�G��J�t�t�G�V�,�,�.?��F�F�F�'�'�6�):�'�'�'�(�D�N�N�(�'��V�H�=�D�N��$�	$��H�Z��#�#�#�	&��J�z�"�"�"�
�H�Z���.�.�.��I�i� � � ��H�Z� � � ���q�!�"�1�"�%�%�%��
�	@�	@�	@��O�O�B�H�j�$�,�?�?�?�?�?�?�	@���s$�,G�G	�G	�=L*�*5M#�"M#c���t|�|j����}|�t	|��d��|ddddk}|dd���|dd|zz
d���|dd|zz
d���|�|d|jddgd	gf��|�|d|z|jd
gdgf��|�|d|z|jggf��|�|dd|zz
|j��dS)Nr�rrwr�r�ry���r�r�r�r�)	�listr�r�rHrD�sortr�r�r��r9�all�flippeds   r�test_walk_topdownzWalkTests.test_walk_topdownMsZ���4�9�9�T�^�,�,�-�-������S���1�%�%�%��a�&��)�A�,�&�(���A��q�	�������A��G��O��R� �%�%�'�'�'��A��G��O��Q��$�$�&�&�&�����Q��$�.�6�6�2B�V�H�!M�N�N�N�����Q��[�)�D�N�W�I��x�+P�Q�Q�Q�����Q��[�)�D�O�R��+D�E�E�E�����Q��W��_�-�t�~�>�>�>�>�>rNc�
�|�|j}g}|�|��D]7\}}}|�|||f��d|vr|�d���8|�t|��d��|�|d|jdgdgf��|dd���|dd���|�|d|j��dS)Nr�ryrr�r�rwr�)r�r��append�removerHrDr�r�)r9r�r�r��dirsrcs      r�test_walk_prunezWalkTests.test_walk_prune^s������I���!%���9�!5�!5�	$�	$��D�$���J�J��d�E�*�+�+�+���~�~����F�#�#�#������S���1�%�%�%�����Q��$�.�6�(�V�H�!E�F�F�F��A��r�
�������A��q�	����������Q����0�0�0�0�0rc�T�|�t|j����dSr.)r�rr�rjs r�test_file_like_pathzWalkTests.test_file_like_pathqs&�����X�d�n�5�5�6�6�6�6�6rc���t|�|jd�����}|�t	|��d|��|ddddk}|dd���|dd|zz
d	���|dd|zz
d���|�|d|jdd
gdgf��|�|||jggf��|�||dz|jdgd
gf��|�|dd|zz
|j��dS)NF��topdownr�r�rwrr�ryr�r�r�r�r�)	r�r�r�rHrDr�r�r�r�r�s   r�test_walk_bottom_upzWalkTests.test_walk_bottom_upts����4�9�9�T�^�U�9�;�;�<�<������S���1�c�*�*�*��a�&��)�A�,�&�(���A��q�	�������A��G��O��R� �%�%�'�'�'��A��G��O��Q��$�$�&�&�&�����Q���.�6�6�*:�V�H�E�	G�	G�	G�����W���/�2�r�2�	4�	4�	4�����W�q�[�)��.�7�)�f�X�>�	@�	@�	@�����Q��W��_�-���	)�	)�	)�	)�	)rc�@�tj��s|�d��|�|jd���}|D]A\}}}||jkr0|�|g��|�|dg��dS�B|�d��dS)Nzneed symlink supportTr�r�z+Didn't follow symlink with followlinks=True)rr�r|r�r�r�rHr=)r9�walk_itr�r�rcs     r�test_walk_symlinkzWalkTests.test_walk_symlink�s����$�&�&�	2��M�M�0�1�1�1��)�)�D�N�D�)�A�A��!(�	E�	E��D�$���t�~�%�%�� � ��r�*�*�*�� � ����1�1�1����&�

�I�I�C�D�D�D�D�Drc���g}|�|j|j���}t|��\}}}|�|g��d}t
j�||��}t
j�||dz��}tj||��	d�|D��}	|�	|��|�
||	��|�
||	��|D]<}
|
|kr4|�t
j�||
��|	���=	tj||��dS#tj||��wxYw)N)�onerrorr�z.newc��g|]\}}}|��	Sr
r
)rr��drts    rrz/WalkTests.test_walk_bad_dir.<locals>.<listcomp>�s��.�.�.�7�1�a��Q�.�.�.r)r�r�r�r"rHrrIrKr�rprfr�)r9�errorsr�r�r�rc�dir1�path1�path1new�roots�dir2s           r�test_walk_bad_dirzWalkTests.test_walk_bad_dir�sZ�����)�)�D�N�F�M�)�B�B�� ��M�M���d�E������$�$�$�������T�4�(�(���7�<�<��d�V�m�4�4��
�	�%��"�"�"�		'�.�.�g�.�.�.�E��O�O�F�#�#�#����U�E�*�*�*����X�u�-�-�-��
C�
C���4�<�<��M�M�"�'�,�,�t�T�":�":�E�B�B�B��
C�
�I�h��&�&�&�&�&��B�I�h��&�&�&�&���s
�(BE�E#c�����d}tj�tjd���tjj�gdg|z�R�}tj|����fd�t
d��D��}t
|dz��D]S}||rdgnggf}|D]%}��t|��|���&tj�	|��}�T��fd�t
d��D��}�}t
|dz��D]X}|||krdgnggf}|D]%}��t|��|���&tj�|d��}�YdS)N��deepr�c�>��g|]}���d�����S)Fr��r��r�j�baser9s  ��rrz7WalkTests.test_walk_many_open_files.<locals>.<listcomp>�s)���D�D�D�A����4���/�/�D�D�Drr�rwc�>��g|]}���d�����S)Tr�r�r�s  ��rrz7WalkTests.test_walk_many_open_files.<locals>.<listcomp>�s)���C�C�C�1����4���.�.�C�C�Cr)
rrIrKrrhr�r�rHr"rV)r9�depthrY�itersr�rXr$r�s`      @r�test_walk_many_open_filesz#WalkTests.test_walk_many_open_files�s��������w�|�|�I�,�f�5�5���G�L��.�#��u��.�.�.��
��A����D�D�D�D�D��s���D�D�D���u�q�y�!�!�	#�	#�A��A�-�C�5�5�2�r�2�H��
5�
5��� � ��b���8�4�4�4�4������"�"�A�A�C�C�C�C�C��c�
�
�C�C�C�����u�q�y�!�!�	%�	%�A��A��I�I�C�5�5�2�r�:�H��
5�
5��� � ��b���8�4�4�4�4�����Q��$�$�A�A�		%�	%rr.)
rarbrcr�r�rkr�r�r�r�r�r�r�r
rrr�r��s���������&�&�&�
E&�E&�E&�N?�?�?�"1�1�1�1�&7�7�7�)�)�)�*E�E�E�'�'�'�*%�%�%�%�%rr��fwalkzTest needs os.fwalk()c�x�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
jej
d��d	���Zd
Zd
S)�
FwalkTestszTests for os.fwalk().c+�DK�|j|fi|��D]\}}}}|||fV��dSr.)r)r9r�r�r�r�rc�root_fds       rr�zFwalkTests.walk�sR����*4�$�*�S�*C�*C�F�*C�*C�	&�	&�&�D�$��w���u�%�%�%�%�%�	&�	&rc�$�tj|i|��Sr.)rr�r9r�r�s   rrzFwalkTests.fwalk�s���x��(��(�(�(rc	�&�|���}|���}tjdd���D]�\}}|�||���|�||���i}t	jdi|��D]'\}}}t
|��t
|��f||<�(|jdi|��D]U\}}}}	|�||��|�	||t
|��t
|��f���V��dS)z.
        compare with walk() results.
        �TFry��repeat)r�r�)r�r�Nr
)
r��	itertools�productrrr��setrr�rH)
r9�walk_kwargs�fwalk_kwargsr�r�rXr�r�rc�rootfds
          r�_compare_to_walkzFwalkTests._compare_to_walk�sF��"�&�&�(�(��#�(�(�*�*��(1�(9�-�PQ�(R�(R�(R�
	J�
	J�$�G�_����w�O��L�L�L�������Q�Q�Q��H�%'�W�%;�%;�{�%;�%;�
9�
9�!��d�E�"%�d�)�)�S��Z�Z�!8�����-7�T�Z�-G�-G�,�-G�-G�
J�
J�)��d�E�6��
�
�d�H�-�-�-�� � ��$��#�d�)�)�S��Z�Z�1H�I�I�I�I�
J�
	J�
	Jrc�N�dtji}|�||��dS)Nr�)rrhr)r9r�s  r�test_compare_to_walkzFwalkTests.test_compare_to_walk�s+����)�*�����f�f�-�-�-�-�-rc��	tjdtj��}dtji}|���}||d<|�||��tj|��dS#tj|��wxYw)N�.r�r�)rr&r�rrhr�rro)r9r�rrs    r�test_dir_fdzFwalkTests.test_dir_fd�s{��	����b�k�*�*�B� �)�"2�3�K�&�+�+�-�-�L�%'�L��"��!�!�+�|�<�<�<��H�R�L�L�L�L�L��B�H�R�L�L�L�L���s�AA4�4B
c	�z�tjdd���D]�\}}tj|df}|j|d|i�D]�\}}}}tj|��tj|��|�ttj
|����t|��t|��z������dS)Nrryr	r�)rrrrhrr�fstatr�rHr
r�)r9r�r�r�r�r�rcrs        r�test_yields_correct_dir_fdz%FwalkTests.test_yields_correct_dir_fd�s���(1�(9�-�PQ�(R�(R�(R�	R�	R�$�G�_��#�W�d�2�D�-7�T�Z��-_��-_�-_�
R�
R�)��d�E�6���� � � �������� � ��R�Z��%7�%7�!8�!8�#�d�)�)�c�%�j�j�:P�Q�Q�Q�Q�

R�	R�	RrzCannot dup stdout on Emscriptenc�R�tjd��}tj|��td��D]$}|�t
j��D]}��%tjd��}|�tj|��|�||��dS)Nrw�)	rr{ror�rrrhr�rH)r9�minfdr�r%�newfds     r�test_fd_leakzFwalkTests.test_fd_leak�s�����q�	�	��
�������s���	�	�A��Z�Z�	� 0�1�1�
�
���
���q�	�	�������%�(�(�(������&�&�&�&�&rN)rarbrcr�r�rrrrrrrrrrr�r
rrrr�s���������&�&�&�)�)�)�J�J�J�$.�.�.����
R�
R�
R��X�_���@���'�'���'�!%���rrc��eZdZdZd�ZdS)�BytesWalkTests�Tests for os.walk() with bytes.c+�K�d|vr|�d��|d<tjtj|��fi|��D]�\}}}tj|��}tt
tj|����}tt
tj|����}|||fV�tt
tj|����|dd�<tt
tj|����|dd�<��dSr�)rWrr��fsencoder_r��map)	r9r�r��broot�bdirs�bfilesr�r�rcs	         rr�zBytesWalkTests.walks�������&�&�$*�J�J�/@�$A�$A�F�=�!�$&�G�B�K��,<�,<�$G�$G��$G�$G�	6�	6� �E�5�&��;�u�%�%�D���B�K��/�/�0�0�D���R�[�&�1�1�2�2�E���u�%�%�%�%��C���T�2�2�3�3�E�!�!�!�H��S���e�4�4�5�5�F�1�1�1�I�I�
	6�	6rN)rarbrcr�r�r
rrr r 
s)������)�)�	6�	6�	6�	6�	6rr c��eZdZdZdd�ZdS)�BytesFwalkTestsr!rc/��K�tjtj|��g|�Ri|��D]�\}}}}tj|��}t	ttj|����}	t	ttj|����}
||	|
|fV�t	ttj|	����|dd�<t	ttj|
����|dd�<��dSr.)rrr#r_r�r$)r9r�r�r�r%r&r'�topfdr�r�rcs           rrzBytesFwalkTests.fwalks�����+-�8�B�K��4D�4D�+V�t�+V�+V�+V�v�+V�+V�	6�	6�'�E�5�&�%��;�u�%�%�D���B�K��/�/�0�0�D���R�[�&�1�1�2�2�E���u�e�,�,�,�,��C���T�2�2�3�3�E�!�!�!�H��S���e�4�4�5�5�F�1�1�1�I�I�
	6�	6rN)r)rarbrcr�rr
rrr)r)s.������)�)�6�6�6�6�6�6rr)c�
�eZdZd�Zd�Zejejpej	d��d���Z
ejejpej	d��d���Zejejpej	d��d���Zd�Z
d�Zd	S)
�MakedirTestsc�B�tjtj��dSr.�rrLrrhrjs rrkzMakedirTests.setUp(s��
���!�"�"�"�"�"rc
�f�tj}tj�|ddd��}tj|��tj�|dddd��}tj|��|�ttjtj��tj�|dddddtj��}tj|��tj�|dtjddddd��}tj|��dS�Nr�r��dir3�dir4�dir5�dir6)	rrhrrIrKr�r~rO�curdir)r9r�rIs   r�test_makedirzMakedirTests.test_makedir+s�������w�|�|�D�&�&�&�9�9��
��D�����w�|�|�D�&�&�&�&�A�A��
��D����	
���'�2�;��	�:�:�:��w�|�|�D�&�&�&�&�&�"�)�T�T��
��D�����w�|�|�D�&�"�)�V�V�V�"�F�,�,��
��D�����rz$Emscripten's/WASI's umask is a stub.c���tjd��5tj}tj�|d��}tj�|d��}tj|d��|�tj�|����|�tj�	|����tj
dkr`|�tj|��j
dzd��|�tj|��j
dzd��ddd��dS#1swxYwYdS)Nryr�r�im�ntr�i�)r�
temp_umaskrhrrIrKr�rpr}�isdirr!rHr�r?)r9r��parentrIs    r�	test_modezMakedirTests.test_mode:sh��
�
!�%�
(�
(�		I�		I��#�D��W�\�\�$��/�/�F��7�<�<���/�/�D��K��e�$�$�$��O�O�B�G�N�N�4�0�0�1�1�1��O�O�B�G�M�M�$�/�/�0�0�0��w�$���� � ������!6��!>��F�F�F�� � ������!8�5�!@�%�H�H�H�		I�		I�		I�		I�		I�		I�		I�		I�		I�		I�		I�		I����		I�		I�		I�		I�		I�		Is�D6E�E�Ec�:�tj�tjd��}d}tjd��}tj||��|�ttj||��|�ttj||d���tj|dd���tj||d���tj|��tjtj�	d	��d���dS)
Nr�r��F��exist_oki�T)r�rA�/)
rrIrKrrh�umaskr�r~rOr�)r9rIr��old_masks    r� test_exist_ok_existing_directoryz-MakedirTests.test_exist_ok_existing_directoryJs���
�w�|�|�I�,�f�5�5�����8�E�?�?��
��D�$�������'�2�;��d�;�;�;����'�2�;��d�U��K�K�K�
��D�%�$�/�/�/�/�
��D�t�d�3�3�3�3�
������	��B�G�O�O�C�(�(�4�8�8�8�8�8�8rc��tj�tjd��}t
j}d}tjd��}	tjtj	tj��j
��}	tjtj||z��n"#t$rtjd���wxYwtj	tj��j
|z|krtjd���tj|||z��tj||d���tj|tjtj	|��j
��|z��tj|||zd���tj|��dS#tj|��wxYw)Nr�r�r?zCannot set S_ISGID for dir.z No support for S_ISGID dir mode.Tr@)rrIrKrrhr��S_ISGIDrC�S_IMODE�lstatr?r�r�r�SkipTestr�)r9rIrGr�rD�existing_testfn_modes      r�test_exist_ok_s_isgid_directoryz,MakedirTests.test_exist_ok_s_isgid_directory\s���
�w�|�|�I�,�f�5�5���,�����8�E�?�?��	�#'�<��H�Y�-�.�.�6�$8�$8� �
G����)�+?�'�+I�J�J�J�J��"�
G�
G�
G��'�(E�F�F�F�
G�������)�*�*�2�W�<��G�G��'�(J�K�K�K�
�K��d�W�n�-�-�-�
�K��d�T�2�2�2�2��H�T�4�<������(>�?�?�7�(�J�K�K�K��K��d�W�n�t�<�<�<�<��H�X�������B�H�X�������s%�5F(�"B'�&F(�'C�CF(�(F>c��tj}tj�tjd��}t|dd���5}|�d��ddd��n#1swxYwY|�ttj	|��|�ttj	|d���|�ttj	|d���tj
|��dS)	Nr�r{r�r�r:Fr@T)rrhrrIrKr&r'r~rOr�r�)r9r�rIrts    r�#test_exist_ok_existing_regular_filez0MakedirTests.test_exist_ok_existing_regular_file{s������w�|�|�I�,�f�5�5��
�$��g�
.�
.�
.�	�!�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	����'�2�;��5�5�5����'�2�;��u��E�E�E����'�2�;��t��D�D�D�
�	�$�����s�	A+�+A/�2A/c	��tj�tjdddddd��}tj�|��s^|tjkrNtj�|��}tj�|��s|tjk�Ntj|��dSr1)rrIrKrrhr}rV�
removedirs�r9rIs  rrzMakedirTests.tearDown�s����w�|�|�I�,�f�f�f�"�F�F�4�4��
�'�.�.��&�&�	)�4�9�3C�+C�+C��7�?�?�4�(�(�D��'�.�.��&�&�	)�4�9�3C�+C�+C�	�
�d�����rN)rarbrcrkr7rrrrrr=rErLrNrr
rrr-r-'s������#�#�#�
�
�
��X�_���0���.���
I�
I�	��
I��X�_���0���.���9�9�	��9��X�_���0���.�����	���6���	�	�	�	�	rr-c�.�eZdZed���Zd�Zejee	d��d��d���Z
ejeoee
��dkd��d���Zejeoee
��dkd	��d
���Zed���ZdS)
�ChownFileTestsc�B�tjtj��dSr.r/��clss r�
setUpClasszChownFileTests.setUpClass����
���!�"�"�"�"�"rc�N�tjtj��}|j}|j}ddt
jd��tj	dd��fD]f}|�
ttjtj||��|�
ttjtj||���g|�
tjtj||����|�
tjtjdd����dS)Ng�y��r����ry)rr�rrh�st_uid�st_gid�decimal�Decimal�	fractions�Fractionr~r��chown�assertIsNone)r9r��uid�gidrns     r�*test_chown_uid_gid_arguments_must_be_indexz9ChownFileTests.test_chown_uid_gid_arguments_must_be_index�s����w�y�'�(�(���k���k���C����!4�!4�i�6H��Q�6O�6O�P�	Q�	Q�E����i���9�3C�U�C�P�P�P����i���9�3C�S�%�P�P�P�P����"�(�9�#3�S�#�>�>�?�?�?����"�(�9�#3�R��<�<�=�=�=�=�=r�	getgroupszneed os.getgroupsc�@�tj��}t|��dkr|�d��|dd�\}}tjt
j��j}tjt
j||��tjt
j��j	}|�
||��tjt
j||��tjt
j��j	}|�
||��dS)Nryztest needs at least 2 groups)rrfrDr|r�rrhr[rar\rH)r9�groups�gid_1�gid_2rcrds      r�test_chown_gidzChownFileTests.test_chown_gid�s���������v�;�;��?�?��M�M�8�9�9�9��b�q�b�z���u��g�i�&�'�'�.��
���!�3��.�.�.��g�i�&�'�'�.������e�$�$�$�
���!�3��.�.�.��g�i�&�'�'�.������e�$�$�$�$�$rrwz0test needs root privilege and more than one userc���tdd�\}}tjtj��j}tjtj||��tjtj��j}|�||��tjtj||��tjtj��j}|�||��dS�Nry)	�	all_usersrr�rrhr\rar[rH)r9�uid_1�uid_2rdrcs     r�test_chown_with_rootz#ChownFileTests.test_chown_with_root�s���!��!��}���u��g�i�&�'�'�.��
���!�5�#�.�.�.��g�i�&�'�'�.������e�$�$�$�
���!�5�#�.�.�.��g�i�&�'�'�.������e�$�$�$�$�$rz2test needs non-root account and more than one userc�V�tdd�\}}tjtj��j}|�t��5tjtj||��tjtj||��ddd��dS#1swxYwYdSrm)	rnrr�rrhr\r~r�ra)r9rorprds    r�test_chown_without_permissionz,ChownFileTests.test_chown_without_permission�s���!��!��}���u��g�i�&�'�'�.��
�
�
��
/�
/�	3�	3��H�Y�%�u�c�2�2�2��H�Y�%�u�c�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s�AB�B"�%B"c�B�tjtj��dSr.)rr�rrhrUs r�
tearDownClasszChownFileTests.tearDownClass�rXrN)rarbrc�classmethodrWrerrrrrk�
root_in_posixrDrnrqrsrur
rrrSrS�s%�������#�#��[�#�>�>�>��X�����[�1�1�3F�G�G�%�%�H�G�%� �X���=�3�3�y�>�>�A�+=�K�M�M�%�%�M�M�%��X��]�*�A�s�s�9�~�~��/A�M�O�O�3�3�O�O�3��#�#��[�#�#�#rrSc�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�RemoveDirsTestsc�B�tjtj��dSr.)rr�rrhrjs rrkzRemoveDirsTests.setUp�s��
��I�$�%�%�%�%�%rc�B�tjtj��dSr.)rr�rhrjs rrzRemoveDirsTests.tearDown�s�����)�*�*�*�*�*rc�R�tj�tjd��}tj|��tj�|d��}tj|��tj|��|�tj�|����|�tj�|����|�tj�tj����dS)N�dira�dirb)	rrIrKrrhrLrP�assertFalser}�r9r}r~s   r�test_remove_allzRemoveDirsTests.test_remove_all�s����w�|�|�I�,�f�5�5��
�������w�|�|�D�&�)�)��
������
�
�d������������-�-�.�.�.���������-�-�.�.�.��������	�(8�9�9�:�:�:�:�:rc��tj�tjd��}tj|��tj�|d��}tj|��t
tj�|d����tj|��|�tj�	|����|�
tj�	|����|�
tj�	tj����dS�Nr}r~�file.txt)rrIrKrrhrLr+rPrr}rpr�s   r�test_remove_partialz#RemoveDirsTests.test_remove_partial�s����w�|�|�I�,�f�5�5��
�������w�|�|�D�&�)�)��
�������B�G�L�L��z�2�2�3�3�3�
�
�d������������-�-�.�.�.��������t�,�,�-�-�-��������y�'7�8�8�9�9�9�9�9rc��tj�tjd��}tj|��tj�|d��}tj|��t
tj�|d����|�t��5tj	|��ddd��n#1swxYwY|�
tj�|����|�
tj�|����|�
tj�tj����dSr�)rrIrKrrhrLr+r~rOrPrpr}r�s   r�test_remove_nothingz#RemoveDirsTests.test_remove_nothing�sI���w�|�|�I�,�f�5�5��
�������w�|�|�D�&�)�)��
�������B�G�L�L��z�2�2�3�3�3�
�
�
�w�
'�
'�	 �	 ��M�$����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��������t�,�,�-�-�-��������t�,�,�-�-�-��������y�'7�8�8�9�9�9�9�9s�:C�C�"CN)rarbrcrkrr�r�r�r
rrryry�s_������&�&�&�+�+�+�;�;�;�	:�	:�	:�
:�
:�
:�
:�
:rryzWASI has no /dev/nullc��eZdZd�ZdS)�DevNullTestsc�t�ttjdd��5}|�d��|���ddd��n#1swxYwYttjd��5}|�|���d��ddd��dS#1swxYwYdS)Nr�r�hellor�r)r&r�devnullr'rorHr�rss  r�test_devnullzDevNullTests.test_devnull�s��
�"�*�d�A�
&�
&�	�!�
�G�G�H����
�G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��"�*�d�
#�
#�	,�q����Q�V�V�X�X�s�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s#�*A�A�A�7)B-�-B1�4B1N)rarbrcr�r
rrr�r��s#������,�,�,�,�,rr�c�&�eZdZd�Zd�Zd�Zd�ZdS)�URandomTestsc��|�ttjd����d��|�ttjd����d��|�ttjd����d��|�ttjd����d��|�ttjd����d��dS)Nrrwrxr�r>)rHrDr�urandomrjs r�test_urandom_lengthz URandomTests.test_urandom_lengths�������R�Z��]�]�+�+�Q�/�/�/�����R�Z��]�]�+�+�Q�/�/�/�����R�Z��^�^�,�,�b�1�1�1�����R�Z��_�_�-�-�s�3�3�3�����R�Z��-�-�.�.��5�5�5�5�5rc��tjd��}|�|t��tjd��}|�||��dS�N�)rr�r6r^r��r9�data1�data2s   r�test_urandom_valuezURandomTests.test_urandom_valuesN���
�2�������e�U�+�+�+��
�2�������E�5�)�)�)�)�)rc��d�dd|zddf��}td|��}|d}|�t|��|��|S)N�
zimport os, syszdata = os.urandom(%s)zsys.stdout.buffer.write(data)zsys.stdout.buffer.flush()r�rw)rKrrHrD)r9�countr��outrTs     r�get_urandom_subprocessz#URandomTests.get_urandom_subprocesssf���y�y��#�e�+�+�'�	)�*�*��
�t�T�*�*���Q�������V���e�,�,�,��
rc��|�d��}|�d��}|�||��dSr�)r�r�r�s   r�test_urandom_subprocessz$URandomTests.test_urandom_subprocesssD���+�+�B�/�/���+�+�B�/�/�����E�5�)�)�)�)�)rN)rarbrcr�r�r�r�r
rrr�r�sP������6�6�6�*�*�*�	�	�	�*�*�*�*�*rr��	getrandomzneed os.getrandom()c�B�eZdZed���Zd�Zd�Zd�Zd�Zd�Z	dS)�GetRandomTestsc��	tjd��dS#t$r/}|jtjkrtjd����d}~wwxYw)Nrwz%getrandom() syscall fails with ENOSYS)rr�rOrPr�rrJ)rVrZs  rrWzGetRandomTests.setUpClass!s]��	��L��O�O�O�O�O���	�	�	��y�E�L�(�(��'�(O�P�P�P������
	���s��
A�*A�Ac��tjd��}|�|t��|�t|��d��dSr�)rr�r6r^rHrD)r9r�s  r�test_getrandom_typez"GetRandomTests.test_getrandom_type-sI���|�B�������d�E�*�*�*�����T���B�'�'�'�'�'rc�Z�tjd��}|�|d��dS)Nrr)rr�rH)r9�emptys  r�test_getrandom0zGetRandomTests.test_getrandom02s+����Q���������$�$�$�$�$rc�V�|�ttd����dS)N�GRND_RANDOM)rprrrjs r�test_getrandom_randomz$GetRandomTests.test_getrandom_random6s$�������M�2�2�3�3�3�3�3rc�h�	tjdtj��dS#t$rYdSwxYw�Nrw)rr��
GRND_NONBLOCK�BlockingIOErrorrjs r�test_getrandom_nonblockz&GetRandomTests.test_getrandom_nonblock<sD��	��L��B�,�-�-�-�-�-���	�	�	��D�D�	���s�#�
1�1c��tjd��}tjd��}|�||��dSr�)rr�r�r�s   r�test_getrandom_valuez#GetRandomTests.test_getrandom_valueDs<����R� � ����R� � �����E�5�)�)�)�)�)rN)
rarbrcrvrWr�r�r�r�r�r
rrr�r�sx�������	�	��[�	�(�(�(�
%�%�%�4�4�4����*�*�*�*�*rr��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�eZdZejed��d���Zd�Zd�ZdS)�URandomFDTestsz!test requires the resource modulec�*�d}td|��dS)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�rr�s  r�test_urandom_failurez#URandomFDTests.test_urandom_failureVs!��
��	��t�$�$�$�$�$rc�2�d}td|��\}}}dS)Naif 1:
            import os
            import sys
            import test.support
            os.urandom(4)
            with test.support.SuppressCrashReport():
                os.closerange(3, 256)
            sys.stdout.buffer.write(os.urandom(4))
            �-Scr)r9r��rcr��errs     r�test_urandom_fd_closedz%URandomFDTests.test_urandom_fd_closedms$����(��t�4�4���C���rc�"�|�tjtj��t	tjd��d�tj���}t
d|��\}}}|�t|��d��|�	|dd�|dd���t
d|��\}}}|�t|��d��|�	||��dS)Nsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa�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))
            )rhr�r/rr�)
r�rrirhr+�formatrrHrDr�)r9r�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��!��H�c�!�A�#�h�/�/�/�)�%��6�6���D�$�����T���A�&�&�&����D�#�&�&�&�&�&rN)	rarbrcrr�resourcer�r�r�r
rrr�r�Qs_������
�X���#F�G�G�%�%�H�G�%�,5�5�5�$'�$'�$'�$'�$'rr�c#�\�K�g��fd�}�fd�}	tj}tj}tj}|t_|t_|�|t_�V�|t_|t_|t_dS#|t_|t_|t_wxYw)z�
    Stubs out execv and execve functions when used as context manager.
    Records exec calls. The mock execv and execve functions always raise an
    exception as they would normally never return.
    c�R����d||f��td���)N�execvzexecv called)r��RuntimeError�r!r��callss  �r�
mock_execvz#_execvpe_mockup.<locals>.mock_execv�s*���
���g�t�T�*�+�+�+��>�*�*�*rc�h����d||f��ttjd���)N�execvez
execve called)r�rOrP�ENOTDIRr�s  �r�mock_execvez$_execvpe_mockup.<locals>.mock_execve�s.���
���h��d�+�,�,�,��e�m�_�5�5�5rN)rr�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�������	��� �B�J����������	�!��
�
�
�������	�!��
�!�!�!�!s�AB�&B+r�zneed os.execv()c���eZdZejed��d���Zd�Zd�Zej	e
ed��d��d���Zd�Z
d	�Zej	ejd
kd��d���Zd
S)�	ExecTestsz4avoid triggering a linuxthreads bug: see issue #4970c�X�|�ttjddgd��dS)Nzno such app-)r~rOr�execvperjs r�test_execvpe_with_bad_programz'ExecTests.test_execvpe_with_bad_program�s6��	
���'�2�:�~�)�*�D�	2�	2�	2�	2�	2rc�@�|�ttjdd��|�ttjdg��|�ttjdd��|�ttjddg��dS)N�notepadr
r6r�)r~r�rr�rjs r�test_execv_with_bad_arglistz%ExecTests.test_execv_with_bad_arglist�sz�����*�b�h�	�2�>�>�>����*�b�h�	�2�>�>�>����*�b�h�	�5�A�A�A����*�b�h�	�B�4�@�@�@�@�@rc��|�ttjdgd��|�ttjdgi��|�ttjddgi��dS)Nr�r�)r~r�rr�rjs r�test_execvpe_with_bad_arglistz'ExecTests.test_execvpe_with_bad_arglist�sd�����*�b�j�)�R��F�F�F����*�b�j�)�R��D�D�D����*�b�j�)�b�T�2�F�F�F�F�Fr�_execvpez)No internal os._execvpe function to test.c��tjdz}|tur;d}tj�tj|��|��}|}gd�}nMd}gd�}tj�||��}tjdkrtj|��}n|}ddi}t��5}|�ttj
||��|�t|��d	��|�|d
d||ff��ddd��n#1swxYwYt|���5}|�ttj
|||�
��|�t|��d	��|�|d
d|||ff��ddd��n#1swxYwYt��5}|���}	|tur||	d<n||	d<|�ttj
|||	�
��|�t|��d	��|�|d
d|||	ff��ddd��dS#1swxYwYdS)N�absolutepaths
executable)sprogname�arg1�arg2r�)�prognamer�r�r9�spamr�rwrr�)r;r5r�r8r4)rrJr^rIrKr#r!r�r~r�r�rHrDrOr=r�)
r9�	test_type�program_path�program�fullpath�native_fullpath�	argumentsr0r��env_paths
          r�_test_internal_execvpez ExecTests._test_internal_execvpe�sr���v��.������#�G��w�|�|�B�K��$=�$=�w�G�G�H�&�O�5�5�5�I�I�"�G�4�4�4�I��w�|�|�L�'�:�:�H��w�$���"$�+�h�"7�"7���"*���w����
�
�	J�%����l���X�y�
2�
2�
2����S��Z�Z��+�+�+����U�1�X���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���W�i�S�
�
:�
:�
:����S��Z�Z��+�+�+��$�$�U�1�X��?�Y��,<�=�
?�
?�
?�		?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?��
�
�
	D�%��x�x�z�z�H��E�!�!�$0���!�!�#/��� ����g���W�i�X�
�
?�
?�
?����S��Z�Z��+�+�+��$�$�U�1�X��?�Y��,A�B�
D�
D�
D�
	D�
	D�
	D�
	D�
	D�
	D�
	D�
	D�
	D�
	D�
	D�
	D����
	D�
	D�
	D�
	D�
	D�
	Ds9�3A+D*�*D.�1D.�A.F?�?G�G�BI;�;I?�I?c��|�t��tjdkr|�t��dSdS)Nr9)r�r7rr!r^rjs r�test_internal_execvpe_strz#ExecTests.test_internal_execvpe_strsB���#�#�C�(�(�(�
�7�d�?�?��'�'��.�.�.�.�.��?rc���tjddg}tj���}d|d<|�t��5tj|d||��ddd��n#1swxYwYtj���}d|d<|�t��5tj|d||��ddd��n#1swxYwYtj���}d|d	<|�t��5tj|d||��ddd��dS#1swxYwYdS)
Nr��pass�cabbage�FRUITVEGETABLEr�orangeVEGETABLE=cabbage�FRUIT�lemon�FRUIT=ORANGE)rBr�rr�r�r~r�r�)r9r��newenvs   r�test_execve_invalid_envz!ExecTests.test_execve_invalid_env
s������f�-������"�"��%.��!�"�
�
�
�z�
*�
*�	-�	-��I�d�1�g�t�V�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�����"�"��5��w��
�
�
�z�
*�
*�	-�	-��I�d�1�g�t�V�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�����"�"��!(��~��
�
�
�z�
*�
*�	-�	-��I�d�1�g�t�V�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-s6�
A6�6A:�=A:�>C'�'C+�.C+�/E�E� Er�zWin32-specific testc���	tjddgi��|�d��dS#t$r2}|�|jdup
|jdk��Yd}~dSd}~wwxYw)Nr��argzNo OSError raisedr)rr�r=rOrp�winerrorrvs  r�test_execve_with_empty_pathz%ExecTests.test_execve_with_empty_path"s���	+��I�b�5�'�2�&�&�&�
�I�I�)�*�*�*�*�*���	C�	C�	C��O�O�A�J�$�.�A�!�*��/�B�B�B�B�B�B�B�B�B�����	C���s�0�
A,�'A'�'A,N)rarbrcrr�USING_LINUXTHREADSr�r�r�rrrr�r�r�rBrCr�r
rrr�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�����0�2G�H�H�+�+�I�H�+�+�+rr�r�rtc�8�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�Win32ErrorTestsc�"�	tjtj��|�dtjz��dS#t
$rd}YdSt$r2}d}|�dtj�d|����Yd}~dSd}~wwxYw)Nzfile %s must not existFTzfile z% must not exist; os.stat failed with )rr�rrhr=rNrO)r9r}rZs   rrkzWin32ErrorTests.setUp/s���		C��G�I�$�%�%�%�
�I�I�.��1A�A�B�B�B�B�B��!�	�	�	��F�F�F�F��	1�	1�	1��F��I�I�I�"�)�)�)�3�3�0�
1�
1�
1�
1�
1�
1�
1�
1�
1�����	1���s�A�B�	B�'B	�	Bc��|�ttjtjtjdz��dS)Nz.bak)r~rOrr�rrhrjs rr�zWin32ErrorTests.test_rename;s0�����'�2�9�i�.>�	�@P�QW�@W�X�X�X�X�Xrc�f�|�ttjtj��dSr.)r~rOrr�rrhrjs r�test_removezWin32ErrorTests.test_remove>s%�����'�2�9�i�.>�?�?�?�?�?rc�f�|�ttjtj��dSr.)r~rOrrMrrhrjs r�
test_chdirzWin32ErrorTests.test_chdirAs%�����'�2�8�Y�-=�>�>�>�>�>rc� �|�tjtj��t	tjd��5}|�ttjtj��ddd��dS#1swxYwYdS)Nr%)	r�rrirhr&r~rOrrLrss  r�
test_mkdirzWin32ErrorTests.test_mkdirDs������	�(�)�*:�;�;�;�
�)�"�C�
(�
(�	C�A����g�r�x��1A�B�B�B�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C�	C�	Cs�1B�B�
Bc�h�|�ttjtjd��dSr.)r~rOrr�rrhrjs rr�zWin32ErrorTests.test_utimeJs'�����'�2�8�Y�-=�t�D�D�D�D�Drc�h�|�ttjtjd��dSr�)r~rOrr�rrhrjs r�
test_chmodzWin32ErrorTests.test_chmodMs'�����'�2�8�Y�-=�q�A�A�A�A�ArN)
rarbrcrkr�rrrr�rr
rrrr-s�������
C�
C�
C�Y�Y�Y�@�@�@�?�?�?�C�C�C�E�E�E�B�B�B�B�Brrz!Cannot create invalid FD on WASI.c�J�eZdZgd�Zd�ZeD]Zee��e��dez<�d�Zd�Ze	j
eed��d��d���Z
e	j
eed	��d
��d���Ze	j
eed��d
��d���Ze	j
eed��d
��e	jejd��d�����Ze	j
eed��d��d���Ze	j
eed��d��d���Ze	j
eed��d��e	jejpejd��d�����Ze	j
eed��d��d���Ze	j
eed��d��d ���Ze	j
eed!��d"��d#���Ze	j
eed$��d%��d&���Ze	j
eed'��d(��d)���Ze	j
eed*��d+��d,���Ze	j
eed-��d.��d/���Zej��d0���Z e	j
eed1��d2��d3���Z!d4S)5�
TestInvalidFD)�fchdirr{�	fdatasyncr�fstatvfs�fsync�	tcgetpgrp�ttynamec����fd�}|S)Nc���tt���r*|�tt�����dSdSr.)rrrSr:rss �r�helperz(TestInvalidFD.get_single.<locals>.helperXs=�����A���
+��
�
�7�2�q�>�>�*�*�*�*�*�
+�
+rr
)rtrs` r�
get_singlezTestInvalidFD.get_singleWs#���	+�	+�	+�	+�	+��
r�test_c���	|tj��g|�Ri|��|�d|z��dS#t$r0}|�|jt
j��Yd}~dSd}~wwxYw)Nz5%r didn't raise an OSError with a bad file descriptor)r�make_bad_fdr=rOrHrPrz)r9rtr�r�r�s     rrSzTestInvalidFD.check_s���	�
�A�i�#�%�%�7��7�7�7��7�7�7�
�I�I�M���
�
�
�
�
���	3�	3�	3����Q�W�e�k�2�2�2�2�2�2�2�2�2�����	3���s�9�
A3�%A.�.A3c�H�|�tjd���dS)Nr�r�)rSrr�rjs rr�zTestInvalidFD.test_fdopenhs ���
�
�2�9�w�
�/�/�/�/�/r�isattyztest needs os.isatty()c�x�|�tjtj����d��dS�NF)rHrrrrrjs r�test_isattyzTestInvalidFD.test_isattyks1�������9�#8�#:�#:�;�;�U�C�C�C�C�Crr}ztest needs os.closerange()c�2�tj��}td��D]*}tj||z��n#t
$rY�'wxYw|dkrt
jd���|�tj	|||zdz
��d��dS)Nrxryz5Unable to acquire a range of invalid file descriptorsrw)
rrr�rrrOrrJrHr})r9r�r�s   rr�zTestInvalidFD.test_closerangeos���
�
"�
$�
$���r���	�	�A���"�Q�$��������
�
�
���
����
�q�5�5��#�G�I�I�
I������r�2��6�!�8�4�4�d�;�;�;�;�;s�>�
A�
A�dup2ztest needs os.dup2()c�F�|�tjd��dS)N�)rSrr!rjs r�	test_dup2zTestInvalidFD.test_dup2s���
�
�2�7�B�����rz@dup2() with negative fds is broken on Emscripten (see gh-102179)c��tjttj��}|�tj|��|ddg}t
j|d���D]�\}}||kr�|�||���5|�	t��5}tj||��ddd��n#1swxYwY|�|j
jtj��ddd��n#1swxYwY��dS)Nr�i�ryr	)r��fd2)rr&r�r�r�rorr�subTestr~rOr!rHryrPrz)r9�valid_fd�fdsr�r&r|s      r�test_dup2_negative_fdz#TestInvalidFD.test_dup2_negative_fd�s����7�8�R�[�1�1�������(�+�+�+����
��
!�(��Q�7�7�7�	G�	G�G�B���S�y�y��\�\�R�S�\�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�	Gs6�D�B?�3D�?C�D�C�-D�D	�D	�fchmodztest needs os.fchmod()c�F�|�tjd��dSr�)rSrr+rjs r�test_fchmodzTestInvalidFD.test_fchmod�s���
�
�2�9�a� � � � � r�fchownztest needs os.fchown()c�H�|�tjdd��dS)Nr�)rSrr.rjs r�test_fchownzTestInvalidFD.test_fchown�s ���
�
�2�9�b�"�%�%�%�%�%r�	fpathconfztest needs os.fpathconf()z-musl libc issue on Emscripten/WASI, bpo-46390c��|�tjd��|�tjd��dS)N�PC_NAME_MAX)rSr�pathconfr1rjs r�test_fpathconfzTestInvalidFD.test_fpathconf�s6��	
�
�
�2�;�
�.�.�.��
�
�2�<��/�/�/�/�/r�	ftruncateztest needs os.ftruncate()c��|�tjd��|�tjd��dSr�)rSr�truncater6rjs r�test_ftruncatezTestInvalidFD.test_ftruncate�s4���
�
�2�;��"�"�"��
�
�2�<��#�#�#�#�#rr�ztest needs os.lseek()c�H�|�tjdd��dSr�)rSrr�rjs r�
test_lseekzTestInvalidFD.test_lseek�s ���
�
�2�8�Q��"�"�"�"�"rr�ztest needs os.read()c�F�|�tjd��dSr�)rSrr�rjs rr�zTestInvalidFD.test_read�s���
�
�2�7�A�����r�readvztest needs os.readv()c�f�td��}|�tj|g��dS)Nrx)r�rSrr=)r9r�s  r�
test_readvzTestInvalidFD.test_readv�s+����m�m���
�
�2�8�c�U�#�#�#�#�#r�	tcsetpgrpztest needs os.tcsetpgrp()c�F�|�tjd��dSr�)rSrr@rjs r�test_tcsetpgrptzTestInvalidFD.test_tcsetpgrpt�s���
�
�2�<��#�#�#�#�#rr'ztest needs os.write()c�F�|�tjd��dS)N� )rSrr'rjs rr�zTestInvalidFD.test_write�s���
�
�2�8�T�"�"�"�"�"r�writevztest needs os.writev()c�H�|�tjdg��dS)Nr9)rSrrErjs r�test_writevzTestInvalidFD.test_writev�s ���
�
�2�9�v�h�'�'�'�'�'rc��|�tj��|�tjd��dS�NT)rSr�get_inheritable�set_inheritablerjs r�test_inheritablezTestInvalidFD.test_inheritable�s4���
�
�2�%�&�&�&��
�
�2�%�t�,�,�,�,�,r�get_blocking�-needs os.get_blocking() and os.set_blocking()c��|�tj��|�tjd��dSrI)rSrrM�set_blockingrjs r�
test_blockingzTestInvalidFD.test_blocking�s4��	
�
�
�2�?�#�#�#��
�
�2�?�D�)�)�)�)�)rN)"rarbrc�singlesrrt�localsrSr�rrrrrr�r$rrrr*r-r0rr5r9r;r�r?rBr�rGr�rLrQr
rrr
r
Qs^������<�<�<�G����
�,�,��(�j��m�m�������������0�0�0��X�����X�.�.�0H�I�I�D�D�J�I�D��X�����\�2�2�4P�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�1�3N�O�O��X�_���0���7���0�0�	��P�O�
0��X�����[�1�1�3N�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�1�3N�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�*�*�*rr
r�zrequires os.linkc�2�eZdZd�Zd�Zd�Zd�Zd�Zd�ZdS)�	LinkTestsc��tj|_tj�tjdz��|_dS)Nr�)rrh�file1rrIrK�file2rjs rrkzLinkTests.setUp�s-���%��
��W�\�\�)�"2�S�"8�9�9��
�
�
rc��|j|jfD]5}tj�|��rtj|���6dSr.)rWrXrrIr}ri)r9�files  rrzLinkTests.tearDown�sH���Z���,�	 �	 �D��w�~�~�d�#�#�
 ��	�$�����	 �	 rc	��t|��	tj||��n/#t$r"}|�d|z��Yd}~nd}~wwxYwt|d��5}t|d��5}|�tj�|�	��|�	������ddd��n#1swxYwYddd��dS#1swxYwYdS)N�
os.link(): %sr�)
r+rr�r�r|r&rprI�sameopenfiler�)r9rWrXr�r��f2s      r�
_test_linkzLinkTests._test_link�s����E����	/��G�E�5�!�!�!�!���	/�	/�	/��M�M�/�A�-�.�.�.�.�.�.�.�.�����	/����
�%��
�
�	L�"�d�5�$�&7�&7�	L�2��O�O�B�G�0�0������b�i�i�k�k�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�	LsK�'�
A�A�A�&C3�7AC�C3�C	�C3�"C	�#C3�3C7�:C7c�F�|�|j|j��dSr.)r_rWrXrjs r�	test_linkzLinkTests.test_link�s ������
�D�J�/�/�/�/�/rc���|�t|jtj����t|jtj������dSr.)r_r^rWrBrOrXrjs r�test_link_byteszLinkTests.test_link_bytes�sV������d�j�#�*C�*E�*E�F�F��d�j�#�*C�*E�*E�F�F�	H�	H�	H�	H�	Hrc���	tjd��n"#t$rtjd���wxYw|xjdz
c_|jdz|_|�|j|j��dS)N�ñz#Unable to encode for this platform.r�)rr#�UnicodeErrorrrJrWrXr_rjs r�test_unicode_namezLinkTests.test_unicode_name�s���	K��K��������	K�	K�	K��#�$I�J�J�J�	K����	
�
�
�f��
�
��Z�#�%��
�����
�D�J�/�/�/�/�/s��6N)	rarbrcrkrr_rarcrgr
rrrUrU�st������:�:�:� � � �
L�L�L�0�0�0�H�H�H�0�0�0�0�0rrUzPosix specific testsc���eZdZdZdZejeed��d��d���Z	ejeed��d��d���Z
ejeed��d	��d
���Zejeed��d��d
���Zejeed��d��d���Z
ejeed��d��ej��d�����Zejeed��d��ej��d�����Zejeed��d��ej��d�����ZdS)�PosixUidGidTests��setuidztest needs os.setuid()c�"�tj��dkr&|�ttjd��|�t
tjd��|�ttj|j��dS�Nrz
not an int)r�getuidr~rOrkr��
OverflowError�UID_OVERFLOWrjs r�test_setuidzPosixUidGidTests.test_setuid�sj��
�9�;�;�!������g�r�y�!�4�4�4����)�R�Y��=�=�=����-���D�4E�F�F�F�F�Fr�setgidztest needs os.setgid()c�0�tj��dkr-ts&|�ttjd��|�ttjd��|�ttj|j��dSrm)	rrn�HAVE_WHEEL_GROUPr~rOrrr�ro�GID_OVERFLOWrjs r�test_setgidzPosixUidGidTests.test_setgid	sp��
�9�;�;�!���$4�����g�r�y�!�4�4�4����)�R�Y��=�=�=����-���D�4E�F�F�F�F�Fr�seteuidztest needs os.seteuid()c�"�tj��dkr&|�ttjd��|�t
tjd��|�ttj|j��dSrm)	rrnr~rOrwr��setegidrorprjs r�test_seteuidzPosixUidGidTests.test_seteuid	sj��
�9�;�;�!������g�r�z�1�5�5�5����)�R�Z��>�>�>����-���T�5F�G�G�G�G�Grryztest needs os.setegid()c�0�tj��dkr-ts&|�ttjd��|�ttjd��|�ttj|j��dSrm)	rrnrtr~rOryr�rorurjs r�test_setegidzPosixUidGidTests.test_setegid	sp��
�9�;�;�!���$4�����g�r�z�1�5�5�5����)�R�Z��>�>�>����-���T�5F�G�G�G�G�Gr�setreuidztest needs os.setreuid()c���tj��dkr'|�ttjdd��|�t
tjdd��|�t
tjdd��|�ttj|jd��|�ttjd|j��dSrm)rrnr~rOr}r�rorprjs r�
test_setreuidzPosixUidGidTests.test_setreuid	s���
�9�;�;�!������g�r�{�A�q�9�9�9����)�R�[�,��B�B�B����)�R�[�!�\�B�B�B����-���d�6G��K�K�K����-���a��9J�K�K�K�K�Krc�H�tjtjddg��dS)Nr�z,import os,sys;os.setreuid(-1,-1);sys.exit(0)�r�r�rBr�rjs r�test_setreuid_neg1z#PosixUidGidTests.test_setreuid_neg1#	�8��
	�����>�@�	A�	A�	A�	A�	Ar�setregidztest needs os.setregid()c���tj��dkr.ts'|�ttjdd��|�ttjdd��|�ttjdd��|�ttj|jd��|�ttjd|j��dSrm)	rrnrtr~rOr�r�rorurjs r�
test_setregidzPosixUidGidTests.test_setregid,	s����9�;�;�!���$4�����g�r�{�A�q�9�9�9����)�R�[�,��B�B�B����)�R�[�!�\�B�B�B����-���d�6G��K�K�K����-���a��9J�K�K�K�K�Krc�H�tjtjddg��dS)Nr�z,import os,sys;os.setregid(-1,-1);sys.exit(0)r�rjs r�test_setregid_neg1z#PosixUidGidTests.test_setregid_neg16	r�rN)rarbrcrprurrrrrqrvrzr|rrr�r�r�r�r
rrriri�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�0�2L�M�M�L�L�N�M�L��X�����Z�0�0�2L�M�M� �W� �"�"�A�A�#�"�N�M�A��X�����Z�0�0�2L�M�M� �W� �"�"�L�L�#�"�N�M�L��X�����Z�0�0�2L�M�M� �W� �"�"�A�A�#�"�N�M�A�A�Arric�t�eZdZd�Zd�Zd�Zd�Zeje	e
d��d��d���Zd�Zd	S)
�Pep383Testsc�d��tjrtj|_n/tjrtj|_ntj|_tj|j��|_g��fd�}|tj��tjr|tj��tjr|tj���s|�	d��t��|_tj|j��	�D]}tj
t
j�|j|����tj|��}||jvrt#d���|j�|����dS#t'j|j���xYw)Nc���	tj|��}n#t$rYdSwxYw��|��dSr.)rr#rPr�)�fn�bytesfns �r�add_filenamez'Pep383Tests.setUp.<locals>.add_filenameK	sQ���
��[��_�_����%�
�
�
����
�����N�N�2�����s��
&�&z&couldn't create any non-ascii filenamezduplicate filename)r�TESTFN_UNENCODABLEr7�TESTFN_NONASCIIrhrr#�bdir�TESTFN_UNICODEr|r
�	unicodefnrL�create_empty_filerIrKr_r��add�shutilr�)r9r�r�r�s   @rrkzPep383Tests.setUpA	s�����'�	(� �3�D�H�H�
�
&�	(� �0�D�H�H� �'�D�H��K���)�)��	���	�	�	�	�	�	��Y�-�.�.�.��'�	7��L��5�6�6�6��$�	4��L��2�3�3�3��	D��M�M�B�C�C�C������
�������		��
'�
'���+�B�G�L�L���B�,G�,G�H�H�H��[��_�_�����'�'�$�%9�:�:�:���"�"�2�&�&�&�&�
'�
'��	��M�$�(�#�#�#����s
�BF�F/c�8�tj|j��dSr.)r�r�r7rjs rrzPep383Tests.tearDownf	s���
�d�h�����rc��|j}ttj|j����}|�||��tj��}	tjtj��|�ttj����ttjtj������tj|��dS#tj|��wxYwr.)	r�r
rr�r7rHr5rMrJ)r9rX�found�current_directorys    r�test_listdirzPep383Tests.test_listdiri	s����>���B�J�t�x�(�(�)�)�������)�)�)��I�K�K��	(��H�R�V�������S�����.�.��B�J�r�v�4F�4F�0G�0G�H�H�H��H�&�'�'�'�'�'��B�H�&�'�'�'�'���s
�A;C)�)C?c��|jD]I}ttj�|j|��d��}|����JdS�Nr�)r�r&rrIrKr7ro)r9r�rts   r�	test_openzPep383Tests.test_openu	sM���.�	�	�B��R�W�\�\�$�(�B�/�/��6�6�A�
�G�G�I�I�I�I�	�	rr\rqc��|jD];}tj�|j|��}tj|���<dSr.)r�rrIrKr7r\)r9r��fullnames   r�test_statvfszPep383Tests.test_statvfsz	sI���.�	!�	!�B��w�|�|�D�H�b�1�1�H��J�x� � � � �	!�	!rc��|jD]9}tjtj�|j|�����:dSr.)r�rr�rIrKr7)r9r�s  r�	test_statzPep383Tests.test_stat�	sB���.�	0�	0�B��G�B�G�L�L���2�.�.�/�/�/�/�	0�	0rN)
rarbrcrkrr�r�rrrrr�r�r
rrr�r�?	s�������#�#�#�J � � �
(�
(�
(����
�X�����Y�/�/�/�1�1�!�!�1�1�!�0�0�0�0�0rr�c���eZdZd�Zd�Zd�Zejedud��d���Z	ej
d��ej��d�����Z
ej��d	���ZdS)
�Win32KillTestsc�~�ddl}ddlm}ddl}|jjj}|j|_|j|�	|j
��|j|�	|j��|�	|j��|�	|j��f|_d}tjtjdd�|��gtjtjtj���}|�|jj��|�|jj��|�|jj��d\}}	||	k�r|�����|�t5|����}
||�|j�����|
|�|
��ddd��}|�|dd��|
jr.|� ||
j�!����nHtEj#d	��|d
z
}||	kr|�����|�$d��tKj&|j'|��|� |�(��|��dS)Nr��wintypes�runningr�z<import sys;sys.stdout.write('{}');sys.stdout.flush();input())rT�stderr�stdin�rr�zPeekNamedPipe failed皙�����?rwz1Did not receive communication from the subprocess))r�r��msvcrtr�r��
PeekNamedPipe�BOOL�restype�HANDLE�POINTER�c_char�DWORD�argtypesr��PopenrBr�r�rZr�rTror�r��poll�create_string_bufferrD�
get_osfhandler��sizeofr�rnrHrLr��sleepr=r�kill�pid�wait)r9�sigr�r�r�r�r�r]r��maxr��rslts            r�_killzWin32KillTests._kill�	st��
	�
�
�
�#�#�#�#�#�#��
�
�
��
�.�<�
� (�
�
��"*�/�"(�.�.���"?�"?�"*�.�"(�.�.���"@�"@�"(�.�.���"@�"@�"(�.�.���"@�"@�"B�
���������"+�,2�6�#�;�;�	!8�
(2��'1��&0�o�7�7�7��	
�����)�*�*�*������)�*�*�*�����
�(�)�)�)��
��s��c�k�k�d�i�i�k�k�1��-�-�c�#�h�h�7�7�C�!�=��!5�!5�d�k�6H�6H�6J�6J�!K�!K�!$�f�m�m�C�&8�&8�$��d�L�L�D�����a�)?�@�@�@��y�
�� � ��c�i�&6�&6�&8�&8�9�9�9���J�s�O�O�O��Q�J�E��c�k�k�d�i�i�k�k�1�
�I�I�I�J�J�J�
����#������������c�*�*�*�*�*rc�D�|�tj��dSr.)r��signal�SIGTERMrjs r�test_kill_sigtermz Win32KillTests.test_kill_sigterm�	s���
�
�6�>�"�"�"�"�"rc�0�|�d��dS)Nr�)r�rjs r�
test_kill_intzWin32KillTests.test_kill_int�	s���
�
�3�����rNz
requires mmapc��dtj��z}tjdd|��}d|d<tjt
jtj�	tj�
t��d��|gtj���}d\}}||krT|�
���@|ddkrnltjd��|dz
}||kr|�
���@tj|jt$j��|�d	��tj|j|��tjd
��|�
��sNtj|jt$j��|�d�|����dSdS)Nz
test_os_%sr�rwrzwin_console_handler.pyr�r�r�z'Subprocess didn't finish initializationg�?zsubprocess did not stop on {})�uuid�uuid1�mmapr�r�rBr�rrIrKrVr��CREATE_NEW_PROCESS_GROUPr�r�r�r�r�r��SIGINTr=r�)r9�eventr!�tagname�mr]r�r�s        r�_kill_with_eventzWin32KillTests._kill_with_event�	s��������-���I�b�!�W�%�%����!�������7�<�<������ 9� 9� 8�:�:�;B�!D�",�!D�F�F�F��
�
��s��c�k�k�d�i�i�k�k�1���t�q�y�y���J�s�O�O�O��Q�J�E�	�c�k�k�d�i�i�k�k�1�
�G�D�H�f�m�,�,�,��I�I�?�@�@�@�
����%� � � �	
�
�3�����y�y�{�{�	D��G�D�H�f�m�,�,�,��I�I�5�<�<�T�B�B�C�C�C�C�C�	D�	Drz.subprocesses aren't inheriting Ctrl+C propertyc�<�ddlm}ddl}|�|j����}|jjj}|�|j��|jf|_|j|_	||d��|�
tjd��dS)Nrr��CTRL_C_EVENT)
r�r�r��c_intr�r��SetConsoleCtrlHandlerr�r�r�r�r�r�)r9r�r��NULLr�s     r�test_CTRL_C_EVENTz Win32KillTests.test_CTRL_C_EVENT�	s���	$�#�#�#�#�#��
�
�
�,�v�~�~�f�l�+�+�-�-�� &�
� 6� L��*0�.�.���*F�*F�*2�-�*9��&�(0�
��%�
	��d�A�&�&�&����f�1�>�B�B�B�B�Brc�F�|�tjd��dS)N�CTRL_BREAK_EVENT)r�r�r�rjs r�test_CTRL_BREAK_EVENTz$Win32KillTests.test_CTRL_BREAK_EVENT�	s"�����f�5�7I�J�J�J�J�Jr)rarbrcr�r�r�rrr�r��skiprr�r�r�r
rrr�r��	s�������4+�4+�4+�l#�#�#�����X�_�T�T�\�?�3�3�D�D�4�3�D�:�X�]�C�D�D� �W� �"�"�C�C�#�"�E�D�C�$!�W� �"�"�K�K�#�"�K�K�Krr�c�*�eZdZdZd�Zd�Zd�Zd�ZdS)�Win32ListdirTestszTest listdir on Windows.c�
�g|_td��D]�}d|z}tj�t
j|��}d|z}tj�t
j|��}tj|��t|dd���5}|�	d|z��ddd��n#1swxYwY|j�
||g����|j���dS)NryzSUB%dzFILE%dr{r�r�z'I'm %s and proud of it. Blame test_os.
)�
created_pathsr�rrIrKrrhr�r&r'�extendr�)r9r��dir_name�dir_path�	file_name�	file_pathrts       rrkzWin32ListdirTests.setUp
s:������q���	=�	=�A���{�H��w�|�|�I�$4�h�?�?�H� �1��I�����Y�%5�y�A�A�I��K��!�!�!��i��w�7�7�7�
P�1����B�Y�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�tjtj��dSr.)r�r�rrhrjs rrzWin32ListdirTests.tearDown
s���
�i�&�'�'�'�'�'rc	�N�|�ttjtj����|j��|�ttjtjtj������d�|jD����dS)z-Test when the path is not an "extended" path.c�6�g|]}tj|����Sr
�rr#�rrIs  rrzCWin32ListdirTests.test_listdir_no_extended_path.<locals>.<listcomp>
�"��B�B�B�t���T�"�"�B�B�BrN)rH�sortedrr�rrhr�r#rjs r�test_listdir_no_extended_pathz/Win32ListdirTests.test_listdir_no_extended_path
s���	
����r�z�)�"2�3�3�4�4��"�	$�	$�	$�
	
����r�z�"�+�i�.>�"?�"?�@�@�A�A�B�B�t�/A�B�B�B�	D�	D�	D�	D�	Drc���dtj�tj��z}|�t
tj|����|j��dtj	tj�tj����z}|�t
tj|����d�|jD����dS)z&Test when the path starts with '\\?\'.�\\?\�\\?\c�6�g|]}tj|����Sr
r�r�s  rrz@Win32ListdirTests.test_listdir_extended_path.<locals>.<listcomp>+
r�rN)
rrIr�rrhrHr�r�r�r#rQs  r�test_listdir_extended_pathz,Win32ListdirTests.test_listdir_extended_path
s����2�7�?�?�9�+;�<�<�<������r�z�$�'�'�(�(��"�	$�	$�	$�
�B�K�����	�8H�(I�(I�J�J�J������r�z�$�'�'�(�(�B�B�t�/A�B�B�B�	D�	D�	D�	D�	DrN)rarbrcr�rkrr�r�r
rrr�r��	s^������"�"�"�"�"�(�(�(�
D�
D�
D�
D�
D�
D�
D�
Drr��readlinkzneeds os.readlink()c��eZdZdZej�e��Zej	e��Z
ej	e��Zd�Zd�Z
d�Zd�Zejd���Zejd���Zejd���Zd	S)
�
ReadlinkTests�readlinktestc�(�tj�|��}tj�|��}tjdkr-d�}||��r
|dd�}||��r
|dd�}|�||��dS)Nr�c�Z�|�t|t��rdnd��S)Nr�r�)�
startswithrkr^)rYs rrz/ReadlinkTests.assertPathEqual.<locals>.<lambda>;
s,��1�<�<�(��E�2�2�A�
�
�	�$C�$C�rr�)rrI�normcaserBrCrH)r9�left�right�
has_prefixs    r�assertPathEqualzReadlinkTests.assertPathEqual5
s����w����%�%���� � ��'�'���<�7�"�"�C�C�J��z�$���
 ��A�B�B�x���z�%� � �
"��a�b�b�	������u�%�%�%�%�%rc��|�tj�|j����|�tj�|j����|�tj�|j����|�tj�|j����dSr.)	rprrIr}�filelink_target�filelinkb_targetr�filelink�	filelinkbrjs rrkzReadlinkTests.setUpC
s����������t�';�<�<�=�=�=��������t�'<�=�=�>�>�>���������
�6�6�7�7�7����������7�7�8�8�8�8�8rc���t|j��}|�ttj|j��|�ttj|��dSr.)rrr~rOrr�)r9rs  r�test_not_symlinkzReadlinkTests.test_not_symlinkI
sO��"�4�#7�8�8�����'�2�;��0D�E�E�E����'�2�;��@�@�@�@�@rc��|�ttjd��|�ttjt	d����dS)Nzmissing-link)r~rNrr�rrjs r�test_missing_linkzReadlinkTests.test_missing_linkN
sQ�����+�R�[�.�I�I�I����+�R�[�"�>�2�2�	4�	4�	4�	4�	4rc��tj|j|j��|�t
j|j��t|j��}|�tj	|��|j��dSr.)
rr�rrr�rrirrr�)r9rs  r�
test_pathlikezReadlinkTests.test_pathlikeS
sj��
�
�4�'���7�7�7����	�(�$�-�8�8�8��D�M�*�*�����R�[��2�2�D�4H�I�I�I�I�Irc�F�tj|j|j��|�t
j|j��tjt|j����}|�	||j��|�
|t��dSr.)rr�rrr�rrir�rrr6r^rQs  r�test_pathlike_bytesz!ReadlinkTests.test_pathlike_bytesZ
s���
�
�4�(�$�.�9�9�9����	�(�$�.�9�9�9��{�8�D�N�3�3�4�4�����T�4�#8�9�9�9����d�E�*�*�*�*�*rc�,�tj|j|j��|�t
j|j��tj|j��}|�||j��|�	|t��dSr.)rr�rrr�rrir�rr6r^rQs  r�
test_byteszReadlinkTests.test_bytesb
sx��
�
�4�(�$�.�9�9�9����	�(�$�.�9�9�9��{�4�>�*�*�����T�4�#8�9�9�9����d�E�*�*�*�*�*rN)rarbrcrrrIr�r�rr#rrrrkrr	r�skip_unless_symlinkrr
rr
rrr�r�.
s��������H��g�o�o�h�/�/�O����H�%�%�I�"�r�{�?�3�3��&�&�&�9�9�9�A�A�A�
4�4�4�
�"�J�J�#�"�J��"�+�+�#�"�+��"�+�+�#�"�+�+�+rr�c�b�eZdZdZej�e��ZdZ	ej�
e��ZdZd�Z
d�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zejej�d��oej�d��d��d���Zd�Zd�ZdS)�Win32SymlinkTests�filelinktest�dirlinktestzmissing linkc��tj�|j��sJ�tj�|j��sJ�tj�|j��rJ�tj�|j��rJ�tj�|j��rJ�dSr.)rrIr}�dirlink_targetr�dirlinkr�missing_linkrjs rrkzWin32SymlinkTests.setUpt
s����w�~�~�d�1�2�2�2�2�2��w�~�~�d�2�3�3�3�3�3��7�>�>�$�,�/�/�/�/�/��7�>�>�$�-�0�0�0�0�0��7�>�>�$�"3�4�4�4�4�4�4�4rc�x�tj�|j��rtj|j��tj�|j��rtj|j��tj�|j��rtj|j��dSdSr.)	rrIr}rr�rr�rgrrjs rrzWin32SymlinkTests.tearDown{
s���
�7�>�>�$�-�(�(�	%��I�d�m�$�$�$�
�7�>�>�$�,�'�'�	#��H�T�\�"�"�"�
�7�?�?�4�,�-�-�	)��I�d�'�(�(�(�(�(�	)�	)rc���tj|j|j��|�tj�|j����|�tj�|j����|�tj�|j����|�	|j|j��dSr.)
rr�rrrprIr}r;�islink�
check_statrjs r�test_directory_linkz%Win32SymlinkTests.test_directory_link�
s���
�
�4�&���5�5�5��������t�|�4�4�5�5�5������
�
�d�l�3�3�4�4�4��������t�|�4�4�5�5�5������d�&9�:�:�:�:�:rc���tj|j|j��|�tj�|j����|�tj�|j����|�tj�|j����|�	|j|j��dSr.)
rr�rrrprIr}�isfilerrrjs 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�';�<�<�<�<�<rc���|j}tj�|��rtj|��d}tj�|��rJ�d}tj|||��dS)z2Create a "directory" link to a non-existent targetz"c:\\target does not exist.29r3c740TN)rrrIrgr�r}r�)r9�linknamer��
target_is_dirs    r�_create_missing_dir_linkz*Win32SymlinkTests._create_missing_dir_link�
sn���$��
�7�?�?�8�$�$�	 ��I�h����6���7�>�>�&�)�)�)�)�)��
�
�
�6�8�]�3�3�3�3�3rc�`�|���tj|j��dSr.)r$rr�rrjs r�,test_remove_directory_link_to_missing_targetz>Win32SymlinkTests.test_remove_directory_link_to_missing_target�
s/���%�%�'�'�'�	�	�$�#�$�$�$�$�$rc��|���|�tj�|j����dSr.)r$rrrIr;rrjs r�.test_isdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_isdir_on_directory_link_to_missing_target�
s?���%�%�'�'�'��������t�'8�9�9�:�:�:�:�:rc�`�|���tj|j��dSr.)r$rr�rrjs r�.test_rmdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_rmdir_on_directory_link_to_missing_target�
s-���%�%�'�'�'�
���"�#�#�#�#�#rc��|�tj|��tj|����|�tj|��tj|����tj|��}|�tj|��tj|����|�tj|��tj|����dSr.)rHrr�r�rIr#)r9r�r��
bytes_links    rrzWin32SymlinkTests.check_stat�
s����������������8�8�8����B�H�T�N�N�B�G�D�M�M�:�:�:��[��&�&�
�������,�,�b�g�f�o�o�>�>�>����B�H�Z�0�0�"�'�*�2E�2E�F�F�F�F�Frc��tj�tj��}tj�|d��}tj�|d��}|�tj|��tj|��tj|��tj|��tj�tj�|d����}t|��tj
��}	tj|��tj�|d��}tjtj�
|��d��|�dtjtj
������|�tj|��tjd����tj|��|�tj|��tjtj�
|������tj|��|�tj|��tjtj�
|������tj|��dS#tj|��wxYw)N�level2�level3rWr�)rrIr�rrhrKr�r�rLr+r5rMr��relpathr�r�rHr�)r9�level1r.r/rW�orig_dirr�s       r�
test_12084zWin32SymlinkTests.test_12084�
s'�������!1�2�2������f�h�/�/������f�h�/�/�����	�(�&�1�1�1�
������
������
��������������V�W� =� =�>�>���E�����9�;�;��	��H�V�����7�<�<���/�/�D��J�r�w���u�-�-�v�6�6�6��M�M�&�"�*�R�Y�[�[�"9�"9�:�:�:�
���R�W�U�^�^�R�W�V�_�_�=�=�=�
�H�V�������R�W�U�^�^��W�R�W�_�_�T�%:�%:�;�;�
=�
=�
=�
�H�V�������R�W�U�^�^��W�R�W�_�_�T�%:�%:�;�;�
=�
=�
=�
�H�X�������B�H�X�������s
�&F/K+�+L�C:\Users\All Users�C:\ProgramDatazTest directories not foundc��tjd��}|�tj�|d����dS)Nr4r5)rr�rprI�samefile)r9r�s  r�
test_29248zWin32SymlinkTests.test_29248�
s?����2�3�3�������(�(��1B�C�C�D�D�D�D�Drc��d}tjj|gdz�}d|z|f||f|dd�|dd�fg}|D]�\}}	tj||��	tj|��n #t
$rYnwxYw#t$rYnwxYw	tjtj|��tj|����	tj|����#t
$rY��wxYw#t$rY��wxYwdS)N�XXXXXXXXXXXXXXXXXXXXXXXXXXXrxr��)rrIrKr�r�rOrNr#)r9�segmentrI�
test_casesr��dests      r�test_buffer_overflowz&Win32SymlinkTests.test_buffer_overflow�
s^�����w�|�g�Y��^�,���D�[�'�"�
�d�O�
�$�3�$�Z��d�s�d��$�

�
�$�	�	�I�C��
��
�3��%�%�%���I�d�O�O�O�O�������D������%�
�
�
���
����
��
�2�;�s�+�+�R�[��->�->�?�?�?���I�d�O�O�O�O�������D������%�
�
�
���
����	�	sH�A;�A+�+
A8�7A8�;
B�B�9C+�C�
C(�'C(�+
C8�7C8c���tj�d���tj����s|�d���fd�tjtj���d��D��}|D]�}tj	rt��td|��tj|��}|�|tj
|����|�tj|j����|�|jtj��dS|�d��dS)Nz$%LOCALAPPDATA%\Microsoft\WindowsAppsz%test requires a WindowsApps directoryc�P��g|]"}tj��|����#Sr
)rrIrK)rrAr�s  �rrz6Win32SymlinkTests.test_appexeclink.<locals>.<listcomp>s?���G�G�G���7�<�<��a�(�(�G�G�Grz*.exezTesting withz$test requires an app execution alias)rrI�
expandvarsr;r|�fnmatch�filterr�rrRrSrIrHr�r�S_ISLNKr?�st_reparse_tag�IO_REPARSE_TAG_APPEXECLINK)r9�aliases�aliasr�r�s    @r�test_appexeclinkz"Win32SymlinkTests.test_appexeclinksE����w�!�!�"I�J�J���w�}�}�T�"�"�	C��M�M�A�B�B�B�G�G�G�G�#�N�2�:�d�+;�+;�W�E�E�G�G�G���	B�	B�E���
-������n�e�,�,�,���%���B����R������0�0�0����T�\�"�*�5�5�6�6�6����R�.��0O�P�P�P��E�E��M�M�@�A�A�A�A�ArN)rarbrcrrrIr�r�rrrVrrrkrrr r$r&r(r*rr3rrrgr}r8r?rJr
rrrrk
se�������H��g�o�o�h�/�/�O��G��W�_�_�_�5�5�N�!�L�5�5�5�)�)�)�;�;�;�=�=�=�4�4�4�%�%�%�;�;�;�$�$�$�G�G�G�!�!�!�F�X������)>�?�?�B� "����/@� A� A�8�:�:�
E�
E�:�:�
E�!�!�!�FB�B�B�B�Brrc��eZdZdZej�ej�e����Z	d�Z
d�Zd�Zd�Z
dS)�Win32JunctionTests�junctiontestc��tj�|j��sJ�tj�|j��rJ�dSr.)rrIr}�junction_targetrg�junctionrjs rrkzWin32JunctionTests.setUp!sA���w�~�~�d�2�3�3�3�3�3��7�?�?�4�=�1�1�1�1�1�1�1rc��tj�|j��rtj|j��dSdSr.)rrIrgrPrirjs rrzWin32JunctionTests.tearDown%s<��
�7�?�?�4�=�)�)�	%��I�d�m�$�$�$�$�$�	%�	%rc���tj|j|j��|�t
j�|j����|�t
j�|j����|�t
j�	|j����|�
tj|j��tj|j����|�
tj|j��tj|j����|�t
j�|j����|�
t
j�d|jz��t
j�tj|j������dS)Nr�)�_winapi�CreateJunctionrOrPrprrIrgr}r;r�r�rIrHrrr�r�rjs r�test_create_junctionz'Win32JunctionTests.test_create_junction)sc����t�3�T�]�C�C�C���������
�6�6�7�7�7��������t�}�5�5�6�6�6������
�
�d�m�4�4�5�5�5����B�G�D�M�2�2�B�H�T�]�4K�4K�L�L�L��������/�/����9M�1N�1N�O�O�O�	
��������
�6�6�7�7�7������)�)�)�d�6J�*J�K�K���)�)�"�+�d�m�*D�*D�E�E�	G�	G�	G�	G�	Grc��tj|j|j��|�t
j�|j����|�t
j�|j����tj	|j��|�
t
j�|j����dSr.)rSrTrOrPrprrIr}rgrirrjs r�test_unlink_removes_junctionz/Win32JunctionTests.test_unlink_removes_junction6s�����t�3�T�]�C�C�C��������t�}�5�5�6�6�6���������
�6�6�7�7�7�
�	�$�-� � � ���������
�6�6�7�7�7�7�7rN)rarbrcrPrrIrVr�r�rOrkrrUrWr
rrrLrLsy�������H��g�o�o�b�g�o�o�h�&?�&?�@�@�O�2�2�2�%�%�%�G�G�G�8�8�8�8�8rrLc�D�eZdZd�Zej��d���ZdS)�Win32NtTestsc��tjd��}tjd��}ddl}|�dd���}|jj|j_|jj|j	_|jj|jj
f|j	_|���}|j���}|�	||�
|����}|�d|��|j}dd	d
t g}t#d��D]S}	|D]N}
	|�|
��n#t&$rYnwxYw	t)j|
���?#t&$rY�KwxYw�T|�	||�
|����}|�d|��|j|z
}|�d|��dS)Nr9r�rzKernel32.dllT)�use_last_errorrwz\\?\C:z\\?\NULz	\\?\CONINrx)r�
import_module�ctypes.wintypes�WinDLLr�r��GetCurrentProcessr�r��GetProcessHandleCount�LPDWORDr�r��byrefrHrnr�r��_getfinalpathname�	Exceptionrr�)r9r9r��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��1G�17��1H�1J��$�-��(�(�*�*����,�,�.�.��
�
)�
)�%����l�1K�1K�
L�
L������B����#�)��
����	
�	��r���
	�
	�A�!�	
�	
����(�(��.�.�.�.�� �����D�������G�D�M�M�M�M�� �����D�����	
��
)�
)�%����l�1K�1K�
L�
L������B����#�)�L�8������L�)�)�)�)�)s$�&D<�<
E	�E	�
E"�"
E/�.E/c	��tj}|�tj|��t	j��dz}tjd��}tjtj
d||t|��g��5}t	j��|krQ	tj
|��n$#t$r}|jdksJ�Yd}~nd}~wwxYwt	j��|k�Q	|�d��n)#tj$r|���YnwxYwddd��dS#1swxYwYdS)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�ryrw)rrhr�rir��textwrap�dedentr�r�rBr�r7rr�rNr�r��TimeoutExpired�	terminate)r9r(�deadline�commandr]r�s      r�test_stat_unlink_racez"Win32NtTests.test_stat_unlink_raceps����$�����	�(�(�3�3�3��9�;�;��?���/�#����(�
�s�~�t�W�h��H�
�
�V�
W�
W�		!�[_��)�+�+��(�(�+��G�H�%�%�%�%��(�+�+�+��:��?�?�?�?�?�?�?�?�?�����+�����)�+�+��(�(�

!��	�	�!�������,�
!�
!�
!���� � � � � �
!����		!�		!�		!�		!�		!�		!�		!�		!�		!�		!�		!�		!����		!�		!�		!�		!�		!�		!s`�D=� B5�4D=�5
C�?
C�D=�C�D=�1D�D=�#D-�*D=�,D-�-D=�=E�EN)rarbrcrlrr�rtr
rrrYrY>sK������.*�.*�.*�`!�W� �"�"�'!�'!�#�"�'!�'!�'!rrYc� �eZdZd�Zd�Zd�ZdS)�NonLocalSymlinkTestsc�.�tjd��dS)zM
        Create this structure:

        base
         \___ some_dir
        z
base/some_dirN)rr�rjs rrkzNonLocalSymlinkTests.setUp�s��	��O�$�$�$�$�$rc�.�tjd��dS)Nr�)r�r�rjs rrzNonLocalSymlinkTests.tearDown�s���
�f�����rc��tj�dd��}tjd|��tj�|��sJ�dS)a�
        The symlink target should resolve relative to the link, not relative
        to the current directory.

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

        In issue13772, it was discovered that directory detection failed if
        the symlink target was not specified relative to the current
        directory, which was a defect in the implementation.
        r��	some_link�some_dirN)rrIrKr�r;)r9r�s  r�test_directory_link_nonlocalz1NonLocalSymlinkTests.test_directory_link_nonlocal�sK���g�l�l�6�;�/�/��
�
�:�s�#�#�#��w�}�}�S�!�!�!�!�!�!�!rN)rarbrcrkrr|r
rrrvrv�sA������%�%�%����"�"�"�"�"rrvc��eZdZd�Zd�ZdS)�FSEncodingTestsc��|�tjd��d��|�tjd��d��dS)Nsabc�uabcŁ)rHrr#r_rjs r�test_nopzFSEncodingTests.test_nop�sH�������Z�0�0�*�=�=�=������[�1�1�;�?�?�?�?�?rc��dD]P}	tj|��}n#t$rY�$wxYw|�tj|��|���QdS)N)u	unicodeŁulatiné�ascii)rr#rPrHr_)r9r�r�s   r�
test_identityzFSEncodingTests.test_identity�sr��9�	7�	7�B�
��+�b�/�/����%�
�
�
���
�������R�[��1�1�2�6�6�6�6�	7�	7s��
(�(N)rarbrcr�r�r
rrr~r~�s5������@�@�@�7�7�7�7�7rr~c��eZdZd�Zejejd��o<e��o1e	j
�d��pee
d��oee
d��d��ejejd��d�����Zd	S)
�DeviceEncodingTestsc�T�|�tjd����dS)Ni@�)rbr�device_encodingrjs r�test_bad_fdzDeviceEncodingTests.test_bad_fd�s'�����"�,�V�4�4�5�5�5�5�5rr�win�nl_langinfo�CODESETz>test requires a tty and either Windows or nl_langinfo(CODESET)z*Cannot get encoding of stdin on Emscriptenc��tjd��}|�|��|�t	j|����dSr�)rr��assertIsNotNonerp�codecs�lookup)r9r�s  r�test_device_encodingz(DeviceEncodingTests.test_device_encoding�sJ���%�a�(�(�����X�&�&�&�����
�h�/�/�0�0�0�0�0rN)rarbrcr�rrrrrrBrCr�r�localerrrr�r
rrr�r��s�������6�6�6��X�����1���M�l�l�n�n�*<�M�#�,�BY�BY�Z_�B`�B`�CL�
�W�V�]�
+�
+�
J����	�0J�0J�L�N�N��X�_���K���1�1���N�N�1�1�1rr�c�>�eZdZejeed��d��d���Zdd�Zd�Z	d�Z
ejejdkd	��d
���Z
ejejdkd	��d���Zejeed��d
��d���ZdS)�PidTests�getppidztest needs os.getppidc��tjtjddgtj���}|���\}}|�t|��tj	����dS)Nr�zimport os; print(os.getppid()))rT)
r�r�rBr�rZ�communicaterHr#r�getpid)r9rYrTrjs    r�test_getppidzPidTests.test_getppid�sh����c�n�d�>�@�$.�O�
5�
5�
5���M�M�O�O�	�������V���b�i�k�k�2�2�2�2�2rNc��tjdkrdtj�d�dd|�d�g}ntjd|g}tjtjtj|��}|�||��tj|d��\}}|�tj|��|��|�||��dS)Nr��"r�r)	rBrCr�r�spawnv�P_NOWAIT�waitpidrH�waitstatus_to_exitcode)r9r��exitcode�callbackr�r��pid2�statuss        r�
check_waitpidzPidTests.check_waitpid�s����<�7�"�"�*���)�)�)�4��T����=�D�D��N�D�$�/�D��i���S�^�T�:�:�����H�S�M�M�M��z�#�q�)�)���f�����2�6�:�:�H�E�E�E�����s�#�#�#�#�#rc�4�|�dd���dS)Nr�r)r�r��r�rjs r�test_waitpidzPidTests.test_waitpid�s!��������3�3�3�3�3rc���d}d|�d�}|�||���|�t��5tjd��ddd��dS#1swxYwYdS)N�zimport sys; sys.exit(�)�r�g)r�r~r�rr�)r9r�r�s   r�test_waitstatus_to_exitcodez$PidTests.test_waitstatus_to_exitcode�s�����2�x�2�2�2�����4�(��3�3�3�
�
�
�y�
)�
)�	+�	+��%�c�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+s�A�A �#A r��win32-specific testc�D�d}d|�d�}|�||���dS)Nl:z$import _winapi; _winapi.ExitProcess(r�r�r�)r9�STATUS_CONTROL_C_EXITr�s   r�test_waitpid_windowszPidTests.test_waitpid_windowss;��!+��N�6K�N�N�N�����4�*?��@�@�@�@�@rc��d}ddd|fD]-}|�tj|dz��|���.|�t��5tj|dzdz��ddd��n#1swxYwY|�t
��5tjd��ddd��dS#1swxYwYdS)Nr�rrwr�r/r�)rHrr�r~r�ro)r9�max_exitcoder�s   r�#test_waitstatus_to_exitcode_windowsz,PidTests.test_waitstatus_to_exitcode_windows
s_��"���A�q�,�/�	'�	'�H����R�6�x�1�}�E�E�%�
'�
'�
'�
'��
�
�z�
*�
*�	?�	?��%�|�a�'7�A�&=�>�>�>�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�
�
�
�}�
-�
-�	*�	*��%�b�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s$�A8�8A<�?A<�B?�?C�C�SIGKILLzneed signal.SIGKILLc�|��dtj�d�}tj��fd�}|�|�|���dS)Nzimport time; time.sleep(r�c�2��tj|���dSr.)rr�)r��signums �r�kill_processz?PidTests.test_waitstatus_to_exitcode_kill.<locals>.kill_process s����G�C�� � � � � r)r�r�)r�LONG_TIMEOUTr�r�r�)r9r�r�r�s   @r� test_waitstatus_to_exitcode_killz)PidTests.test_waitstatus_to_exitcode_kills[���A�'�*>�A�A�A�����	!�	!�	!�	!�	!�	
���4�6�'�L��I�I�I�I�Irr.)rarbrcrrrrr�r�r�r�rBrCr�r�r�r�r
rrr�r��s&�������X�����Y�/�/�1H�I�I�3�3�J�I�3�$�$�$�$�$4�4�4�+�+�+��X�����0�2G�H�H�A�A�I�H�A��X�����0�2G�H�H�
*�
*�I�H�
*��X������3�3�5J�K�K�J�J�L�K�J�J�Jrr�c��eZdZddd�d�Zed��d���Zed��d���Zed��d	���Zed
��d���Zed��d
���Z	ed��d���Z
ed��d���Zed��d���Zed��d���Z
ed��d���Zed��d���Zed��d���Zed��d���Zed��d���Zd�Zed��d���Zed��d���ZdS)�
SpawnTestsF��with_env�	use_bytesc�`�d|_tj}|�tj|��|sd|jz}njttj��|_ttj����|_|j|j|j<d|j�d|j�d�}t|dd���5}|�|��ddd��n#1swxYwYtj|g}|r4d	�|D��}d
�|j���D��|_|S)N�zimport sys; sys.exit(%s)z#import sys, os; magic = os.environ[z]; sys.exit(r�r{r�r�c�6�g|]}tj|����Sr
r�)rrAs  rrz*SpawnTests.create_args.<locals>.<listcomp>>s ��1�1�1�q�B�K��N�N�1�1�1rc�b�i|],\}}tj|��tj|����-Sr
r�)r�k�vs   r�
<dictcomp>z*SpawnTests.create_args.<locals>.<dictcomp>?s>��6�6�6� �A�q���A�����A���6�6�6r)r�rrhr�rirrr�r0r7r��uuid4r
r&r'rBr�r)r9r�r�r(r�r*r�s       r�create_argszSpawnTests.create_args(se����
��#�����	�(�(�3�3�3��		1�-��
�=�D�D��B�J�'�'�D�H��4�:�<�<�(�(�D�H�!%��D�H�T�X����x�x�x�����0�D��(�C�'�
2�
2�
2�	�b��H�H�T�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	����)���	6�1�1�D�1�1�1�D�6�6�$(�H�N�N�$4�$4�6�6�6�D�H��s�=C�C#�&C#�spawnlc��|���}tjtj|dg|�R�}|�||j��dSr�)r�rr��P_WAITrHr��r9r�r�s   r�test_spawnlzSpawnTests.test_spawnlDsP�����!�!���9�R�Y��Q��7�$�7�7�7������4�=�1�1�1�1�1r�spawnlec��|�d���}tjtj|dg|�|j�R�}|�||j��dS�NT)r�r)r�rr�r�r0rHr�r�s   r�test_spawnlezSpawnTests.test_spawnleJs\�������.�.���:�b�i��a��B�4�B���B�B�B������4�=�1�1�1�1�1r�spawnlpc��|���}tjtj|dg|�R�}|�||j��dSr�)r�rr�r�rHr�r�s   r�test_spawnlpzSpawnTests.test_spawnlpPsP�����!�!���:�b�i��a��8�4�8�8�8������4�=�1�1�1�1�1r�spawnlpec��|�d���}tjtj|dg|�|j�R�}|�||j��dSr�)r�rr�r�r0rHr�r�s   r�
test_spawnlpezSpawnTests.test_spawnlpeVs\�������.�.���;�r�y�$�q�'�C�D�C�$�(�C�C�C������4�=�1�1�1�1�1rr�c�L�|���}tjtj|d|��}|�||j��tjtjt
|d��|��}|�||j��dSr�)r�rr�r�rHr�rr�s   r�test_spawnvzSpawnTests.test_spawnv\s������!�!���9�R�Y��Q���6�6������4�=�1�1�1��9�R�Y���a��(9�(9�4�@�@������4�=�1�1�1�1�1r�spawnvec��|�d���}tjtj|d||j��}|�||j��dSr��r�rr�r�r0rHr�r�s   r�test_spawnvezSpawnTests.test_spawnvefsS�������.�.���:�b�i��a��$���A�A������4�=�1�1�1�1�1r�spawnvpc��|���}tjtj|d|��}|�||j��dSr�)r�rr�r�rHr�r�s   r�test_spawnvpzSpawnTests.test_spawnvplsJ�����!�!���:�b�i��a��$�7�7������4�=�1�1�1�1�1r�spawnvpec��|�d���}tjtj|d||j��}|�||j��dSr�)r�rr�r�r0rHr�r�s   r�
test_spawnvpezSpawnTests.test_spawnvpersS�������.�.���;�r�y�$�q�'�4���B�B������4�=�1�1�1�1�1rc��|���}tjtj|d|��}t	j||j���dS)Nrr�)r�rr�r�r�wait_processr�)r9r�r�s   r�test_nowaitzSpawnTests.test_nowaitxsJ�����!�!���i���T�!�W�d�3�3����S�4�=�9�9�9�9�9�9rc���|�dd���}tjtj|d||j��}|�||j��dS)NTr�rr�r�s   r�test_spawnve_byteszSpawnTests.test_spawnve_bytes~sW��������>�>���:�b�i��a��$���A�A������4�=�1�1�1�1�1rc��|���}|�ttjtj|d��|�ttjtj|dd��dS�Nrr�)r�r~r�rr�r��r9r�s  r�test_spawnl_noargszSpawnTests.test_spawnl_noargs�s_�����!�!�����*�b�i���d�1�g�F�F�F����*�b�i���d�1�g�r�J�J�J�J�Jrc��|���}|�ttjtj|di��|�ttjtj|ddi��dSr�)r�r~r�rr�r�r�s  r�test_spawnle_noargszSpawnTests.test_spawnle_noargs�sc�����!�!�����*�b�j�"�+�t�A�w��K�K�K����*�b�j�"�+�t�A�w��B�O�O�O�O�Orc���|���}|�ttjtj|dd��|�ttjtj|dg��|�ttjtj|dd��|�ttjtj|ddg��dS�Nrr
r6r�)r�r~r�rr�r�r�s  r�test_spawnv_noargszSpawnTests.test_spawnv_noargs�s������!�!�����*�b�i���d�1�g�r�J�J�J����*�b�i���d�1�g�r�J�J�J����*�b�i���d�1�g�u�M�M�M����*�b�i���d�1�g��t�L�L�L�L�Lrc��|���}|�ttjtj|ddi��|�ttjtj|dgi��|�ttjtj|ddi��|�ttjtj|ddgi��dSr�)r�r~r�rr�r�r�s  r�test_spawnve_noargszSpawnTests.test_spawnve_noargs�s������!�!�����*�b�j�"�+�t�A�w��B�O�O�O����*�b�j�"�+�t�A�w��B�O�O�O����*�b�j�"�+�t�A�w��r�R�R�R����*�b�j�"�+�t�A�w���b�Q�Q�Q�Q�Qrc�:�tjddg}tj���}d|d<	|tj|d||��}|�|d��n#t$rYnwxYwtj���}d|d<	|tj|d||��}|�|d��n#t$rYnwxYwtj���}d	|d
<	|tj|d||��}|�|d��n#t$rYnwxYwtj	}|�
tj|��t|dd�
��5}|�
d��ddd��n#1swxYwYtj|g}tj���}d|d<|tj|d||��}|�|d��dS)Nr�r�r�r�r�r�r�r�r�r{r�r�zPimport sys, os
if os.getenv("FRUIT") != "orange=lemon":
    raise AssertionErrorzorange=lemon)rBr�rr�r�r�rHr�rrhr�rir&r')r9�spawnr�r�r�r(r*s       r�_test_invalid_envzSpawnTests._test_invalid_env�s������f�-������"�"��%.��!�"�	,��u�R�Y��Q���v�>�>�H�
���X�s�+�+�+�+���	�	�	��D�	��������"�"��5��w��	,��u�R�Y��Q���v�>�>�H�
���X�s�+�+�+�+���	�	�	��D�	��������"�"��!(��~��	,��u�R�Y��Q���v�>�>�H�
���X�s�+�+�+�+���	�	�	��D�	�����#�����	�(�(�3�3�3�
�(�C�'�
2�
2�
2�	1�b��H�H�0�
1�
1�
1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1����)������"�"��(��w���5���D��G�T�6�:�:������1�%�%�%�%�%sG�A)�)
A6�5A6�C�
C�C�D;�;
E�E�	F+�+F/�2F/c�D�|�tj��dSr.)r�rr�rjs r�test_spawnve_invalid_envz#SpawnTests.test_spawnve_invalid_env�s�����r�z�*�*�*�*�*rc�D�|�tj��dSr.)r�rr�rjs r�test_spawnvpe_invalid_envz$SpawnTests.test_spawnvpe_invalid_env�s�����r�{�+�+�+�+�+rN)rarbrcr�r"r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rrr�r�&s�������&+�u������8��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�!�!�,�,�"�!�,�,�,rr�z>Skip due to platform/environment differences on *NIX buildbots�getloginztest needs os.getloginc��eZdZd�ZdS)�
LoginTestsc�r�tj��}|�t|��d��dSr�)rr�r�rD)r9�	user_names  r�
test_getloginzLoginTests.test_getlogin�s/���K�M�M�	����C�	�N�N�A�.�.�.�.�.rN)rarbrcrr
rrr�r��s#������/�/�/�/�/rr��getpriority�setpriorityz'needs os.getpriority and os.setpriorityc��eZdZdZd�ZdS)�ProgramPriorityTestsz0Tests for os.getpriority() and os.setpriority().c�2�tjtjtj����}tjtjtj��|dz��	tjtjtj����}|dkr|dkrtjd|z���|�||dz��		tjtjtj��|��dS#t$r!}|j	tj
kr�Yd}~dSd}~wwxYw#	tjtjtj��|��w#t$r }|j	tj
kr�Yd}~wd}~wwxYwxYw)Nrw�z?unable to reliably test setpriority at current nice level of %s)rr�PRIO_PROCESSr�rrrJrHrOrP�EACCES)r9r��new_prior�s    r�test_set_get_priorityz*ProgramPriorityTests.test_set_get_priority�s����~�b�o�r�y�{�{�;�;��
��r���	���T�A�X�>�>�>�	��~�b�o�r�y�{�{�C�C�H��r�z�z�h�"�n�n��'�)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�5F�71E)�(F�)
F�3F�	F�F�FN)rarbrcr�r
r
rrrr�s+������;�:�����rr�sendfileztest needs os.sendfile()c�~�eZdZddzZej�d��o5ej�d��oej�d��Zej	ed��Z
ej	ejdkd��Ze
d	���Ze
d
���Zed���Zd�Zd
�Zd�Zed���Zed���Zd�Zd�Zd�Zd�Zd�Ze
d���Ze
d���Ze
ed�����Ze
ed�����Ze
ej	e e!d��d��d�����Z"dS)�TestSendfiles�12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdei�linux�solaris�sunosz%requires headers and trailers supportrjz(test is only meaningful on 32-bit buildsc�D�ttj|j��dSr.)r+rrh�DATArUs rrWzTestSendfile.setUpClass
s���I�$�c�h�/�/�/�/�/rc�B�tjtj��dSr.)rrirhrUs rruzTestSendfile.tearDownClass

s�����)�*�*�*�*�*rc�K�|���s3|����d{V��WV�|����1dSdSr.)�at_eofr�)�readers r�chunkszTestSendfile.chunks
se�����-�-�/�/�	&����
�
�%�%�%�%�%�%�%�%�%�%��-�-�/�/�	&�	&�	&�	&�	&rc���K�d�d�|�|��2���d{V����|_|���|j���dS)Nrc��"K�g|3d{V��}|��
6Sr.r
)rr%s  rrz2TestSendfile.handle_new_client.<locals>.<listcomp>
s.����&L�&L�&L�&L�&L�&L�&L�&L�1�q�&L�&L�&L�&Ls�)rKr�
server_bufferro�server)r9r�writers   r�handle_new_clientzTestSendfile.handle_new_client
sn���� �X�X�&L�&L����F�8K�8K�&L�&L�&L�&L�&L�&L�&L�&L�&L�M�M�����������������rc��<K�d|_tj|jtj���d{V��|_|jjd���}tj	��|_
|j
�d��tj���
|j
|���d{V��|j
���|_t!t"jd��|_|j���|_dS)NrrFr�)rr/�start_serverrr�HOSTv4r�sockets�getsockname�socket�client�setblocking�get_running_loop�sock_connectr��socknor&rrhrZ)r9�server_names  r�
asyncSetUpzTestSendfile.asyncSetUp
s���� ���#�0��1G�1>�1E�G�G�G�G�G�G�G�G����k�)�!�,�8�8�:�:���m�o�o��������&�&�&��&�(�(�5�5�d�k�;�O�O�O�O�O�O�O�O�O��k�(�(�*�*�����)�4�0�0��	��i�&�&�(�(����rc��K�|j���|j���|j����d{V��dSr.)rZror$r�wait_closedrjs r�
asyncTearDownzTestSendfile.asyncTearDown$
sX�����	��������������k�%�%�'�'�'�'�'�'�'�'�'�'�'rc��PK�tjtjg|�Ri|���d{V��Sr.)r/�	to_threadrr)r�r�s  r�async_sendfilezTestSendfile.async_sendfile*
s;�����&�r�{�D�T�D�D�D�V�D�D�D�D�D�D�D�D�Drc���K�		tj|i|���d{V��S#t$r@}|jtjkr�|jtjtjfvrYd}~�]�d}~wwxYw)zfA higher level wrapper representing how an application is
        supposed to use sendfile().
        TN)r
r0rOrP�
ECONNRESET�EAGAIN�EBUSY)r�r�r�s   r�sendfile_wrapperzTestSendfile.sendfile_wrapper.
s�����
	�

�)�8�$�I�&�I�I�I�I�I�I�I�I�I���
�
�
��9�� 0�0�0���Y�5�<���"=�=�=��H�H�H�H������
���s��
A&�5A!� A!�!A&c��K�d}d}d}|t|j��kr�|�|j|j||���d{V��}|dkrnQ||z
}||z
}|�||k��|�||��|t|j��k��|�|t|j����|j�tj
��|j���|j�
���d{V��|�t|j��t|j����|�|j|j��dS)Nr�)rDrr5r(r�rprHr$�shutdownr#�	SHUT_RDWRrorr,r)r9�
total_sent�offset�nbytes�sents     r�test_send_whole_filez!TestSendfile.test_send_whole_file@
s������
������3�t�y�>�>�)�)��.�.�t�{�D�K�/5�v�?�?�?�?�?�?�?�?�D��q�y�y���d�N�F��$��J��O�O�D�F�N�+�+�+����V�Z�0�0�0��3�t�y�>�>�)�)�	
����S���^�^�4�4�4�����V�-�.�.�.���������k�%�%�'�'�'�'�'�'�'�'�'�����T�/�0�0�#�d�i�.�.�A�A�A�����+�T�Y�7�7�7�7�7rc��K�d}t|j��dz}t|j��|z
}d}||krX|�|j|j||���d{V��}|dkrn)||z
}||z
}|�||k��||k�X|j�tj	��|j�
��|j����d{V��|jt|j��dzd�}|�
|t|����|�
t|j��t|����|�
|j|��dS)Nrryr7)rDrr5r(r�rpr$r8r#r9rorr,rHr)r9r:r;�	must_sendr<r=rXs       r�test_send_at_certain_offsetz(TestSendfile.test_send_at_certain_offsetV
s������
��T�Y���1�$����	�N�N�V�+�	����9�$�$��.�.�t�{�D�K�/5�v�?�?�?�?�?�?�?�?�D��q�y�y���d�N�F��$��J��O�O�D�F�N�+�+�+��9�$�$�	
����V�-�.�.�.���������k�%�%�'�'�'�'�'�'�'�'�'��9�S���^�^�q�0�1�1�2������S��]�]�3�3�3�����T�/�0�0�#�h�-�-�@�@�@�����+�X�6�6�6�6�6rc��K�t|j��dz}	|�|j|j|d���d{V��}|�|d��n-#t$r }|jtjkr�Yd}~nd}~wwxYw|j	�
tj��|j	�
��|j����d{V��|�|jd��dS)Nr7rr)rDrr0r(r�rHrOrP�EINVALr$r8r#r9rorr,r)r9r;r=r�s    r�test_offset_overflowz!TestSendfile.test_offset_overflowm
s0�����T�Y���$�&��	&��,�,�T�[�$�+�-3�T�;�;�;�;�;�;�;�;�D�
���T�1�%�%�%�%���	�	�	��w�%�,�&�&��'�&�&�&�&�����	����	
����V�-�.�.�.���������k�%�%�'�'�'�'�'�'�'�'�'�����+�S�1�1�1�1�1s�(A�
B�$A?�?Bc��K�|�t��5}|�|j|jdd���d{V��ddd��n#1swxYwY|�|jjtj��dS)Nr�r7)	r~rOr0r(r�rHryrPrC�r9rks  r�test_invalid_offsetz TestSendfile.test_invalid_offset~
s�����
�
�
�w�
'�
'�	J�2��%�%�d�k�4�;��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�Ac	���K�|�|j|jdd����d{V��|jr.|�|j|jddddd����d{V��dSdS)Nrr7)r�r�r;r�r
)r�r�r;r��headers�trailersr�)r0r(r��SUPPORT_HEADERS_TRAILERSrjs r�
test_keywordszTestSendfile.test_keywords�
s������!�!���D�K�)*�$�"�8�8�	8�	8�	8�	8�	8�	8�	8��(�	H��%�%�T�[���-.�d�.0�2�Q�&�H�H�
H�
H�
H�
H�
H�
H�
H�
H�
H�	H�	Hrc��K�d}d|jdd�z}|�|j|jddddg����d{V��}|�|d��||z
}d}|t|��kr�t
t|��|z
d��}|�|j|j||���d{V��}|dkrn3|�||��||z
}||z
}|t|��k��|�|t|����|j	�
��|j����d{V��|�t|j��t|����dS)	Nrsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyr�r7sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy�rIi)rr0r(r��assertLessEqualrD�minr5rHr$rorr,�hashr)r9r:�
expected_datar=r;r<s      r�test_headerszTestSendfile.test_headers�
s������
�/�$�)�C�R�C�.�@�
��(�(���d�k�1�d�2<�j�1I�)�K�K�K�K�K�K�K�K�����T�#3�4�4�4��d��
����3�}�-�-�-�-���]�+�+�j�8�$�?�?�F��.�.�t�{�D�K�/5�v�?�?�?�?�?�?�?�?�D��q�y�y��� � ��v�.�.�.��$��J��d�N�F��3�}�-�-�-�-�	
����S��%7�%7�8�8�8���������k�%�%�'�'�'�'�'�'�'�'�'�����d�0�1�1�4�
�3F�3F�G�G�G�G�Grc	��K�tjdz}d}|�tj|��t	||��t|d��5}|�|j|���ddddg����d{V��|j	�
��|j����d{V��|�
|jd	��ddd��dS#1swxYwYdS)
Nr�sabcdefr�rr�s123456s789�rJsabcde123456789)rrhr�rir+r&r0r(r�r$rorr,rHr)r9r��	file_datarts    r�
test_trailerszTestSendfile.test_trailers�
su�����"�S�(���	����	�(�'�2�2�2��G�Y�'�'�'�
�'�4�
 �
 �	D�A��%�%�d�k�1�8�8�:�:�q�!�09�6�/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�	Ds�B
C.�.C2�5C2c	��FK�d|jj_|�t��5}|�|j|jddddzgdz����d{V��ddd��n#1swxYwY|�|j	j
tj��dS)NFr�x�r`rN�r�handler_instance�
accumulater~rOr0r(r�rHryrPrCrFs  r�test_headers_overflow_32bitsz)TestSendfile.test_headers_overflow_32bits�
s����38���$�/�
�
�
�w�
'�
'�	F�2��%�%�d�k�4�;��1�/3�e�|�n�u�.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�3A0c	��FK�d|jj_|�t��5}|�|j|jddddzgdz����d{V��ddd��n#1swxYwY|�|j	j
tj��dS)NFrrYrZr`rUr[rFs  r�test_trailers_overflow_32bitsz*TestSendfile.test_trailers_overflow_32bits�
s����38���$�/�
�
�
�w�
'�
'�	G�2��%�%�d�k�4�;��1�04�u��~��/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�\�:�:�:�:�:r_�SF_NODISKIOztest needs os.SF_NODISKIOc���K�	|�|j|jddtj����d{V��dS#t
$r+}|jtjtjfvr�Yd}~dSd}~wwxYw)Nrr7)r�)	r0r(r�rrbrOrPr4r3)r9r�s  r�
test_flagszTestSendfile.test_flags�
s�����	��%�%�d�k�4�;��4�,.�N�&�<�<�
<�
<�
<�
<�
<�
<�
<�
<�
<���	�	�	��y���e�l� ;�;�;��<�;�;�;�;�;�����	���s�4:�
A/� A*�*A/N)#rarbrcrrBrCr�rKrr�requires_headers_trailers�maxsize�requires_32brvrWrurrrr*r-r0r5r>rArDrGrLrSrWr^rarrrdr
rrr
r
�s���������$�D�#&�<�#:�#:�7�#C�#C�C� D�#&�<�#:�#:�9�#E�#E�E� D�#&�<�#:�#:�7�#C�#C�C��!4�� 3�4L�3�!5�!5��&�8�&�s�{�U�':�6�8�8�L��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�����rr
c���ttd��sdS	ttjdd��5}	tj|���dd��n:#t$r-Yddd��tjtj��dSwxYw	ddd��n#1swxYwYtjtj��n##tjtj��wxYwdS)N�setxattrFr%r�	user.testrT)	rrr&rrhrir�rOri)r*s r�supports_extended_attributesrk�
s>���2�z�"�"���u�+�
�)�"�D�!�
,�
,�	��
���B�I�I�K�K��s�;�;�;�;���
�
�
��		�	�	�	�	�	�	���)�*�*�*�*�*�
����<�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	���)�*�*�*�*��	���)�*�*�*�*�����4sW�C�B&�(A�B&�
B�)B&�*C�B�B&�C�&B*�*C�-B*�.C� C0z(no non-broken extended attribute supportryr��'c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�ExtendedAttributeTestsc�>	�tj}|�tj|��t	|��|�t��5}|||d��fi|��ddd��n#1swxYwY|�|jj	tj
��||��}	|�|	t��|||d��dfi|��t|	��}
|
�d��|�t||����|
��|�||dfi|��d��|||d��dtjfi|��|�||dfi|��d��|�t��5}|||d��dtjfi|��ddd��n#1swxYwY|�|jj	tj��|�t��5}|||d��dtjfi|��ddd��n#1swxYwY|�|jj	tj
��|||d��dtjfi|��|
�d��|�t||����|
��|||d��fi|��|�t��5}|||d��fi|��ddd��n#1swxYwY|�|jj	tj
��|
�d��|�t||����|
��|�|||d��fi|��d��|||d��dfi|��|�|||d��fi|��d��|||d��fi|��t)d	�t+d
��D����}|D]
}|||dfi|���|�t||����t|	��t|��z��dS)N�	user.testrrjr�sbyez
user.test2sfoosaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac3�@K�|]}d�|��V��dS)zuser.test{}N)r�)rr�s  rr.z;ExtendedAttributeTests._check_xattrs_str.<locals>.<genexpr>s0����B�B�!�m�*�*�1�-�-�B�B�B�B�B�Brr�rY)rrhr�rir+r~rOrHryrP�ENODATAr6r�r
r�r�
XATTR_REPLACE�XATTR_CREATE�EEXISTr�r�r�)
r9r��getxattrri�removexattr�	listxattrr�r�rk�
init_xattr�xattr�many�things
             r�_check_xattrs_strz(ExtendedAttributeTests._check_xattrs_str�
s���
�
�����	�(�"�-�-�-��B����
�
�
�w�
'�
'�	3�2��H�R���;���2�2�6�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3������+�U�]�;�;�;��Y�r�]�]�
����j�$�/�/�/����Q�Q�{�^�^�S�3�3�F�3�3�3��J����
�	�	�+��������Y�Y�r�]�]�+�+�U�3�3�3������"�l�=�=�f�=�=�s�C�C�C����Q�Q�{�^�^�X�r�/?�J�J�6�J�J�J������"�l�=�=�f�=�=�x�H�H�H�
�
�
�w�
'�
'�	L�2��H�R���;������K�K�F�K�K�K�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L����	L�	L�	L�	L������+�U�\�:�:�:�
�
�
�w�
'�
'�	N�2��H�R���<���&�"�2B�M�M�f�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N������+�U�]�;�;�;����Q�Q�|�_�_�f�b�o�H�H��H�H�H�
�	�	�,��������Y�Y�r�]�]�+�+�U�3�3�3���B���+���1�1�&�1�1�1�
�
�
�w�
'�
'�	3�2��H�R���;���2�2�6�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3������+�U�]�;�;�;�
���[�!�!�!�����Y�Y�r�]�]�+�+�U�3�3�3������"�a�a��o�o�@�@��@�@�&�I�I�I����Q�Q�{�^�^�Y�9�9�&�9�9�9������"�a�a��n�n�?�?��?�?��K�K�K���B���+���1�1�&�1�1�1��B�B�u�S�z�z�B�B�B�B�B���	0�	0�E��H�R���/�/��/�/�/�/�����Y�Y�r�]�]�+�+�S��_�_�s�4�y�y�-H�I�I�I�I�IsH�A6�6A:�=A:�* G�G�G�% I�I�I�L3�3L7�:L7c���|jtg|�Ri|��tjtj��|jt
jg|�Ri|��tjtj��dSr.)r}r7rrirhrr#rs   r�
_check_xattrsz$ExtendedAttributeTests._check_xattrssx�����s�4�T�4�4�4�V�4�4�4����)�*�*�*����r�{�<�T�<�<�<�V�<�<�<����)�*�*�*�*�*rc��|�tjtjtjtj��dSr.�rrrvrirwrxrjs r�test_simplez"ExtendedAttributeTests.test_simple s5�����2�;���R�^��<�	)�	)�	)�	)�	)rc��|�tjtjtjtjd���dS)NFr�r�rjs r�
test_lpathz!ExtendedAttributeTests.test_lpath$sA�����2�;���R�^��<��	�	@�	@�	@�	@�	@rc�N�d�}d�}d�}d�}|�||||��dS)Nc��t|d��5}tj|���g|�R�cddd��S#1swxYwYdSr�)r&rrvr��rIr�r*s   rrvz1ExtendedAttributeTests.test_fds.<locals>.getxattr)s����d�D�!�!�
7�R��{�2�9�9�;�;�6��6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�
7�
7��$A�A�	Ac��t|dd��5}tj|���g|�R�ddd��dS#1swxYwYdS�Nr�r)r&rrir�r�s   rriz1ExtendedAttributeTests.test_fds.<locals>.setxattr,s����d�D�!�$�$�
0����B�I�I�K�K�/�$�/�/�/�/�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0�
0�
0��%A�A�Ac��t|dd��5}tj|���g|�R�ddd��dS#1swxYwYdSr�)r&rrwr�r�s   rrwz4ExtendedAttributeTests.test_fds.<locals>.removexattr/s����d�D�!�$�$�
3����r�y�y�{�{�2�T�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}tj|���g|�R�cddd��S#1swxYwYdSr�)r&rrxr�r�s   rrxz2ExtendedAttributeTests.test_fds.<locals>.listxattr2s����d�D�!�!�
8�R��|�B�I�I�K�K�7�$�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�
8�
8r�)r)r9rvrirwrxs     r�test_fdszExtendedAttributeTests.test_fds(s`��	7�	7�	7�	0�	0�	0�	3�	3�	3�	8�	8�	8�	
���8�X�{�I�F�F�F�F�FrN)rarbrcr}rr�r�r�r
rrrnrn�
sk������.J�.J�.J�`+�+�+�)�)�)�@�@�@�
G�
G�
G�
G�
Grrn�get_terminal_sizezrequires os.get_terminal_sizec��eZdZd�Zd�ZdS)�
TermsizeTestsc�J�	tj��}nW#t$rJ}tjdks|jt
jt
jfvr|�d���d}~wwxYw|�	|j
d��|�	|jd��dS)z�Check if get_terminal_size() returns a meaningful value.

        There's no easy portable way to actually check the size of the
        terminal, so let's check if it returns something sensible instead.
        r��failed to query terminal sizeNr)rr�rOrBrCrPrC�ENOTTYr|�assertGreaterEqual�columns�lines)r9r�r�s   r�test_does_not_crashz!TermsizeTests.test_does_not_crash:s���	��'�)�)�D�D���	�	�	��|�w�&�&�!�'�e�l�E�L�5Q�*Q�*Q��
�
�=�>�>�>������	����	
�����a�0�0�0�����
�A�.�.�.�.�.s��
A*�AA%�%A*c�t�	tjddgtjd������}n7#ttjtf$r|�d��YnwxYwt|d��t|d��f}	tj
tj�
����}nW#t$rJ}tjdks|jt jt jfvr|�d	���d
}~wwxYw|�||��d
S)z�Check if stty returns the same results

        stty actually tests stdin, so get_terminal_size is invoked on
        stdin explicitly. If stty succeeded, then get_terminal_size()
        should work too.
        �sttyr�T)r�rUzstty invocation failedrwrr�r�N)r��check_output�DEVNULLr;rN�CalledProcessErrorr�r|r#rr�rB�	__stdin__r�rOrCrPrCr�rH)r9r�rXr�r�s     r�test_stty_matchzTermsizeTests.test_stty_matchLs:��	4��'��V�$�Z�-?�d�����%�'�'�
�D��
"�:�#@��!�	4�	4�	4��M�M�2�3�3�3�3�3�	4������Q��L�L�#�d�1�g�,�,�/��	��)�#�-�*>�*>�*@�*@�A�A�F�F���	�	�	��|�w�&�&�!�'�e�l�E�L�5Q�*Q�*Q��
�
�=�>�>�>������	����	
����6�*�*�*�*�*s(�58�1A,�+A,�0C�
D�AD�DN)rarbrcr�r�r
rrr�r�8s2������/�/�/�$+�+�+�+�+rr��memfd_createzrequires os.memfd_creater�r�c��eZdZd�ZdS)�MemfdCreateTestsc��tjdtj��}|�|d��|�tj|��|�tj|����t|dd���5}|�	d��|�
|���d��ddd��n#1swxYwYtjd��}|�tj|��|�tj|����dS)N�Hir�r�F)�closefdsmemfd_creater2)rr��MFD_CLOEXECr�r�rorrJr&r'rH�tell)r9r�rtr&s    r�test_memfd_createz"MemfdCreateTests.test_memfd_createlsC��
�_�T�2�>�
2�
2�����B��#�#�#������"�%�%�%�����+�B�/�/�0�0�0�
�"�d�E�
*�
*�
*�	+�a�
�G�G�O�$�$�$����Q�V�V�X�X�r�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��o�d�#�#�������#�&�&�&�����+�C�0�0�1�1�1�1�1s�>C�C� CN)rarbrcr�r
rrr�r�is#������2�2�2�2�2rr��eventfdzrequires os.eventfdr�c� �eZdZd�Zd�Zd�ZdS)�EventfdTestsc��d�}d}d}tj|��}|�|d��|�tj|��|�tj|����tj||��}|�|||����tj	||d����tj||��}|�||d����tj	||d����tj	||d����tj||��}|�||d����tj
|d��tj
|d	��tj|��}|�|d��dS)
Nc�,�tjd|��S)z$Pack as native uint64_t
            z@Q)�struct�pack)rns rr�z/EventfdTests.test_eventfd_initval.<locals>.pack~s���;�t�U�+�+�+rr/r�r�r��(ryr#r�)rr�r�r�rorrJr�rHr'�
eventfd_write�eventfd_read)r9r�r��initvalr��ress      r�test_eventfd_initvalz!EventfdTests.test_eventfd_initval}s���	,�	,�	,�����
�Z��
 �
 �����B��#�#�#������"�%�%�%�����+�B�/�/�0�0�0��g�b�$��������d�d�7�m�m�,�,�,�
���T�T�"�X�X�����g�b�$��������d�d�2�h�h�'�'�'�
���T�T�"�X�X����
���T�T�!�W�W�����g�b�$��������d�d�2�h�h�'�'�'�	���R� � � �
���Q�����o�b�!�!������b�!�!�!�!�!rc��d}tjtjztjz}tj||��}|�|d��|�tj|��tj|��}|�	|d��tj|��}|�	|d��|�
t��5tj|��ddd��n#1swxYwY|�
t��5tj|d��ddd��n#1swxYwYtj
|d��tj|��}|�	|d��|�
t��5tj|��ddd��dS#1swxYwYdS)Nryr�rwr/)r�EFD_CLOEXEC�
EFD_SEMAPHORE�EFD_NONBLOCKr�r�r�ror�rHr~r�r�r�)r9r�r�r�r�s     r�test_eventfd_semaphorez#EventfdTests.test_eventfd_semaphore�sY�������!1�1�B�O�C��
�Z���
'�
'�����B��#�#�#������"�%�%�%��o�b�!�!������a� � � ��o�b�!�!������a� � � �
�
�
��
/�
/�	 �	 ��O�B����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �
�
�
��
/�
/�	�	��G�B��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	���Q�����o�b�!�!������a� � � �
�
�
��
/�
/�	 �	 ��O�B����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	 �	 s6�"D�D�
D�(E
�
E�E�.G�G�Gc��tjtjz}tjd|��}|�|d��|�tj|��tj|g|g|gd��\}}}|�|||fg|ggf��tj	|d��tj|g|g|gd��\}}}|�|||f|g|ggf��|�tj
|��d��tj	|d��tj|g|g|gd��\}}}|�|||f|gggf��tj
|��dS)Nrr�r�l����)rr�r�r�r�r�ro�selectrHr�r�)r9r�r��rfd�wfd�xfds      r�test_eventfd_selectz EventfdTests.test_eventfd_select�s�������0��
�Z��5�
!�
!�����B��#�#�#������"�%�%�%��
�r�d�R�D�2�$��:�:�
��S�#����#�s�C��2��t�R�.�9�9�9�	���R� � � ��
�r�d�R�D�2�$��:�:�
��S�#����#�s�C��B�4�"��r�*:�;�;�;�������,�,�b�1�1�1�	���[�)�)�)��
�r�d�R�D�2�$��:�:�
��S�#����#�s�C��B�4��R�.�9�9�9�
�������rN)rarbrcr�r�r�r
rrr�r�zsA������"�"�"�> � � �4����rr�c��eZdZd�Zd�ZdS)�OSErrorTestsc�r�Gd�dt��}g|_g|_tj�
tj}ntj}|j�|��|j�||����tj�
tj}ntj	tj��}|j�|��|j�t|����|j�t|����|j|jz|_dS)Nc��eZdZdS)�OSErrorTests.setUp.<locals>.StrN�rarbrcr
rr�Strr����������Drr�)
r7�bytes_filenames�unicode_filenamesrr�rhr��TESTFN_UNDECODABLErr#r�r�ri)r9r��decoded�encodeds    rrkzOSErrorTests.setUp�s��	�	�	�	�	�#�	�	�	� "���!#����'�3��2�G�G��&�G���%�%�g�.�.�.���%�%�c�c�'�l�l�3�3�3��'�3��2�G�G��k�)�"2�3�3�G���#�#�G�,�,�,���#�#�I�g�$6�$6�7�7�7���#�#�J�w�$7�$7�8�8�8��-��0F�F����rc
�
�|jtjf|jtjf|jtjtjf|jtjf|jtjf|jtjfg}tj
dkrt|�|jtj
df|jtjdf|jtj
df|jtjdf|jtjff��nM|�|jtjf|jtj
df|jtjdff��t#j��r'|�|jtjdf��t+td��r(|�|jtjddf��t+td��r(|�|jtjddf��t+td��r'|�|jtjdf��t+td	��r'|�|jtjdf��t+td
��r'|�|jtjdf��t+td��r&|�|jtjf��t+td��r�tj
dkrO|�|jtjdf��|�|jtjdf��n'|�|jtjdf��t+td
��ra|�|jtjf|jtjdf|jtjddf|jtj dff��t+td��r'|�|jtj!df��t+td��r&|�|jtj"f��|D]�^}}}|D]�}	tG|tHtJf��r
||g|�R�n<|�&tNd��5||g|�R�ddd��n#1swxYwY|�(d�)|������#tT$r3}|�+|j,|tI|����Yd}~��d}~wtZ$rY��wxYw��dS)Nr�sdstr�r�rar�lchownr8�chflags�lchflags�chrootr�rxrpsuser�lchmodr�z	should bezNo exception thrown by {}).rirrMrIr&r�r�r�rirBrCr�r�r�r�r�r�r�	can_chmodr�r�rrar�r8r�r�r�r�rxrvrirwr�r�rkr7r^�assertWarnsRegex�DeprecationWarningr=r�rOrhr(�UnicodeDecodeError)r9�funcsri�func�	func_argsr!r�s       r�test_oserror_filenamez"OSErrorTests.test_oserror_filename�s"��
�^�R�X�'�
�^�R�X�'�
�^�R�W�b�k�2�
�^�R�X�'�
�^�R�W�&�
�^�R�Y�(�

���<�7�"�"��L�L��%�r�y�&�9��%�r�z�6�:��'���E�:��'���U�;��'���6��
�
�
�
�
�L�L�����-�����E�2�����U�3��
�
�
�
�� � �	<��L�L�$�.�"�(�E�:�;�;�;��2�w���	;��L�L�$�.�"�(�A�q�9�:�:�:��2�x� � �	<��L�L�$�.�"�)�Q��:�;�;�;��2�z�"�"�	;��L�L�$�.�"�+�q�9�:�:�:��2�y�!�!�	:��L�L�$�.�"�*�a�8�9�9�9��2�z�"�"�	;��L�L�$�.�"�+�q�9�:�:�:��2�x� � �	7��L�L�$�.�"�)�5�6�6�6��2�v���	?��|�w�&�&����d�2�B�G�V�D�E�E�E����d�4�b�g�u�E�F�F�F�F����d�n�b�g�u�=�>�>�>��2�{�#�#�	��L�L�����/�����k�:�����k�7�C������=�	�
�
�
��2�x� � �	=��L�L�$�.�"�)�U�;�<�<�<��2�z�"�"�	9��L�L�$�.�"�+�7�8�8�8�,1�
	H�
	H�'�I�t�i�!�
H�
H��H�!�$��e��5�5�3���T�.�I�.�.�.�.�.�!�2�2�3E�{�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��I�I�9�@�@��F�F�G�G�G�G���A�A�A��M�M�#�,��c�$�i�i�@�@�@�@�@�@�@�@�����)�����D�����
H�
	H�
	HsC�AT
�
S�
T
�S�T
� S�!T
�
U�)U�
U�UN)rarbrcrkr�r
rrr�r��s?������G�G�G�,EH�EH�EH�EH�EHrr�c��eZdZd�ZdS)�
CPUCountTestsc��tj��}|�3|�|t��|�|d��dS|�d��dS)Nrz&Could not determine the number of CPUs)r�	cpu_countr6r#�
assertGreaterr|)r9�cpuss  r�test_cpu_countzCPUCountTests.test_cpu_count,s^���|�~�~�����!�!�$��,�,�,����t�Q�'�'�'�'�'��M�M�B�C�C�C�C�CrN)rarbrcr�r
rrr�r�+s(������D�D�D�D�Drr�c��eZdZd�Zejedud��d���Zejedud��d���Zej	e
ed��d��d���Zd	�Z
d
�Zej	e
ed��d��d
���Zd�Zd�Zej	ejdkd��d���Zej	e
ed��d��d���Zej	e
ed��d��d���ZdS)�FDInheritanceTestsc�X�tjttj��}|�tj|��|�tj|��d��tj|d��|�tj|��d��dS�NFT)	rr&r�r�r�rorHrJrKr�s  r�test_get_set_inheritablez+FDInheritanceTests.test_get_set_inheritable8s���
�W�X�r�{�
+�
+�������"�%�%�%�����+�B�/�/��7�7�7�
��2�t�$�$�$�����+�B�/�/��6�6�6�6�6rNz
need fcntlc���tjttj��}|�tj|��|�tj|��d��tj|tj	��}|tj
z}tj|tj|��|�tj|��d��dSr�)rr&r�r�r�rorHrJ�fcntl�F_GETFD�
FD_CLOEXEC�F_SETFD)r9r�r�s   r�test_get_inheritable_cloexecz/FDInheritanceTests.test_get_inheritable_cloexec@s���
�W�X�r�{�
+�
+�������"�%�%�%�����+�B�/�/��7�7�7���B��
�.�.��
�%�"�"�"��
��B��
�u�-�-�-�����+�B�/�/��6�6�6�6�6rc���tjttj��}|�tj|��|�tj|tj��tj	ztj	��tj
|d��|�tj|tj��tj	zd��dS)NTr)rr&r�r�r�rorHr�r�r�rKr�s  r�test_set_inheritable_cloexecz/FDInheritanceTests.test_set_inheritable_cloexecMs���
�W�X�r�{�
+�
+�������"�%�%�%������R���7�7�%�:J�J��)�	+�	+�	+�	��2�t�$�$�$������R���7�7�%�:J�J��	�	�	�	�	r�O_PATHzneed os.O_PATHc���tjttj��}|�tj|��|�tj|��d��tj|d��|�tj|��d��tj|d��|�tj|��d��dSr�)	rr&r�r�r�rorHrJrKr�s  r�test_get_set_inheritable_o_pathz2FDInheritanceTests.test_get_set_inheritable_o_pathXs���
�W�X�r�y�
)�
)�������"�%�%�%�����+�B�/�/��7�7�7�
��2�t�$�$�$�����+�B�/�/��6�6�6�
��2�u�%�%�%�����+�B�/�/��7�7�7�7�7rc���tj��}|�t��5}t	j|��ddd��n#1swxYwY|�|jjtj	��|�t��5}t	j
|d��ddd��n#1swxYwY|�|jjtj	��|�t��5}t	j
|d��ddd��n#1swxYwY|�|jjtj	��dS�NTF)rrr~rOrrJrHryrPrzrK)r9r�r|s   r�test_get_set_inheritable_badfz0FDInheritanceTests.test_get_set_inheritable_badfds���
�
"�
$�
$��
�
�
�w�
'�
'�	#�3���r�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#������,�e�k�:�:�:�
�
�
�w�
'�
'�	)�3���r�4�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)������,�e�k�:�:�:�
�
�
�w�
'�
'�	*�3���r�5�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*������,�e�k�:�:�:�:�:s5�A�A�A�C�C�C�D1�1D5�8D5c���tjttj��}|�tj|��|�tj|��d��dSr)rr&r�r�r�rorHrJr�s  rr�zFDInheritanceTests.test_openssR��
�W�X�r�{�
+�
+�������"�%�%�%�����+�B�/�/��7�7�7�7�7rr	zneed os.pipe()c�R�tj��\}}|�tj|��|�tj|��|�tj|��d��|�tj|��d��dSr)rr	r�rorHrJ)r9r�r�s   r�	test_pipezFDInheritanceTests.test_pipexs����7�9�9���S������#�&�&�&������#�&�&�&�����+�C�0�0�%�8�8�8�����+�C�0�0�%�8�8�8�8�8rc�F�tjttj��}|�tj|��tj|��}|�tj|��|�tj|��d��dSr)	rr&r�r�r�ror{rHrJ�r9�fd1r&s   r�test_dupzFDInheritanceTests.test_dup�su���g�h���,�,�������#�&�&�&��f�S�k�k�������#�&�&�&�����+�C�0�0�%�8�8�8�8�8rc��tjd��}|�tj|��|�|d��dS�Nrwr)rr{r�ror�r�s  r�test_dup_standard_streamz+FDInheritanceTests.test_dup_standard_stream�sA��
�V�A�Y�Y�������"�%�%�%����2�q�!�!�!�!�!rr�r�c�:�tjdtj��}|�tj|��tj|��}|�tj|��|�tj|����dS)N�NUL)rr&r�r�ror{rrJr�s   r�test_dup_nulzFDInheritanceTests.test_dup_nul�su���g�e�R�[�)�)�������#�&�&�&��f�S�k�k�������#�&�&�&�����+�C�0�0�1�1�1�1�1rr!zneed os.dup2()c���tjttj��}|�tj|��tjttj��}|�tj|��|�tj||��|��|�tj	|����tjttj��}|�tj|��|�tj||d���|��|�
tj	|����dS)NF)�inheritable)rr&r�r�r�rorHr!rprJr)r9r�r&�fd3s    rr$zFDInheritanceTests.test_dup2�s��
�W�X�r�{�
+�
+�������"�%�%�%��g�h���,�,�������#�&�&�&�������S�)�)�3�/�/�/�����*�3�/�/�0�0�0��g�h���,�,�������#�&�&�&�������S�e�<�<�<�c�B�B�B�����+�C�0�0�1�1�1�1�1r�openptyzneed os.openpty()c�R�tj��\}}|�tj|��|�tj|��|�tj|��d��|�tj|��d��dSr)rrr�rorHrJ)r9�	master_fd�slave_fds   r�test_openptyzFDInheritanceTests.test_openpty�s��� �j�l�l��	�8������)�,�,�,������(�+�+�+�����+�I�6�6��>�>�>�����+�H�5�5�u�=�=�=�=�=r)rarbrcr�rrr�r�r�rrrr�r�r�r�r�r�rBrCrr$r
r
rrr�r�6s�������7�7�7��X�_�U�d�]�L�1�1�
7�
7�2�1�
7��X�_�U�d�]�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�����0�2G�H�H�2�2�I�H�2��X�����V�,�,�.>�?�?�2�2�@�?�2� �X�����Y�/�/�1D�E�E�>�>�F�E�>�>�>rr�c
�h�eZdZddddejfdfddddejfeed	d��fgZd
�Zd�Z	dS)�PathTConverterTests)r�Tr
N)rIFr
NrqFN)r�F�rN)r�Fr
Nr&roc	��tj}tjdkrdx}}n-tjtj��}t|��}tjt|��tjtjz��}|�	tj
tj��|�	tj|��t|��}t|��}|jD�]J\}}}	}
|�
|���5	tt|��}n#t$rYddd���MwxYw||||fD]J}|��|�
||���5||g|	�R�}
|
�|
|
��ddd��n#1swxYwY�K|�t"d��5||g|	�R�ddd��n#1swxYwY|r||g|	�R�}
|
�|
|
��n<|�t"d��5||g|	�R�ddd��n#1swxYwYddd��n#1swxYwY��LdS)Nr9r )r!rIzto return str or byteszos.PathLike)rrhrr!r#rr&r�rmr�riro�	functionsr'r:r@�assertRaisesRegexr�)r9�str_filename�bytes_fspath�bytes_filenamer��
int_fspath�
str_fspathr!�allow_fd�
extra_args�
cleanup_fnr�rIrDs              r�test_path_t_converterz)PathTConverterTests.test_path_t_converter�s��� �'��
�7�d�?�?�,0�0�L�>�>��[��)9�:�:�N�#�N�3�3�L�
�W�X�l�+�+�R�[���-C�
D�
D�����	�(�)�*:�;�;�;������"�%�%�%��b�\�\�
��l�+�+�
�6:�n�	,�	,�2�D�(�J�
����4��(�(�
,�
,�� ��T�*�*�B�B��%�����	
,�
,�
,�
,�
,�
,�
,�����*�>�:�)�+�/�/�D��|� ����4�d��;�;�/�/�!#��D�!6�:�!6�!6�!6��%�1�&�J�v�.�.�.�/�/�/�/�/�/�/�/�/�/�/����/�/�/�/��
�+�+�!�#;�=�=�0�0��B�z�/�J�/�/�/�/�0�0�0�0�0�0�0�0�0�0�0����0�0�0�0��,��R��0�Z�0�0�0�F�!�-�"�
�6�*�*�*���/�/�%�)�+�+�,�,���2�+�
�+�+�+�+�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�1
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,��	,�	,s��H6�D-�,H6�-
E�7H6�E�%H6�*F
	�H6�
F
�H6�F
�H6�4
G
�>H6�
G�H6�G�7H6�	
H�H6�H#�#H6�&H#�'H6�6H:	�=H:	c�.�d}|�t|dz��5tjt	d����ddd��n#1swxYwY|�t|dz��5tjt	d����ddd��n#1swxYwY|�t|dz��5tjt	t������ddd��dS#1swxYwYdS)Nz-__fspath__\(\) to return str or bytes, not %sr#ry�floatg���Q�@�object)rr�rr�rr)r9r�s  r�&test_path_t_converter_and_custom_classz:PathTConverterTests.test_path_t_converter_and_custom_class�s���>��
�
#�
#�I�s�V�|�
<�
<�	!�	!��G�H�Q�K�K� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�
�
#�
#�I�s�X�~�
>�
>�	$�	$��G�H�T�N�N�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�
�
#�
#�I�s�Y��
?�
?�	(�	(��G�H�V�X�X�&�&�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s5�"A�A�A�8"B&�&B*�-B*�.D
�
D�D)
rarbrcr�F_OKr�r:rrrr
rrrr�sv������	!�"�	�5�2�7�*�d�+�&�'�	��������G�T�(B�(B�C�
�I�*,�*,�*,�X(�(�(�(�(rrrMrNzCannot unset blocking flagc��eZdZd�ZdS)�
BlockingTestsc���tjttj��}|�tj|��|�tj|��d��tj|d��|�tj|��d��tj|d��|�tj|��d��dSr�)	rr&r�r�r�rorHrMrPr�s  rrQzBlockingTests.test_blocking�s���
�W�X�r�{�
+�
+�������"�%�%�%�������,�,�d�3�3�3�
���E�"�"�"�������,�,�e�4�4�4�
���D�!�!�!�������,�,�d�3�3�3�3�3rN)rarbrcrQr
rrr r �s#������	4�	4�	4�	4�	4rr c��eZdZd�ZdS)�ExportsTestsc��|�dtj��|�dtj��dS)Nr&r�)r�r�__all__rjs r�test_os_allzExportsTests.test_os_alls4���
�
�f�b�j�)�)�)��
�
�f�b�j�)�)�)�)�)rN)rarbrcr&r
rrr#r#s#������*�*�*�*�*rr#c� �eZdZd�Zd�Zd�ZdS)�TestDirEntryc���tj�tj��|_|�tj|j��tj|j��dSr.)rrI�realpathrrhr�r�rLrjs rrkzTestDirEntry.setUp
sM���G�$�$�Y�%5�6�6��	����	�(�$�)�4�4�4�
��������rc�P�|�ttj��dSr.)r~r�r�DirEntryrjs r�test_uninstantiablez TestDirEntry.test_uninstantiables �����)�R�[�1�1�1�1�1rc��ttj�|jd��d��}d�tj|j��D�����}|�|tj��|�|j	d��ddl
}|�t|j
||��dS)Nr��pythonc��g|]}|��Sr
r
�r�entrys  rrz0TestDirEntry.test_unpickable.<locals>.<listcomp>s��:�:�:�5��:�:�:rr)r+rrIrK�scandirrWr6r,rHr!rSr~r�rU)r9r(r2rSs    r�test_unpickablezTestDirEntry.test_unpickables����r�w�|�|�D�I�z�B�B�I�N�N��:�:�B�J�t�y�$9�$9�:�:�:�>�>�@�@�����e�R�[�1�1�1������Z�0�0�0��
�
�
����)�V�\�5�(�C�C�C�C�CrN)rarbrcrkr-r4r
rrr(r(	sF���������
2�2�2�D�D�D�D�Drr(c�F�eZdZejZd�Zd!d�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d!d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejejejvd��d���Zejej d��d���Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d S)"�TestScandirc��tj�tj��|_tj|j��|_|�tj|j��tj	|j��dSr.)
rrIr*rrhr#�
bytes_pathr�r�rLrjs rrkzTestScandir.setUps`���G�$�$�Y�%5�6�6��	��+�d�i�0�0������	�(�$�)�4�4�4�
��������rr�c��t|t��r|jn|j}tj�||��}t
|d��|S)Nr/)rkr^r8rIrrKr+)r9r!rIr(s    rr+zTestScandir.create_file$sH��",�T�5�"9�"9�H�t���t�y���7�<�<��d�+�+���H�i�(�(�(��rc���td�tj|j��D����}|�t|�����|��|S)Nc3�(K�|]
}|j|fV��dSr.r r1s  rr.z*TestScandir.get_entries.<locals>.<genexpr>+s=����;�;� ��
�E�*�;�;�;�;�;�;r)rrr3rIrHr��keys)r9�names�entriess   r�get_entrieszTestScandir.get_entries*sd���;�;�$&�J�t�y�$9�$9�;�;�;�;�;�����������/�/��7�7�7��rc��|ret|��D]S}|�d��s�|dvr�|�t||��t||��|||f���TdS|�||��dS)N�st_)�st_dev�st_ino�st_nlink)r7r�rHr:)r9�stat1�stat2�skip_fieldsrFs     r�assert_stat_equalzTestScandir.assert_stat_equal0s����
	+��E�
�
�
7�
7�����u�-�-����;�;�;��� � ����!5�!5�!(���!5�!5�"'���!5�7�7�7�7�
7�
7�
���U�E�*�*�*�*�*rc��tj|j��}|�tt|����|���dSr.)rr3rIr~r�r�ro)r9�scandir_iters  rr-zTestScandir.test_uninstantiable=sI���z�$�)�,�,�����)�T�,�%7�%7�8�8�8��������rc���|�d��}tj|j��}ddl}|�t|j||��|���dS)Nr�r)	r+rr3rIrSr~r�rUro)r9r(rJrSs    rr4zTestScandir.test_unpickableBsc���#�#�J�/�/���z�$�)�,�,���
�
�
����)�V�\�<��J�J�J��������rc�f�|�|tj��|�|j|��|�|jtj�|j|����|�|���tj|jd���j	��tj|j��}|�|�
��tj|j����|�|�
��tj|j����|�|���tj�|j����tj|jd���}|�|�
d���tj|j����|�|�
d���tj|j����|�|���|tjdko|��|�|�d���|tjdk��dS)NFr�r9)r6rr,rHr!rIrK�inoder�rC�is_dir�S_ISDIRr?�is_file�S_ISREG�
is_symlinkrrH)r9r2r!rNrPrR�
entry_stat�entry_lstats        r�check_entryzTestScandir.check_entryIsJ�����e�R�[�1�1�1������T�*�*�*������R�W�\�\�$�)�T�%B�%B�C�C�C�������������U�C�C�C�J�	L�	L�	L��W�U�Z�(�(�
�����������j�&8�9�9�	;�	;�	;�����������j�&8�9�9�	;�	;�	;�����)�)�+�+������
�3�3�	5�	5�	5��g�e�j�%�@�@�@��������e��<�<���k�&9�:�:�	<�	<�	<�������u��=�=���k�&9�:�:�	<�	<�	<�	
���u�z�z�|�|�)�!�w�$��A�z�>�	C�	C�	C�	
���u�z�z�%�z�@�@�*�!�w�$��	0�	0�	0�	0�	0rc��ttd��}tj��}tj�|jd��}tj|��|�d��}|ri	tj|tj�|jd����n/#t$r"}|�
d|z��Yd}~nd}~wwxYw|rrtj|tj�|jd��d���tj|tj�|jd	����ddg}|r|�d��|r|�
d
��|�|��}|d}|�|dddd��|d}|�|dddd��|r!|d}|�|dddd��|rD|d}|�|dddd��|d	}|�|d	ddd��dSdS)Nr�r7r�z
link_file.txtr\�symlink_dirT)r��symlink_file.txt)rWrXF)rrrr�rIrKrLr+r�r�r|r�r�r�r?rU)	r9r�r�rVr(r�r=r>r2s	         r�test_attributeszTestScandir.test_attributesesg���r�6�"�"���'�)�)���'�,�,�t�y�%�0�0��
�������#�#�J�/�/���	3�
3����"�'�,�,�t�y�/�"J�"J�K�K�K�K��"�
3�
3�
3��
�
�o��1�2�2�2�2�2�2�2�2�����
3�����	N��J�w�����T�Y�
� F� F�+/�
1�
1�
1�
1��J�x�����d�i�9K�!L�!L�M�M�M��
�#���	*��L�L��)�)�)��	>��L�L�<�=�=�=��"�"�5�)�)�����������t�U�E�:�:�:��
�#������
�E�4��?�?�?��	I��O�,�E����U�O�U�D�%�H�H�H��	K��M�*�E����U�M�4���E�E�E��.�/�E����U�$6��t�T�J�J�J�J�J�	K�	Ks�:8B3�3
C�=C�Cc��t|t��r|jn|j}t	tj|����}|�t|��d��|d}|�|j	|��|Sr�)
rkr^r8rIr�rr3rHrDr!)r9r!rIr>r2s     r�	get_entryzTestScandir.get_entry�sw��",�T�5�"9�"9�H�t���t�y���r�z�$�'�'�(�(������W���q�)�)�)���
�������T�*�*�*��rc��|�|���}|�tj�|����S)Nr )r+r[rrI�basename)r9r!r(s   r�create_file_entryzTestScandir.create_file_entry�s:���#�#��#�.�.���~�~�b�g�.�.�x�8�8�9�9�9rc���|���}tj��}	tj|j��td�tj��D����}|�t|�	����tj�
|��g��tj|��dS#tj|��wxYw)Nc3�(K�|]
}|j|fV��dSr.r r1s  rr.z5TestScandir.test_current_directory.<locals>.<genexpr>�s)����I�I�5�E�J��.�I�I�I�I�I�Ir)r+rr5rMrIrr3rHr�r<r])r9r(�old_dirr>s    r�test_current_directoryz"TestScandir.test_current_directory�s����#�#�%�%���)�+�+��		��H�T�Y�����I�I�B�J�L�L�I�I�I�I�I�G����V�G�L�L�N�N�3�3� �g�.�.�x�8�8�9�
;�
;�
;�
�H�W�������B�H�W�������s�BC�C+c�t�|���}|�t|��d��dS)Nz<DirEntry 'file.txt'>)r^rHr/�r9r2s  r�	test_reprzTestScandir.test_repr�s6���&�&�(�(������e���&=�>�>�>�>�>rc���|���}|�tj|��tj�|jd����dS)Nr�)r^rHr�fspathrIrKrds  r�test_fspath_protocolz TestScandir.test_fspath_protocol�sK���&�&�(�(�������5�)�)�2�7�<�<��	�:�+N�+N�O�O�O�O�Orc�N�tjd��}|�|���}tj|��}|�|t
��|�|tj�tj|j��|����dS)Nz
bytesfile.txtr )	rr#r^rgr6r^rHrIrK)r9r�bytes_entryrgs    r�test_fspath_protocol_bytesz&TestScandir.test_fspath_protocol_bytes�s�����_�5�5���,�,�.�,�A�A����;�'�'�����f�e�,�,�,���������b�k�$�)�&<�&<�^�L�L�	N�	N�	N�	N�	Nrc�`�tj�|jd��}tj|��|�d��}tj|��tjdkr'|�|�����|�	|�
����|�	|�����tjdkrL|�t|j��|���|�d���dS|�|���d��|�t|j��|�t|jd���dS)Nr7r9Fr�r)rrIrKrLr[r�r!rprNrrPrRr~rNrMr�r�)r9rIr2s   r�test_removed_dirzTestScandir.test_removed_dir�sM���w�|�|�D�I�u�-�-��
���������u�%�%��
�������7�d�?�?��O�O�E�L�L�N�N�+�+�+���������)�)�)�����)�)�+�+�,�,�,�
�7�d�?�?����/���=�=�=��J�J�L�L�L��J�J�u�J�-�-�-�-�-����u�{�{�}�}�a�0�0�0����/���<�<�<����/���U��S�S�S�S�Src��|���}tj|j��|�|�����tjdkr'|�|�����|�|�	����tjdkrL|�
t|j��|�
��|�
d���dS|�|���d��|�
t|j
��|�
t|j
d���dS)Nr9Fr�r)r^rrirIrrNr!rprPrRr~rNrMr�r�rds  r�test_removed_filezTestScandir.test_removed_file�s,���&�&�(�(��
�	�%�*������������(�(�(�
�7�d�?�?��O�O�E�M�M�O�O�,�,�,�����)�)�+�+�,�,�,�
�7�d�?�?����/���=�=�=��J�J�L�L�L��J�J�u�J�-�-�-�-�-����u�{�{�}�}�a�0�0�0����/���<�<�<����/���U��S�S�S�S�Src��tj��s|�d��S|�d��}t	j|tj�|jd����|�ddg��}|d}t	j	|��|�
|���d��|�|�
����|�|�����|�|�
d�����|�|�d�����|�|�����|�t$|j��|�d���dS)Nzcannot create symbolic linkr�zsymlink.txtrFr�)rr�r|r+rr�rIrKr?rir�rMrrNrPrprRr~rNr�)r9r(r>r2s    r�test_broken_symlinkzTestScandir.test_broken_symlink�s����$�&�&�	@��=�=�!>�?�?�?��#�#�J�/�/��
�
�8��7�<�<��	�=�9�9�	;�	;�	;��"�"�J�
�#>�?�?���
�&��
�	�(�������5�;�;�=�=�!�,�,�,���������(�(�(���������)�)�)�������e��<�<�=�=�=�������u��=�=�>�>�>�����(�(�*�*�+�+�+����+�U�Z�8�8�8�
�
�
�5�
�)�)�)�)�)rc	���|�d��tj|j��}t	tj|����}|�t|��d|��|d}|�|jd��|�|jtjtj�	|jd������dS�Nr�rwrsfile.txt)
r+rr#rIr�r3rHrDr!rK)r9�
path_bytesr>r2s    rrzTestScandir.test_bytes�s�������$�$�$��[���+�+�
��r�z�*�-�-�.�.������W���q�'�2�2�2���
�������[�1�1�1��������R�W�\�\�$�)�Z�%H�%H�I�I�	K�	K�	K�	K�	Krc
�"�|�d��ttfD�]i}|tj|j����}|�t��5ttj	|����}ddd��n#1swxYwY|�
t|��d|��|d}|�
|jd��|�
|jtjtj�
|jd������|�t|j��t ��|�t|j��t ����kdSrs)r+r�r�rr#rI�assertWarnsr�r�r3rHrDr!rKrhr�r^)r9rVrtr>r2s     r�test_bytes_likezTestScandir.test_bytes_likes�������$�$�$��j�(�	3�	3�C���R�[���3�3�4�4�J��!�!�"4�5�5�
7�
7��r�z�*�5�5�6�6��
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7����S��\�\�1�g�6�6�6��A�J�E����U�Z��5�5�5����U�Z��[�����d�i��)L�)L�M�M�
O�
O�
O��M�M�$�u�z�*�*�E�2�2�2��M�M�$�u�z�*�*�E�2�2�2�2�	3�	3s�#"B�B	�B	z.fd support for listdir required for this test.c� �|�tjtj��|�d��dg}tj��rMtjdtj�	|jd����|�
d��tj|j��5}tj|��5}t|��}ddd��n#1swxYwYd�|D��}|�
t|��|��|�
|tj|����|D�]"}|�
|j|j��|�
tj|��|j��|�
|���|jdk��tjtjvr�tj|j|���}|�
|���|��tj|j|d���}|�
|�d���|����$	ddd��dS#1swxYwYdS)Nr�r�c��g|]	}|j��
Sr
r r1s  rrz'TestScandir.test_fd.<locals>.<listcomp> s��5�5�5�E�U�Z�5�5�5rr�F)r�r�r�)r�rr3r�r+rr�r�rIrKr�r�r�rHr�r�r!rgrRr�r�)r9�expected_namesr�r$r>r=r2r�s        r�test_fdzTestScandir.test_fds���	
�
�
�b�j�"�.�1�1�1�����$�$�$�$���� �"�"�	*��J�z�2�7�<�<��	�6�#B�#B�C�C�C��!�!�&�)�)�)�
�
"�4�9�
-�
-�	L����B���
#�2��r�(�(��
#�
#�
#�
#�
#�
#�
#�
#�
#�
#�
#����
#�
#�
#�
#�5�5�W�5�5�5�E����V�E�]�]�N�;�;�;����U�B�J�r�N�N�3�3�3� �
L�
L��� � ���U�Z�8�8�8�� � ���5�!1�!1�5�:�>�>�>�� � ��!1�!1�!3�!3�U�Z�6�5I�J�J�J��7�b�0�0�0�����B�7�7�7�B��$�$�U�Z�Z�\�\�2�6�6�6�����B��N�N�N�B��$�$�U�Z�Z��Z�%F�%F��K�K�K��
L�
	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L����	L�	L�	L�	L�	L�	Ls7�<J�C-�!J�-C1	�1J�4C1	�5FJ�J�
JzWASI maps '' to cwdc�R�|�ttjd��dS)Nr�)r~rNrr3rjs r�test_empty_pathzTestScandir.test_empty_path-s#�����+�R�Z��<�<�<�<�<rc�.�|�d��tj|j��}t	|��}|�t
|��d|��t	|��}|�t
|��d|��dS)Nr�rwr)r+rr3rIr�rHrD)r9rqr>�entries2s    r�test_consume_iterator_twicez'TestScandir.test_consume_iterator_twice1s�������$�$�$��:�d�i�(�(���x�.�.������W���q�'�2�2�2���>�>������X����8�4�4�4�4�4rc�b�digfD](}|�ttj|���)dS)NgX9��v��?)r~r�rr3)r9�objs  r�test_bad_path_typezTestScandir.test_bad_path_type<s>���2�r�?�	:�	:�C����i���S�9�9�9�9�	:�	:rc�V�|�d��|�d��tj|j��}t	|��|���|���|���5~ddd��dS#1swxYwYdS�Nr��	file2.txt)r+rr3rIr"ro�check_no_resource_warning�r9rqs  r�
test_closezTestScandir.test_close@s�������$�$�$�����%�%�%��:�d�i�(�(���X����������������
�
+�
+�
-�
-�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�B�B"�%B"c�6�|�d��|�d��tj|j��5}t	|��ddd��n#1swxYwY|���5~ddd��dS#1swxYwYdSr�)r+rr3rIr"r�r�s  r�test_context_managerz TestScandir.test_context_managerKs������$�$�$�����%�%�%�
�Z��	�
"�
"�	�h���N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
+�
+�
-�
-�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s$�A � A$�'A$�?B�B�Bc��|�d��|�d��tj|j��5}t	|��|���ddd��dS#1swxYwYdSr�)r+rr3rIr"ror�s  r�test_context_manager_closez&TestScandir.test_context_manager_closeSs�������$�$�$�����%�%�%�
�Z��	�
"�
"�	�h���N�N�N��N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�$A5�5A9�<A9c��|�d��|�d��|�t��5tj|j��5}t
|��ddzddd��n#1swxYwYddd��n#1swxYwY|���5~ddd��dS#1swxYwYdS)Nr�r�rwr)r+r~�ZeroDivisionErrorrr3rIr"r�r�s  r�test_context_manager_exceptionz*TestScandir.test_context_manager_exceptionZs�������$�$�$�����%�%�%�
�
�
�0�
1�
1�	�	���D�I�&�&�
�(��X�����!���
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��
+�
+�
-�
-�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	sH�B�B�4B�B	�B�B	�B�B�B�6C�C	�C	c���|�d��|�d��tj|j��}t	|��|�t��5~tj��ddd��n#1swxYwYtj|j��}t|��|�
��5~ddd��dS#1swxYwYdSr�)r+rr3rIr"rv�ResourceWarningr�
gc_collectr�r�r�s  r�test_resource_warningz!TestScandir.test_resource_warningdsX������$�$�$�����%�%�%��:�d�i�(�(���X����
�
�
�o�
.�
.�	!�	!���� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!��:�d�i�(�(���X����
�
+�
+�
-�
-�	�	��	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s$�-B�B�B�C$�$C(�+C(N)r�))rarbrcrr�rkr+r?rHr-r4rUrYr[r^rbrerhrkrmrorqrrwrrrr�r�r{rrrr}r�r�r�r�r�r�r�r
rrr6r6s/������ /� I������������+�+�+����
���0�0�0�8'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�:�:�:�	�	�	��������������rr6c�d�eZdZeej��Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
S)�
TestPEP519c�b�dD]+}|�||�|�����,dS)N)r�sgoodbyessome/path/and/file�rHrg)r9�bs  r�test_return_byteszTestPEP519.test_return_bytesys>��<�	0�	0�A����Q����A���/�/�/�/�	0�	0rc�b�dD]+}|�||�|�����,dS)N)�hello�goodbyezsome/path/and/filer�)r9r�s  r�test_return_stringzTestPEP519.test_return_string}s>��9�	0�	0�A����Q����A���/�/�/�/�	0�	0rc� �dD]�}t|��}|�||�|����|�dtj|����|�dtj|������dS)N)�path/like/object�path/like/objectr�r�)rrHrgrr#r_)r9rY�pathlikes   r�test_fsencode_fsdecodez!TestPEP519.test_fsencode_fsdecode�s���8�	H�	H�A���{�{�H����Q����H� 5� 5�6�6�6����0�"�+�h�2G�2G�H�H�H����/���X�1F�1F�G�G�G�G�	H�	Hrc�J�|�d|�td������|�t	tt
j����|�ttd��t
j����dS)Nz#feelthegilr%)rHrgrrp�
issubclassr�PathLikerkrjs rrzTestPEP519.test_pathlike�st���������H�]�4K�4K�(L�(L�M�M�M����
�8�R�[�9�9�:�:�:����
�8�C�=�=�"�+�>�>�?�?�?�?�?rc��tddi��}ttt|��fD]#}|�t|j|���$dS)N�blahr
)r�r#rr~r�rg)r9�vapor�os   r�test_garbage_in_exception_outz(TestPEP519.test_garbage_in_exception_out�sX���V�R��$�$���d�B�����'�	9�	9�A����i���a�8�8�8�8�	9�	9rc�F�|�t|j��dSr.)r~r�rgrjs r�test_argument_requiredz!TestPEP519.test_argument_required�s �����)�T�[�1�1�1�1�1rc�X�|�t|jtd����t	ddi��}d|_|�t|j|����|�t|jtt
������dS)Nr��foor
rw)r~r�rgrr��
__fspath__r�)r9�cs  r�test_bad_pathlikezTestPEP519.test_bad_pathlike�s������)�T�[�(�2�,�,�?�?�?����B����������)�T�[�!�!�#�#�6�6�6����+�T�[�"�#4�#6�#6�7�7�	9�	9�	9�	9�	9rc���Gd�dtj��}|�tt|����|�tttj����dS)Nc��eZdZdS)�0TestPEP519.test_pathlike_subclasshook.<locals>.ANr�r
rr�Ar��r�rr�)rr�rr�rrp)r9r�s  r�test_pathlike_subclasshookz%TestPEP519.test_pathlike_subclasshook�sp��	�	�	�	�	���	�	�	�����H�a�0�0�1�1�1����
�8�R�[�9�9�:�:�:�:�:rc�p�|�tjttj��dSr.)r6rr�r^�types�GenericAliasrjs r�test_pathlike_class_getitemz&TestPEP519.test_pathlike_class_getitem�s(�����b�k�%�0�%�2D�E�E�E�E�ErN)rarbrcrrrgr�r�r�rr�r�r�r�r�r
rrr�r�ss��������\�"�)�
$�
$�F�0�0�0�0�0�0�H�H�H�@�@�@�
9�9�9�
2�2�2�	9�	9�	9�;�;�;�F�F�F�F�Frr�c��eZdZd�ZdS)�
TimesTestsc��tj��}|�|tj��dD]-}t	||��}|�|t
���.tjdkrS|�|jd��|�|j	d��|�|j
d��dSdS)N)�user�system�
children_user�children_system�elapsedr9r)rr�r6�times_resultr:rr!rHr�r�r�)r9r��fieldrns    r�
test_timeszTimesTests.test_times�s�����
�
�����e�R�_�5�5�5�!�	0�	0�E��E�5�)�)�E��!�!�%��/�/�/�/�
�7�d�?�?����U�0�!�4�4�4����U�2�A�6�6�6����U�]�A�.�.�.�.�.��?rN)rarbrcr�r
rrr�r��s#������/�/�/�/�/rr�c��eZdZd�ZdS)�	ForkTestsc�N�d}td|��td|d���dS)Nz�if 1:
            import os
            from test import support
            pid = os.fork()
            if pid != 0:
                support.wait_process(pid, exitcode=0)
        r��malloc_debug)�PYTHONMALLOCrr�s  r�	test_forkzForkTests.test_fork�s6����	��t�$�$�$���t�.�A�A�A�A�A�ArN)rarbrcr�r
rrr�r��s(������B�B�B�B�Brr��_fspathc�2�eZdZdZeej��ZdS)�TestPEP519PurePythonz>Explicitly test the pure Python implementation of os.fspath().N)rarbrcr�rrr�rgr
rrr�r��s%������L�L���b�j�)�)���rr��__main__)r#r.)�r/r��
contextlibr]rPrCr_rr�rrSr�r�r�r#r�r�r�rB�	sysconfigrErnr�r�rr�r?�testr�test.supportrrrrrCrr��ImportErrorr�rS�pwd�getpwallrnr@�	_testcapirrrfr��test.support.script_helperrr�test.support.os_helperrrwrrr�versionr�r��getgidrtr"r+rrr1�TestCaser3rerr�r�BasicTestMappingProtocolrr�rrr r)r-�skip_unless_working_chmodrSryrr�r�r��get_config_var�OS_URANDOM_DONT_USE_FDr��contextmanagerr�r�rr
rUrir�r�r�r�rrrLrYrvr~r�r�r�r�r�r�r�IsolatedAsyncioTestCaser
rk�requires_linux_versionrnr�r�r�r�r�r�rrr r#r(r6r�r��
requires_forkr�r�ra�mainr
rr�<module>r�s���
����
�
�
�
�������������������������
�
�
�
�	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�����
�
�
�
�����
�
�
�
���������������������������������������&�&�&�&�&�&�"�"�"�"�"�"�&�&�&�&�&�&�(�(�(�(�(�(�!�!�!�!�!�!���O�O�O�O�������H�H�H�������L�L�L�L�������E�E�E�������N�N�N�N�������G�G�G�������J�J�J�2�2�<�3�<�>�>�2�2�2�I�I���^�$�����I�I�I�����+�1�1�1�1�1�1�1�1�1���+�+�+�"�{�*�G�n�n�n�+������K�K�K�K�������D�D�D�����8�7�7�7�7�7�#�#�#�#�#�#�+�+�+�+�+�+��
�
�7�2�y���(��R�Z�\�\�Q�&�M��7�3�
����3�?�#:����0�;�;�N�K�K������<�*�*�9�5�5�J�)�"�)�+�+��:J��K�K�K�����'�x��s�|�'>�'>�u�'E�'E�'N�P�P��(�(�(�A8�A8�A8�A8�A8��!�A8�A8�A8�JZ8�Z8�Z8�Z8�Z8��!�Z8�Z8�Z8�|
a7�a7�a7�a7�a7��*�a7�a7�a7�HXA�XA�XA�XA�XA��"�XA�XA�XA�v������kJ�kJ�kJ�kJ�kJ�=�9�kJ�kJ�kJ�\	C%�C%�C%�C%�C%��!�C%�C%�C%�L���W�W�R��)�)�+B�C�C�G%�G%�G%�G%�G%��G%�G%�D�C�G%�T6�6�6�6�6�Y�6�6�6����W�W�R��)�)�+B�C�C�	6�	6�	6�	6�	6�j�	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�$�*�*�*�>���W�W�R��-�-�/D�E�E�'*�'*�'*�'*�'*�X�&�'*�'*�F�E�'*�Z�I��.�/�/�1�4�?��y�� 0�1�1�Q�6�?��y�� 8�9�9�Q�>��
���'�=�?�?�������*�7�9�9�J'�J'�J'�J'�J'�X�&�J'�J'�9�9�?�?�J'�Z��"�"�"���"�@���W�W�R��)�)�&�(�(�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�}*�@���W�W�R��(�(�*<�=�=�#0�#0�#0�#0�#0��!�#0�#0�>�=�#0�J������(�*@�A�A�DA�DA�DA�DA�DA�x�(�DA�DA�B�A�DA�L������(�*@�A�A�E0�E0�E0�E0�E0�(�#�E0�E0�B�A�E0�N���S�\�W�,�.D�E�E�sK�sK�sK�sK�sK�X�&�sK�sK�F�E�sK�l���S�\�W�,�.D�E�E�,D�,D�,D�,D�,D��)�,D�,D�F�E�,D�^���W�W�R��,�,�.C�D�D�9+�9+�9+�9+�9+�H�%�9+�9+�E�D�9+�x���S�\�W�,�.D�E�E�
��mB�mB�mB�mB�mB��)�mB�mB���F�E�mB�^���S�\�W�,�.D�E�E�8�8�8�8�8��*�8�8�F�E�8�B���S�\�W�,�.D�E�E�Y!�Y!�Y!�Y!�Y!�8�$�Y!�Y!�F�E�Y!�x��"�"�"�"�"�8�,�"�"���"�>7�7�7�7�7�h�'�7�7�7� 1�1�1�1�1�(�+�1�1�1�$�����EJ�EJ�EJ�EJ�EJ�x� �EJ�EJ���EJ�P�����n,�n,�n,�n,�n,��"�n,�n,���n,�f���O�P�P����W�W�R��,�,�.F�G�G�/�/�/�/�/��"�/�/�H�G�Q�P�/����W�W�R��/�/�N�G�G�B�
�4N�4N�>�@�@������8�,���@�@��,���W�W�R��,�,�.H�I�I�U�U�U�U�U�8�3�U�U�J�I�U�p
�
�
� ���1�1�3�3�?�A�A� ����1�b�)�)�NG�NG�NG�NG�NG�X�.�NG�NG�*�)�A�A�NG�b���W�W�R�!4�5�5�7V�W�W�-+�-+�-+�-+�-+�H�%�-+�-+�X�W�-+�`���W�W�R��0�0�2L�M�M�����2�&�&�2�2�2�2�2�x�(�2�2�'�&�N�M�2����W�W�R��+�+�-B�C�C�����1�b�)�)�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���W�W�R��0�0�D�F�F�����&�(D�E�E�
4�
4�
4�
4�
4�H�%�
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
7F�7F�7F�7F�7F��"�7F�7F�7F�t
/�
/�
/�
/�
/��"�
/�
/�
/� �����B�B�B�B�B��!�B�B���B�"�7�2�y���*�*�*�*�*�*�z�*�*�*��z����H�M�O�O�O�O�O��sl�B�B!� B!�%B*�*B4�3B4�8B=�=C�C�C)�)	C5�4C5�9D�D�D�D�D&�%D&