Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_os.cpython-312.opt-2.pyc

�

'Μg;����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$	ddl%Z%	ddl'Z'	ddl(Z(	ddl)Z)e)jT�D�cgc]}|jV��c}Z,	dd	l.m/Z/m0Z0	ddl2Z2dd
l3m4Z4ddlm5Z5ddl6m7Z7d
Z8e9e	d�re	jt�dk(Z8e9ed�r<ejvjxr&ejvjxj{d�Z>nd
Z>ejFj{d�xre	j~�dk(Z@d�ZAd�d�ZBej�ejFj{d�d�ZDd�ZEGd�dej��ZGGd�dej��ZHGd�dej��ZIGd�dej��ZJddlmKZKGd �d!eKj��ZMGd"�d#ej��ZNej�e9e	d$�d%�Gd&�d'eN��ZPGd(�d)eN�ZQej�e9e	d$�d%�Gd*�d+eP��ZRGd,�d-ej��ZSej�e9e	d.�d/�Gd0�d1ej���ZTGd2�d3ej��ZUej�ej�d4�Gd5�d6ej���ZWGd7�d8ej��ZXej�e9e	d9�d:�Gd;�d<ej���ZYej�d=�d>k(xs,ej�d?�d>k(xsej�d@�d>k(Z[ej�e[dA�ej�ejFdBk(dC�GdD�dEej����Z\ej�d�dF��Z^ej�e9e	dG�dH�GdI�dJej���Z_ej�ejFdKk(dL�GdM�dNej���Z`ej�ej�dO�GdP�dQej���Zaej�e9e	dR�dS�GdT�dUej���Zbej�ejFdKk(dV�GdW�dXej���Zcej�ejFdKk(dV�GdY�dZej���Zdej�ejFdKk(dL�Gd[�d\ej���Zeej�ejFdKk(dL�Gd]�d^ej���Zfej�e	j�d_k(d`�Gda�dbej���Zhej�e9e	dc�dd�Gde�dfej���Ziej�ejFdKk(dL�ej�Gdg�dhej����Zkej�ejFdKk(dL�Gdi�djej���Zlej�ejFdKk(dL�Gdk�dlej���Zmej�Gdm�dnej���ZnGdo�dpej��ZoGdq�drej��Zpej��Gds�dtej���Zrej��Gdu�dvej���Zsej�dw�ej�e9e	dx�dy�Gdz�d{ej����Zuej�e9e	d|�xr	e9e	d}�d~�Gd�d�ej���Zvej�e9e	d��d��Gd��d�ej���Zxd��Zyej�ey�d��ej�d�d�d��Gd��d�ej����Z{ej�e9e	d��d��Gd��d�ej���Z|ej�e9e	d��d��ej�d�d��Gd��d�ej����Z}ej�e9e	d��d��ej�d�d�d��Gd��d�ej����Z~Gd��d�ej��ZGd��d�ej��Z�ej��Gd��d�ej���Z�Gd��d�ej��Z�ej�e9e	d��d��ej�e�jd��ej�ejFdKk(d��Gd��d�ej�����Z�Gd��d�ej��Z�Gd��d�ej��Z�Gd��d�ej��Z�Gd��d�ej��Z�Gd��d�ej��Z�e�j�Gd��d�ej���Z�e9e	d��rGd��d�e��Z�e�d�k(re�j�yy#e&$rdZ%Y�
�]wxYw#e&$rdZ'Y�
�fwxYw#e&$rdZ(Y�
�owxYwcc}w#e&e-f$rgZ,Y�
�VwxYw#e&$rejbxZ/Z0Y�
�gwxYw#e&$rdZ2Y�
�pwxYw)��N)�support)�
import_helper)�	os_helper)�
socket_helper)�set_recursion_limit)�warnings_helper)�win32_is_iot)�INT_MAX�PY_SSIZE_T_MAX��assert_python_ok)�
unix_shell)�FakePathF�geteuid�thread_info�linuxthreads�freebsdc�P�tjtt|�d|z�S)Nzrequires os.%s)�unittest�
skipUnless�hasattr�os��names �)/usr/local/lib/python3.12/test/test_os.py�requires_os_funcrYs"�����w�r�4�0�2B�T�2I�J�J�c�j�t|dd�5}|j|�ddd�y#1swYyxYw)N�xbr)�open�write)�filename�content�fps   r�create_filer%]s(��	
�h��a�	 �B�
�����
!�	 �	 �s�)�2�aixz%on AIX, splice() only accepts socketsc�.�tjd�y�N)�asyncio�set_event_loop_policy�rr�tearDownModuler,gs���!�!�$�'rc��eZdZd�Zd�Zd�Zy)�	MiscTestsc�X�tj�}|j|t�yr()r�getcwd�assertIsInstance�str��self�cwds  r�test_getcwdzMiscTests.test_getcwdls���i�i�k�����c�3�'rc�`�d}tjdk(rd}d}d}|d|t|�z
zz}tj�5}tj|�5}|}	tj�}|j||�|t|�ttjj�zz
}|dkrnft|�|kDr
|dkDr|d|}tjj||�}	tj|�tj|�|}��t&j(rt+dt|����ddd�ddd�y#t$rY�Ct $r(}	|	j"t"j$k(rYd}	~	�m�d}	~	wwxYw#1swY�PxYw#1swYyxYw)	Ni��vxworks�����python_test_dir_�arz!Tested current directory length: )�sys�platform�len�tempfile�TemporaryDirectoryr�
change_cwdrr0�assertEqual�path�sep�join�mkdir�chdir�FileNotFoundError�OSError�errno�ENAMETOOLONGr�verbose�print)
r4�min_len�dirlen�dirname�tmpdirrD�expectedr5�need�excs
          r�test_getcwd_long_pathzMiscTests.test_getcwd_long_pathpsw�����<�<�9�$��G���$���S�F�S��\�$9�:�;��
�
(�
(�
*�f��%�%�f�-������)�)�+�C��$�$�S�(�3�"�c�#�h��R�W�W�[�[�1A�&A�B�D��q�y���7�|�d�*�t�a�x�")�%�4�.���7�7�<�<��g�6�D�"����������� $�H�7�:�?�?��=�c�#�h�Z�H�I�C.�+�
*��(-���"�"��9�9��(:�(:�:�!�!��	"��1.�-��+�
*�sa�F$�BF�5*E�*F�	F$�	F�#F�%F�-F�
F�F�F�F�F!	�F$�$F-c���tj�}|j|t�|j	tj
|�tj��yr()r�getcwdbr1�bytesrC�fsdecoder0r3s  r�test_getcwdbzMiscTests.test_getcwdb�s<���j�j�l�����c�5�)�������S�)�2�9�9�;�7rN)�__name__�
__module__�__qualname__r6rVr[r+rrr.r.ks��(�7J�r8rr.c��eZdZd�ZeZd�Zejejd�ejejd�d���Zejd��Z
d�Zejejeekd�ej$ed	zd
d��d
����Zd�Zd�Zejej.dk(d�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'y#)$�	FileTestsc��tjjtj�r$tj
tj�yyr()rrD�lexistsr�TESTFN�unlink�r4s r�setUpzFileTests.setUp�s/��
�7�7�?�?�9�+�+�,��I�I�i�&�&�'�-rc�6�tjtjtjtj
z�}tj|�|jtjtjtj��yr()
rr rrc�O_CREAT�O_RDWR�close�
assertTrue�access�W_OK�r4�fs  r�test_accesszFileTests.test_access�sQ���G�G�I�$�$�b�j�j����&:�;��
���������	�	�)�"2�"2�B�G�G�<�=rz"Test is unstable under Emscripten.zWASI does not support dup.c�F�tjtjtjtj
z�}tj|�}	d}||dzk7rPtj|�|dz
}|dkDr|jd�|tj|�}}||dzk7r�Ptj|�tj||dz�|jttj|d�y#tj|�wxYw)Nr��
z%couldn't allocate two consecutive fds��a)
rr rrcrhri�duprj�skipTest�
closerange�assertRaisesrJr!)r4�first�second�retriess    r�test_closerangezFileTests.test_closerange�s������	�(�(�"�*�*�R�Y�Y�*>�?��������
	��G��E�A�I�%�������1����R�<��M�M�"I�J� &����v��v��
�E�A�I�%�
�H�H�V��
�
�
�e�U�Q�Y�'����'�2�8�8�U�D�9��
�H�H�V��s
�AD	�	D c���tj}tj|�}|j	t
tj|d�tj|�}|j||�y�Nr)	rrcr=�getrefcountry�	TypeErrorr�renamerC)r4rD�old�news    r�test_renamezFileTests.test_rename�sQ�������o�o�d�#�����)�R�Y�Y��a�8��o�o�d�#������c�"rc��ttjd�5}|jd�|j	�|j�}t
j|dd�t
j|d�}|jt|�t�|j|d�ddd�y#1swYyxYw)N�w+b�spamr�)r rrcr!�flush�filenor�lseek�readrC�typerY)r4�fobj�fd�ss    r�	test_readzFileTests.test_read�s���
�)�"�"�E�
*�d��J�J�w���J�J�L�����B��H�H�R��A������A��A����T�!�W�e�,����Q��(�+�
*�
*�s�BB4�4B=zneeds INT_MAX < PY_SSIZE_T_MAXrsrrF)�size�memuse�dry_runc�^�|jtjtj�t	tjd�ttjd�5}t
j|j�|�}ddd�|jd�y#1swY�xYw)Nstest�rb)
�
addCleanuprrdrcr%r rr�r�rC)r4r�r$�datas    r�test_large_readzFileTests.test_large_read�sx��	
���	�(�(�)�*:�*:�;��I�$�$�g�.��)�"�"�D�
)�R��7�7�2�9�9�;��-�D�*�
	
����w�'�*�
)�s�#%B#�#B,c�f�tjtjtjtj
z�}|j
ttj|d�tj|d�tj|td��tj|td��tj|�ttjd�5}|j|j�j�gd��ddd�y#1swYyxYw)N�beanssbacon
seggs
sspam
r�)sbaconseggsr�)rr rrcrh�O_WRONLYryr�r!�	bytearray�
memoryviewrjrCr��
splitlines)r4r�r�s   r�
test_writezFileTests.test_write�s���
�W�W�Y�%�%�r�z�z�B�K�K�'?�
@�����)�R�X�X�r�7�;�
����Z� �
����Y�y�)�*�
����Z�	�*�+�
�����
�)�"�"�D�
)�T����T�Y�Y�[�3�3�5�,�
.�*�
)�
)�s�-1D'�'D0c�t�tj|tjd��}|j|d�y)NT)�
creationflags�shellr)�
subprocess�call�CREATE_NEW_CONSOLErC)r4�args�retcodes   r�write_windows_consolezFileTests.write_windows_consoles0���/�/�$�$�7�7��	��
	
����!�$r�win32z$test specific to the Windows consolec��d}|jtjd|�|jtjdd|�y)Nzprint('x' * 100000)�-cz-u)r�r=�
executable�r4�codes  r�test_write_windows_consolez$FileTests.test_write_windows_consoles7��%���"�"�3�>�>�4��>��"�"�3�>�>�4��t�Drc��tjtjtj�}tj
|g|��ddi�}|j
�y)N�encoding�utf-8)rr rrc�O_RDONLY�fdopenrj)r4r�r�ros    r�
fdopen_helperzFileTests.fdopen_helpers=��
�W�W�Y�%�%�r�{�{�
3���I�I�b�2�4�2�'�2��	���	rc��tjtjtjtj
z�}tj|�|j�|jd�|jdd�y)N�r�d)rr rrcrhrirjr��r4r�s  r�test_fdopenzFileTests.test_fdopensZ��
�W�W�Y�%�%�r�z�z�"�)�)�';�
<��
������������3�����3��$rc�F�tjdz}|jtjtj�|jtj|�t	tjd�t	|d�tjtj|�|jtt
jtj�t|dd��5}|j|j�d�ddd�y#1swYyxYw)Nz.2�1�2r�r��r��1)
rrcr�rdr%r�replaceryrI�statr rCr�)r4�TESTFN2ros   r�test_replacezFileTests.test_replace's����"�"�T�)�����	�(�(�)�*:�*:�;����	�(�(�'�2��I�$�$�d�+��G�T�"�
�
�
�9�#�#�W�-����+�R�W�W�i�6F�6F�G�
�'�3��
1�Q����Q�V�V�X�s�+�2�
1�
1�s�-!D�D c��tjttjdd��}tj|�y)N�)rD�flags�mode�dir_fd)rr �__file__r�rjrns  r�test_open_keywordszFileTests.test_open_keywords4s(���G�G�����5��
��
����rc��tjtd�}	|dtjdd��y#t
tf$rYywxYw)N�symlink�targetF)�src�dst�target_is_directoryr�)r�
get_attributerrrc�NotImplementedErrorrJ)r4r�s  r�test_symlink_keywordszFileTests.test_symlink_keywords9sG���'�'��I�6��	���i�&6�&6�$)�$�
8��#�W�-�	��	�s�7�A	�A	�copy_file_rangeztest needs os.copy_file_range()c��|jt�5tjddd�ddd�y#1swYyxYw�Nrrri����)ry�
ValueErrorrr�res r�#test_copy_file_range_invalid_valuesz-FileTests.test_copy_file_range_invalid_valuesAs.��
�
�
�z�
*����q�!�S�)�+�
*�
*��	�7�Ac�p�tjdz}d}ttj|�|jtjtj�ttjd�}|j|j�|j�}t|d�}|jtj|�|j|j�|j�}	tj||d�}|j|tdd��t|d�5}|j|j�|d|�ddd�y#1swYyxYw#t$r9}|jtj k7r�|j#|�Yd}~yd}~wwxYw)N�.3�
0123456789r�r��r�)rrcr%r�rdr rjr�rr��assertIn�rangerCr�rJrK�ENOSYSrw)	r4r�r��in_file�in_fd�out_file�out_fd�i�es	         r�test_copy_file_rangezFileTests.test_copy_file_rangeFsC���"�"�T�)�����I�$�$�d�+����	�(�(�)�*:�*:�;��y�'�'��.������
�
�&���� �����'�����	�(�(�'�2�������'����"��	;��"�"�5�&�!�4�A�
�M�M�!�U�1�a�[�)��g�t�$��� � ������b�q��:�%�$�$���	��w�w�%�,�,�&���M�M�!����
	�s$�;E3�:$E'�'E0�3	F5�</F0�0F5c���tjdz}d}d}d}d}ttj|�|jtjtj�ttjd�}|j|j�|j�}t|d�}|jtj|�|j|j�|j�}		tj||	|||��}
|j|
td	|d
z��t|d�5}|j�}ddd�|jd|d|z�|j||d||||
z�y#1swY�=xYw#t$r9}|jtj k7r�|j#|�Yd}~yd}~wwxYw)N�.4r�r��r�r�r�)�
offset_src�
offset_dstrrr�)rrcr%r�rdr rjr�rr�r�r�r�rCrJrKr�rw)
r4�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_offseths����"�"�T�)�����
������I�$�$�d�+����	�(�(�)�*:�*:�;��y�'�'��.������
�
�&���� �����'�����	�(�(�'�2�������'����"��	6��"�"�5�&�-�.5�.6�8�A�
�M�M�!�U�1�m�A�o�6�7��g�t�$���|�|�~��%�
���T�)�8�_�g�h�.>�?�
���T�(�)�_�!�'�'�!�)�4�
6�
%�$���	��w�w�%�,�,�&���M�M�!����
	�s$�F�F�F�	G!�(/G�G!�spliceztest needs os.splice()c��|jt�5tjddd�ddd�y#1swYyxYwr�)ryr�rr�res r�test_splice_invalid_valuesz$FileTests.test_splice_invalid_values�s,��
�
�
�z�
*��I�I�a��C� �+�
*�
*�r�c����tjdz}d}ttj|�|jtjtj�ttjd�}|j|j�|j�}tj�\��|j�fd��|j�fd��	tj|�d�}|j|tdd��|jtj�d	�|d|�y#t$r9}|j t j"k7r�|j%|�Yd}~yd}~wwxYw)
Nr�r�r�c�.��tj��Sr(�rrj��read_fds�r�<lambda>z'FileTests.test_splice.<locals>.<lambda>��������� 1rc�.��tj��Sr(r���write_fds�rr�z'FileTests.test_splice.<locals>.<lambda>��������� 2rr�rr�r�)rrcr%r�rdr rjr�r�piper�r�r�rCr�rJrKr�rw)	r4r�r�r�r�r�r�r�rs	       @@r�test_splicezFileTests.test_splice�s ����"�"�T�)�����I�$�$�d�+����	�(�(�)�*:�*:�;��y�'�'��.������
�
�&���� ���G�G�I�������1�2����2�3�	>��	�	�%��1�-�A�
�M�M�!�U�1�a�[�)����R�W�W�W�c�2�D��!�H�=���	��w�w�%�,�,�&���M�M�!����
	�s�%E�	F�/E?�?Fc�*�
��tjdz}d}d}d}ttj|�|jtjtj�ttjd�}|j|j�|j�}tj�\�
�|j�
fd��|j�fd��	tj|�||��}|j|td	|d
z��tj�
d�}|j|||||z�y#t$r9}	|	j t j"k7r�|j%|	�Yd}	~	yd}	~	wwxYw)Nr�r�r�r�r�c�.��tj��Sr(r�r�s�rr�z1FileTests.test_splice_offset_in.<locals>.<lambda>�r�rc�.��tj��Sr(r�rs�rr�z1FileTests.test_splice_offset_in.<locals>.<lambda>�rr)r�rrrr�)rrcr%r�rdr rjr�rrr�r�r�r�rCrJrKr�rw)r4r�r�r�r�r�r�r�r�r�r�rs          @@r�test_splice_offset_inzFileTests.test_splice_offset_in�s=����"�"�T�)�����
����I�$�$�d�+����	�(�(�)�*:�*:�;��y�'�'��.������
�
�&���� ���G�G�I�������1�2����2�3�	<��	�	�%��=�W�M�A�
�M�M�!�U�1�m�A�o�6�7��7�7�7�C�(�D�
���T�4����	�#:�;���	��w�w�%�,�,�&���M�M�!����
	�s�)E�	F�/F
�
Fc�����tjdz}d}d}d}ttj|�|jtjtj�tj�\��|j�fd��|j�fd��tj�|�t|d�}|jtj|�|j|j�|j�}	tj�|||��}|j|td	|d
z��t|d�5}|j�}	ddd�|j	d|d|z�|j|	|d|d|�y#1swY�:xYw#t $r9}
|
j"t"j$k7r�|j'|
�Yd}
~
yd}
~
wwxYw)
Nr�r�r�r�c�.��tj��Sr(r�r�s�rr�z2FileTests.test_splice_offset_out.<locals>.<lambda>�r�rc�.��tj��Sr(r�rs�rr�z2FileTests.test_splice_offset_out.<locals>.<lambda>�rrr�)r�rrrr�r�)rrcr%r�rdrrr!r rjr�r�r�r�r�rCrJrKr�rw)
r4r�r�r�r�r�r�r�r�r�r�r�rs
           @@r�test_splice_offset_outz FileTests.test_splice_offset_out�s�����"�"�T�)�����
����I�$�$�d�+����	�(�(�)�*:�*:�;��G�G�I�������1�2����2�3�
����4� ����'�����	�(�(�'�2�������'����"��	8��	�	�'�6�=�X�N�A�
�M�M�!�U�1�m�A�o�6�7��g�t�$���|�|�~��%�
���T�)�8�_�g�h�.>�?�
���T�(�)�_�d�2�A�h�7�
%�$���	��w�w�%�,�,�&���M�M�!����
	�s$�F+�F�F(�+	G-�4/G(�(G-N)(r\r]r^rf�tearDownrpr�skipIfr�
is_emscripten�is_wasir}�cpython_onlyr�r�rr
r�
bigmemtestr�r�r�r=r>r�r�r�r�r�r�rrr�r�r�r��requires_splice_piperr	r
r+rrr`r`�s}��(��H�>�
�X�_�_����C���X�_�_����5��:���:�*
���#��#�)�
����X����>�1�9�;��W���W�r�\�!�U�C�(�D�;��(�
.�%��X�������0�?�A�E�A�E��
%�,��
��X�����%6�7�9Z�[�*�\�*��X�����%6�7�9Z�[�;�\�;�B�X�����%6�7�9Z�[�*6�\�*6�X�X�����X�.�0H�I�!�J�!��X�����X�.�0H�I��>��J�>�>�X�����X�.�0H�I��"<��J�"<�H�X�����X�.�0H�I��'8��J�'8rr`c�f�eZdZd�Zd�Zd�Zd�Zd�Zeje
ed�d�d��Zeje
ed�d	�d
��Z
ejejdk(d�d
��Zejejdk(d�eje
ed�d�d���Zd�Zejejdk(d�d��Zejejdk(d�d��Zejejdk(d�d��Zy)�StatAttributeTestsc��tj|_|jtj|j�t|jd�y)N�ABC)rrc�fnamer�rdr%res rrfzStatAttributeTests.setUps5���%�%��
����	�(�(�$�*�*�5��D�J�J��'rc	��tj|�}|j|tjd�|j|jd�t|�}tt�D]x}|dddk(s�|j
�}|jd�rd�}nd�}|j|t||��|tt|��|j||��zdj�D]@}tt||�dz�}t||dz�d	z}|j||d
���B	t|jdz�}|jd	z}|j||d
��	|d|j!d
�	d|_|j!d
�	d|_|j!d
�	d|_|j!d
�	tj,d�}	|j!d
�	tj,d�}	y#t$rY��wxYw#t"$rY��wxYw#t$rY��wxYw#tt(f$rY��wxYw#t$rY��wxYw#t($rY�swxYw#t($rYywxYw)Nr��ST_�TIMEc��t|�Sr()�int��xs r�truncz7StatAttributeTests.check_stat_attributes.<locals>.trunc!s
���Q��-rc��|Sr(r+rs rr!z7StatAttributeTests.check_stat_attributes.<locals>.trunc#s���(rzst_atime st_mtime st_ctimei���_nsi'rt��deltar:�No exception raisedrr�rs�rrrrtr�r�r�r����	rs���
�)rr�rC�ST_SIZE�st_size�dir�lower�endswith�getattrr��splitr�assertAlmostEqual�st_birthtime�st_birthtime_ns�AttributeError�fail�
IndexError�st_mode�st_rdevr��parrot�stat_result)
r4r�result�membersr�attrr!�floaty�nanosecondy�result2s
          r�check_stat_attributesz(StatAttributeTests.check_stat_attributessv��������	
�������-�q�1��������+��f�+����I�D��B�Q�x�5� ��z�z�|���=�=��(�/�*�� � ��w�v�t�'<�!=�"(���t�)<�"=�?��
�
�d�G�,��1�6�6�8�D�����.��7�8�F�!�&�$��,�7�5�@�K��"�"�6�;�a�"�@�9�	A���,�,�v�5�6�F� �0�0�E�9�K�
�"�"�6�;�a�"�@�	��3�K��I�I�+�,�
	��F�N��I�I�+�,�	��F�N��I�I�+�,�	��F�M��I�I�+�,�
	��n�n�U�+�G��I�I�+�,�
	��n�n�%I�J�G��O�	��	���	��	���	��	���	�*�	��	���	��	���	��	���	��	�s~�>'H�:H(�H7�*I�I�&I*�I9�	H%�$H%�(	H4�3H4�7	I�I�I�I�	I'�&I'�*	I6�5I6�9	J�Jc�:�|j|j�yr()rGrres r�test_stat_attributesz'StatAttributeTests.test_stat_attributes^s���"�"�4�:�:�.rc���	|jjtj��}|j
�y#t$r!|jd|jz�Y�;wxYw)Nz#cannot encode %a for the filesystem)r�encoder=�getfilesystemencoding�UnicodeEncodeErrorrwrG)r4rs  r�test_stat_attributes_bytesz-StatAttributeTests.test_stat_attributes_bytesas^��	N��J�J�%�%�c�&?�&?�&A�B�E�	
�"�"�5�)��"�	N��M�M�?�$�*�*�L�M�	N�s�-A�'A+�*A+c��tj|j�}ttj
dz�D]�}|j
d|���5t	j||�}|jd|�|dkr|jd|�t	j|�}|j||�ddd���y#1swY��xYw)Nrrz	protocol sstat_resultr�scos
stat_result
)rr�rr��pickle�HIGHEST_PROTOCOL�subTest�dumpsr��loadsrC�r4rA�proto�p�	unpickleds     r�test_stat_result_picklez*StatAttributeTests.test_stat_result_picklehs���������$���6�2�2�Q�6�7�E����	�%��1�2��L�L���/���
�
�n�a�0��1�9��M�M�"7��;�"�L�L��O�	�� � ���3�
3�2�8�2�2�s
�A'C�C	�statvfsztest needs os.statvfs()c���tj|j�}|j|j|d�d}t|�D]'\}}|jt
|d|z�||��)|jt|jt��|jt|�d�	d|_|jd�	d|_|jd�	tjd�}|jd�	tjd�}y#t$rY�bwxYw#t$rY�XwxYw#t $rY�@wxYw#t $rYywxYw)	Nr�)
�bsize�frsize�blocks�bfree�bavail�files�ffree�favail�flag�namemax�f_rsrrr&r'r()rrZrrC�f_bfree�	enumerater5rk�
isinstance�f_fsidrr?r;r:r?�statvfs_resultr�)r4rArB�value�memberrFs      r�test_statvfs_attributesz*StatAttributeTests.test_statvfs_attributesssM�����D�J�J�'��	
���������3�:��&�w�/�M�E�6����W�V�T�F�]�;�V�E�]�K�0�	
���
�6�=�=�#�6�7�	
����V��b�)�	��F�N��I�I�+�,�	��F�M��I�I�+�,�
	��'�'��.�G��I�I�+�,�
	��'�'�(L�M�G��%�	��	���	��	���	��	���	��	�sH�;D*�D9�-&E�E�*	D6�5D6�9	E�E�	E�E�	E#�"E#�need os.statvfs()c�P�tj|j�}ttj
dz�D]h}t	j||�}|jd|�|dkr|jd|�t	j|�}|j||��jy)Nrrsstatvfs_resultr�scos
statvfs_result
)
rrZrr�rPrQrSr�rTrCrUs     r�test_statvfs_result_picklez-StatAttributeTests.test_statvfs_result_pickle�s������D�J�J�'���6�2�2�Q�6�7�E����V�U�+�A��M�M�+�Q�/��q�y��
�
�6��:����Q��I����V�Y�/�
8rr��Win32 specific testsc��	tjd�y#t$r|jd�Yyt$r}|jd�Yd}~yd}~wwxYw)Nzc:\pagefile.syszc:\pagefile.sys does not existzCould not stat pagefile.sys)rr�rIrwrJr;�r4r�s  r�test_1686475zStatAttributeTests.test_1686475�sI��	5��G�G�&�'�� �	=��M�M�;�<��	5��I�I�3�4�4��	5�s��A�A�A�Arzrequires os.pipe()c��tj�\}}	tj|�tj|�tj|�|j	t
�5}tj|�ddd�|j
jjtj�y#tj|�tj|�wxYw#1swY�mxYwr()
rrr�rjryrJrC�	exceptionrK�EBADF)r4r��w�ctxs    r�
test_15261zStatAttributeTests.test_15261�s����w�w�y���1�	��G�G�A�J��H�H�Q�K��H�H�Q�K�
�
�
�w�
'�3��G�G�A�J�(�������,�,�e�k�k�:��	
�H�H�Q�K��H�H�Q�K��
'�
'�s�C�-C/�,C,�/C8c���|jt|d��|jt|jt��|jd|jcxkxr
dk�yc�y)N�st_file_attributesr���)rkrrir}r)r4rAs  r�check_file_attributesz(StatAttributeTests.check_file_attributes�sQ�������(<�=�>����
�6�#<�#<�c�B�C�����V�6�6�D�*�D�E�D�Erz$st_file_attributes is Win32 specificc��tj|j�}|j|�|j	|j
tjzd�tjdz}tj|�|jtj|�tj|�}|j|�|j	|j
tjztj�y)Nrr2)rr�rrrCr}�FILE_ATTRIBUTE_DIRECTORYrrcrGr��rmdir)r4rArQs   r�test_file_attributesz'StatAttributeTests.test_file_attributes�s���������$���"�"�6�*�����%�%��(E�(E�E�
�	�
�"�"�U�*��
�����������'�*�����!���"�"�6�*�����%�%��(E�(E�E��)�)�	+rc���tjjtjd|jdz�}|jtj|�t|d�d}tjd|ddg|��tj|�}|j|jd	�|jtjj|��y)
N�TEMP�_accessrr*z
icacls.exez/denyz*S-1-5-32-545:(S)�r�r)rrDrF�environrr�rrdr%r��
check_callr��assertNotEqualr1rk�isfile)r4r�DETACHED_PROCESSrAs    r�test_access_deniedz%StatAttributeTests.test_access_denied�s��������R�Z�Z��/����i�1G�H�����	�(�(�%�0��E�6�"�������5�'�+>�?�*�		
����������F�N�N�A�.���������u�-�.rc���dtjjtj��dz}tj|�}|j|jtj�y)Nz//./r)rrD�
splitdriver0r�rCr=�S_IFBLK)r4rrAs   r�test_stat_block_devicez)StatAttributeTests.test_stat_block_device�sM������+�+�B�I�I�K�8��;�;�����������������6rN)r\r]r^rfrGrIrNrYrrrrrnrqr=r>rur{rr�r�r�r+rrrrs���(�
H�T/�*�	4��X�����Y�/�1J�K�)�L�)�V�X�����Y�/�,�.�	0�.�	0��X�������0�2H�I�5�J�5��X�������0�2H�I��X�����V�,�.B�C�
;�D�J�
;�F�
�X�������0�?�A�+�A�+�&�X�������0�2H�I�/�J�/�*�X�������0�2H�I�7�J�7rrc��eZdZd�Zd�Zdd�Zd�Zed��Zd�Z	d�Z
eje
je
jvd	�d
��Zeje
je
j"vd�d��Zeje
je
j&vd
�d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zej:d��Zy)�
UtimeTestsc�H�tj|_tjj|jd�|_|jtj|j�tj|j�t|j�y)N�f1)rrcrQrrDrFrr��rmtreerGr%res rrfzUtimeTests.setUp�s]�� �'�'����W�W�\�\�$�,�,��5��
����	�(�(�$�,�,�7�
��������D�J�J�rc��tj|�}|j|dk7xs&|j|dk7xs|j|dk7S)Nr)r*r+)rr��st_atime�st_mtime�st_ctime)r4r"�sts   r�support_subsecondzUtimeTests.support_subsecondsQ���W�W�X�
������1��%�*��K�K�2�a�5�(�*��K�K�2�a�5�(�	+rNc��|s|j}|j|�}|rd}d}nd}d}||||f�tj|�}|rC|j	|j
|dzd��|j	|j|dzd��n>|j|j
|dz�|j|j|dz�|j|j|�|j|j|�y)Ni8Z�;l�
o]�rTlP�9��&�.>g���ư>r$)
rr�rr�r7r�r�rC�st_atime_ns�st_mtime_ns)r4�set_timer"r��atime_ns�mtime_nsr�s       r�_test_utimezUtimeTests._test_utimes�����z�z�H� �2�2�8�<���"�H�!�H�!�H� �H���H�h�/�0�
�W�W�X�
����"�"�2�;�;��4��t�"�L��"�"�2�;�;��4��t�"�L����R�[�[�(�T�/�:����R�[�[�(�T�/�:��������2��������2rc�,�d�}|j|�y)Nc�2�tj||��y�N��ns�r�utime�r"r�s  rr�z'UtimeTests.test_utime.<locals>.set_time.����H�H�X�"�%r�r��r4r�s  r�
test_utimezUtimeTests.test_utime-s��	&�	
����"rc��|dzdzS)Nr�g��&�.>r+r�s r�	ns_to_seczUtimeTests.ns_to_sec3s��
�T�	�V�#�#rc�2���fd�}�j|�y)Nc���|\}}�j|�}�j|�}tj|||f�yr(�r�rr��r"r�r�r��atime�mtimer4s      �rr�z2UtimeTests.test_utime_by_indexed.<locals>.set_time<s=���!#��H�h��N�N�8�,�E��N�N�8�,�E�
�H�H�X��u�~�.rr�r�s` r�test_utime_by_indexedz UtimeTests.test_utime_by_indexed:s���	/�	
����"rc�2���fd�}�j|�y)Nc���|\}}�j|�}�j|�}tj|||f��y)N)�timesr�r�s      �rr�z0UtimeTests.test_utime_by_times.<locals>.set_timeFs;���!#��H�h��N�N�8�,�E��N�N�8�,�E��H�H�X�e�U�^�4rr�r�s` r�test_utime_by_timeszUtimeTests.test_utime_by_timesEs���	5�	
����"rz9follow_symlinks support for utime required for this test.c�,�d�}|j|�y)Nc�4�tj||d��y)NF)r��follow_symlinksr�r�s  rr�z9UtimeTests.test_utime_nofollow_symlinks.<locals>.set_timeRs��
�H�H�X�"�e�<rr�r�s  r�test_utime_nofollow_symlinksz'UtimeTests.test_utime_nofollow_symlinksNs��	=�	
����"rz,fd support for utime required for this test.c�,�d�}|j|�y)Nc��t|dd�5}tj|j�|��ddd�y#1swYyxYw)N�wbrr�)r rr�r�)r"r�r$s   rr�z*UtimeTests.test_utime_fd.<locals>.set_time[s2���h��a�(�B���������,�)�(�(�s	�&=�Ar�r�s  r�
test_utime_fdzUtimeTests.test_utime_fdXs��	-�
	
����"rz0dir_fd support for utime required for this test.c�,�d�}|j|�y)Nc���tjj|�\}}tj|�5}tj
|||��ddd�y#1swYyxYw)N)r�r�)rrDr6r�open_dir_fdr�)r"r�rQr�dirfds     rr�z.UtimeTests.test_utime_dir_fd.<locals>.set_timeesD���G�G�M�M�(�3�M�G�T��&�&�w�/�5�����e��3�0�/�/�s�A�A#r�r�s  r�test_utime_dir_fdzUtimeTests.test_utime_dir_fdbs��	4�
	
����"rc�D�d�}|j||j��y)Nc�2�tj||��yr�r�r�s  rr�z1UtimeTests.test_utime_directory.<locals>.set_timemr�r)r")r�rQr�s  r�test_utime_directoryzUtimeTests.test_utime_directoryls ��	&�	
����D�L�L��9rc�P�tj�}||j�|j|j�sd}nd}tj|j�}d|j
�d|�d|j
|z
��}|j
|j
|||��y)Ng�?g�������?zst_time=z
, current=z, dt=)r%�msg)�timerr�rr�r�r7)r4r��currentr%r�r�s      r�_test_utime_currentzUtimeTests._test_utime_currentrs����)�)�+��	������%�%�d�j�j�1��E��E�
�W�W�T�Z�Z�
 ���+�+�w����g�(=�?�����r�{�{�G�%*��	�	5rc�2���fd�}�j|�y)Nc�D��tj�j�yr(�rr�r�r"r4s �rr�z/UtimeTests.test_utime_current.<locals>.set_time�s����H�H�T�Z�Z� r�r�r�s` r�test_utime_currentzUtimeTests.test_utime_current�s���	!�	
� � ��*rc�2���fd�}�j|�y)Nc�F��tj�jd�yr(r�r�s �rr�z3UtimeTests.test_utime_current_old.<locals>.set_time�s����H�H�T�Z�Z��&rr�r�s` r�test_utime_current_oldz!UtimeTests.test_utime_current_old�s���	'�	
� � ��*rc�f�tjdk(r�tjj	tjj|��ddz}ddl}|jj}|jdd�}|j|ddddd|t|��}|r|jSyy)Nr�r�\�r�)
r=r>rrDr��abspath�ctypes�windll�kernel32�create_unicode_buffer�GetVolumeInformationWr?rl)r4rD�rootr�r��buf�oks       r�get_file_systemzUtimeTests.get_file_system�s����<�<�7�"��7�7�%�%�b�g�g�o�o�d�&;�<�Q�?�$�F�D���}�}�-�-�H��.�.�r�3�7�C��/�/��d�A�04�d�D�03�S��X�?�B���y�y� ��#rc��|j|j�dk7r|jd�d}tj|j
||f�|j
tj|j
�j|�y)N�NTFSz
requires NTFSr�)	r�rQrwrr�rrCr�r�)r4�larges  r�test_large_timezUtimeTests.test_large_time�se��������-��7��M�M�/�*���
������e�U�^�,����������,�5�5�u�=rc��|jt�5tj|jdd��ddd�|jt
�5tj|jddg�ddd�|jt
�5tj|jd�ddd�|jt
�5tj|jd�ddd�|jt
�5tj|jddg��ddd�|jt
�5tj|jd��ddd�|jt
�5tj|jd��ddd�tjtjvr@|jt�5tj|jdd��ddd�tjtjvrbt|jdd	�5}|jt
�5tj|j�d�ddd�ddd�tjtjvrA|jt�5tj|jdd	�
�ddd�yy#1swY���xYw#1swY���xYw#1swY��exYw#1swY��4xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��IxYw#1swY��xYw#1swY��xYw#1swYyxYw)N)r�r�r�r�)r�)r�r�r�F�r�r�r�r�)ryr�rr�rr��supports_follow_symlinksr��supports_fdr r��supports_dir_fd)r4r$s  r�test_utime_invalid_argumentsz'UtimeTests.test_utime_invalid_arguments�s4��
�
�
�z�
*��H�H�T�Z�Z��F�3�+�
�
�
�y�
)��H�H�T�Z�Z�!�Q��(�*�
�
�
�y�
)��H�H�T�Z�Z��&�*�
�
�
�y�
)��H�H�T�Z�Z��+�*�
�
�
�y�
)��H�H�T�Z�Z�Q��F�+�*�
�
�
�y�
)��H�H�T�Z�Z�D�)�*�
�
�
�y�
)��H�H�T�Z�Z�I�.�*��8�8�2�6�6�6��"�"�#6�7�������V�U�C�8�
�8�8�2�>�>�)��d�j�j�$��*�b��&�&�y�1��H�H�R�Y�Y�[�&�1�2�+��8�8�2�-�-�-��"�"�#6�7�������V�A�6�8�7�.�-+�
*��
)�
)��
)�
)��
)�
)��
)�
)��
)�
)��
)�
)��8�7��2�1��+�*��8�7�s��#L�#L
�!L�!L'�$L4�"M�"M�1#M�M4�)%M(�M4�#N�L
�
L�L$�'L1�4L>�M�M�M%�(M1	�-M4�4M=�N	c��d�}|jt�5tj|j|d�df��ddd�|jt�5tj|j|d�df��ddd�|jt�5tj|j|d�df��ddd�y#1swY��xYw#1swY�]xYw#1swYyxYw)Nc�*��G�fd�d�}|�S)Nc���eZdZ�fd�Zy)�?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)r\r]r^r�)r�s�r�BadIntr��s���*rr�r+)r�r�s` r�get_bad_intz/UtimeTests.test_issue31577.<locals>.get_bad_int�s���
*�
*��8�Or�*rrr�r+)rrrtr�)ryr�rr�r)r4r�s  r�test_issue31577zUtimeTests.test_issue31577�s���	�
�
�
�y�
)��H�H�T�Z�Z�[��_�a�$8�9�*�
�
�
�y�
)��H�H�T�Z�Z�[��_�a�$8�9�*�
�
�
�y�
)��H�H�T�Z�Z�[��%;�Q�$?�@�*�
)�	*�
)��
)�
)��
)�
)�s#�*C� *C&�'*C2�C#�&C/�2C;r()r\r]r^rfr�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�>#��$��$�	#�#��X������R�%@�%@�@�*�+�#�+�#��X������R�^�^�3�G�I�#�I�#��X������R�%7�%7�7�K�M�#�M�#�:�5�,+�+�
!�>�7�8
���
A��
Arr�)�
mapping_testsc���eZdZ	dZd�Zd�Zd�Zd�Zeje
xrejje
�d�ejeed�d�ej �d	����Zeje
xrejje
�d�ejeed�d�ej �d
����Zd�Zd�Zd
�Zd�Zejej.d�d��Zej �d��Zej4dd�d��Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&y) �EnvironTestsNc��ttj�|_tjrttj
�|_|j�j�D]\}}|tj|<�yr()	�dictrr��_EnvironTests__save�supports_bytes_environ�environb�_EnvironTests__saveb�
_reference�items�r4�keyrls   rrfzEnvironTests.setUp�sV���2�:�:�&���
�$�$�����,�D�L��/�/�+�1�1�3�J�C��#�B�J�J�s�O�4rc�B�tjj�tjj|j�tj
rHtjj�tjj|j�yyr()rr��clear�updaterrrr	res rrzEnvironTests.tearDown�s\��
�
�
����
�
�
���$�+�+�&�
�$�$��K�K�����K�K���t�|�|�,�%rc��dddd�S)N�VALUE1�VALUE2�VALUE3)�KEY1�KEY2�KEY3r+res rr
zEnvironTests._reference�s�����B�Brc�^�tjj�tjSr()rr�rres r�_empty_mappingzEnvironTests._empty_mapping�s��
�
�
�����z�z�rzrequires a shell�popenzneeds os.popen()c�B�tjj�tjjd��tjdt
z�5}|j
�j�}|j|d�ddd�y#1swYyxYw)N�World)�HELLOz%s -c 'echo $HELLO')	rr�rrrrr��striprC)r4rrls   r�test_update2zEnvironTests.test_update2�sm��
	�
�
����
�
�
�����(�
�X�X�+�j�8�
9�U��J�J�L�&�&�(�E����U�G�,�:�
9�
9�s�1B�Bc�T�tjdtz�5}t|�}|j	t|�d�|j	t|�d�|j	t|�d�|j
tt
|�ddd�y#1swYyxYw)Nz %s -c 'echo "line1
line2
line3"'zline1
zline2
zline3
)rrr�iterrC�nextry�
StopIteration)r4r�its   r�test_os_popen_iterzEnvironTests.test_os_popen_iter�s���
�X�X�<�"�#�$�',��e��B����T�"�X�y�1����T�"�X�y�1����T�"�X�y�1����m�T�2�6�
$�$�$�s�A8B�B'c���tjj�D]C\}}|jt	|�t
�|jt	|�t
��Eyr()rr�rrCr�r2)r4r
�vals   r�test_keyvalue_typesz EnvironTests.test_keyvalue_typessE���
�
�(�(�*�H�C�����T�#�Y��,����T�#�Y��,�+rc��|j�j�D]4\}}|jtjj|�|��6yr()r
rrCrr��getrs   r�
test_itemszEnvironTests.test_itemss=���/�/�+�1�1�3�J�C�����R�Z�Z�^�^�C�0�%�8�4rc��	tj}djd�|j�D��}|j	t|�d|�d��y)Nz, c3�0K�|]\}}|�d|�����y�w)z: Nr+)�.0r
rls   r�	<genexpr>z-EnvironTests.test___repr__.<locals>.<genexpr>s'����$
�)�
��U��g�R��y�!�)�s�z	environ({z}))rr�rFrrC�repr)r4�env�formatted_itemss   r�
test___repr__zEnvironTests.test___repr__sO��L��j�j���)�)�$
�!�i�i�k�$
�
��	
����c��j��0A��$E�Frc�z�tjjtj�}gd�}dtjj	|�i}tj
}	t
|�t_|j|tj��|j|tjd���|t_|j|tji��|jdtjddi��|j|tj|��tjr�	tjd��5dd	d
�}ddd�|jttj�|jtjddi�d
g�|jtjdd
i�d
g�|jtjddi�d
g�yy#|t_wxYw#1swY��xYw#t$rY��wxYw)N)z/montyz/pythonr�z/flying/circus�PATH�r1�r�r�T)�recordr�r�)r5�PATHr9�abc�abc)r�defpathr6�pathseprFr�r�assertSequenceEqual�
get_exec_pathr�warnings�catch_warningsryr��BytesWarning)r4�defpath_list�	test_path�test_env�
saved_environ�	mixed_envs      r�test_get_exec_pathzEnvironTests.test_get_exec_path!s����z�z�'�'��
�
�3��?�	��B�J�J�O�O�I�6�7���
�
�
�	'��h��B�J��$�$�Y��0@�0@�0B�C��$�$�Y��0@�0@�T�0J�K�&�B�J�	
� � ��r�/?�/?��/C�D�� � ���(8�(8�&���(E�F�� � ��B�,<�,<�X�,F�G�
�$�$�
K��,�,�D�9�),�t� <�I�:��!�!�*�b�.>�.>�	�J�
�$�$�R�%5�%5�w��6G�%H���
��$�$�R�%5�%5�w��6F�%G���
��$�$�R�%5�%5�v�v�6F�%G���
�#%��'�B�J��:�9���
��
�s7�$AH�H.�%H"�+H.�
H�"H+�'H.�.	H:�9H:z#os.environb required for this test.c�r�d}	|jtj�d�}|t
jd<|jt
jd|�|jt
jd�d}|t
jd<|jt
jd|�|jtj�d�}|jt
jd|�y#t$r,dtj���}|j	|�Y��
wxYw)	Nueuro€�surrogateescapez%U+20AC character is not encodable to �unicodesunicode��sbytesrY)
rKr=rLrMrwrr�rCr�decode)r4rl�value_bytesr��	value_strs     r�
test_environbzEnvironTests.test_environbJs�����	��,�,�s�'@�'@�'B�'8�:�K�!&��
�
�9��������I�.��6�������Z�0�+�>��� %����H��������X�.��6��L�L��!:�!:�!<�>O�P�	�������G�,�i�8��"�	��)�)�+�.�C��M�M�#��	�s�$D�1D6�5D6c��d}d}d|�d�}tj�5}|j|d�tj||�tjtjd|gdt
jd��}|j|jj�t|��tj|�tjtjd|gdt
jd��}|j|jj�td��ddd�y#1swYyxYw)N�
PYTHONTESTVAR�	testvaluez%import os; print(repr(os.environ.get(z)))r�T)�check�stdout�text)r�EnvironmentVarGuard�popr�putenvr��runr=r��PIPErCrU�rstripr0�unsetenv)r4rrlr�r1�procs      r�test_putenv_unsetenvz!EnvironTests.test_putenv_unsetenvas�������6�t�h�c�B��
�
*�
*�
,���G�G�D�$���I�I�d�E�"��>�>�3�>�>�4��">�d�)3���t�E�D����T�[�[�/�/�1�4��;�?��K�K����>�>�3�>�>�4��">�d�)3���t�E�D����T�[�[�/�/�1�4��:�>�-�
,�
,�s�DD<�<Ersr�c�x�dD]Y}|jttftj|d�|jttftj
|��[dD]M}|jttj|d�|jttj
|��Otjdk(rwddz}|jttj|d�|jttjd|�|jttj
|�yy)	N)r�z=namezna=mezname=rl)znameznamer�r ��r��X)ryrJr�rrYr]r=r>)r4r�longstrs   r�test_putenv_unsetenv_errorz'EnvironTests.test_putenv_unsetenv_errorus���4�D����w�
�3�R�Y�Y��g�N����w�
�3�R�[�[�$�G�4�)�D����j�"�)�)�T�7�C����j�"�+�+�t�<�)��<�<�7�"��F�l�G����j�"�)�)�W�c�B����j�"�)�)�S�'�B����j�"�+�+�w�?�
#rc�p�d}|j|tj�|jt�5}tj|ddd�|jjjd|�|j|jj�|jt�5}tj|=ddd�|j|jjd|�|j|jj�y#1swY��xYw#1swY�dxYw)N�
missingkeyr)
�assertNotInrr�ry�KeyError�assertIsrwr�rk�__suppress_context__)r4�missing�cms   r�
test_key_typezEnvironTests.test_key_type�s���������"�*�*�-�
�
�
�x�
(�B��J�J�w��)��
�
�b�l�l�'�'��*�G�4�������9�9�:�
�
�
�x�
(�B��
�
�7�#�)��
�
�b�l�l�'�'��*�G�4�������9�9�:�)�
(��
)�
(�s�D �7D,� D)�,D5c��t|�}d}t|�dtj|<	t|�|j	tj|d�tj|=y#tj|=wxYw)N�__new_key__�test_environ_iteration)r!r"rr�rC)r4�
collection�iterator�new_keys    r�_test_environ_iterationz$EnvironTests._test_environ_iteration�sg���
�#�����X��7��
�
�7��	$���N����R�Z�Z��0�2J�K��
�
�7�#���
�
�7�#�s�.A-�-Bc�B�|jtj�yr()rtrr�res r�(test_iter_error_when_changing_os_environz5EnvironTests.test_iter_error_when_changing_os_environ�s���$�$�R�Z�Z�0rc�^�|jtjj��yr()rtrr�rres r�.test_iter_error_when_changing_os_environ_itemsz;EnvironTests.test_iter_error_when_changing_os_environ_items�s���$�$�R�Z�Z�%5�%5�%7�8rc�^�|jtjj��yr()rtrr��valuesres r�/test_iter_error_when_changing_os_environ_valuesz<EnvironTests.test_iter_error_when_changing_os_environ_values�s���$�$�R�Z�Z�%6�%6�%8�9rc�B�tr#tjjt�sytj
sytjt�d|�d��5}|j�j�}ddd�|j|�y#1swY�xYw)Nz -c 'echo $�')
rrrD�existsr�has_subprocess_supportrr�rrC)r4�varrSrrls     r�_test_underlying_process_envz)EnvironTests._test_underlying_process_env�sr���r�w�w�~�~�j�9���/�/��
�X�X���K��u�A�6�
7�5��J�J�L�&�&�(�E�8�	
����5�)�8�
7�s�B�Bc���d}d}|tj|<dddd|di}ttj�}|j|�tj|z}|j	||�|jd||�|j
�}|jttjj|��|jdd�|j||�y�	N�
_TEST_VAR_�original_value�_A_r��_B_�2�3r�)rr�rr�assertDictEqualrCrri�NotImplemented�__or__r��r4�overridden_keyr��
new_vars_dictrS�actual�new_vars_itemss       r�test_or_operatorzEnvironTests.test_or_operator�s���%��)��%3��
�
�>�"���U�C���E�
���
�
�#�����
�&����m�+�����X�v�.�����f�^�4�5�&�,�,�.���
�
�n�b�j�j�&7�&7��&G�H��)�)�%��4��)�)�.�.�Irc��d}dtj|<dddd|di}ttj�}|j|�txj|zc_|j	|tj�|j	dtj|�|jdd�|j|d�y)Nr�r�r�r�r�r�r��rr�rrrCr�)r4r�r�rSs    r�test_ior_operatorzEnvironTests.test_ior_operator�s���%��%5��
�
�>�"���U�C���E�
���
�
�#�����
�&�
�
�
�m�#�
�����2�:�:�.�����b�j�j��8�9��)�)�%��5��)�)�.�#�>rc��tjj�}|jt�5ddi}txj|zc_ddd�|jt�5ddi}txj|zc_ddd�|j|tj�y#1swY�exYw#1swY�6xYw)Nrrr�)rr��copyryr�rC)r4�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�*��
�
�y�
)�!&��
���J�J�+�+�J�*�
	
����"�*�*�5�*�
)��*�
)�s�B6�/C�6B?�Cc��d}dtj|<dd|dff}ttj�}|j|�txj|zc_|j	|tj�|j	dtj|�|jdd�|j|d�y)Nr�r�)r�r�)r�r�r�r�r�r�)r4r�r�rSs    r�$test_ior_operator_key_value_iterablez1EnvironTests.test_ior_operator_key_value_iterable�s���%��%5��
�
�>�"�&��~�s�6K�L����
�
�#������'�
�
�
�n�$�
�����2�:�:�.�����b�j�j��8�9��)�)�%��5��)�)�.�#�>rc���d}d}|tj|<dddd|di}t|�}|jtj�|tjz}|j	||�|j|||�|j
�}|jttjj|��|jdd�|j||�yr�)rr�rrr�rCrrir��__ror__r�r�s       r�test_ror_operatorzEnvironTests.test_ror_operator�s���%��)��%3��
�
�>�"���U�C���E�
��
�&������
�
�#�����+�����X�v�.�������)?�@�&�,�,�.���
�
�n�b�j�j�&8�&8��&H�I��)�)�%��4��)�)�.�.�Ir)'r\r]r^�	type2testrfrr
rrrrrrDr~rr�requires_subprocessrr%r(r+r3rHrrPr_�requires_mac_verrdrmrtrvrxr{r�r�r�r�r�r�r+rrrr�s���B��I�$�-�C��
�X����B������z�(B�+�-��X�����W�-�/A�B� �W� � �"�-�#�C�-�-��X����B������z�(B�+�-��X�����W�-�/A�B� �W� � �"�7�#�C�-�7�-�
9�
G�'�R�X����2�2�>�@�9�@�9�*!�W� � �"�?�#�?�&�W���b�!�$�@�%�@�$;�
$�1�9�:�	*�J�&
?�6�
?�Jrrc�b�eZdZ	dZd�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Ze
jeed�d
�e
j"ej&dk(d�d���Ze
jeed�d
�e
j"ej&dk(d�d���Zd�Zd�Zy)�	WalkTestsFc�^�d|vr|jd�|d<tj|fi|��S�Nr��followlinks)rXr�walk)r4�top�kwargss   rr�zWalkTests.walks2����&�$*�J�J�/@�$A�F�=�!��w�w�s�%�f�%�%rc�<�tjj}|jtj
tj�|tjd�|_||jd�|_||jd�|_	||jd�}||d�}||jd�|_
||jd�}||d�}||d�}||d	�|_|tjd
�}|tjd
d�}||d�|_||d
�}	||d�}
tj|j�tj|�tj|�tj|�|j||||fD]0}t|dd��5}|jd|zdz�ddd��2t	j �r�tj"tjj%|�|j�tj"d|jd�tj"|dd�|	d�tj"|dd�|
d�|dd	ggd�f|_n|dgdgf|_t(j*stj,|d�	tj.|�tj,|t0j2�tj4|�tj6|�|j&ddd�=y#1swY���xYw#t8$r2|jtj,|t0j2�YywxYw)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�rrr)rrDrFr�rr�rc�	walk_path�	sub1_path�
sub11_path�	tmp1_path�	link_path�broken_link_path�makedirsr r!�can_symlinkr�r��	sub2_treerr�chmod�listdirr��S_IRWXUrdr��PermissionError)
r4rF�	sub2_path�
sub21_path�	tmp2_path�	tmp3_path�	tmp5_path�t2_path�	tmp4_path�broken_link2_path�broken_link3_pathrDros
             rrfzWalkTests.setUps����w�w�|�|�����	�(�(�)�*:�*:�;�&�i�.�.��8����d�n�n�f�5����t�~�~�w�7��������0�	��)�W�-�
��d�n�n�f�5��������0�	���F�+�	���V�,�	��i��0����y�'�'��1����)�)�7�F�;�	� $�Y�
� >��� ��N�;�� ��N�;��	���D�O�O�$�
���I��
���J��
���G���N�N�I�y�)�Y�N�D��d�C�'�2�a������
�(M�M�N�3�2�O�� � �"��J�J�r�w�w���w�/����@��J�J�x��!6�!6��=��J�J�t�F�H�-�/@�$�G��J�J�t�G�V�,�.?��F�'�'�6�):�'�(�D�N�(�'��V�H�=�D�N��$�$��H�H�Z��#�	&��J�J�z�"�
�H�H�Z����.��I�I�i� ��H�H�Z� ����q�!�"�1�"�%�33�2��&�	@��O�O�B�H�H�j�$�,�,�?�	@�s�M�M �M	� 8N�Nc�f�t|j|j��}|jt	|�d�|ddddk7}|ddj�|dd|zz
dj�|dd|zz
dj�|j|d|jddgd	gf�|j|d|z|jd
gdgf�|j|d|z|jggf�|j|dd|zz
|j�y)Nr�rrrr�r�rt���r�r�r�r�)	�listr�r�rCr?�sortr�r�r��r4�all�flippeds   r�test_walk_topdownzWalkTests.test_walk_topdown]s&���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�����Q��[�)�D�N�N�W�I��x�+P�Q�����Q��[�)�D�O�O�R��+D�E�����Q��W��_�-�t�~�~�>rNc��|�|j}g}|j|�D]0\}}}|j|||f�d|vs� |jd��2|j	t|�d�|j	|d|jdgdgf�|ddj
�|ddj
�|j	|d|j�y)Nr�rtrr�r�rrr�)r�r��append�removerCr?r�r�)r4r�r�r��dirsras      r�test_walk_prunezWalkTests.test_walk_prunens��������I���!%���9�!5��D�$���J�J��d�E�*�+���~����F�#�"6�	
����S��1�%�����Q��$�.�.�6�(�V�H�!E�F��A��r�
�����A��q�	��������Q�����0rc�L�|jt|j��yr()r�rr�res r�test_file_like_pathzWalkTests.test_file_like_path�s�����X�d�n�n�5�6rc�f�t|j|jd���}|jt	|�d|�|ddddk7}|ddj�|dd|zz
d	j�|dd|zz
dj�|j|d|jdd
gdgf�|j|||jggf�|j||dz|jdgd
gf�|j|dd|zz
|j�y)NF��topdownr�r�rrrr�rtr�r�r�r�r�)	r�r�r�rCr?r�r�r�r�r�s   r�test_walk_bottom_upzWalkTests.test_walk_bottom_up�s5���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�����W���/�/�2�r�2�	4�����W�q�[�)��.�.�7�)�f�X�>�	@�����Q��W��_�-����	)rc���tj�s|jd�|j|jd��}|D]<\}}}||j
k(s�|j
|g�|j
|dg�n|jd�|j|jd��}|jr|jtt|�|jtt|�y)Nzneed symlink supportTr�r�z+Didn't follow symlink with followlinks=True)rr�rwr�r�r�rCr;r��is_fwalkryrIr"r#)r4�walk_itr�r�ras     r�test_walk_symlinkzWalkTests.test_walk_symlink�s����$�$�&��M�M�0�1��)�)�D�N�N�D�)�A��!(��D�$���t�~�~�%�� � ��r�*�� � ����1��	")�
�I�I�C�D��)�)�D�1�1�4�)�H���=�=����/��w�?����-��w�7rc���g}|j|j|j��}t|�\}}}|j	|g�d}t
jj||�}t
jj||dz�}tj||�	|D�	�
�cgc]\}	}
}|	��
}}
}	}|j|�|j||�|j||�|D]8}
|
|k7s�	|jt
jj||
�|��:	tj||�ycc}}
}	w#tj||�wxYw)N��onerrorr�z.new)r�r�r�r"rCrrDrFr�rkrgr�)r4�errorsr�r�r�ra�dir1�path1�path1newr��dro�roots�dir2s              r�test_walk_bad_dirzWalkTests.test_walk_bad_dir�s �����)�)�D�N�N�F�M�M�)�B�� ��M���d�E������$��������T�4�(���7�7�<�<��d�V�m�4��
�	�	�%��"�		'�&-�.�g�7�1�a��Q�g�E�.��O�O�F�#����U�E�*����X�u�-����4�<��M�M�"�'�'�,�,�t�T�":�E�B��
�I�I�h��&��/��
�I�I�h��&�s%�'E�-
E�:AE�>2E�E�E'c�~�|jd�}|jr|jtt|�|jt
t|�|jdd��}|jr|jtt|�|jt
t|�|j|j�}|jt
t|�|j|jd��}|jr|jtt|�|jt
t|�y)N�nonexistingTr�)r�r�ryrIr"r#r��NotADirectoryError)r4r�s  r�test_walk_bad_dir2zWalkTests.test_walk_bad_dir2�s����)�)�M�*���=�=����/��w�?����-��w�7��)�)�M�4�)�@���=�=����/��w�?����-��w�7��)�)�D�N�N�+�����-��w�7��)�)�D�N�N�D�)�A���=�=����0�$��@����-��w�7r�mkfifozrequires os.mkfifo()r8z%fifo requires special path on VxWorksc��tjdz}tj|�|j	tj
|�|j
|�}|jtt|�|j
|d��}|jr|jtt|�|jtt|�y)Nz-pipeTr�)rrcrr�r�rdr�ryr#r"r�r�)r4rDr�s   r�test_walk_named_pipezWalkTests.test_walk_named_pipe�s������'�)��
�	�	�$������	�	�4�(��)�)�D�/�����-��w�7��)�)�D�$�)�7���=�=����0�$��@����-��w�7rc���tjdz}tj|�|j	t
j|�tjtjj|d��g}|j||j��}t|�|jtt|�|j|g�g}|j||j��}t|�\}}}|j||�|j|g�|j|dg�|j!|�|j#�|j$r|jt&t|�|jtt|�|j$r|j|g�y|jt)|�d|�|j+|dt&�y)Nz-dir�mypiper�rrr)rrcrrGr��shutilr�r�rDrFr�r�r"ryr#rC�extendrr�r�r?r1)r4rDr�r�r�r�ras       r�test_walk_named_pipe2zWalkTests.test_walk_named_pipe2�sp�����&�(��
���������
�
�t�,�
�	�	�"�'�'�,�,�t�X�.�/����)�)�D�&�-�-�)�8���W�
����-��w�7������$����)�)�D�&�-�-�)�8�� ��M���d�E�����t�$�����r�"������
�+����E��
���
��=�=����0�$��@����-��w�7��=�=����V�R�(����S��[�!�V�4��!�!�&��)�-?�@rc��d}tjjtjd�}tjj|gdg|z���}tj
|�t
d�D�cgc]}|j|d����}}t
|dz�D]M}||rdgnggf}|D]}|jt|�|��tjj|�}�Ot
d�D�cgc]}|j|d����}}|}t
|dz�D]Q}|||krdgnggf}|D]}|jt|�|��tjj|d�}�Sycc}wcc}w)	N��deepr�r�Fr�rrT)rrDrFrrcr�r�r�rCr"rQ)	r4�depth�baserW�j�itersr�rSr$s	         r�test_walk_many_open_filesz#WalkTests.test_walk_many_open_filessV�����w�w�|�|�I�,�,�f�5���G�G�L�L��.�#��u��.��
���A��9>�s��D��A����4���/���D��u�q�y�!�A��A�C�5�2�r�2�H���� � ��b��8�4��������"�A�	"�9>�c�
�C�
�1����4���.�
��C����u�q�y�!�A��A��I�C�5�2�r�:�H���� � ��b��8�4�������Q��$�A�	"��E��Ds�7E?�>Fc���d}tjtjj|jgdg|z����t|dz
�5t
|j|j��}ddd�|jd}D],\}}}||k(s�
|j�|j��.g}|j}t|�D]7}	tjj|d�}|j|dggf��9|ddj�|jdgdgf|jggfg|jg|d	�}
|dd}|j|d
gfg}|D]}|j|
|��|j!t#|�|dz�|j!t%|�gd	��|j!||�y#1swY��dxYw)N�2r�r�rr�rrr�r�)r�r�r�r�r�)rr�rDrFr�rr�r�r�r�r�r�rr�r�r�rCr?�sorted)
r4rr�r�r�r�ra�	d_entries�d_path�_�sectionsrSr�s
             r�test_walk_above_recursion_limitz)WalkTests.test_walk_above_recursion_limits�����
���B�G�G�L�L����B�C�5�5�=�B�C�
 ����
+��t�y�y����0�1�C�,��N�N�1�%�	�!$��D�$���y� ��	�	���
�
��"%�
�	������u��A��W�W�\�\�&�#�.�F����f�s�e�R�0�1��	�"�
�a���� �
���'��V�H�5����"�b�)���^�^�$��

���1�v�a�y���^�^�T�F�8�4�5���A��O�O�H�Q�K�(��	
����S��5�1�9�-�������'<�=�����h�'�G,�
+�s�%G�G#r()r\r]r^r�r�rfr�r�r�r�r�r�r�rrrrrr=r>r�rrrr+rrr�r�s�����H�&�
E&�N?�"1�&7�)�*8�&'�*8�&�X�����X�.�0F�G��X�_�_�S�\�\�Y�.�;�=�8�=�H�8��X�����X�.�0F�G��X�_�_�S�\�\�Y�.�;�=�A�=�H�A�:%�*&(rr��fwalkzTest needs os.fwalk()c��eZdZ	dZd�Zd�Zd�Zd�Zd�Zd�Z	e
jejd�d	��Ze
jejd�e
jejd
�d���ZdZy)
�
FwalkTestsTc+�TK�|j|fi|��D]\}}}}|||f���y�wr()r)r4r�r�r�r�ra�root_fds       rr�zFwalkTests.walkGs7����*4�$�*�*�S�*C�F�*C�&�D�$��w���u�%�%�+D�s�&(c�,�tj|i|��Sr()rr�r4r�r�s   rrzFwalkTests.fwalkKs���x�x��(��(�(rc	���	|j�}|j�}tjdd��D]�\}}|j||��|j||��i}t	j
di|��D]\}}}t
|�t
|�f||<�!|jdi|��D]B\}}}}	|j||�|j||t
|�t
|�f��D��y)N�TFrt��repeat)r�r�)r�r�r+)
r��	itertools�productrrr��setrr�rC)
r4�walk_kwargs�fwalk_kwargsr�r�rSr�r�ra�rootfds
          r�_compare_to_walkzFwalkTests._compare_to_walkNs���	�"�&�&�(��#�(�(�*��(1�(9�(9�-�PQ�(R�$�G�_����w�O��L�������Q��H�%'�W�W�%;�{�%;�!��d�E�"%�d�)�S��Z�!8����&<�.8�T�Z�Z�-G�,�-G�)��d�E�6��
�
�d�H�-�� � ��$��#�d�)�S��Z�1H�I�.H�)Src�L�dtji}|j||�y)Nr�)rrcr")r4r�s  r�test_compare_to_walkzFwalkTests.test_compare_to_walk`s"����)�)�*�����f�f�-rc��	tjdtj�}dtji}|j�}||d<|j
||�tj|�y#tj�wxYw)N�.r�r�)rr r�rrcr�r"rj)r4r�rr s    r�test_dir_fdzFwalkTests.test_dir_fddsj��	�����b�k�k�*�B� �)�"2�"2�3�K�&�+�+�-�L�%'�L��"��!�!�+�|�<��H�H�R�L��B�H�H�R�L�s�AA5�5Bc	�z�tjdd��D]�\}}tj|df}|j|d|i�D]t\}}}}tj|�tj|�|jttj|��t|�t|�z��v��y)Nrrtrr�)rrrrcrr�fstatr�rCrr�)r4r�r�r�r�r�rar!s        r�test_yields_correct_dir_fdz%FwalkTests.test_yields_correct_dir_fdns���(1�(9�(9�-�PQ�(R�$�G�_��#�#�W�d�2�D�-7�T�Z�Z��-_��-_�)��d�E�6����� ������� � ��R�Z�Z��%7�!8�#�d�)�c�%�j�:P�Q�
.`�)SrzCannot dup stdout on Emscriptenc�N�tjd�}tj|�td�D]&}|j	t
j�D]}��(tjd�}|jtj|�|j||�y)Nrr�)	rrvrjr�rrrcr�rC)r4�minfdr�r �newfds     r�test_fd_leakzFwalkTests.test_fd_leakzsw�����q�	��
������s��A��Z�Z�	� 0� 0�1���2�����q�	��������%�(������&rz,dup return value is unpredictable on Androidc�(�d�}dD]�}|�}|jtj|��}|j|�|�t	|�|j|�|�|j
�|j|�|���y)Nc�Z�tjd�}tj|�|S�Nrr)rrvrj)r�s r�getfdz.FwalkTests.test_fd_finalization.<locals>.getfd�s�������B��H�H�R�L��Ir)FTr�)rrrcrCr"�
assertGreaterrj)r4r3r��old_fdr$s     r�test_fd_finalizationzFwalkTests.test_fd_finalization�sx��	�%�G��W�F����I�,�,�g��>�B����U�W�f�-���H����u�w��/��H�H�J����U�W�f�-�%rN)r\r]r^r�r�rr"r$r'r*rrrrr/�
is_androidr6rr+rrrrBs�����H�&�)�J�$.��
R��X�_�_����@��'��'��X�_�_����@���X�_�_����J��
.���
.� !%�rrc��eZdZ	d�Zy)�BytesWalkTestsc+�K�d|vr|jd�|d<tjtj|�fi|��D]�\}}}tj|�}tt
tj|��}tt
tj|��}|||f��tt
tj|��|ddtt
tj|��|dd��y�wr�)rXrr��fsencoderZr��map)	r4r�r��broot�bdirs�bfilesr�r�ras	         rr�zBytesWalkTests.walk�s�������&�$*�J�J�/@�$A�F�=�!�$&�G�G�B�K�K��,<�$G��$G� �E�5�&��;�;�u�%�D���B�K�K��/�0�D���R�[�[�&�1�2�E���u�%�%��C����T�2�3�E�!�H��S����e�4�5�F�1�I�
%H�s�C:C<N)r\r]r^r�r+rrr9r9�s
��)�	6rr9c��eZdZ	dd�Zy)�BytesFwalkTestsc/��K�tjtj|�g|��i|��D]�\}}}}tj|�}t	ttj|��}	t	ttj|��}
||	|
|f��t	ttj|	��|ddt	ttj|
��|dd��y�wr()rrr;rZr�r<)r4r�r�r�r=r>r?�topfdr�r�ras           rrzBytesFwalkTests.fwalk�s�����+-�8�8�B�K�K��4D�+V�t�+V�v�+V�'�E�5�&�%��;�;�u�%�D���B�K�K��/�0�D���R�[�[�&�1�2�E���u�e�,�,��C����T�2�3�E�!�H��S����e�4�5�F�1�I�
,W�s�C'C)N)r&)r\r]r^rr+rrrArA�s
��)�6rrAc��eZdZd�Zd�Zejejxsejd�d��Z
ejejxsejd�d��Zejejxsejd�d��Zd�Z
ejej dk(d	�d
��Zd�Zy)
�MakedirTestsc�J�tjtj�yr(�rrGrrcres rrfzMakedirTests.setUp�s��
����!�!�"rc
��tj}tjj	|ddd�}tj
|�tjj	|dddd�}tj
|�|j
ttj
tj�tjj	|dddddtj�}tj
|�tjj	|dtjddddd�}tj
|�y�Nr�r��dir3�dir4�dir5�dir6)	rrcrrDrFr�ryrJ�curdir)r4rrDs   r�test_makedirzMakedirTests.test_makedir�s��������w�w�|�|�D�&�&�&�9��
���D���w�w�|�|�D�&�&�&�&�A��
���D��	
���'�2�;�;��	�	�:��w�w�|�|�D�&�&�&�&�&�"�)�)�T��
���D���w�w�|�|�D�&�"�)�)�V�V�V�"�F�,��
���D�rz$Emscripten's/WASI's umask is a stub.c���tjd�5tj}tjj|d�}tjj|d�}tj|d�|jtjj|��|jtjj|��tjdk7rd|jtj|�jdzd�|jtj|�jdzd�ddd�y#1swYyxYw)Nrtr�r�im�ntr�i�)r�
temp_umaskrcrrDrFr�rkr~�isdirrrCr�r=)r4r�parentrDs    r�	test_modezMakedirTests.test_mode�s���
�
!�
!�%�
(��#�#�D��W�W�\�\�$��/�F��7�7�<�<���/�D��K�K��e�$��O�O�B�G�G�N�N�4�0�1��O�O�B�G�G�M�M�$�/�0��w�w�$��� � ������!6�!6��!>��F�� � ������!8�!8�5�!@�%�H�)�
(�
(�s�D:E�E"c�H�tjjtjd�}d}tj
d�}tj||�|jttj||�|jttj||d��tj|dd��tj||d��tj
|�tjtjjd	�d��y)
Nr�r��F��exist_oki�T)r�rY�/)
rrDrFrrc�umaskr�ryrJr�)r4rDr��old_masks    r� test_exist_ok_existing_directoryz-MakedirTests.test_exist_ok_existing_directory�s���
�w�w�|�|�I�,�,�f�5�����8�8�E�?��
���D�$�����'�2�;�;��d�;����'�2�;�;��d�U��K�
���D�%�$�/�
���D�t�d�3�
�����	���B�G�G�O�O�C�(�4�8rc���tjjtjd�}t
j}d}tjd�}	tjtjtj�j�}	tjtj||z�tjtj�j|z|k7rtjd��tj|||z�tj||d��tj|tjtj|�j�|z�tj|||zd��tj|�y#t$rtjd��wxYw#tj|�wxYw)Nr�r�rWzCannot set S_ISGID for dir.z No support for S_ISGID dir mode.TrX)rrDrFrrcr��S_ISGIDr[�S_IMODE�lstatr=r�r�r�SkipTestr�)r4rDr_r�r\�existing_testfn_modes      r�test_exist_ok_s_isgid_directoryz,MakedirTests.test_exist_ok_s_isgid_directory�sa��
�w�w�|�|�I�,�,�f�5���,�,�����8�8�E�?��	�#'�<�<��H�H�Y�-�-�.�6�6�$8� �
G�����)�)�+?�'�+I�J�����)�)�*�2�2�W�<��G��'�'�(J�K�K�
�K�K��d�W�n�-�
�K�K��d�T�2��H�H�T�4�<�<������(>�(>�?�7�(�J�K��K�K��d�W�n�t�<��H�H�X���#�
G��'�'�(E�F�F�
G��
�H�H�X��s&�AG�'F3�?CG�3G�G�G,c��tj}tjj	tjd�}t|dd��5}|j
d�ddd�|jttj|�|jttj|d��|jttj|d��tj|�y#1swY��xYw)	Nr�ryr�r�r;FrXT)rrcrrDrFr r!ryrJr�r�)r4rrDros    r�#test_exist_ok_existing_regular_filez0MakedirTests.test_exist_ok_existing_regular_files��������w�w�|�|�I�,�,�f�5��
�$��g�
.�!�
�G�G�E�N�/����'�2�;�;��5����'�2�;�;��u��E����'�2�;�;��t��D�
�	�	�$��/�
.�s�
C0�0C9rQzrequires Windowsc��tj}tjj	tjjtjd��}tj|d��tjd|dgd��}tj|�|j�jdd	�d	}|j|d
�y)Nr2i�)r�z	cacls.exez/s�oemr�� rrz5"D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)")
rrcrrDr�rFrGr��check_outputr�r�rsplitrC)r4rrD�outs    r�test_win32_mkdir_700z!MakedirTests.test_win32_mkdir_700s��������w�w���r�w�w�|�|�I�,<�,<�e�D�E��
����E�"��%�%�{�D�$�&?�%�P��
������i�i�k� � ��a�(��+������C�	
rc	��tjjtjdddddd�}tjj|�se|tjk7rRtjj
|�}tjj|�s|tjk7r�Rtj|�yrI)rrDrFrrcr~rQ�
removedirs�r4rDs  rrzMakedirTests.tearDown(s����w�w�|�|�I�,�,�f�f�f�"�F�F�4��
�'�'�.�.��&�4�9�3C�3C�+C��7�7�?�?�4�(�D��'�'�.�.��&�4�9�3C�3C�+C�	�
�
�d�rN)r\r]r^rfrOrrrrrrUr]rdrfrrrrmrr+rrrErE�s���#�
��X�_�_����0����.��
I�	�
I��X�_�_����0����.��9�	�9��X�_�_����0����.���	��6��X������D��*<�=�

�>�

�	rrE�chownzrequires os.chown()c��eZdZed��Zd�Zejee	d�d�d��Z
ejexree
�dkDd�d��Zejexree
�dkDd	�d
��Zed��Zy)
�ChownFileTestsc�J�tjtj�yr(rG��clss r�
setUpClasszChownFileTests.setUpClass7���
����!�!�"rc��tjtj�}|j}|j
}ddt
jd�tjdd�fD]l}|jttjtj||�|jttjtj||��n|jtjtj||��|jtjtjdd��y)Ng�y��r����rt)rr�rrc�st_uid�st_gid�decimal�Decimal�	fractions�Fractionryr�rq�assertIsNone)r4r��uid�gidrls     r�*test_chown_uid_gid_arguments_must_be_indexz9ChownFileTests.test_chown_uid_gid_arguments_must_be_index;s����w�w�y�'�'�(���k�k���k�k���C�����!4�i�6H�6H��Q�6O�P�E����i����9�3C�3C�U�C�P����i����9�3C�3C�S�%�P�Q�	
���"�(�(�9�#3�#3�S�#�>�?����"�(�(�9�#3�#3�R��<�=r�	getgroupszneed os.getgroupsc�d�tj�}t|�dkr|jd�|dd\}}tjt
j�j}tjt
j||�tjt
j�j}|j||�tjt
j||�tjt
j�j}|j||�y)Nrtztest needs at least 2 groups)rr�r?rwr�rrcr{rqr|rC)r4�groups�gid_1�gid_2r�r�s      r�test_chown_gidzChownFileTests.test_chown_gidEs���������v�;��?��M�M�8�9��b�q�z���u��g�g�i�&�&�'�.�.��
����!�!�3��.��g�g�i�&�&�'�.�.������e�$�
����!�!�3��.��g�g�i�&�&�'�.�.������e�$rrrz0test needs root privilege and more than one userc��tdd\}}tjtj�j
}tjtj||�tjtj�j}|j||�tjtj||�tjtj�j}|j||�y�Nrt)	�	all_usersrr�rrcr|rqr{rC)r4�uid_1�uid_2r�r�s     r�test_chown_with_rootz#ChownFileTests.test_chown_with_rootVs���!��!�}���u��g�g�i�&�&�'�.�.��
����!�!�5�#�.��g�g�i�&�&�'�.�.������e�$�
����!�!�5�#�.��g�g�i�&�&�'�.�.������e�$rz2test needs non-root account and more than one userc�^�tdd\}}tjtj�j
}|j
t�5tjtj||�tjtj||�ddd�y#1swYyxYwr�)	r�rr�rrcr|ryr�rq)r4r�r�r�s    r�test_chown_without_permissionz,ChownFileTests.test_chown_without_permissionbss��!��!�}���u��g�g�i�&�&�'�.�.��
�
�
��
/��H�H�Y�%�%�u�c�2��H�H�Y�%�%�u�c�2�0�
/�
/�s
�AB#�#B,c�J�tjtj�yr()rr�rrcrus r�
tearDownClasszChownFileTests.tearDownClasskrxrN)r\r]r^�classmethodrwr�rrrrr��
root_in_posixr?r�r�r�r�r+rrrsrs4s����#��#�>��X�����[�1�3F�G�%�H�%� �X����=�3�y�>�A�+=�K�M�%�M�%��X���]�*�A�s�9�~��/A�M�O�3�O�3��#��#rrsc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�RemoveDirsTestsc�J�tjtj�yr()rr�rrcres rrfzRemoveDirsTests.setUpqs��
���I�$�$�%rc�J�tjtj�yr()rr�rcres rrzRemoveDirsTests.tearDownts������)�)�*rc�N�tjjtjd�}tj
|�tjj|d�}tj
|�tj|�|jtjj|��|jtjj|��|jtjjtj��y)N�dira�dirb)	rrDrFrrcrGro�assertFalser~�r4r�r�s   r�test_remove_allzRemoveDirsTests.test_remove_allws����w�w�|�|�I�,�,�f�5��
������w�w�|�|�D�&�)��
�����
�
�
�d�����������-�.����������-�.���������	�(8�(8�9�:rc��tjjtjd�}tj
|�tjj|d�}tj
|�t
tjj|d��tj|�|jtjj|��|jtjj|��|jtjjtj��y�Nr�r��file.txt)rrDrFrrcrGr%ror�r~rkr�s   r�test_remove_partialz#RemoveDirsTests.test_remove_partial�s����w�w�|�|�I�,�,�f�5��
������w�w�|�|�D�&�)��
������B�G�G�L�L��z�2�3�
�
�
�d�����������-�.���������t�,�-���������y�'7�'7�8�9rc���tjjtjd�}tj
|�tjj|d�}tj
|�t
tjj|d��|jt�5tj|�ddd�|jtjj|��|jtjj|��|jtjjtj��y#1swY��xYwr�)rrDrFrrcrGr%ryrJrorkr~r�s   r�test_remove_nothingz#RemoveDirsTests.test_remove_nothing�s����w�w�|�|�I�,�,�f�5��
������w�w�|�|�D�&�)��
������B�G�G�L�L��z�2�3�
�
�
�w�
'��M�M�$��(���������t�,�-���������t�,�-���������y�'7�'7�8�9�	(�
'�s�7E.�.E7N)r\r]r^rfrr�r�r�r+rrr�r�ps��&�+�;�	:�
:rr�zWASI has no /dev/nullc��eZdZd�Zy)�DevNullTestsc�D�ttjdd�5}|jd�|j	�ddd�ttjd�5}|j|j
�d�ddd�y#1swY�MxYw#1swYyxYw)Nr�r�hellor�r)r r�devnullr!rjrCr�rns  r�test_devnullzDevNullTests.test_devnull�sp��
�"�*�*�d�A�
&�!�
�G�G�H��
�G�G�I�'��"�*�*�d�
#�q����Q�V�V�X�s�+�$�
#�'�
&��$�
#�s�"B
� !B�
B�BN)r\r]r^r�r+rrr�r��s��,rr�c�$�eZdZd�Zd�Zd�Zd�Zy)�URandomTestsc���|jttjd��d�|jttjd��d�|jttjd��d�|jttjd��d�|jttjd��d�y)Nrrrrsr�r9)rCr?r�urandomres r�test_urandom_lengthz URandomTests.test_urandom_length�s�������R�Z�Z��]�+�Q�/�����R�Z�Z��]�+�Q�/�����R�Z�Z��^�,�b�1�����R�Z�Z��_�-�s�3�����R�Z�Z��-�.��5rc��tjd�}|j|t�tjd�}|j	||�y�N�)rr�r1rYr��r4�data1�data2s   r�test_urandom_valuezURandomTests.test_urandom_value�s<���
�
�2������e�U�+��
�
�2������E�5�)rc��djdd|zddf�}td|�}|d}|jt|�|�|S)N�
zimport os, syszdata = os.urandom(%s)zsys.stdout.buffer.write(data)zsys.stdout.buffer.flush()r�rr)rFr
rCr?)r4�countr�rlrUs     r�get_urandom_subprocessz#URandomTests.get_urandom_subprocess�sV���y�y��#�e�+�+�'�	)�*��
�t�T�*���Q�������V��e�,��
rc�l�|jd�}|jd�}|j||�yr�)r�r�r�s   r�test_urandom_subprocessz$URandomTests.test_urandom_subprocess�s2���+�+�B�/���+�+�B�/�����E�5�)rN)r\r]r^r�r�r�r�r+rrr�r��s��6�*�	�*rr��	getrandomzneed os.getrandom()c�:�eZdZed��Zd�Zd�Zd�Zd�Zd�Z	y)�GetRandomTestsc��	tjd�y#t$r8}|jtjk(rtjd���d}~wwxYw)Nrrz%getrandom() syscall fails with ENOSYS)rr�rJrKr�rrb)rvrUs  rrwzGetRandomTests.setUpClass�sI��	��L�L��O���	��y�y�E�L�L�(��'�'�(O�P�P���
	�s��	A�3A�Ac��tjd�}|j|t�|j	t|�d�yr�)rr�r1rYrCr?)r4r�s  r�test_getrandom_typez"GetRandomTests.test_getrandom_type�s4���|�|�B������d�E�*�����T��B�'rc�R�tjd�}|j|d�y)Nrr)rr�rC)r4�emptys  r�test_getrandom0zGetRandomTests.test_getrandom0�s�����Q��������$rc�B�|jttd��y)N�GRND_RANDOM)rkrrres r�test_getrandom_randomz$GetRandomTests.test_getrandom_random�s�������M�2�3rc�l�	tjdtj�y#t$rYywxYwr2)rr��
GRND_NONBLOCK�BlockingIOErrorres r�test_getrandom_nonblockz&GetRandomTests.test_getrandom_nonblock�s-��	��L�L��B�,�,�-���	��	�s�$'�	3�3c�|�tjd�}tjd�}|j||�yr�)rr�r�r�s   r�test_getrandom_valuez#GetRandomTests.test_getrandom_value�s.�����R� �����R� �����E�5�)rN)
r\r]r^r�rwr�r�r�r�r�r+rrr�r��s-���	��	�(�
%�4��*rr��HAVE_GETENTROPYrr�HAVE_GETRANDOM�HAVE_GETRANDOM_SYSCALLz*os.random() does not use a file descriptorr8z$VxWorks can't set RLIMIT_NOFILE to 1c�J�eZdZejed�d��Zd�Zd�Zy)�URandomFDTestsz!test requires the resource modulec� �d}td|�y)Na�if 1:
            import errno
            import os
            import resource

            soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
            resource.setrlimit(resource.RLIMIT_NOFILE, (1, hard_limit))
            try:
                os.urandom(16)
            except OSError as e:
                assert e.errno == errno.EMFILE, e.errno
            else:
                raise AssertionError("OSError not raised")
            r�rr�s  r�test_urandom_failurez#URandomFDTests.test_urandom_failure�s��
��	��t�$rc�(�d}td|�\}}}y)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)r4r��rcrl�errs     r�test_urandom_fd_closedz%URandomFDTests.test_urandom_fd_closeds����(��t�4���C�rc���|jtjtj�t	tjd�djtj��}t
d|�\}}}|jt|�d�|j|dd|dd�t
d|�\}}}|jt|�d�|j||�y)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))
            )rcr�r*rr�)
r�rrdrcr%�formatr
rCr?r�)r4r�r�rlr��out2�err2s       r�test_urandom_fd_reopenedz'URandomFDTests.test_urandom_fd_reopeneds���	
���	�(�(�)�*:�*:�;��I�$�$�j�1��0��i�.�.��/�1	
�2(��t�4���C������S��1�%����C��!�H�c�!�A�h�/�)�%��6���D�$�����T��A�&����D�#�&rN)	r\r]r^rr�resourcer�r�r�r+rrr�r��s1��
�X����#F�G�%�H�%�,5�$'rr�c#�f�K�	g��fd�}�fd�}	tj}tj}tj}|t_|t_|�|t_���|t_|t_|t_y#t_t_t_wxYw�w)Nc�B���jd||f�td��)N�execvzexecv called)r��RuntimeError�rr��callss  �r�
mock_execvz#_execvpe_mockup.<locals>.mock_execvPs!���
���g�t�T�*�+��>�*�*rc�`���jd||f�ttjd��)N�execvez
execve called)r�rJrK�ENOTDIRr�s  �r�mock_execvez$_execvpe_mockup.<locals>.mock_execveTs'���
���h��d�+�,��e�m�m�_�5�5r)rr�r�r<)r<r�r��
orig_execv�orig_execve�orig_defpathr�s      @r�_execvpe_mockupr�Es�������
�E�+�6�"��X�X�
��i�i���z�z�������	��� �B�J��������	�!��
�������	�!��
�s�B1�AB�)"B1�#B.�.B1r�zneed os.execv()c���eZdZejed�d��Zd�Zd�Zeje
ed�d�d��Zd�Z
d	�Zejej d
k(d�d��Zy
)�	ExecTestsz4avoid triggering a linuxthreads bug: see issue #4970c�T�|jttjddgd�y)Nzno such app-)ryrJr�execvperes r�test_execvpe_with_bad_programz'ExecTests.test_execvpe_with_bad_programis$��	
���'�2�:�:�~�)�*�D�	2rc�6�|jttjdd�|jttjdg�|jttjdd�|jttjddg�y)N�notepadr+r7r�)ryr�rr�res r�test_execv_with_bad_arglistz%ExecTests.test_execv_with_bad_arglistosd�����*�b�h�h�	�2�>����*�b�h�h�	�2�>����*�b�h�h�	�5�A����*�b�h�h�	�B�4�@rc���|jttjdgd�|jttjdgi�|jttjddgi�y)Nr�r�)ryr�rr�res r�test_execvpe_with_bad_arglistz'ExecTests.test_execvpe_with_bad_arglistusR�����*�b�j�j�)�R��F����*�b�j�j�)�R��D����*�b�j�j�)�b�T�2�Fr�_execvpez)No internal os._execvpe function to test.c��tjdz}|tur<d}tjj	tj
|�|�}|}gd�}nQd}gd�}tjj	||�}tjdk7rtj
|�}n|}ddi}t�5}|jttj||�|jt|�d	�|j|d
d||ff�ddd�t|��5}|jttj|||�
�|jt|�d	�|j|d
d|||ff�ddd�t�5}|j�}	|tur||	d<n||	d<|jttj|||	�
�|jt|�d	�|j|d
d|||	ff�ddd�y#1swY��xYw#1swY��xYw#1swYyxYw)N�absolutepaths
executable)sprogname�arg1�arg2r�)�prognamer�rrQ�spamr�rrrr�)r<r6r�r9r5)rrErYrDrFr;rr�ryr�r�rCr?rJr>r�)
r4�	test_type�program_path�program�fullpath�native_fullpath�	argumentsr1r��env_paths
          r�_test_internal_execvpez ExecTests._test_internal_execvpezs����v�v��.�����#�G��w�w�|�|�B�K�K��$=�w�G�H�&�O�5�I�"�G�4�I��w�w�|�|�L�'�:�H��w�w�$��"$�+�+�h�"7��"*���w����
�%����l����X�y�
2����S��Z��+����U�1�X���I�<�'H�I�	��\�
2�e����g����W�i�S�
�
:����S��Z��+��$�$�U�1�X��?�Y��,<�=�
?�	3��
�%��x�x�z�H��E�!�$0���!�#/��� ����g����W�i�X�
�
?����S��Z��+��$�$�U�1�X��?�Y��,A�B�
D��
�#�
��3�
2���
�s'�7AH �&AH-�BH9� H*�-H6�9Ic��|jt�tjdk7r|jt�yy)NrQ)r
r2rrrYres r�test_internal_execvpe_strz#ExecTests.test_internal_execvpe_str�s.���#�#�C�(�
�7�7�d�?��'�'��.�rc��tjddg}tjj	�}d|d<|jt�5tj|d||�ddd�tjj	�}d|d<|jt�5tj|d||�ddd�tjj	�}d|d	<|jt�5tj|d||�ddd�y#1swY��xYw#1swY�qxYw#1swYyxYw)
Nr��pass�cabbage�FRUITVEGETABLEr�orangeVEGETABLE=cabbage�FRUIT�lemon�FRUIT=ORANGE)r=r�rr�r�ryr�r�)r4r��newenvs   r�test_execve_invalid_envz!ExecTests.test_execve_invalid_env�s�������f�-�������"��%.��!�"�
�
�
�z�
*��I�I�d�1�g�t�V�,�+������"��5��w��
�
�
�z�
*��I�I�d�1�g�t�V�,�+������"��!(��~��
�
�
�z�
*��I�I�d�1�g�t�V�,�+�
*�+�
*��+�
*��+�
*�s$�D&�'D2�D>�&D/�2D;�>Er�zWin32-specific testc���	tjddgi�|jd�y#t$r8}|j	|j
duxs|j
dk7�Yd}~yd}~wwxYw)Nr��argzNo OSError raisedr)rr�r;rJrk�winerrorrts  r�test_execve_with_empty_pathz%ExecTests.test_execve_with_empty_path�sa��	+��I�I�b�5�'�2�&�
�I�I�)�*���	C��O�O�A�J�J�$�.�A�!�*�*��/�B�B��	C�s�,�	A-�.A(�(A-N)r\r]r^rr�USING_LINUXTHREADSr�r�r�rrrr
rrr=r>rr+rrr�r�fs����X�_�_�'�K�M�2�M�2�A�G�
�X�����Z�0�D�F�-D�F�-D�^/�
-�*�X�������0�2G�H�+�I�+rr�r�rrc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�Win32ErrorTestsc�"�	tjtj�|j	dtjz�y#t
$rd}Yyt$r1}d}|j	dtj�d|���Yd}~yd}~wwxYw)Nzfile %s must not existFTzfile z% must not exist; os.stat failed with )rr�rrcr;rIrJ)r4r~rUs   rrfzWin32ErrorTests.setUp�sy��		C��G�G�I�$�$�%�
�I�I�.��1A�1A�A�B��!�	��F��	1��F��I�I�"�)�)�3�0�
1�
1��	1�s�#A�B�B�'B	�	Bc��|jttjtj
tj
dz�y)Nz.bak)ryrJrr�rrcres rr�zWin32ErrorTests.test_rename�s,�����'�2�9�9�i�.>�.>�	�@P�@P�QW�@W�Xrc�j�|jttjtj
�yr()ryrJrr�rrcres r�test_removezWin32ErrorTests.test_remove�s�����'�2�9�9�i�.>�.>�?rc�j�|jttjtj
�yr()ryrJrrHrrcres r�
test_chdirzWin32ErrorTests.test_chdir�s�����'�2�8�8�Y�-=�-=�>rc�$�|jtjtj�t	tjd�5}|jttjtj�ddd�y#1swYyxYw)Nr )	r�rrdrcr ryrJrrGrns  r�
test_mkdirzWin32ErrorTests.test_mkdir�sV�����	�(�(�)�*:�*:�;�
�)�"�"�C�
(�A����g�r�x�x��1A�1A�B�)�
(�
(�s�	4B�Bc�l�|jttjtj
d�yr()ryrJrr�rrcres rr�zWin32ErrorTests.test_utime�s �����'�2�8�8�Y�-=�-=�t�Drc�l�|jttjtj
d�yr)ryrJrr�rrcres r�
test_chmodzWin32ErrorTests.test_chmod�s �����'�2�8�8�Y�-=�-=�q�ArN)
r\r]r^rfr�r!r#r%r�r(r+rrrr�s+��
C�Y�@�?�C�E�Brrz!Cannot create invalid FD on WASI.c���eZdZgd�Zd�ZeD]Zee�e�dez<�d�Zd�Ze	jeed�d�d��Z
e	jeed	�d
�d��Ze	jeed�d
�d��Ze	jeed�d
�e	j ej$d�d���Ze	jeed�d�d��Ze	jeed�d�d��Ze	jeed�d�e	j ej$xsej,d�d���Ze	jeed�d�d��Ze	jeed�d�d ��Ze	jeed!�d"�d#��Ze	jeed$�d%�d&��Ze	jeed'�d(�d)��Ze	jeed*�d+�d,��Ze	jeed-�d.�d/��Zej>�d0��Z e	jeed1�d2�d3��Z!y4)5�
TestInvalidFD)�fchdirrv�	fdatasyncr)�fstatvfs�fsync�	tcgetpgrp�ttynamec����fd�}|S)Nc�f��tt��r |jtt���yyr()rrrTr5rns �r�helperz(TestInvalidFD.get_single.<locals>.helper�s#�����A���
�
�7�2�q�>�*�rr+)ror3s` r�
get_singlezTestInvalidFD.get_single�s���	+��
r�test_c���	|tj�g|��i|��|jd|z�y#t$r4}|j	|j
t
j�Yd}~yd}~wwxYw)Nz5%r didn't raise an OSError with a bad file descriptor)r�make_bad_fdr;rJrCrKrx)r4ror�r�r�s     rrTzTestInvalidFD.check	sh��	�
�i�#�#�%�7��7��7�
�I�I�M���
���	3����Q�W�W�e�k�k�2�2��	3�s�5�	A2�*A-�-A2c�F�|jtjd��y)Nr�r�)rTrr�res rr�zTestInvalidFD.test_fdopen	s���
�
�2�9�9�w�
�/r�isattyztest needs os.isatty()c�r�|jtjtj��d�y�NF)rCrr9rr7res r�test_isattyzTestInvalidFD.test_isatty	s$��������9�#8�#8�#:�;�U�Crrxztest needs os.closerange()c�(�tj�}td�D]}tj||z�ndkrt
jd��|jtj|||zdz
�d�y#t
$rY�pwxYw)Nrsrtz5Unable to acquire a range of invalid file descriptorsrr)
rr7r�rr)rJrrbrCrx)r4r�r�s   rr}zTestInvalidFD.test_closerange	s���
�
"�
"�
$���r��A����"�Q�$����
�q�5��#�#�G�I�
I�������r�2��6�!�8�4�d�;���
��
�s�B�	B�B�dup2ztest needs os.dup2()c�D�|jtjd�y)N�)rTrr>res r�	test_dup2zTestInvalidFD.test_dup2"	s���
�
�2�7�7�B�rz@dup2() with negative fds is broken on Emscripten (see gh-102179)c� �tjttj�}|j	tj
|�|ddg}t
j|d��D]�\}}||k7s�|j||��5|jt�5}tj||�ddd�|jjjtj�ddd���y#1swY�HxYw#1swY��xYw)Nr�i�rtr)r��fd2)rr r�r�r�rjrrrRryrJr>rCrwrKrx)r4�valid_fd�fdsr�rCrzs      r�test_dup2_negative_fdz#TestInvalidFD.test_dup2_negative_fd&	s����7�7�8�R�[�[�1��������(�+����
��
!�(�(��Q�7�G�B���S�y��\�\�R�S�\�1��*�*�7�3�s�����C�(�4��$�$�S�]�]�%8�%8�%�+�+�F�2�1�8�4�3��2�1�s$�D�C8�1<D�8D�=D�D
	�fchmodztest needs os.fchmod()c�D�|jtjd�yr)rTrrGres r�test_fchmodzTestInvalidFD.test_fchmod:	s���
�
�2�9�9�a� r�fchownztest needs os.fchown()c�F�|jtjdd�y)Nr�)rTrrJres r�test_fchownzTestInvalidFD.test_fchown>	s���
�
�2�9�9�b�"�%r�	fpathconfztest needs os.fpathconf()z-musl libc issue on Emscripten/WASI, bpo-46390c��|jtjd�|jtjd�y)N�PC_NAME_MAX)rTr�pathconfrMres r�test_fpathconfzTestInvalidFD.test_fpathconfB	s(��	
�
�
�2�;�;�
�.��
�
�2�<�<��/r�	ftruncateztest needs os.ftruncate()c��|jtjd�|jtjd�yr)rTr�truncaterRres r�test_ftruncatezTestInvalidFD.test_ftruncateK	s&���
�
�2�;�;��"��
�
�2�<�<��#rr�ztest needs os.lseek()c�F�|jtjdd�yr)rTrr�res r�
test_lseekzTestInvalidFD.test_lseekP	s���
�
�2�8�8�Q��"rr�ztest needs os.read()c�D�|jtjd�yr2)rTrr�res rr�zTestInvalidFD.test_readT	s���
�
�2�7�7�A�r�readvztest needs os.readv()c�\�td�}|jtj|g�y)Nrs)r�rTrrY)r4r�s  r�
test_readvzTestInvalidFD.test_readvX	s����m���
�
�2�8�8�c�U�#r�	tcsetpgrpztest needs os.tcsetpgrp()c�D�|jtjd�yr)rTrr\res r�test_tcsetpgrptzTestInvalidFD.test_tcsetpgrpt]	s���
�
�2�<�<��#rr!ztest needs os.write()c�D�|jtjd�y)N� )rTrr!res rr�zTestInvalidFD.test_writea	s���
�
�2�8�8�T�"r�writevztest needs os.writev()c�F�|jtjdg�y)Nr:)rTrrares r�test_writevzTestInvalidFD.test_writeve	s���
�
�2�9�9�v�h�'rc��|jtj�|jtjd�y�NT)rTr�get_inheritable�set_inheritableres r�test_inheritablezTestInvalidFD.test_inheritablei	s(���
�
�2�%�%�&��
�
�2�%�%�t�,r�get_blocking�-needs os.get_blocking() and os.set_blocking()c��|jtj�|jtjd�yre)rTrri�set_blockingres r�
test_blockingzTestInvalidFD.test_blockingn	s&��	
�
�
�2�?�?�#��
�
�2�?�?�D�)rN)"r\r]r^�singlesr4ro�localsrTr�rrrrr<r}rArrrrFrIrLrrQrUrWr�r[r^r�rcr�rhrmr+rrr*r*�s9��<�G��
��(��m���������0��X�����X�.�0H�I�D�J�D��X�����\�2�4P�Q�
<�R�
<��X�����V�,�.D�E� �F� ��X�����V�,�.D�E��X�_�_����J��
G�	�F�

G��X�����X�.�0H�I�!�J�!��X�����X�.�0H�I�&�J�&��X�����[�1�3N�O��X�_�_����0����7��0�	�P�
0��X�����[�1�3N�O�$�P�$��X�����W�-�/F�G�#�H�#��X�����V�,�.D�E��F���X�����W�-�/F�G�$�H�$��X�����[�1�3N�O�$�P�$��X�����W�-�/F�G�#�H�#��X�����X�.�0H�I�(�J�(�!�W� � �"�-�#�-��X�����^�4�H�J�*�J�*rr*r�zrequires os.linkc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�	LinkTestsc��tj|_tjjtjdz�|_y)Nr�)rrc�file1rrDrF�file2res rrfzLinkTests.setUpw	s.���%�%��
��W�W�\�\�)�"2�"2�S�"8�9��
rc��|j|jfD]7}tjj	|�s�#tj
|��9yr()rsrtrrDr~rd)r4�files  rrzLinkTests.tearDown{	s4���Z�Z����,�D��w�w�~�~�d�#��	�	�$��-rc	��t|�	tj||�t|d�5}t|d�5}|j
tjj|j�|j���ddd�ddd�y#t$r}|j	d|z�Yd}~��d}~wwxYw#1swY�<xYw#1swYyxYw)N�
os.link(): %sr�)
r%rr�r�rwr rkrD�sameopenfiler�)r4rsrtr�r��f2s      r�
_test_linkzLinkTests._test_link�	s����E��	/��G�G�E�5�!��%��
�"�d�5�$�&7�2��O�O�B�G�G�0�0�����b�i�i�k�J�K�'8�
�
���	/��M�M�/�A�-�.�.��	/��&7�&7��
�
�s:�B�
C�AC�C�	C�"B;�;C�C	�C�Cc�P�|j|j|j�yr()r{rsrtres r�	test_linkzLinkTests.test_link�	s������
�
�D�J�J�/rc��|jt|jtj��t|j
tj���yr()r{rYrsr=rLrtres r�test_link_byteszLinkTests.test_link_bytes�	s<������d�j�j�#�*C�*C�*E�F��d�j�j�#�*C�*C�*E�F�	Hrc��	tjd�|xj
dz
c_|j
dz|_|j|j
|j�y#t$rtjd��wxYw)N�ñz#Unable to encode for this platform.r�)rr;�UnicodeErrorrrbrsrtr{res r�test_unicode_namezLinkTests.test_unicode_name�	so��	K��K�K���	
�
�
�f��
��Z�Z�#�%��
�����
�
�D�J�J�/���	K��#�#�$I�J�J�	K�s�A'�'BN)	r\r]r^rfrr{r}rr�r+rrrqrqu	s"��:� �
L�0�H�0rrqzPosix specific testsc��eZdZdZdZejeed�d�d��Z	ejeed�d�d��Z
ejeed�d	�d
��Zejeed�d�d
��Zejeed�d�d��Z
ejeed�d�ej�d���Zejeed�d�ej�d���Zejeed�d�ej�d���Zy)�PosixUidGidTests��setuidztest needs os.setuid()c�$�tj�dk7r%|jttjd�|jt
tjd�|jttj|j�y�Nrz
not an int)r�getuidryrJr�r��
OverflowError�UID_OVERFLOWres r�test_setuidzPosixUidGidTests.test_setuid�	sX��
�9�9�;�!�����g�r�y�y�!�4����)�R�Y�Y��=����-����D�4E�4E�Fr�setgidztest needs os.setgid()c�0�tj�dk7r+ts%|jttj
d�|jttj
d�|jttj
|j�yr�)	rr��HAVE_WHEEL_GROUPryrJr�r�r��GID_OVERFLOWres r�test_setgidzPosixUidGidTests.test_setgid�	s[��
�9�9�;�!��$4����g�r�y�y�!�4����)�R�Y�Y��=����-����D�4E�4E�Fr�seteuidztest needs os.seteuid()c�$�tj�dk7r%|jttjd�|jt
tjd�|jttj|j�yr�)	rr�ryrJr�r��setegidr�r�res r�test_seteuidzPosixUidGidTests.test_seteuid�	sX��
�9�9�;�!�����g�r�z�z�1�5����)�R�Z�Z��>����-����T�5F�5F�Grr�ztest needs os.setegid()c�0�tj�dk7r+ts%|jttj
d�|jttj
d�|jttj
|j�yr�)	rr�r�ryrJr�r�r�r�res r�test_setegidzPosixUidGidTests.test_setegid�	s[��
�9�9�;�!��$4����g�r�z�z�1�5����)�R�Z�Z��>����-����T�5F�5F�Gr�setreuidztest needs os.setreuid()c���tj�dk7r&|jttjdd�|jt
tjdd�|jt
tjdd�|jttj|jd�|jttjd|j�yr�)rr�ryrJr�r�r�r�res r�
test_setreuidzPosixUidGidTests.test_setreuid�	s���
�9�9�;�!�����g�r�{�{�A�q�9����)�R�[�[�,��B����)�R�[�[�!�\�B����-����d�6G�6G��K����-����a��9J�9J�Krc�P�tjtjddg�y)Nr�z,import os,sys;os.setreuid(-1,-1);sys.exit(0)�r�r�r=r�res r�test_setreuid_neg1z#PosixUidGidTests.test_setreuid_neg1�	�%��
	�������>�@�	Ar�setregidztest needs os.setregid()c���tj�dk7r,ts&|jttj
dd�|jttj
dd�|jttj
dd�|jttj
|jd�|jttj
d|j�yr�)	rr�r�ryrJr�r�r�r�res r�
test_setregidzPosixUidGidTests.test_setregid�	s����9�9�;�!��$4����g�r�{�{�A�q�9����)�R�[�[�,��B����)�R�[�[�!�\�B����-����d�6G�6G��K����-����a��9J�9J�Krc�P�tjtjddg�y)Nr�z,import os,sys;os.setregid(-1,-1);sys.exit(0)r�res r�test_setregid_neg1z#PosixUidGidTests.test_setregid_neg1�	r�rN)r\r]r^r�r�rrrrr�r�r�r�r�rr�r�r�r�r+rrr�r��	s����L��L��X�����X�.�0H�I�G�J�G��X�����X�.�0H�I�G�J�G��X�����Y�/�1J�K�H�L�H��X�����Y�/�1J�K�H�L�H��X�����Z�0�2L�M�L�N�L��X�����Z�0�2L�M� �W� � �"�A�#�N�A��X�����Z�0�2L�M� �W� � �"�L�#�N�L��X�����Z�0�2L�M� �W� � �"�A�#�N�Arr�c�j�eZdZd�Zd�Zd�Zd�Zeje	e
d�d�d��Zd�Zy	)
�Pep383Testsc����tjrtj|_n;tjrtj|_ntj|_tj|j�|_g��fd�}|tj�tjr|tj�tjr|tj��s|jd�t�|_tj|j�	�D]�}tjt
jj|j|��tj |�}||jvrt#d��|jj%|���y#t'j(|j��xYw)Nc�r��	tj|�}�j|�y#t$rYywxYwr()rr;rMr�)�fn�bytesfns �r�add_filenamez'Pep383Tests.setUp.<locals>.add_filename�	s7���
��[�[��_��
�N�N�2���&�
��
�s�*�	6�6z&couldn't create any non-ascii filenamezduplicate filename)r�TESTFN_UNENCODABLEr2�TESTFN_NONASCIIrcrr;�bdir�TESTFN_UNICODErwr�	unicodefnrG�create_empty_filerDrFrZr��addr�r�)r4r�r�r�s   @rrfzPep383Tests.setUp�	sB����'�'� �3�3�D�H�
�
&�
&� �0�0�D�H� �'�'�D�H��K�K����)��	���	�	�Y�-�-�.��'�'���5�5�6��$�$���2�2�3���M�M�B�C�����
�������		����+�+�B�G�G�L�L����B�,G�H��[�[��_������'�$�%9�:�:����"�"�2�&���	��M�M�$�(�(�#��s
�2B
G�"G"c�B�tj|j�yr()r�r�r2res rrzPep383Tests.tearDown	
s���
�
�d�h�h�rc��|j}ttj|j��}|j||�tj�}	tjtj�|jttj��ttjtj���tj|�y#tj|�wxYwr()	r�rrr�r2rCr0rHrE)r4rS�found�current_directorys    r�test_listdirzPep383Tests.test_listdir
s����>�>���B�J�J�t�x�x�(�)�������)��I�I�K��	(��H�H�R�V�V�����S�����.��B�J�J�r�v�v�4F�0G�H��H�H�&�'��B�H�H�&�'�s
�A:C,�,Dc��|jD]F}ttjj	|j
|�d�}|j
��Hy�Nr�)r�r rrDrFr2rj)r4r�ros   r�	test_openzPep383Tests.test_open
s8���.�.�B��R�W�W�\�\�$�(�(�B�/��6�A�
�G�G�I�!rrZroc��|jD]A}tjj|j|�}tj
|��Cyr()r�rrDrFr2rZ)r4r��fullnames   r�test_statvfszPep383Tests.test_statvfs
s6���.�.�B��w�w�|�|�D�H�H�b�1�H��J�J�x� �!rc��|jD]?}tjtjj	|j
|���Ayr()r�rr�rDrFr2)r4r�s  r�	test_statzPep383Tests.test_stat&
s/���.�.�B��G�G�B�G�G�L�L����2�.�/�!rN)
r\r]r^rfrr�r�rrrrr�r�r+rrr�r��	sI��#�J �
(��
�X�����Y�/�/�1�!�1�!�0rr�c���eZdZd�Zd�Zd�Zejedud�d��Z	ejd�ej�d���Z
ej�d	��Zy)
�Win32KillTestsc��ddl}ddlm}ddl}|jjj
}|j|_|j|j|j�|j|j|j�|j|j�|j|j�f|_d}tjtj ddj#|�gtj$tj$tj$��}|j'|j(j*�|j'|j,j*�|j'|j.j*�d\}}	||	kr�|j1���|j3t5|��}
||j7|j(j9��|
|j;|
�ddd�}|j=|dd�|
j>r+|jA||
j>jC��nAtEjFd	�|d
z
}||	kr|j1����|jId�tKjL|jN|�|jA|jQ�|�y)Nr��wintypes�runningr�z<import sys;sys.stdout.write('{}');sys.stdout.flush();input())rU�stderr�stdin)rr�zPeekNamedPipe failedg�������?rrz1Did not receive communication from the subprocess))r�r��msvcrtr�r��
PeekNamedPipe�BOOL�restype�HANDLE�POINTER�c_char�DWORD�argtypesr��Popenr=r�r�r[r�rUrjr�r��poll�create_string_bufferr?�
get_osfhandler��sizeofr�rlrCrMr��sleepr;r�kill�pid�wait)r4�sigr�r�r�r�r�r^r��maxr��rslts            r�_killzWin32KillTests._kill,
s��
	�#���
�
�.�.�<�<�
� (�
�
�
��"*�/�/�"(�.�.����"?�"*�.�.�"(�.�.����"@�"(�.�.����"@�"(�.�.����"@�"B�
�����������"+�,2�6�#�;�	!8�
(2���'1���&0�o�o�7��	
������)�)�*�������)�)�*�����
�
�(�(�)��
��s��c�k�d�i�i�k�1��-�-�c�#�h�7�C�!��!5�!5�d�k�k�6H�6H�6J�!K�!$�f�m�m�C�&8�$��d�L�D�����a�)?�@��y�y�� � ��c�i�i�&6�&6�&8�9���J�J�s�O��Q�J�E��c�k�d�i�i�k�1�
�I�I�I�J�
������#���������c�*rc�B�|jtj�yr()r��signal�SIGTERMres r�test_kill_sigtermz Win32KillTests.test_kill_sigtermb
s���
�
�6�>�>�"rc�&�|jd�y)Nr�)r�res r�
test_kill_intzWin32KillTests.test_kill_intf
s
���
�
�3�rNz
requires mmapc�T�dtj�z}tjdd|�}d|d<tjjtjj
t�d�}tj||g}tj|tj��}|5tjtj�D]}|j!���n"|j#�|j%d�tj"|j&|�	|j)tj��ddd�y#tj*$r3|j#�|j%d	j-|��Y�NwxYw#1swYyxYw)
Nz
test_os_%sr�rrrzwin_console_handler.pyr�z'Subprocess didn't finish initialization)�timeoutzsubprocess did not stop on {})�uuid�uuid1�mmaprrDrFrQr�r=r�r�r��CREATE_NEW_PROCESS_GROUPr�sleeping_retry�
SHORT_TIMEOUTr�r�r;r�r��TimeoutExpiredr�)	r4�eventr�tagname�m�script�cmdr^rs	         r�_kill_with_eventzWin32KillTests._kill_with_eventj
s>�������-���I�I�b�!�W�%����!�������b�g�g�o�o�h�7�6�8���~�~�v�w�/������.8�.Q�.Q�S����+�+�G�,A�,A�B���9�9�;�&��C�
�	�	���	�	�C�D��G�G�D�H�H�e�$�
H��	�	�'�"7�"7�	�8��T�� �,�,�
H��	�	���	�	�9�@�@��F�G�
H��!�T�s2�/7F�'AF�, E�AF�F�F�F�F'z.subprocesses aren't inheriting Ctrl+C propertyc�d�ddlm}ddl}|j|j��}|jj
j}|j|j�|jf|_|j|_	||d�|jtjd�y)Nrr��CTRL_C_EVENT)
r�r�r��c_intr�r��SetConsoleCtrlHandlerr�r�r�r�r�r�)r4r�r��NULLr�s     r�test_CTRL_C_EVENTz Win32KillTests.test_CTRL_C_EVENT�
s���	$��,�v�~�~�f�l�l�+�-�� &�
�
� 6� 6� L� L��*0�.�.����*F�*2�-�-�*9��&�(0�
�
��%�
	�d�A�&����f�1�1�>�Brc�D�|jtjd�y)N�CTRL_BREAK_EVENT)r�r�r�res r�test_CTRL_BREAK_EVENTz$Win32KillTests.test_CTRL_BREAK_EVENT�
s�����f�5�5�7I�Jr)r\r]r^r�r�r�rrr�r��skiprr�r�r�r+rrr�r�*
s���4+�l#���X�_�_�T�T�\�?�3�H�4�H�B�X�]�]�C�D� �W� � �"�C�#�E�C�$!�W� � �"�K�#�Krr�c�&�eZdZ	d�Zd�Zd�Zd�Zy)�Win32ListdirTestsc��g|_td�D]�}d|z}tjj	t
j|�}d|z}tjj	t
j|�}tj|�t|dd��5}|jd|z�ddd�|jj||g���|jj�y#1swY�CxYw)NrtzSUB%dzFILE%dryr�r�z'I'm %s and proud of it. Blame test_os.
)�
created_pathsr�rrDrFrrcr�r r!r�r�)r4r��dir_name�dir_path�	file_name�	file_pathros       rrfzWin32ListdirTests.setUp�
s�������q��A���{�H��w�w�|�|�I�$4�$4�h�?�H� �1��I������Y�%5�%5�y�A�I��K�K��!��i��w�7�1����B�Y�N�O�8����%�%�x��&;�<��	
�����!�8�7�s�C6�6C?	c�J�tjtj�yr()r�r�rrcres rrzWin32ListdirTests.tearDown�
s���
�
�i�&�&�'rc	��	|jttjtj
��|j�|jttjtjtj
���|jD�cgc]}tj|���c}�ycc}wr()rCrrr�rrcrr;rps  r�test_listdir_no_extended_pathz/Win32ListdirTests.test_listdir_no_extended_path�
s���;�����r�z�z�)�"2�"2�3�4��"�"�	$�
	
����r�z�z�"�+�+�i�.>�.>�"?�@�A�/3�/A�/A�B�/A�t����T�"�/A�B�	D��Bs�C
c	��	dtjjtj�z}|jt
tj|��|j�dtjtjjtj��z}|jt
tj|��|jD�cgc]}tj|���c}�ycc}w)N�\\?\�\\?\)
rrDr�rrcrCrr�rr;rps  r�test_listdir_extended_pathz,Win32ListdirTests.test_listdir_extended_path�
s���7��2�7�7�?�?�9�+;�+;�<�<������r�z�z�$�'�(��"�"�	$�
�B�K�K������	�8H�8H�(I�J�J������r�z�z�$�'�(�/3�/A�/A�B�/A�t����T�"�/A�B�	D��Bs�#D
N)r\r]r^rfrrrr+rrr�r��
s��"�"�(�
D�
Drr�rQzNT specific testsc�&�eZdZ	d�Zd�Zd�Zd�Zy)�Win32ListdriveTestsc	��tjgd�tjj	tj
dd�d�dd��}|j
�}|D�chc]}|jd�s�|��c}|_|D�chc]
}|d	dd
k(s�|��c}|_	|D�chc]
}|d	dd
k(s�|��c}|_
ycc}wcc}wcc}w)N)z
fsutil.exe�volumer��
SystemRootz\Windows�System32�mbcs�ignore)r5r�r�r	rrz:\r�)r�rjrrDrF�getenvr��
startswith�
known_volumes�known_drives�known_mounts)r4rl�lines�ls    rrfzWin32ListdriveTests.setUp�
s����%�%�,������R�Y�Y�|�[�A�:�N���	
����� ��).�J��A�!�,�,�y�2I�a��J���(-�@��1��1�2��%��Q��@���(-�A��1��1�Q��5��Q��A����K��@��As$�"C�9C�	
C�C�'
C�5Cc��tj�}|j|t�|j	|j
|j
t
|�z�yr()r�
listdrivesr1r��assertSetEqualrr)r4�drivess  r�test_listdrivesz#Win32ListdriveTests.test_listdrives�
sF����������f�d�+�����������F��+�	
rc��tj�}|j|t�|j	|j
|j
t
|�z�yr()r�listvolumesr1r�rrr)r4�volumess  r�test_listvolumesz$Win32ListdriveTests.test_listvolumes�
sG���.�.�"�����g�t�,�����������W��-�	
rc�X�tj�D]_}	tj|�}|j|t�|jt
|�|jt
|�z��ay#t$r(}tjrtd|d|�Yd}~��d}~wwxYw)N�Skippingz
because of)rr!�
listmountsr1r�rrrrJrrMrN)r4r�mounts�exs    r�test_listmountsz#Win32ListdriveTests.test_listmounts�
s����n�n�&�F�

����v�.��
�%�%�f�d�3��#�#���K��%�%��F��3��'���
@��?�?��*�f�l�B�?���
@�s�A8�8	B)�B$�$B)N)r\r]r^rfrr#r)r+rrr
r
�
s��?�B�
�
�rr
�readlinkzneeds os.readlink()c��eZdZdZej
j
e�Zeje�Z
eje�Zd�Zd�Z
d�Zd�Zej"d��Zej"d��Zej"d��Zy	)
�
ReadlinkTests�readlinktestc��tjj|�}tjj|�}tjdk(rd�}||�r|dd}||�r|dd}|j||�y)Nr�c�P�|jt|t�rd�Sd�S)Nr
r	)rrirY)rWs rr�z/ReadlinkTests.assertPathEqual.<locals>.<lambda>s#��1�<�<�(��E�2�
�$C�8A�$Crr�)rrD�normcaser=r>rC)r4�left�right�
has_prefixs    r�assertPathEqualzReadlinkTests.assertPathEqualst���w�w����%����� � ��'���<�<�7�"�C�J��$���A�B�x���%� ��a�b�	������u�%rc���|jtjj|j��|jtjj|j
��|j
tjj|j��|j
tjj|j��yr()	rkrrDr~�filelink_target�filelinkb_targetr��filelink�	filelinkbres rrfzReadlinkTests.setUps~����������t�';�';�<�=���������t�'<�'<�=�>����������
�
�6�7������������7�8rc���t|j�}|jttj
|j�|jttj
|�yr()rr6ryrJrr*)r4r6s  r�test_not_symlinkzReadlinkTests.test_not_symlink sD��"�4�#7�#7�8�����'�2�;�;��0D�0D�E����'�2�;�;��@rc��|jttjd�|jttjt	d��y)Nzmissing-link)ryrIrr*rres r�test_missing_linkzReadlinkTests.test_missing_link%s8�����+�R�[�[�.�I����+�R�[�[�"�>�2�	4rc�4�tj|j|j�|j	t
j|j�t|j�}|jtj|�|j�yr()
rr�r6r8r�rrdrr4r*)r4r8s  r�
test_pathlikezReadlinkTests.test_pathlike*s_��
�
�
�4�'�'����7����	�(�(�$�-�-�8��D�M�M�*�����R�[�[��2�D�4H�4H�Irc�`�tj|j|j�|j	t
j|j�tjt|j��}|j||j�|j|t�yr()rr�r7r9r�rrdr*rr4r1rYrps  r�test_pathlike_bytesz!ReadlinkTests.test_pathlike_bytes1so��
�
�
�4�(�(�$�.�.�9����	�(�(�$�.�.�9��{�{�8�D�N�N�3�4�����T�4�#8�#8�9����d�E�*rc�N�tj|j|j�|j	t
j|j�tj|j�}|j||j�|j|t�yr()rr�r7r9r�rrdr*r4r1rYrps  r�
test_byteszReadlinkTests.test_bytes9sj��
�
�
�4�(�(�$�.�.�9����	�(�(�$�.�.�9��{�{�4�>�>�*�����T�4�#8�#8�9����d�E�*rN)r\r]r^r8rrDr�r�r6r;r9r7r4rfr;r=r�skip_unless_symlinkr?rArCr+rrr,r,s����H��g�g�o�o�h�/�O�����H�%�I�"�r�{�{�?�3��&�9�A�
4�
�"�"�J�#�J��"�"�+�#�+��"�"�+�#�+rr,c�j�eZdZdZej
j
e�ZdZ	ej
je�ZdZd�Z
d�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zej0ej
j3d�xrej
j5d�d�d��Zd�Zd�Zy)�Win32SymlinkTests�filelinktest�dirlinktestzmissing linkc��yr(r+res rrfzWin32SymlinkTests.setUpK��rc��tjj|j�rtj|j�tjj|j
�rtj|j
�tjj|j�r tj|j�yyr()	rrDr~r8r��dirlinkr�rb�missing_linkres rrzWin32SymlinkTests.tearDownRsw��
�7�7�>�>�$�-�-�(��I�I�d�m�m�$�
�7�7�>�>�$�,�,�'��H�H�T�\�\�"�
�7�7�?�?�4�,�,�-��I�I�d�'�'�(�.rc���tj|j|j�|j	tj
j
|j��|j	tj
j|j��|j	tj
j|j��|j|j|j�yr()
rr��dirlink_targetrLrkrDr~rS�islink�
check_statres r�test_directory_linkz%Win32SymlinkTests.test_directory_linkZs���
�
�
�4�&�&����5���������t�|�|�4�5�������
�
�d�l�l�3�4���������t�|�|�4�5�������d�&9�&9�:rc���tj|j|j�|j	tj
j
|j��|j	tj
j|j��|j	tj
j|j��|j|j|j�yr()
rr�r6r8rkrDr~r�rPrQres r�test_file_linkz Win32SymlinkTests.test_file_linkas���
�
�
�4�'�'����7���������t�}�}�5�6���������t�}�}�5�6���������t�}�}�5�6�����
�
�t�';�';�<rc��	|j}tjj|�rtj|�d}d}tj
|||�y)Nz"c:\\target does not exist.29r3c740T)rMrrDrbr�r�)r4�linknamer��
target_is_dirs    r�_create_missing_dir_linkz*Win32SymlinkTests._create_missing_dir_linkhsF��<��$�$��
�7�7�?�?�8�$��I�I�h��6���
�
�
�
�6�8�]�3rc�b�|j�tj|j�yr()rXrr�rMres r�,test_remove_directory_link_to_missing_targetz>Win32SymlinkTests.test_remove_directory_link_to_missing_targetrs"���%�%�'�	�	�	�$�#�#�$rc��|j�|jtjj	|j
��yr()rXr�rrDrSrMres r�.test_isdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_isdir_on_directory_link_to_missing_targetys/���%�%�'���������t�'8�'8�9�:rc�b�|j�tj|j�yr()rXrr�rMres r�.test_rmdir_on_directory_link_to_missing_targetz@Win32SymlinkTests.test_rmdir_on_directory_link_to_missing_target}s ���%�%�'�
����"�"�#rc���|jtj|�tj|��|jtj|�tj|��tj
|�}|jtj|�tj|��|jtj|�tj|��yr()rCrr�r�rar;)r4r�r��
bytes_links    rrQzWin32SymlinkTests.check_stat�s����������������8����B�H�H�T�N�B�G�G�D�M�:��[�[��&�
��������,�b�g�g�f�o�>����B�H�H�Z�0�"�'�'�*�2E�Frc�
�tjjtj�}tjj|d�}tjj|d�}|j
tj|�tj|�tj|�tj|�tjjtjj|d��}t|�tj�}	tj|�tjj|d�}tjtjj|�d�|jdtjtj���|j!tj"|�tj"d��tj|�|j!tj"|�tj"tjj|���tj|�|j!tj"|�tj"tjj|���tj|�y#tj|�wxYw)N�level2�level3rsr�)rrDr�rrcrFr�r�rGr%r0rHr��relpathr�r�rCr�)r4�level1rbrcrs�orig_dirr�s       r�
test_12084zWin32SymlinkTests.test_12084�s���������!1�!1�2�������f�h�/�������f�h�/�����	�(�(�&�1�
�����
�����
���������������V�W� =�>���E���9�9�;��	��H�H�V���7�7�<�<���/�D��J�J�r�w�w���u�-�v�6��M�M�&�"�*�*�R�Y�Y�[�"9�:�
���R�W�W�U�^�R�W�W�V�_�=�
�H�H�V�����R�W�W�U�^��W�W�R�W�W�_�_�T�%:�;�
=�
�H�H�V�����R�W�W�U�^��W�W�R�W�W�_�_�T�%:�;�
=�
�H�H�X���B�H�H�X��s
�*F+K+�+L�C:\Users\All Users�C:\ProgramDatazTest directories not foundc��tjd�}|jtjj	|d��y)Nrhri)rr*rkrD�samefile)r4r�s  r�
test_29248zWin32SymlinkTests.test_29248�s1�����2�3��������(�(��1B�C�Drc��d}tjj|gdz�}d|z|f||f|dd|ddfg}|D]�\}}	tj||�	tj|�	tjtj|�tj|��	tj|���y#t
$rY�awxYw#t$rY�pwxYw#t
$rY��wxYw#t$rY��wxYw)N�XXXXXXXXXXXXXXXXXXXXXXXXXXXrsr��)rrDrFr�r�rJrIr;)r4�segmentrD�
test_casesr��dests      r�test_buffer_overflowz&Win32SymlinkTests.test_buffer_overflow�s�����w�w�|�|�g�Y��^�,���D�[�'�"�
�d�O�
�$�3�Z��d�s��$�

�
�$�I�C��
��
�
�3��%���I�I�d�O�
��
�
�2�;�;�s�+�R�[�[��->�?���I�I�d�O�#$�������%�
��
�������%�
��
�sH�C�C�-<C/�*C �	C�
C�	C�C� 	C,�+C,�/	C;�:C;c�R�tjjd�}tjj|�s|j	d�tjtj|�d�D�cgc]"}tjj||���$}}|D]�}tjrt�td|�tj|�}|j|tj|��|jtj |j"��|j|j$tj&�|j)tjj+|��y|j	d�ycc}w)Nz$%LOCALAPPDATA%\Microsoft\WindowsAppsz%test requires a WindowsApps directoryz*.exezTesting withz$test requires an app execution alias)rrD�
expandvarsrSrw�fnmatch�filterr�rFrrMrNrarCr�r��S_ISLNKr=�st_reparse_tag�IO_REPARSE_TAG_APPEXECLINKrkr�)r4r�r<�aliases�aliasr�s      r�test_appexeclinkz"Win32SymlinkTests.test_appexeclink�s*���w�w�!�!�"I�J���w�w�}�}�T�"��M�M�A�B�$�N�N�2�:�:�d�+;�W�E�G�E�q��7�7�<�<��a�(�E�	�G��E�������n�e�,����%��B����R������0����T�\�\�"�*�*�5�6����R�.�.��0O�0O�P��O�O�B�G�G�N�N�5�1�2���
�M�M�@�A��Gs�;'F$N)r\r]r^r8rrDr�r�r6rLrQrOrMrfrrRrTrXrZr\r^rQrgrrrbr~rlrsr}r+rrrFrFBs����H��g�g�o�o�h�/�O��G��W�W�_�_�_�5�N�!�L�5�)�;�=�4�%�;�$�G�!�F�X��������)>�?�B� "�����/@� A�8�:�
E�:�
E�!�FBrrFc��eZdZdZej
j
ej
je��Z	d�Z
d�Zd�Zd�Z
y)�Win32JunctionTests�junctiontestc��yr(r+res rrfzWin32JunctionTests.setUp�rJrc��tjj|j�r tj|j�yyr()rrDrb�junctionrdres rrzWin32JunctionTests.tearDown�s+��
�7�7�?�?�4�=�=�)��I�I�d�m�m�$�*rc�4�tj|j|j�|j	t
jj|j��|j	t
jj|j��|j	t
jj|j��|jtj|j�tj|j��|jtj|j�tj|j��|jt
jj|j��|jt
jj!d|jz�t
jj!tj"|j���y)Nr	)�_winapi�CreateJunction�junction_targetr�rkrrDrbr~rSr�r�rarCr�rPr0r*res r�test_create_junctionz'Win32JunctionTests.test_create_junctions4�����t�3�3�T�]�]�C����������
�
�6�7���������t�}�}�5�6�������
�
�d�m�m�4�5����B�G�G�D�M�M�2�B�H�H�T�]�]�4K�L����������/�����9M�9M�1N�O�	
���������
�
�6�7�������)�)�)�d�6J�6J�*J�K����)�)�"�+�+�d�m�m�*D�E�	Grc���tj|j|j�|j	t
jj|j��|j	t
jj|j��tj|j�|jt
jj|j��yr()r�r�r�r�rkrrDr~rbrdr�res r�test_unlink_removes_junctionz/Win32JunctionTests.test_unlink_removes_junctions������t�3�3�T�]�]�C���������t�}�}�5�6����������
�
�6�7�
�	�	�$�-�-� ����������
�
�6�7rN)r\r]r^r�rrDrQr�r�r�rfrr�r�r+rrrr�s;���H��g�g�o�o�b�g�g�o�o�h�&?�@�O�2�%�G�8rrc�n�eZdZd�Zej
�d��Zej
�d��Zy)�Win32NtTestsc���tjd�}tjd�}ddl}|jdd��}|jj
|j_|jj|j_|jj
|jjf|j_|j
�}|jj�}|j||j|��}|jd|�|j}dd	d
t g}t#d�D]1}	|D]*}
	|j%|
�	t)j*|
��,�3|j||j|��}|jd|�|j|z
}|jd|�y#t&$rY�zwxYw#t&$rY��wxYw)NrQr�rzKernel32.dllT)�use_last_errorrrz\\?\C:z\\?\NULz	\\?\CONINrs)r�
import_module�ctypes.wintypes�WinDLLr�r��GetCurrentProcessr�r��GetProcessHandleCount�LPDWORDr�r��byrefrCrlr�r��_getfinalpathname�	Exceptionrr�)r4rQr��kernel�hproc�handle_countr��before_count�	filenamesrr�handle_deltas            r�test_getfinalpathname_handlesz*Win32NtTests.test_getfinalpathname_handless���
�
(�
(��
.���,�,�X�6������~�d��C��+1�?�?�+A�+A�� � �(�/5���/C�/C��$�$�,�17���1G�1G�17���1H�1H�1J��$�$�-��(�(�*�����,�,�.��
�
)�
)�%����l�1K�
L������B��#�)�)��
����	
�	��r��A�!����(�(��.���G�G�D�M�"���
)�
)�%����l�1K�
L������B��#�)�)�L�8������L�)��!�����
!����s$�G� G�	G�G�	G)�(G)c	�t�tj}|jtj|�t	j�dz}tjd�}tjtjd||t|�g�5}t	j�|kr.	tj|�t	j�|kr�.	|jd�ddd�y#t$r
}Yd}~�Ad}~wwxYw#tj $r|j#�Y�DwxYw#1swYyxYw)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�rr)rrcr�rdr��textwrap�dedentr�r�r=r�r2rr�rIr�r��	terminate)r4r"�deadline�commandr^r�s      r�test_stat_unlink_racez"Win32NtTests.test_stat_unlink_raceIs����$�$�����	�(�(�(�3��9�9�;��?���/�/�#���(�
�
�s�~�~�t�W�h��H�
�V�
W�[_��)�)�+��(�+��G�G�H�%��)�)�+��(�

!��	�	�!��X�
W��)�+��+���,�,�
!���� �
!��X�
W�sN�D.�'C/�<D.�D�/	D�8D.�=D�D.�#D+�(D.�*D+�+D.�.D7c����tj�tjj	d��t�d�5}|j
d�ddd�tj��}	tj��dgtj����fd
�}|j+|�tjrtd��td|�tj��}tjrtd
|�|j-|j.d|j.f�|j-|j0d|j0f�|j3|j4|j4�|j3|j6|j6�|j3|j8|j8�|j3|j:|j:�|j=|j>|j>�y#1swY���xYw#tj$r�}tjrAt��dd�t|jj!dd�j#��	tj$��n#t&$rYnwxYw|j)d	�Yd}~��-d}~wwxYw)Nz %SystemRoot%\System32\icacls.exer�s	Test dataz/inheritance:r�r�zfailed.rhr�z"Unable to create inaccessible filec���tj��ddgtj��tj��y)Nz/grantz*WD:(D)r�)r�rj�STDOUTrrd)�ICACLSr"s��r�cleanupz9Win32NtTests.test_stat_inaccessible_file.<locals>.cleanup�s1����#�#�V�X�x��$K�+5�+<�+<�
>��I�I�h�rzFile:zstat with access:z without access:r) rrcrrDrur r!r�r�rjr��CalledProcessErrorrrMrNrUrMr\rdrJrwr�r��st_dev�st_inorCr=r1r�r��assertGreaterEqualr�)r4ro�stat1r(r��stat2r�r"s      @@r�test_stat_inaccessible_filez(Win32NtTests.test_stat_inaccessible_filess����#�#�����#�#�$G�H��
�(�D�
!�Q�
�G�G�L�!�"�����!��	@��#�#�V�X�7G�$H�+5�+<�+<�
>�	 �	
���� ��?�?��'�8�$��%�u�-�����!���?�?��$�e�,�	
�
�
�e�l�l�Q����$5�6��
�
�e�l�l�Q����$5�6�	
�������
�
�6��������
�
�6�	
���������8����������8�	
���������?�g"�
!���,�,�	@�����f�h�(8�)�D��b�i�i�&�&�u�i�8�?�?�A�B�
��	�	�(�#���
��
���M�M�>�?�?��	@�sH�H�.(H"�H�"K�5AK�J�K�	J)�&K�(J)�)K�KN)r\r]r^r�rr�r�r�r+rrr�r�sI��/*�b!�W� � �"�'!�#�'!�R!�W� � �"�7@�#�7@rr�c��eZdZd�Zd�Zd�Zy)�NonLocalSymlinkTestsc�0�	tjd�y)Nz
base/some_dir)rr�res rrfzNonLocalSymlinkTests.setUp�s��	�	���O�$rc�.�tjd�y)Nr)r�r�res rrzNonLocalSymlinkTests.tearDown�s���
�
�f�rc�r�	tjjdd�}tjd|�y)Nr�	some_link�some_dir)rrDrFr�)r4r�s  r�test_directory_link_nonlocalz1NonLocalSymlinkTests.test_directory_link_nonlocal�s+��
	��g�g�l�l�6�;�/��
�
�
�:�s�#rN)r\r]r^rfrr�r+rrr�r��s��%��"rr�c��eZdZd�Zd�Zy)�FSEncodingTestsc��|jtjd�d�|jtjd�d�y)Nsabc�uabcŁ)rCrr;rZres r�test_nopzFSEncodingTests.test_nop�s4��������Z�0�*�=�������[�1�;�?rc��dD]=}	tj|�}|jtj|�|��?y#t$rY�LwxYw)N)u	unicodeŁulatiné�ascii)rr;rMrCrZ)r4r�r�s   r�
test_identityzFSEncodingTests.test_identity�sM��9�B�
��+�+�b�/��
���R�[�[��1�2�6�:��&�
��
�s�A�	A�AN)r\r]r^r�r�r+rrr�r��s
��@�7rr�c��eZdZd�Zej
ejd�xr;e�xr1e	jjd�xsee
d�xr	ee
d�d�ejej d�d���Zy	)
�DeviceEncodingTestsc�L�|jtjd��y)Ni@�)r�r�device_encodingres r�test_bad_fdzDeviceEncodingTests.test_bad_fd�s�����"�,�,�V�4�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�}|j|�|jt	j
|��yr)rr��assertIsNotNonerk�codecs�lookup)r4r�s  r�test_device_encodingz(DeviceEncodingTests.test_device_encoding�s7���%�%�a�(�����X�&�����
�
�h�/�0rN)r\r]r^r�rrrr9r	r=r>rr�localerrrr�r+rrr�r��s���6��X�������1��M�l�n�*<�M�#�,�,�BY�BY�Z_�B`�CL�
�V�]�
+�
J���	�0J�L�N��X�_�_����K��1��N�1rr�c�8�eZdZejeed�d�d��Zdd�Zd�Z	d�Z
ejejdk(d	�d
��Z
ejejdk(d	�d��Zejeed�d
�d��Zy)�PidTests�getppidztest needs os.getppidc�2�tjtjddgtjtj��}|j�\}}|j
|d�|j
t|�tj��y)Nr�zimport os; print(os.getppid()))rUr�r)
r�r�r=�_base_executabler[�communicaterCrr�getpid)r4rWrU�errors    r�test_getppidzPidTests.test_getppid�sn�����c�2�2�D�>�@�$.�O�O�$.�O�O�
5���
�
��
��������$�����V��b�i�i�k�2rNc��tjdk(rdtj�d�dd|�d�g}ntjd|g}tjtj
tj|�}|�||�tj|d�\}}|jtj|�|�|j||�y)Nr��"r�r)	r=r>r�r�spawnv�P_NOWAIT�waitpidrC�waitstatus_to_exitcode)r4r��exitcode�callbackr�r��pid2�statuss        r�
check_waitpidzPidTests.check_waitpid�s����<�<�7�"�����'�q�)�4�1�T�F�!��=�D��N�N�D�$�/�D��i�i����S�^�^�T�:�����S�M��z�z�#�q�)���f�����2�2�6�:�H�E�����s�#rc�*�|jdd��y)Nrr)r�r��r�res r�test_waitpidzPidTests.test_waitpid
s��������3rc��d}d|�d�}|j||��|jt�5tjd�ddd�y#1swYyxYw)N�zimport sys; sys.exit(�)�r�g)r�ryr�rr�)r4r�r�s   r�test_waitstatus_to_exitcodez$PidTests.test_waitstatus_to_exitcode
sP����&�x�j��2�����4�(��3�
�
�
�y�
)��%�%�c�*�*�
)�
)�s�A�Ar��win32-specific testc�:�d}d|�d�}|j||��y)Nl:z$import _winapi; _winapi.ExitProcess(r�r�r�)r4�STATUS_CONTROL_C_EXITr�s   r�test_waitpid_windowszPidTests.test_waitpid_windows
s.��!+��5�6K�5L�A�N�����4�*?��@rc�v�d}ddd|fD]*}|jtj|dz�|��,|jt�5tj|dzdz�ddd�|jt
�5tjd�ddd�y#1swY�=xYw#1swYyxYw)Nr~rrrr�r*r�)rCrr�ryr�r�)r4�max_exitcoder�s   r�#test_waitstatus_to_exitcode_windowsz,PidTests.test_waitstatus_to_exitcode_windows"
s���"���A�q�,�/�H����R�6�6�x�1�}�E�%�
'�0�
�
�
�z�
*��%�%�|�a�'7�A�&=�>�+�
�
�
�}�
-��%�%�b�)�.�
-�+�
*��
-�
-�s�B#�B/�#B,�/B8�SIGKILLzneed signal.SIGKILLc���dtj�d�}tj��fd�}|j	|�|��y)Nzimport time; time.sleep(r�c�2��tj|��yr()rr�)r��signums �r�kill_processz?PidTests.test_waitstatus_to_exitcode_kill.<locals>.kill_process5
s����G�G�C�� r)r�r�)r�LONG_TIMEOUTr�r�r�)r4r�r�r�s   @r� test_waitstatus_to_exitcode_killz)PidTests.test_waitstatus_to_exitcode_kill0
s?���)�'�*>�*>�)?�q�A������	!�	
���4�6�'�L��Irr()r\r]r^rrrrr�r�r�r�r=r>r�r�r�r�r+rrr�r��s����X�����Y�/�1H�I�3�J�3�$�$4�+��X�������0�2G�H�A�I�A��X�������0�2G�H�
*�I�
*��X������3�5J�K�J�L�Jrr�c���eZdZed��Zddd�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��Zed
�d��Zed�d��Zd�Zed�d��Zed�d��Zy)�
SpawnTestsc��tjdk7r|S|D�cgc]}d|j�vrd|�d�n|��c}Scc}w)NrQrir�)rrr)r�rs  r�
quote_argszSpawnTests.quote_args=
sF���7�7�d�?��K�EI�J�T�c�c�S�Y�Y�[�0�!�C�5��
�c�9�T�J�J��Js�!>F��with_env�	use_bytesc��d|_tj}|jtj|�|sd|jz}n�ttj�|_ttj��|_|j|j|j<d|j�d|j�d�}t|dd��5}|j|�ddd�tj }|j#||g�}|r�t
j$|�}|D�cgc]}t
j$|���}}|jj'�D�	�
cic].\}	}
t
j$|	�t
j$|
���0c}
}	|_||fS#1swY��xYwcc}wcc}
}	w)	N�zimport sys; sys.exit(%s)z#import sys, os; magic = os.environ[z]; sys.exit(r�ryr�r�)r�rrcr�rdrrr�r1r2r��uuid4r
r r!r=r�r�r;r)r4r�rr"r�r$rr�r<�k�vs           r�create_argszSpawnTests.create_argsE
sS����
��#�#�����	�(�(�(�3��-��
�
�=�D��B�J�J�'�D�H��4�:�:�<�(�D�H�!%���D�H�H�T�X�X���x�x����0�D��(�C�'�
2�b��H�H�T�N�3��.�.�������2�3����k�k�'�*�G�,0�1�D�q�B�K�K��N�D�D�1�$(�H�H�N�N�$4�6�$4�D�A�q����A�����A��6�$4�6�D�H���}��3�
2��2��6s�F+�0F7�+3F<�+F4�spawnlc��|j�\}}tjtj|g|���}|j	||j
�yr()rrr�P_WAITrCr��r4rr�r�s    r�test_spawnlzSpawnTests.test_spawnlc
sA���(�(�*�
����9�9�R�Y�Y��7�$�7������4�=�=�1r�spawnlec���|jd��\}}tjtj|g|�|j���}|j||j�y�NT)r�)rrrr	r1rCr�r
s    r�test_spawnlezSpawnTests.test_spawnlei
sO���(�(�$�(�7�
����:�:�b�i�i��B�4�B����B������4�=�=�1r�spawnlpc��|j�\}}tjtj|g|���}|j	||j
�yr()rrrr	rCr�r
s    r�test_spawnlpzSpawnTests.test_spawnlpo
sA���(�(�*�
����:�:�b�i�i��8�4�8������4�=�=�1r�spawnlpec���|jd��\}}tjtj|g|�|j���}|j||j�yr)rrrr	r1rCr�r
s    r�
test_spawnlpezSpawnTests.test_spawnlpeu
sO���(�(�$�(�7�
����;�;�r�y�y�'�C�D�C�$�(�(�C������4�=�=�1rr�c�@�|j�\}}tjtj||�}|j	||j
�tjtjt
|�|�}|j	||j
�yr()rrr�r	rCr�rr
s    r�test_spawnvzSpawnTests.test_spawnv{
so���(�(�*�
����9�9�R�Y�Y���6������4�=�=�1��9�9�R�Y�Y���(9�4�@������4�=�=�1r�spawnvec���|jd��\}}tjtj|||j�}|j||j�yr�rrrr	r1rCr�r
s    r�test_spawnvezSpawnTests.test_spawnve�
sI���(�(�$�(�7�
����:�:�b�i�i��$����A������4�=�=�1r�spawnvpc��|j�\}}tjtj||�}|j	||j
�yr()rrrr	rCr�r
s    r�test_spawnvpzSpawnTests.test_spawnvp�
s>���(�(�*�
����:�:�b�i�i��$�7������4�=�=�1r�spawnvpec���|jd��\}}tjtj|||j�}|j||j�yr)rrrr	r1rCr�r
s    r�
test_spawnvpezSpawnTests.test_spawnvpe�
sI���(�(�$�(�7�
����;�;�r�y�y�'�4����B������4�=�=�1rc��|j�\}}tjtj||�}t	j
||j��y)Nr�)rrr�r�r�wait_processr�)r4rr�r�s    r�test_nowaitzSpawnTests.test_nowait�
s>���(�(�*�
����i�i����W�d�3�����S�4�=�=�9rc���|jdd��\}}tjtj|||j�}|j||j�y)NTr�rr
s    r�test_spawnve_byteszSpawnTests.test_spawnve_bytes�
sM���(�(�$�$�(�G�
����:�:�b�i�i��$����A������4�=�=�1rc��|j�\}}|jttjtj
|�|jttjtj
|d�y�Nr�)rryr�rrr��r4r�__s   r�test_spawnl_noargszSpawnTests.test_spawnl_noargs�
sN���&�&�(�������*�b�i�i����g�F����*�b�i�i����g�r�Jrc��|j�\}}|jttjtj
|i�|jttjtj
|di�yr()rryr�rrr�r)s   r�test_spawnle_noargszSpawnTests.test_spawnle_noargs�
sR���&�&�(�������*�b�j�j�"�+�+�w��K����*�b�j�j�"�+�+�w��B�Orc���|j�\}}|jttjtj
|d�|jttjtj
|g�|jttjtj
|d�|jttjtj
|dg�y�Nr+r7r�)rryr�rr�r�r)s   r�test_spawnv_noargszSpawnTests.test_spawnv_noargs�
s����&�&�(�������*�b�i�i����g�r�J����*�b�i�i����g�r�J����*�b�i�i����g�u�M����*�b�i�i����g��t�Lrc���|j�\}}|jttjtj
|di�|jttjtj
|gi�|jttjtj
|di�|jttjtj
|dgi�yr/)rryr�rrr�r)s   r�test_spawnve_noargszSpawnTests.test_spawnve_noargs�
s����&�&�(�������*�b�j�j�"�+�+�w��B�O����*�b�j�j�"�+�+�w��B�O����*�b�j�j�"�+�+�w��r�R����*�b�j�j�"�+�+�w���b�Qrc��tj}|j|ddg�}tjj�}d|d<	|tj|||�}|j|d�tjj�}d|d<	|tj|||�}|j|d�tjj�}d|d	<	|tj|||�}|j|d�tj}|jtj|�t|d
d��5}|jd
�ddd�|j||g�}tjj�}d|d<|tj|||�}|j|d�y#t$rY��dwxYw#t$rY��%wxYw#t$rY��wxYw#1swY��xYw)Nr�rrr�rrrrryr�r�zPimport sys, os
if os.getenv("FRUIT") != "orange=lemon":
    raise AssertionErrorzorange=lemonr)r=r�r�rr�r�r	rCr�rrcr�rdr r!)r4�spawnrr�rr�r"r$s        r�_test_invalid_envzSpawnTests._test_invalid_env�
s����.�.�������v�6�7�������"��%.��!�"�	,��R�Y�Y���v�>�H�
���X�s�+������"��5��w��	,��R�Y�Y���v�>�H�
���X�s�+������"��!(��~��	,��R�Y�Y���v�>�H�
���X�s�+��#�#�����	�(�(�(�3�
�(�C�'�
2�b��H�H�0�
1�3�
�����2�3�������"��(��w������G�T�6�:������1�%��K�	��	���	��	���	��	��3�
2�sB�	G�G�'G,�G;�	G�G�	G)�(G)�,	G8�7G8�;Hc�B�|jtj�yr()r6rrres r�test_spawnve_invalid_envz#SpawnTests.test_spawnve_invalid_env�
s�����r�z�z�*rc�B�|jtj�yr()r6rrres r�test_spawnvpe_invalid_envz$SpawnTests.test_spawnvpe_invalid_env�
s�����r�{�{�+rN)r\r]r^rr�rrrrrrrrrr!r$r&r+r-r0r2r6r8r:r+rrr�r�;
s����K��K�',�u��<�h��2� �2�
�i� �2�!�2�
�i� �2�!�2�
�j�!�2�"�2�
�h��2� �2��i� �2�!�2�
�i� �2�!�2�
�j�!�2�"�2�
�h��:� �:�
�i� �2�!�2��h��K� �K�
�i� �P�!�P�
�h��M� �M��i� �R�!�R�.&�`�i� �+�!�+��j�!�,�"�,rr�z>Skip due to platform/environment differences on *NIX buildbots�getloginztest needs os.getloginc��eZdZd�Zy)�
LoginTestsc�b�tj�}|jt|�d�yr)rr;r�r?)r4�	user_names  r�
test_getloginzLoginTests.test_getlogin�
s!���K�K�M�	����C�	�N�A�.rN)r\r]r^r@r+rrr=r=�
s��/rr=�getpriority�setpriorityz'needs os.getpriority and os.setpriorityc��eZdZ	d�Zy)�ProgramPriorityTestsc� �tjtjtj��}d|�d�}t	d|�\}}}t|�}|dk\r||krt
jd|z��|j||dz�y)NzMif 1:
        import os
        os.setpriority(os.PRIO_PROCESS, os.getpid(), zJ + 1)
        print(os.getpriority(os.PRIO_PROCESS, os.getpid()))
        r��z?unable to reliably test setpriority at current nice level of %srr)	rrA�PRIO_PROCESSr�r
rrrbrC)r4rr�rrl�new_prios      r�test_set_get_priorityz*ProgramPriorityTests.test_set_get_prioritys����~�~�b�o�o�r�y�y�{�;��6�6:�V�<	���%�T�4�0�	��3���s�8���2�:�(�d�*��#�#�%B�DH�%I�J�
J�
���X�t�a�x�0rN)r\r]r^rIr+rrrDrDs��;�1rrD�sendfileztest needs os.sendfile()c�J�eZdZddzZej
j
d�xr:ej
j
d�xrej
j
d�Zejed�Z
ejejdkd�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
eje e!d�d�d���Z"y)�TestSendfiles�12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcde12345abcdei�linux�solaris�sunosz%requires headers and trailers supportr�z(test is only meaningful on 32-bit buildsc�L�ttj|j�yr()r%rrc�DATArus rrwzTestSendfile.setUpClass's���I�$�$�c�h�h�/rc�J�tjtj�yr()rrdrcrus rr�zTestSendfile.tearDownClass+s������)�)�*rc�K�|j�s-|j��d{������|j�s�,yy7��wr()�at_eofr�)�readers r�chunkszTestSendfile.chunks/s,�����-�-�/����
�%�%��-�-�/�%�s�$A�A�A�Ac���K�dj|j|�2�cgc3d{���}|��7�6ncc}wc}�|_|j�|jj�y�w)Nr)rFrV�
server_bufferrj�server)r4rU�writerr s    r�handle_new_clientzTestSendfile.handle_new_client4sN���� �X�X����F�8K�&L�&L�1�q�&L��&L��&L�M�������������s&�A/�3�1
�/�1
�3�1
�3�=A/c��tK�d|_tj|jtj
��d{���|_|jjdj�}tj�|_
|jjd�tj�j|j|��d{���|jj�|_t!t"j$d�|_|j&j�|_y7��7�d�w)NrrFr�)rXr)�start_serverr[r�HOSTv4rY�sockets�getsockname�socket�client�setblocking�get_running_loop�sock_connectr��socknor rrcrv)r4�server_names  r�
asyncSetUpzTestSendfile.asyncSetUp9s����� ���#�0�0��1G�1G�1>�1E�1E�G�G����k�k�)�)�!�,�8�8�:���m�m�o���������&��&�&�(�5�5�d�k�k�;�O�O�O��k�k�(�(�*�����)�)�4�0��	��i�i�&�&�(���G��
	P�s#�9D8�D4�BD8�D6�A#D8�6D8c��K�|jj�|jj�|jj	��d{���y7��wr()rvrjrbrY�wait_closedres r�
asyncTearDownzTestSendfile.asyncTearDownEs:�����	�	�����������k�k�%�%�'�'�'�s�AA�A�Ac��lK�tjtjg|��i|���d{���S7��wr()r)�	to_threadrrJ)r�r�s  r�async_sendfilezTestSendfile.async_sendfileKs+�����&�&�r�{�{�D�T�D�V�D�D�D�D�s�+4�2�4c��K�			tj|i|���d{���S7�#t$rU}|jtjk(r�|jtj
tjfvrYd}~�y�d}~wwxYw�wr()rLrnrJrK�
ECONNRESET�EAGAIN�EBUSY)r�r�r�s   r�sendfile_wrapperzTestSendfile.sendfile_wrapperOst����	��

�)�8�8�$�I�&�I�I�I�I���
��9�9�� 0� 0�0���Y�Y�5�<�<����"=�=����
�s=�B�%�#�%�B�%�	B�A
A>�8B�=A>�>B�Bc�� K�d}d}d}|t|j�kr|j|j|j||��d{���}|dk(rnI||z
}||z
}|j||k�|j
||�|t|j�kr�|j
|t|j��|jjtj�|jj�|jj��d{���|j
t|j�t|j��|j
|j|j�y7��=7�f�w)Nr�)r?rQrsrfr�rkrCrb�shutdownra�	SHUT_RDWRrjrYrjrX)r4�
total_sent�offset�nbytes�sents     r�test_send_whole_filez!TestSendfile.test_send_whole_fileas:�����
������3�t�y�y�>�)��.�.�t�{�{�D�K�K�/5�v�?�?�D��q�y���d�N�F��$��J��O�O�D�F�N�+����V�Z�0��3�t�y�y�>�)�	
����S����^�4������V�-�-�.��������k�k�%�%�'�'�'�����T�/�/�0�#�d�i�i�.�A�����+�+�T�Y�Y�7�?��	(�s-�A
F�F	�
AF� BF�%F�&A$F�Fc��K�d}t|j�dz}t|j�|z
}d}||krZ|j|j|j||��d{���}|dk(rn$||z
}||z
}|j||k�||kr�Z|jjtj�|jj�|jj��d{���|jt|j�dzd}|j|t|��|jt|j�t|��|j|j|�y7��7���w)Nrrtru)r?rQrsrfr�rkrbrvrarwrjrYrjrCrX)r4rxry�	must_sendrzr{rSs       r�test_send_at_certain_offsetz(TestSendfile.test_send_at_certain_offsetwsK�����
��T�Y�Y��1�$����	�	�N�V�+�	����9�$��.�.�t�{�{�D�K�K�/5�v�?�?�D��q�y���d�N�F��$��J��O�O�D�F�N�+��9�$�	
�����V�-�-�.��������k�k�%�%�'�'�'��9�9�S����^�q�0�1�2������S��]�3�����T�/�/�0�#�h�-�@�����+�+�X�6�?��	(�s,�A%F�'F�(-F�A F�6F	�7BF�	Fc��4K�t|j�dz}	|j|j|j|d��d{���}|j|d�|jjtj�|jj�|jj��d{���|j|j d�y7��#t$r(}|jtjk7r�Yd}~��d}~wwxYw7�W�w)Nrurr)r?rQrnrfr�rCrJrK�EINVALrbrvrarwrjrYrjrX)r4ryr{r�s    r�test_offset_overflowz!TestSendfile.test_offset_overflow�s������T�Y�Y��$�&��	&��,�,�T�[�[�$�+�+�-3�T�;�;�D�
���T�1�%������V�-�-�.��������k�k�%�%�'�'�'�����+�+�S�1�;���	��w�w�%�,�,�&��'��	��	(�sM�D�+C"�C �C"�A2D�>D�?!D� C"�"	D�+D�	D�D�Dc��,K�|jt�5}|j|j|jdd��d{���ddd�|jjjtj�y7�A#1swY�@xYw�w)Nr�ru)	ryrJrnrfr�rCrwrKr��r4rls  r�test_invalid_offsetz TestSendfile.test_invalid_offset�sj����
�
�
�w�
'�2��%�%�d�k�k�4�;�;��D�I�I�I�(�������+�+�U�\�\�:�
J��(�
'�s.�B�,B�B�B�	=B�B�B�
Bc	��K�|j|j|jdd���d{���|jr5|j|j|jddddd���d{���yy7�F7��w)Nrru)r�r�ryr�r+)r�r�ryr��headers�trailersr�)rnrfr��SUPPORT_HEADERS_TRAILERSres r�
test_keywordszTestSendfile.test_keywords�s������!�!����D�K�K�)*�$�"�8�	8�	8��(�(��%�%�T�[�[����-.�d�.0�2�Q�&�H�
H�
H�)�	8��
H�s!�-A:�A6�?A:�/A8�0A:�8A:c���K�d}d|jddz}|j|j|jddddg���d{���}|j	|d�||z
}d}|t|�kryt
t|�|z
d�}|j|j|j||��d{���}|dk(rn+|j	||�||z
}||z
}|t|�kr�y|j|t|��|jj�|jj��d{���|jt|j�t|��y7��+7��7�8�w)	Nrsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyr�rusxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy�r�i)rQrnrfr��assertLessEqualr?�minrsrCrbrjrYrj�hashrX)r4rx�
expected_datar{ryrzs      r�test_headerszTestSendfile.test_headers�sg�����
�/�$�)�)�C�R�.�@�
��(�(����d�k�k�1�d�2<�j�1I�)�K�K�����T�#3�4��d��
����3�}�-�-���]�+�j�8�$�?�F��.�.�t�{�{�D�K�K�/5�v�?�?�D��q�y��� � ��v�.��$��J��d�N�F��3�}�-�-�	
����S��%7�8��������k�k�%�%�'�'�'�����d�0�0�1�4�
�3F�G�%K��?��	(�s>�AE8�E1�A.E8�5E4�64E8�+AE8�=E6�>4E8�4E8�6E8c	��K�tjdz}d}|jtj|�t	||�t|d�5}|j
|j|j�ddddg���d{���|jj�|jj��d{���|j|jd	�ddd�y7�e7�+#1swYyxYw�w)
Nr�sabcdefr�rr�s123456s789�r�sabcde123456789)rrcr�rdr%r rnrfr�rbrjrYrjrCrX)r4r��	file_dataros    r�
test_trailerszTestSendfile.test_trailers�s������"�"�S�(���	����	�(�(�'�2��G�Y�'�
�'�4�
 �A��%�%�d�k�k�1�8�8�:�q�!�09�6�/B�&�D�
D�
D��K�K�����+�+�)�)�+�+�+����T�/�/�1B�C�!�
 �
D��
,��	!�
 �sB�AC:�4C.�C*�;C.�C,� C.�!	C:�*C.�,C.�.C7�3C:c	��tK�d|jj_|jt�5}|j|j|jddddzgdz���d{���ddd�|jjjtj�y7�A#1swY�@xYw�w)NFr�x�rar��rY�handler_instance�
accumulateryrJrnrfr�rCrwrKr�r�s  r�test_headers_overflow_32bitsz)TestSendfile.test_headers_overflow_32bits�s�����38����$�$�/�
�
�
�w�
'�2��%�%�d�k�k�4�;�;��1�/3�e�|�n�u�.D�&�F�
F�
F�(�	
������+�+�U�\�\�:�
F��(�
'��.�1B8�5B,�(B*�)B,�-=B8�*B,�,B5�1B8c	��tK�d|jj_|jt�5}|j|j|jddddzgdz���d{���ddd�|jjjtj�y7�A#1swY�@xYw�w)NFrr�r�rar�r�r�s  r�test_trailers_overflow_32bitsz*TestSendfile.test_trailers_overflow_32bits�s�����38����$�$�/�
�
�
�w�
'�2��%�%�d�k�k�4�;�;��1�04�u��~��/E�&�G�
G�
G�(�	
������+�+�U�\�\�:�
G��(�
'�r��SF_NODISKIOztest needs os.SF_NODISKIOc��K�	|j|j|jddtj���d{���y7�#t
$r7}|jtjtjfvr�Yd}~yd}~wwxYw�w)Nrru)r�)	rnrfr�rr�rJrKrrrq)r4r�s  r�
test_flagszTestSendfile.test_flags�so����	��%�%�d�k�k�4�;�;��4�,.�N�N�&�<�
<�
<���	��y�y����e�l�l� ;�;��<��	�s?�B
�;A�A�A�B
�A�	B�-B�=B
�B�B
N)#r\r]r^rQr=r>rr�rr�requires_headers_trailers�maxsize�requires_32br�rwr�rrVr[rhrkrnrsr|rr�r�r�r�r�r�r�rrr�r+rrrLrLs�����$�D�#&�<�<�#:�#:�7�#C�C� D�#&�<�<�#:�#:�9�#E�E� D�#&�<�<�#:�#:�7�#C�C��!4�� 3� 3�4L�3�!5��&�8�&�&�s�{�{�U�':�6�8�L��0��0��+��+��&��&��

)�(��E��E�����"8�,7�.2�";�
H��H��H�.�D��D���;���;���;���;���X�����]�3�4�6��6��rrLc���ttd�sy	ttjdd�5}	tj
|j
�dd�	ddd�tjtj�y#t$r.Yddd�tjtj�ywxYw#1swY�gxYw#tjtj�wxYw)N�setxattrFrr�	user.testrT)	rrr rrcr�r�rJrd)r$s r�supports_extended_attributesr��s����2�z�"��+�
�)�"�"�D�!�
,��
����B�I�I�K��s�;�-�	����)�)�*����
��	-�	����)�)�*�
��-�
,��	����)�)�*�sE�C�B<�%B�C�	B9�B<�C�8B9�9B<�<C�C�%C-z(no non-broken extended attribute supportrtr��'c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�ExtendedAttributeTestsc�b�tj}|jtj|�t	|�|jt�5}|||d�fi|��ddd�|jjjtj�||�}	|j|	t�|||d�dfi|��t|	�}
|
jd�|jt||��|
�|j||dfi|��d�|||d�dtj fi|��|j||dfi|��d�|jt�5}|||d�dtj"fi|��ddd�|j|jjtj$�|jt�5}|||d�dtj fi|��ddd�|j|jjtj�|||d�dtj"fi|��|
jd�|jt||��|
�|||d�fi|��|jt�5}|||d�fi|��ddd�|j|jjtj�|
j'd�|jt||��|
�|j|||d�fi|��d�|||d�dfi|��|j|||d�fi|��d�|||d�fi|��t)d	�t+d
�D��}|D]
}|||dfi|���|jt||��t|	�t|�z�y#1swY���xYw#1swY��xxYw#1swY��xYw#1swY��\xYw)N�	user.testrr�r�sbyez
user.test2sfoosaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac3�>K�|]}dj|����y�w)zuser.test{}N)r�)r.r�s  rr/z;ExtendedAttributeTests._check_xattrs_str.<locals>.<genexpr>5s����B�z�!�m�*�*�1�-�z�s�r�r�)rrcr�rdr%ryrJrCrwrK�ENODATAr1r�rr�r�
XATTR_REPLACE�XATTR_CREATE�EEXISTr�rr�)
r4r��getxattrr��removexattr�	listxattrr�r�rl�
init_xattr�xattr�many�things
             r�_check_xattrs_strz(ExtendedAttributeTests._check_xattrs_str
s]��
�
�
�����	�(�(�"�-��B��
�
�
�w�
'�2��R��;��2�6�2�(�������+�+�U�]�]�;��r�]�
����j�$�/���Q�{�^�S�3�F�3��J���
�	�	�+������Y�r�]�+�U�3�����"�l�=�f�=�s�C���Q�{�^�X�r�/?�/?�J�6�J�����"�l�=�f�=�x�H�
�
�
�w�
'�2��R��;������K�F�K�(�������+�+�U�\�\�:�
�
�
�w�
'�2��R��<��&�"�2B�2B�M�f�M�(�������+�+�U�]�]�;���Q�|�_�f�b�o�o�H��H�
�	�	�,������Y�r�]�+�U�3��B��+��1�&�1�
�
�
�w�
'�2��R��;��2�6�2�(�������+�+�U�]�]�;�
���[�!�����Y�r�]�+�U�3�����"�a��o�@��@�&�I���Q�{�^�Y�9�&�9�����"�a��n�?��?��K��B��+��1�&�1��B�u�S�z�B�B���E��R���/��/������Y�r�]�+�S��_�s�4�y�-H�I�S(�
'��(�
'��(�
'��(�
'�s0�O=�3!P
�%!P�9P$�=P�
P�P!�$P.c��|jtg|��i|��tjtj�|jt
jg|��i|��tjtj�yr()r�r2rrdrcrr;rs   r�
_check_xattrsz$ExtendedAttributeTests._check_xattrs:sb������s�4�T�4�V�4�����)�)�*�����r�{�{�<�T�<�V�<�����)�)�*rc��|jtjtjtjtj
�yr(�r�rr�r�r�r�res r�test_simplez"ExtendedAttributeTests.test_simpleAs)�����2�;�;����R�^�^��<�<�	)rc��|jtjtjtjtj
d��y)NFr�r�res r�
test_lpathz!ExtendedAttributeTests.test_lpathEs1�����2�;�;����R�^�^��<�<��	�	@rc�D�d�}d�}d�}d�}|j||||�y)Nc��t|d�5}tj|j�g|���cddd�S#1swYyxYwr�)r rr�r��rDr�r$s   rr�z1ExtendedAttributeTests.test_fds.<locals>.getxattrJs1���d�D�!�R��{�{�2�9�9�;�6��6�"�!�!��	�$;�Ac��t|dd�5}tj|j�g|���ddd�y#1swYyxYw�Nr�r)r rr�r�r�s   rr�z1ExtendedAttributeTests.test_fds.<locals>.setxattrMs3���d�D�!�$�����B�I�I�K�/�$�/�%�$�$��	�%<�Ac��t|dd�5}tj|j�g|���ddd�y#1swYyxYwr�)r rr�r�r�s   rr�z4ExtendedAttributeTests.test_fds.<locals>.removexattrPs3���d�D�!�$�����r�y�y�{�2�T�2�%�$�$�r�c��t|d�5}tj|j�g|���cddd�S#1swYyxYwr�)r rr�r�r�s   rr�z2ExtendedAttributeTests.test_fds.<locals>.listxattrSs1���d�D�!�R��|�|�B�I�I�K�7�$�7�"�!�!�r�)r�)r4r�r�r�r�s     r�test_fdszExtendedAttributeTests.test_fdsIs,��	7�	0�	3�	8�	
���8�X�{�I�FrN)r\r]r^r�r�r�r�r�r+rrr�r�s��.J�`+�)�@�
Grr��get_terminal_sizezrequires os.get_terminal_sizec�d�eZdZd�Zd�Zejejdk(d�d��Z	y)�
TermsizeTestsc�d�		tj�}|j|jd�|j|jd�y#t$rV}tjdk(s,|j
t
jt
jfvr|jd��d}~wwxYw)Nr��failed to query terminal sizer)rr�rJr=r>rKr��ENOTTYrwr��columnsr)r4r�r�s   r�test_does_not_crashz!TermsizeTests.test_does_not_crash[s���	�
	��'�'�)�D�	
������a�0�����
�
�A�.���	��|�|�w�&�!�'�'�e�l�l�E�L�L�5Q�*Q��
�
�=�>���	�s�A�	B/�AB*�*B/c�b�		tjddgtjd��j�}td�t|d�f}	tjtjj��}|j'||�y#ttj
tf$r|jd�Y��wxYw#t$rV}tjdk(s,|j t j"t j$fvr|jd	��d}~wwxYw)
N�sttyr�T)r�rVzstty invocation failedrrrr�r�)r�rj�DEVNULLr6rIr�r�rwrrr�r=�	__stdin__r�rJr>rKr�r�rC)r4r�rSr�r�s     r�test_stty_matchzTermsizeTests.test_stty_matchms���	�	4��'�'��V�$�Z�-?�-?�d���%�'�
���Q��L�#�d�1�g�,�/��	��)�)�#�-�-�*>�*>�*@�A�F�	
����6�*��"�:�#@�#@��!�	4��M�M�2�3�	4���	��|�|�w�&�!�'�'�e�l�l�E�L�L�5Q�*Q��
�
�=�>���	�s*�6B�1C�/C�C�	D.�AD)�)D.r�zWindows specific testc�D�		tdd�}5tj|j��}ddd�|j
jd�|j
|jd�y#t$r|jd�Y��wxYw#1swY�bxYw)Nzconout$ryzfailed to open conout$r)	r rJrwrr�r�r�r�r)r4�conoutr�s   r�test_windows_fdzTermsizeTests.test_windows_fd�s���P�	4��)�S�)�F���'�'��
�
��8�D��	
������a�0�����
�
�A�.��
�	4��M�M�2�3�	4��
�V�s�A6�$B�6B�B�BN)
r\r]r^r�r�rrr=r>r�r+rrr�r�Ys:��/�$+�8�X�������0�2I�J�
/�K�
/rr��memfd_createzrequires os.memfd_creater�rc��eZdZd�Zy)�MemfdCreateTestsc�R�tjdtj�}|j|d�|j	tj
|�|j
tj|��t|dd��5}|jd�|j|j�d�ddd�tjd�}|j	tj
|�|j
tj|��y#1swY�cxYw)N�Hir�r�F)�closefdsmemfd_creater-)rr��MFD_CLOEXECr�r�rjr�rfr r!rC�tell)r4r�rorCs    r�test_memfd_createz"MemfdCreateTests.test_memfd_create�s���
�_�_�T�2�>�>�
2�����B��#�������"�%�����+�+�B�/�0�
�"�d�E�
*�a�
�G�G�O�$����Q�V�V�X�r�*�+��o�o�d�#��������#�&�����+�+�C�0�1�
+�
*�s�	2D�D&N)r\r]r^r�r+rrr�r��s��2rr��eventfdzrequires os.eventfdrc��eZdZd�Zd�Zd�Zy)�EventfdTestsc�J�d�}d}d}tj|�}|j|d�|jtj|�|jtj|��tj||�}|j|||��tj||d��tj||�}|j||d��tj||d��tj||d��tj||�}|j||d��tj|d�tj|d	�tj|�}|j|d�y)
Nc�0�	tjd|�S)Nz@Q)�struct�pack)rls rr�z/EventfdTests.test_eventfd_initval.<locals>.pack�s��
��;�;�t�U�+�+rr*r�r�r��(rtr@r�)rr�r�r�rjr�rfr�rCr!�
eventfd_write�eventfd_read)r4r�r��initvalr��ress      r�test_eventfd_initvalz!EventfdTests.test_eventfd_initval�s@��	,�����
�Z�Z��
 �����B��#�������"�%�����+�+�B�/�0��g�g�b�$�������d�7�m�,�
����T�"�X���g�g�b�$�������d�2�h�'�
����T�"�X��
����T�!�W���g�g�b�$�������d�2�h�'�	����R� �
����Q���o�o�b�!������b�!rc��d}tjtjztjz}tj||�}|j|d�|j
tj|�tj|�}|j|d�tj|�}|j|d�|jt�5tj|�ddd�|jt�5tj|d�ddd�tj|d�tj|�}|j|d�|jt�5tj|�ddd�y#1swY��xYw#1swY��xYw#1swYyxYw)Nrtr�rrr*)r�EFD_CLOEXEC�
EFD_SEMAPHORE�EFD_NONBLOCKr�r�r�rjr�rCryr�r�r�)r4r�r�r�r�s     r�test_eventfd_semaphorez#EventfdTests.test_eventfd_semaphore�s>��������!1�!1�1�B�O�O�C��
�Z�Z���
'�����B��#�������"�%��o�o�b�!������a� ��o�o�b�!������a� �
�
�
��
/��O�O�B��0�
�
�
��
/��G�G�B��N�0�	����Q���o�o�b�!������a� �
�
�
��
/��O�O�B��0�
/�0�
/��
/�
/��0�
/�s$� F#�F/�F;�#F,�/F8�;Gc���tjtjz}tjd|�}|j	|d�|jtj|�tj|g|g|gd�\}}}|j|||fg|ggf�tj|d�tj|g|g|gd�\}}}|j|||f|g|ggf�|jtj|�d�tj|d�tj|g|g|gd�\}}}|j|||f|gggf�tj|�y)Nrr�r�l����)rr�r�r�r�r�rj�selectrCr�r�)r4r�r��rfd�wfd�xfds      r�test_eventfd_selectz EventfdTests.test_eventfd_select�sN��������0��
�Z�Z��5�
!�����B��#�������"�%��
�
�r�d�R�D�2�$��:�
��S�#����#�s�C��2��t�R�.�9�	����R� ��
�
�r�d�R�D�2�$��:�
��S�#����#�s�C��B�4�"��r�*:�;��������,�b�1�	����[�)��
�
�r�d�R�D�2�$��:�
��S�#����#�s�C��B�4��R�.�9�
����rN)r\r]r^r�r�r�r+rrr�r��s��"�> �4rr�c��eZdZd�Zd�Zy)�OSErrorTestsc��Gd�dt�}g|_g|_tj�tj}ntj
}|jj
|�|jj
||��tj�tj}n#tjtj
�}|jj
|�|j|jz|_
y)Nc��eZdZy)�OSErrorTests.setUp.<locals>.StrN�r\r]r^r+rr�Strr����rr)r2�bytes_filenames�unicode_filenamesrr�rcr��TESTFN_UNDECODABLErr;r�)r4r�decoded�encodeds    rrfzOSErrorTests.setUp�s���	�#�	� "���!#����'�'�3��2�2�G��&�&�G����%�%�g�.����%�%�c�'�l�3��'�'�3��2�2�G��k�k�)�"2�"2�3�G����#�#�G�,��-�-��0F�0F�F��rc���|jtjf|jtjf|jtjtj
f|jtjf|jtjf|jtjf|jtjf|jtjdf|jtjdfg	}tj�r,|j|jtjdf�t!td�r-|j|jtj"ddf�t!td�r-|j|jtj$ddf�t!td�r,|j|jtj&df�t!td�r,|j|jtj(df�t!td�r,|j|jtj*df�t!td	�r+|j|jtj,f�t!td
�r,|j|jtj.df�t!td�r�|j1|jtj2f|jtj4df|jtj6dd
f|jtj8dff�t!td�r,|j|jtj:df�t!td�r+|j|jtj<f�|D]*^}}}|D] }	||g|���|j?d|����"�,y#t@$r0}|jC|jD|tG|��Yd}~�Zd}~wtH$rY�hwxYw)Nr�r�rqr�lchownrT�chflags�lchflags�chrootr�r�r�suser�lchmodr*zNo exception thrown by )%r�rrHrar r�r�r�rdr�r�r�r�	can_chmodr�r�rrqrrTr
rrr�r�r�r�r�r�rr*r;rJrir"r2�UnicodeDecodeError)r4�funcsr��func�	func_argsrr�s       r�test_oserror_filenamez"OSErrorTests.test_oserror_filenames���
�^�^�R�X�X�'�
�^�^�R�X�X�'�
�^�^�R�W�W�b�k�k�2�
�^�^�R�X�X�'�
�^�^�R�W�W�&�
�^�^�R�Y�Y�(�
�^�^�R�Z�Z�)�
�^�^�R�Y�Y��.�
�^�^�R�Z�Z��/�

����� ��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��2�z�"��L�L�$�.�.�"�+�+�q�9�:��2�x� ��L�L�$�.�.�"�)�)�5�6��2�v���L�L�$�.�.�"�'�'�5�9�:��2�{�#��L�L�������/�������k�:�������k�7�C��������=�	�
��2�x� ��L�L�$�.�.�"�)�)�U�;�<��2�z�"��L�L�$�.�.�"�+�+�7�8�+0�'�I�t�i�!��@���*�	�*��I�I� 7��v�>�?�"�,1���A��M�M�#�,�,��c�$�i�@�@��)����s�	P$�$	Q'�-&Q�Q'�&Q'N)r\r]r^rfrr+rrr�r��s��G�(1@rr�c��eZdZd�Zy)�
CPUCountTestsc��tj�}|�)|j|t�|j	|d�y|jd�y)Nrz&Could not determine the number of CPUs)r�	cpu_countr1rr4rw)r4�cpuss  r�test_cpu_countzCPUCountTests.test_cpu_countDs@���|�|�~�����!�!�$��,����t�Q�'��M�M�B�CrN)r\r]r^rr+rrrrCs��Drrc���eZdZd�Zej
edud�d��Zej
edud�d��Zeje
ed�d�d��Zd	�Z
d
�Zeje
ed�d�d
��Zd�Zd�Zejej&dk(d�d��Zeje
ed�d�d��Zeje
ed�d�d��Zy)�FDInheritanceTestsc�T�tjttj�}|j	tj
|�|j
tj|�d�tj|d�|j
tj|�d�y�NFT)	rr r�r�r�rjrCrfrgr�s  r�test_get_set_inheritablez+FDInheritanceTests.test_get_set_inheritablePsn��
�W�W�X�r�{�{�
+��������"�%�����+�+�B�/��7�
���2�t�$�����+�+�B�/��6rNz
need fcntlc���tjttj�}|j	tj
|�|j
tj|�d�tj|tj�}|tjz}tj|tj|�|j
tj|�d�yr )rr r�r�r�rjrCrf�fcntl�F_GETFD�
FD_CLOEXEC�F_SETFD)r4r�r�s   r�test_get_inheritable_cloexecz/FDInheritanceTests.test_get_inheritable_cloexecXs���
�W�W�X�r�{�{�
+��������"�%�����+�+�B�/��7����B��
�
�.��
�%�"�"�"�"��
���B��
�
�u�-�����+�+�B�/��6rc���tjttj�}|j	tj
|�|j
tj|tj�tjztj�tj|d�|j
tj|tj�tjzd�y)NTr)rr r�r�r�rjrCr#r$r%rgr�s  r�test_set_inheritable_cloexecz/FDInheritanceTests.test_set_inheritable_cloexeces���
�W�W�X�r�{�{�
+��������"�%�������R����7�%�:J�:J�J��)�)�	+�	���2�t�$�������R����7�%�:J�:J�J��	r�O_PATHzneed os.O_PATHc���tjttj�}|j	tj
|�|j
tj|�d�tj|d�|j
tj|�d�tj|d�|j
tj|�d�yr )	rr r�r*r�rjrCrfrgr�s  r�test_get_set_inheritable_o_pathz2FDInheritanceTests.test_get_set_inheritable_o_pathps���
�W�W�X�r�y�y�
)��������"�%�����+�+�B�/��7�
���2�t�$�����+�+�B�/��6�
���2�u�%�����+�+�B�/��7rc���tj�}|jt�5}t	j
|�ddd�|j
jjtj�|jt�5}t	j|d�ddd�|j
|jjtj�|jt�5}t	j|d�ddd�|j
|jjtj�y#1swY��xYw#1swY��xYw#1swY�WxYw�NTF)rr7ryrJrrfrCrwrKrxrg)r4r�rzs   r�test_get_set_inheritable_badfz0FDInheritanceTests.test_get_set_inheritable_badf|s���
�
"�
"�
$��
�
�
�w�
'�3����r�"�(�������,�,�e�k�k�:�
�
�
�w�
'�3����r�4�(�(�������,�,�e�k�k�:�
�
�
�w�
'�3����r�5�)�(�������,�,�e�k�k�:�(�
'��(�
'��(�
'�s#�E
�E�9E&�
E�E#�&E/c���tjttj�}|j	tj
|�|j
tj|�d�yr;)rr r�r�r�rjrCrfr�s  rr�zFDInheritanceTests.test_open�sC��
�W�W�X�r�{�{�
+��������"�%�����+�+�B�/��7rrzneed os.pipe()c�F�tj�\}}|jtj|�|jtj|�|j	tj
|�d�|j	tj
|�d�yr;)rrr�rjrCrf)r4r�r�s   r�	test_pipezFDInheritanceTests.test_pipe�sk���7�7�9���S�������#�&�������#�&�����+�+�C�0�%�8�����+�+�C�0�%�8rc�H�tjttj�}|j	tj
|�tj|�}|j	tj
|�|jtj|�d�yr;)	rr r�r�r�rjrvrCrf�r4�fd1rCs   r�test_dupzFDInheritanceTests.test_dup�sb���g�g�h����,��������#�&��f�f�S�k��������#�&�����+�+�C�0�%�8rc��tjd�}|jtj|�|j	|d�y�Nrrr)rrvr�rjr4r�s  r�test_dup_standard_streamz+FDInheritanceTests.test_dup_standard_stream�s1��
�V�V�A�Y��������"�%����2�q�!rr�r�c�>�tjdtj�}|jtj|�tj
|�}|jtj|�|j
tj|��y)N�NUL)rr r�r�rjrvr�rfr4s   r�test_dup_nulzFDInheritanceTests.test_dup_nul�sb���g�g�e�R�[�[�)��������#�&��f�f�S�k��������#�&�����+�+�C�0�1rr>zneed os.dup2()c���tjttj�}|j	tj
|�tjttj�}|j	tj
|�|j
tj||�|�|jtj|��tjttj�}|j	tj
|�|j
tj||d��|�|jtj|��y)NF)�inheritable)rr r�r�r�rjrCr>rkrfr�)r4r�rC�fd3s    rrAzFDInheritanceTests.test_dup2�s���
�W�W�X�r�{�{�
+��������"�%��g�g�h����,��������#�&��������S�)�3�/�����*�*�3�/�0��g�g�h����,��������#�&��������S�e�<�c�B�����+�+�C�0�1r�openptyzneed os.openpty()c�F�tj�\}}|jtj|�|jtj|�|j	tj
|�d�|j	tj
|�d�yr;)rr@r�rjrCrf)r4�	master_fd�slave_fds   r�test_openptyzFDInheritanceTests.test_openpty�sl�� �j�j�l��	�8�������)�,�������(�+�����+�+�I�6��>�����+�+�H�5�u�=r)r\r]r^r!rrr#r'r)rrrr,r/r�r2r6r9r=r>r<rArDr+rrrrNsC��7��X�_�_�U�d�]�L�1�
7�2�
7��X�_�_�U�d�]�L�1��2���X�����X�.�0@�A�	8�B�	8�
;�8�
�X�����V�,�.>�?�9�@�9�9�"�
�X�������0�2G�H�2�I�2��X�����V�,�.>�?�2�@�2� �X�����Y�/�1D�E�>�F�>rrc
�t�eZdZddddejfdfddddej
feed	d�fgZd
�Zd�Z	y)�PathTConverterTests)r�Tr+N)raFr+NrlFN)r
F�rN)rFrGNr rjc	�N�tj}tjdk(rdx}}n.tjtj�}t|�}tjt|�tjtjz�}|jtjtj�|jtj|�t|�}t|�}|jD]�\}}}	}
|j|��5	tt|�}||||fD]4}|��|j||��5||g|	���}
|
�|
|
�ddd��6|j!t"d�5||g|	���ddd�|r||g|	���}
|
�1|
|
�n(|j!t"d�5||g|	���ddd�ddd���y#t$rYddd���wxYw#1swY��xYw#1swY�uxYw#1swY�CxYw#1swY��xYw)NrQr)rrDzto return str or byteszos.PathLike)rrcrrr;rr r�rhr�rdrj�	functionsrRr5r:�assertRaisesRegexr�)r4�str_filename�bytes_fspath�bytes_filenamer��
int_fspath�
str_fspathr�allow_fd�
extra_args�
cleanup_fnr�rDrAs              r�test_path_t_converterz)PathTConverterTests.test_path_t_converter�s��� �'�'��
�7�7�d�?�,0�0�L�>��[�[��)9�)9�:�N�#�N�3�L�
�W�W�X�l�+�R�[�[����-C�
D�����	�(�(�)�*:�*:�;�������"�%��b�\�
��l�+�
�6:�n�n�2�D�(�J�
����4��(�� ��T�*�B�*�>�:�)�+�D��|� ����4�d��;�!#�D�!6�:�!6��%�1�&�v�.�<�;�	+��+�+�!�#;�=��z�/�J�/�=����0�Z�0�F�!�-�"�6�*��/�/�%�)�+��2�+�
�+�+�1)�(�7E��&���	)�(���<�;��
=�=��+�+��1)�(�sx�H�!G�1H�G6	�$ H�
H�4H�
H�H�	G3�(H�2G3�3H�6G?
�;H�H�H�H�H�H$	c���d}|jt|dz�5tjt	d��ddd�|jt|dz�5tjt	d��ddd�|jt|dz�5tjt	t���ddd�y#1swY��xYw#1swY�^xYw#1swYyxYw)Nz-__fspath__\(\) to return str or bytes, not %srrt�floatg���Q�@�object)rJr�rr�rrV)r4r�s  r�&test_path_t_converter_and_custom_classz:PathTConverterTests.test_path_t_converter_and_custom_classs���>��
�
#�
#�I�s�V�|�
<��G�G�H�Q�K� �=�
�
#�
#�I�s�X�~�
>��G�G�H�T�N�#�?�
�
#�
#�I�s�Y��
?��G�G�H�V�X�&�'�@�
?�	=�
<��
>�
>��
?�
?�s#�C�C�'C$�C�C!�$C-)
r\r]r^r�F_OKr�r5rIrSrWr+rrrFrF�sO��	!�"�	�5�2�7�7�*�d�+�&�'�	��������G�T�(B�C�
�I�*,�X(rrFrirjzCannot unset blocking flagz'Windows only supports blocking on pipesc��eZdZd�Zy)�
BlockingTestsc���tjttj�}|j	tj
|�|j
tj|�d�tj|d�|j
tj|�d�tj|d�|j
tj|�d�yr.)	rr r�r�r�rjrCrirlr�s  rrmzBlockingTests.test_blockings���
�W�W�X�r�{�{�
+��������"�%��������,�d�3�
����E�"��������,�e�4�
����D�!��������,�d�3rN)r\r]r^rmr+rrrZrZ
s��
	4rrZc��eZdZd�Zy)�ExportsTestsc��|jdtj�|jdtj�y)Nr r�)r�r�__all__res r�test_os_allzExportsTests.test_os_alls&���
�
�f�b�j�j�)��
�
�f�b�j�j�)rN)r\r]r^r`r+rrr]r]s��*rr]c��eZdZd�Zd�Zd�Zy)�TestDirEntryc��tjjtj�|_|jtj|j�tj|j�yr()rrD�realpathrrcr�r�rGres rrfzTestDirEntry.setUp#sF���G�G�$�$�Y�%5�%5�6��	����	�(�(�$�)�)�4�
������rc�L�|jttj�yr()ryr�r�DirEntryres r�test_uninstantiablez TestDirEntry.test_uninstantiable(s�����)�R�[�[�1rc��ttjj|jd�d�}tj|j�D�cgc]}|��c}j�}|j
|tj�|j|jd�ddl
}|jt|j||�ycc}w)Nr��pythonr)r%rrDrF�scandirrXr1rfrCrrPryr�rS)r4r"�entryrPs    r�test_unpickablezTestDirEntry.test_unpickable+s����r�w�w�|�|�D�I�I�z�B�I�N��$&�J�J�t�y�y�$9�:�$9�5��$9�:�>�>�@�����e�R�[�[�1�������Z�0�����)�V�\�\�5�(�C��	;s�	CN)r\r]r^rfrgrlr+rrrbrb"s���
2�Drrbc��eZdZejZd�Zd#d�Zd�Zd�Zd�Z	d�Z
d�Zd�Ze
jej d	k7d
�d��Zd�Zd#d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Ze
j:ej>ej@vd�d��Z!e
je"jFd�d��Z$d�Z%d�Z&d�Z'd�Z(d�Z)d �Z*d!�Z+y")$�TestScandirc�B�tjjtj�|_tj
|j�|_|jtj|j�tj|j�yr()
rrDrdrrcr;�
bytes_pathr�r�rGres rrfzTestScandir.setUp7sZ���G�G�$�$�Y�%5�%5�6��	��+�+�d�i�i�0������	�(�(�$�)�)�4�
������rc��t|t�r|jn|j}tjj||�}t
|d�|S)Nri)rirYrprDrrFr%)r4rrDr"s    rr%zTestScandir.create_file=s=��",�T�5�"9�t���t�y�y���7�7�<�<��d�+���H�i�(��rc��td�tj|j�D��}|j	t|j
��|�|S)Nc3�8K�|]}|j|f���y�wr(r�r.rks  rr/z*TestScandir.get_entries.<locals>.<genexpr>Ds!����;�$9�5��
�
�E�*�$9���)rrrjrDrCr�keys)r4�names�entriess   r�get_entrieszTestScandir.get_entriesCsF���;�$&�J�J�t�y�y�$9�;�;����������/��7��rc���|rRt|�D]C}|jd�s�|dvr�|jt||�t||�|||f��Ey|j||�y)N�st_)r�r��st_nlinkr��st_ctime_ns)r2rrCr5)r4r�r��skip_fieldsrCs     r�assert_stat_equalzTestScandir.assert_stat_equalIso����E�
�����u�-���+�+��� � ����!5�!(���!5�"'���!5�7�
#�
���U�E�*rc��tj|j�}|jtt|��|j
�yr()rrjrDryr�r�rj)r4�scandir_iters  rrgzTestScandir.test_uninstantiableWs5���z�z�$�)�)�,�����)�T�,�%7�8����rc���|jd�}tj|j�}ddl}|jt|j||�|j�y)Nr�r)	r%rrjrDrPryr�rSrj)r4r"r�rPs    rrlzTestScandir.test_unpickable\sK���#�#�J�/���z�z�$�)�)�,������)�V�\�\�<��J����rc��|j|tj�|j|j|�|j|j
tj
j
|j
|��|j|j�tj|j
d��j�tj|j
�}|j|j�tj|j��|j|j�tj|j��|j|j�tj
j!|j
��tj|j
d��}|j|jd��tj|j��|j|jd��tj|j��|j|j#�tj
j%|j
��|j'|j�|tjdk(xr|�|j'|jd��|tjdk(�y)NFr�rQ)r1rrfrCrrDrF�inoder�r��is_dir�S_ISDIRr=�is_file�S_ISREG�
is_symlinkrP�is_junction�
isjunctionr)r4rkrr�r�r��
entry_stat�entry_lstats        r�check_entryzTestScandir.check_entrycs�����e�R�[�[�1�������T�*�������R�W�W�\�\�$�)�)�T�%B�C��������������U�C�J�J�	L��W�W�U�Z�Z�(�
�����������j�&8�&8�9�	;�����������j�&8�&8�9�	;�����)�)�+�������
�
�3�	5��g�g�e�j�j�%�@��������e��<����k�&9�&9�:�	<�������u��=����k�&9�&9�:�	<�	
����*�*�,�b�g�g�.@�.@����.L�M����u�z�z�|�)�!�w�w�$��A�z�>�	C�	
���u�z�z�%�z�@�*�!�w�w�$��	0rc�H�ttd�}tj�}tjj|jd�}tj|�|jd�}|r?	tj|tjj|jd��|r~tj|tjj|jd�d��tj|tjj|jd	��ddg}|r|jd�|r|jd
�|j|�}|d}|j|dddd�|d}|j|dddd�|r|d}|j|dddd�|r5|d}|j|dddd�|d	}|j|d	ddd�yy#t$r}|jd|z�Yd}~��fd}~wwxYw)Nr�r2r�z
link_file.txtrx�symlink_dirT)r��symlink_file.txt)r�r�F)rrrr�rDrFrGr%r�r�rwr�r�r�ryr�)	r4r�r�rQr"r�rwrxrks	         r�test_attributeszTestScandir.test_attributes�s����r�6�"���'�'�)���'�'�,�,�t�y�y�%�0��
������#�#�J�/���
3�����"�'�'�,�,�t�y�y�/�"J�K���J�J�w������T�Y�Y�
� F�+/�
1��J�J�x������d�i�i�9K�!L�M��
�#����L�L��)���L�L�<�=��"�"�5�)�����������t�U�E�:��
�#������
�E�4��?���O�,�E����U�O�U�D�%�H���M�*�E����U�M�4���E��.�/�E����U�$6��t�T�J���1#�
3��
�
�o��1�2�2��
3�s�8>G9�9	H!�H�H!r�z/Can only test junctions with creation on win32.c��tjj|jd�}tj|�ddl}	|j
|tjj|jd��|jddg�}|j|dj�d�|j|dj�d�y#t$rtjd��wxYw)N�tgtdirr�srcjuncz!creating the test junction failedTF)rrDrFrGr�r�rJrrbryrCr�)r4rQr�rxs    r�test_attributes_junctionsz%TestScandir.test_attributes_junctions�s����'�'�,�,�t�y�y�(�3��
������	I�"�G�"�"�7�B�G�G�L�L����I�,N�O��"�"�I�x�#8�9�������+�7�7�9�4�@������*�6�6�8�%�@���	I��#�#�$G�H�H�	I�s�;C�C9c�
�t|t�r|jn|j}t	tj|��}|jt|�d�|d}|j|j|�|Sr8)
rirYrprDr�rrjrCr?r)r4rrDrxrks     r�	get_entryzTestScandir.get_entry�sc��",�T�5�"9�t���t�y�y���r�z�z�$�'�(������W��q�)���
��������T�*��rc��|j|��}|jtjj	|��S)Nr)r%r�rrD�basename)r4rr"s   r�create_file_entryzTestScandir.create_file_entry�s3���#�#��#�.���~�~�b�g�g�.�.�x�8�9�9rc��|j�}tj�}	tj|j�td�tj�D��}|jt|j��tjj|�g�tj|�y#tj|�wxYw)Nc3�8K�|]}|j|f���y�wr(rrts  rr/z5TestScandir.test_current_directory.<locals>.<genexpr>�s����I�L�5�E�J�J��.�L�ru)r%rr0rHrDrrjrCrrvr�)r4r"�old_dirrxs    r�test_current_directoryz"TestScandir.test_current_directory�s����#�#�%���)�)�+��		��H�H�T�Y�Y���I�B�J�J�L�I�I�G����V�G�L�L�N�3� �g�g�.�.�x�8�9�
;�
�H�H�W���B�H�H�W��s�B
C�Cc�Z�|j�}|jt|�d�y)Nz<DirEntry 'file.txt'>)r�rCr0�r4rks  r�	test_reprzTestScandir.test_repr�s%���&�&�(������e��&=�>rc��|j�}|jtj|�tjj|jd��y�Nr�)r�rCr�fspathrDrFr�s  r�test_fspath_protocolz TestScandir.test_fspath_protocol�s<���&�&�(��������5�)�2�7�7�<�<��	�	�:�+N�Orc�B�tjd�}|j|��}tj|�}|j	|t
�|j
|tjjtj|j�|��y)Nz
bytesfile.txtr)	rr;r�r�r1rYrCrDrF)r4rM�bytes_entryr�s    r�test_fspath_protocol_bytesz&TestScandir.test_fspath_protocol_bytes�sq�����_�5���,�,�.�,�A�����;�'�����f�e�,����������b�k�k�$�)�)�&<�^�L�	Nrc��tjj|jd�}tj|�|j	d�}tj
|�tjdk(r|j|j��|j|j��|j|j��tjdk(rC|jt|j�|j�|jd��y|j!|j�d�|jt|j�|jt|jd��y)Nr2rQFr�r)rrDrFrGr�r�rrkr�r�r�r�ryrIr�r�r4)r4rDrks   r�test_removed_dirzTestScandir.test_removed_dir�s���w�w�|�|�D�I�I�u�-��
��������u�%��
������7�7�d�?��O�O�E�L�L�N�+��������)�����)�)�+�,�
�7�7�d�?����/����=��J�J�L��J�J�u�J�-����u�{�{�}�a�0����/����<����/����U��Src��|j�}tj|j�|j	|j��tjdk(r|j|j��|j	|j��tjdk(rC|jt|j�|j�|jd��y|j|j�d�|jt|j�|jt|jd��y)NrQFr�r)r�rrdrDr�r�rrkr�r�ryrIr�r�r4r�s  r�test_removed_filezTestScandir.test_removed_file�s����&�&�(��
�	�	�%�*�*���������(�
�7�7�d�?��O�O�E�M�M�O�,�����)�)�+�,�
�7�7�d�?����/����=��J�J�L��J�J�u�J�-����u�{�{�}�a�0����/����<����/����U��Src�(�tj�s|jd�S|jd�}t	j
|tjj|jd��|jddg�}|d}t	j|�|j|j�d�|j|j��|j|j��|j|jd���|j|jd���|j|j!��|j#t$|j&�|j'd��y)Nzcannot create symbolic linkr�zsymlink.txtrFr�)rr�rwr%rr�rDrFryrdr4r�r�r�r�rkr�ryrIr�)r4r"rxrks    r�test_broken_symlinkzTestScandir.test_broken_symlink
s%���$�$�&��=�=�!>�?�?��#�#�J�/��
�
�
�8��7�7�<�<��	�	�=�9�	;��"�"�J�
�#>�?���
�&��
�	�	�(�����5�;�;�=�!�,��������(��������)�������e��<�=�������u��=�>�����(�(�*�+����+�U�Z�Z�8�
�
�
�5�
�)rc	���|jd�tj|j�}t	tj
|��}|j
t|�d|�|d}|j
|jd�|j
|jtjtjj|jd���y)Nr�rrrsfile.txt)
r%rr;rDr�rjrCr?rrF)r4�
path_bytesrxrks    rrCzTestScandir.test_bytes"s�������$��[�[����+�
��r�z�z�*�-�.������W��q�'�2���
��������[�1����������R�W�W�\�\�$�)�)�Z�%H�I�	Krc��|jd�ttfD]Z}|tj|j
��}|j
t�5tj|�ddd��\y#1swY�gxYwr�)	r%r�r�rr;rDryr�rj)r4rvr�s   r�test_bytes_likezTestScandir.test_bytes_like.s_������$��j�(�C��R�[�[����3�4�J��"�"�9�-��
�
�:�&�.�-�)�-�-�s�A<�<B	z.fd support for listdir required for this test.c�B�|jtjtj�|j	d�dg}tj�rOtjdtjj|jd��|jd�tj|j�5}tj|�5}t|�}ddd�D�cgc]}|j��}}|jt|�|�|j|tj |��|D�]+}|j|j|j�|jtj"|�|j�|j|j%�|jdk(�tj&tj(vs��tj&|j|��}|j|j'�|�tj&|j|d��}|j|j'd��|���.	ddd�y#1swY���xYwcc}w#1swYyxYw)Nr�r�r�F)r�r�r�)r�rrjr�r%rr�r�rDrFr�r�r�rrCrr�r�r�r�r�)r4�expected_namesr�r$rxrkrwr�s        r�test_fdzTestScandir.test_fd6s���	
�
�
�b�j�j�"�.�.�1�����$�$���� � �"��J�J�z�2�7�7�<�<��	�	�6�#B�C��!�!�&�)�
�
"�
"�4�9�9�
-�����B��2��r�(�� �-4�5�W�E�U�Z�Z�W�E�5����V�E�]�N�;����U�B�J�J�r�N�3� ��� � ����U�Z�Z�8�� � ����5�!1�5�:�:�>�� � ��!1�!1�!3�U�Z�Z�6�5I�J��7�7�b�0�0�0�������B�7�B��$�$�U�Z�Z�\�2�6�������B��N�B��$�$�U�Z�Z��Z�%F��K�!�
.�
-����5�.�
-�s8�J�J�'J�3J�C*J�1BJ�J
	�
J�JzWASI maps '' to cwdc�N�|jttjd�yr()ryrIrrjres r�test_empty_pathzTestScandir.test_empty_pathPs�����+�R�Z�Z��<rc��|jd�tj|j�}t	|�}|jt
|�d|�t	|�}|jt
|�d|�y)Nr�rrr)r%rrjrDr�rCr?)r4rrrx�entries2s    r�test_consume_iterator_twicez'TestScandir.test_consume_iterator_twiceTsb������$��:�:�d�i�i�(���x�.������W��q�'�2���>������X���8�4rc�b�digfD]'}|jttj|��)y)NgX9��v��?)ryr�rrj)r4�objs  r�test_bad_path_typezTestScandir.test_bad_path_type_s(���2�r�?�C����i����S�9�#rc�(�|jd�|jd�tj|j�}t	|�|j�|j�|j
�5~ddd�y#1swYyxYw�Nr��	file2.txt)r%rrjrDr"rj�check_no_resource_warning�r4rrs  r�
test_closezTestScandir.test_closecsf������$�����%��:�:�d�i�i�(���X����������
�
+�
+�
-��.�
-�
-�s�=B�Bc��|jd�|jd�tj|j�5}t	|�ddd�|j�5~ddd�y#1swY�$xYw#1swYyxYwr�)r%rrjrDr"r�r�s  r�test_context_managerz TestScandir.test_context_managernsc������$�����%�
�Z�Z��	�	�
"�h���N�#�
�
+�
+�
-��.�
-�#�
"��
-�
-�s�A1�&A=�1A:�=Bc���|jd�|jd�tj|j�5}t	|�|j�ddd�y#1swYyxYwr�)r%rrjrDr"rjr�s  r�test_context_manager_closez&TestScandir.test_context_manager_closevsM������$�����%�
�Z�Z��	�	�
"�h���N��N�N��#�
"�
"�s�A'�'A0c�p�|jd�|jd�|jt�5tj|j
�5}t
|�ddzddd�ddd�|j�5~ddd�y#1swY�,xYw#1swY�0xYw#1swYyxYw)Nr�r�rrr)r%ry�ZeroDivisionErrorrrjrDr"r�r�s  r�test_context_manager_exceptionz*TestScandir.test_context_manager_exception}s�������$�����%�
�
�
�0�
1����D�I�I�&�(��X���!��'�2��
+�
+�
-��.�
-�'�&��2�
1��.�
-�s/� B �B�)B �	B,�B	�B � B)�,B5c��|jd�|jd�tj|j�}t	|�|jt�5~tj�ddd�tj|j�}t|�|j�5~ddd�y#1swY�NxYw#1swYyxYwr�)r%rrjrDr"�assertWarns�ResourceWarningr�
gc_collectr�r�r�s  r�test_resource_warningz!TestScandir.test_resource_warning�s�������$�����%��:�:�d�i�i�(���X��
�
�
�o�
.����� �/��:�:�d�i�i�(���X��
�
+�
+�
-��.�
-�
/�
.��.�
-�s�"C�:C�C�CN)r�),r\r]r^rr�rfr%ryrrgrlr�r�rrr=r>r�r�r�r�r�r�r�r�r�r�rCr�rrr�r�r�rrr�r�r�r�r�r�r�r�r+rrrnrn4s"�� /� I� I�����+��
�0�<'K�R�X�_�_�S�\�\�W�,�._�`�A�a�A��:��?�P�N�T�,T�&*�*
K�'��X������r�~�~�5�I�K�L�K�L�0�X�_�_�W�_�_�&;�<�=�=�=�	5�:�	����rrnc�f�eZdZeej
�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zy
)�
TestPEP519c�T�dD]#}|j||j|���%y)N)r�sgoodbyessome/path/and/file�rCr�)r4�bs  r�test_return_byteszTestPEP519.test_return_bytes�s$��<�A����Q����A��/�=rc�T�dD]#}|j||j|���%y)N)�hello�goodbyezsome/path/and/filer�)r4r�s  r�test_return_stringzTestPEP519.test_return_string�s$��9�A����Q����A��/�:rc��dD]x}t|�}|j||j|��|jdtj|��|jdtj
|���zy)N)�path/like/object�path/like/objectr�r�)rrCr�rr;rZ)r4rW�pathlikes   r�test_fsencode_fsdecodez!TestPEP519.test_fsencode_fsdecode�sb��8�A���{�H����Q����H� 5�6����0�"�+�+�h�2G�H����/����X�1F�G�9rc��|jd|jtd���|jt	tt
j��|jttd�t
j��y)Nz#feelthegilr )rCr�rrk�
issubclassr�PathLikerires rr?zTestPEP519.test_pathlike�sR���������H�]�4K�(L�M����
�8�R�[�[�9�:����
�8�C�=�"�+�+�>�?rc��tddi�}ttt|�fD]#}|jt|j
|��%y)N�blahr+)r�rrryr�r�)r4�vapor�os   r�test_garbage_in_exception_outz(TestPEP519.test_garbage_in_exception_out�s;���V�R��$���d�B���'�A����i����a�8�(rc�D�|jt|j�yr()ryr�r�res r�test_argument_requiredz!TestPEP519.test_argument_required�s�����)�T�[�[�1rc�0�|jt|jtd��t	ddi�}d|_|jt|j|��|jt|jtt
���y)Nr��foor+rr)ryr�r�rr��
__fspath__r�)r4�cs  r�test_bad_pathlikezTestPEP519.test_bad_pathlike�sl�����)�T�[�[�(�2�,�?����B���������)�T�[�[�!�#�6����+�T�[�[�"�#4�#6�7�	9rc���Gd�dtj�}|jtt|��|jtttj��y)Nc��eZdZy)�0TestPEP519.test_pathlike_subclasshook.<locals>.ANrr+rr�Ar��rrr�)rr�r�r�rrk)r4r�s  r�test_pathlike_subclasshookz%TestPEP519.test_pathlike_subclasshook�s>��	����	�����H�a�0�1����
�8�R�[�[�9�:rc�n�|jtjttj
�yr()r1rr�rY�types�GenericAliasres r�test_pathlike_class_getitemz&TestPEP519.test_pathlike_class_getitem�s!�����b�k�k�%�0�%�2D�2D�ErN)r\r]r^rrr�r�r�r�r?r�r�r�r�r�r+rrr�r��sB���"�)�)�
$�F�0�0�H�@�
9�
2�	9�;�Frr�c��eZdZd�Zy)�
TimesTestsc��tj�}|j|tj�dD]$}t	||�}|j|t
��&tjdk(rU|j|jd�|j|jd�|j|jd�yy)N)�user�system�
children_user�children_system�elapsedrQr)rr�r1�times_resultr5rUrrCr�r�r�)r4r��fieldrls    r�
test_timeszTimesTests.test_times�s������
�����e�R�_�_�5�!�E��E�5�)�E��!�!�%��/�!�
�7�7�d�?����U�0�0�!�4����U�2�2�A�6����U�]�]�A�.�rN)r\r]r^rr+rrr�r��s��/rr�c�b�eZdZd�Zej
ejdvd�d��Zd�Z	y)�	ForkTestsc�<�d}td|�td|d��y)Nz�if 1:
            import os
            from test import support
            pid = os.fork()
            if pid != 0:
                support.wait_process(pid, exitcode=0)
        r��malloc_debug)�PYTHONMALLOCrr�s  r�	test_forkzForkTests.test_fork�s!����	��t�$���t�.�Ar)rM�darwinz'Only Linux and macOS detect this today.c��d}td|d��\}}}|j|jd�d�|j|jd�d�y)Naif 1:
            import os, threading, warnings
            from _testcapi import _spawn_pthread_waiter, _end_spawned_pthread
            _spawn_pthread_waiter()
            try:
                with warnings.catch_warnings(record=True) as ws:
                    warnings.filterwarnings(
                            "always", category=DeprecationWarning)
                    if os.fork() == 0:
                        assert not ws, f"unexpected warnings in child: {ws}"
                        os._exit(0)  # child
                    else:
                        assert ws[0].category == DeprecationWarning, ws[0]
                        assert 'fork' in str(ws[0].message), ws[0]
                        # Waiting allows an error in the child to hit stderr.
                        exitcode = os.wait()[1]
                        assert exitcode == 0, f"child exited {exitcode}"
                assert threading.active_count() == 1, threading.enumerate()
            finally:
                _end_spawned_pthread()
        r��0)�PYTHONOPTIMIZEr�r�)r
rCrM�r4r�rrlr�s     r�-test_fork_warns_when_non_python_thread_existsz7ForkTests.test_fork_warns_when_non_python_thread_exists�sQ����*'�t�T�#�F���3��������G�,�b�1�������G�,�b�1rc�p�d}td|�\}}}|jd|�|jd|�y)NaNif 1:
            import atexit
            import os

            class AtFinalization:
                def __del__(self):
                    print("OK")
                    pid = os.fork()
                    if pid != 0:
                        print("shouldn't be printed")
            at_finalization = AtFinalization()
        r�sOK
s"can't fork at interpreter shutdown)r
rCr�r
s     r�test_fork_at_finalizationz#ForkTests.test_fork_at_finalizations<����'�t�T�2���3������#�&��
�
�;�S�ArN)
r\r]r^rrrr=r>rrr+rrrr�s@��B��X������)<�<�B�D�2�D�2�4Brr�_fspathc�2�eZdZ	eej
�Zy)�TestPEP519PurePythonN)r\r]r^rrrr�r+rrrr s��L��b�j�j�)�rr�__main__)scontentr()�r)r��
contextlibr}rKrvrrr�rrPr�r�r�rar�r�r�r=�	sysconfigr@r�r�r�rr�r@�testr�test.supportrrrrrr>r	r��ImportErrorr#r��pwd�getpwall�pw_uidr�r:�	_testcapir
rr�r��test.support.script_helperr
r�test.support.os_helperrr�rrr�versionrr�getgidr�rr%rrr,�TestCaser.r`rr�r�BasicTestMappingProtocolrr�rrr9rArErsr�rr�r�r��get_config_var�OS_URANDOM_DONT_USE_FDr��contextmanagerr�r�rr*rqr�r�r�r�rr
r,rDrFrr�r�r�r�r�r�r�r�r=rD�IsolatedAsyncioTestCaserLr��requires_linux_versionr�r�r�r�r�rrrFrrZr]rbrnr�r��
requires_forkrrr\�main)�us0r�<module>r,sU��
�
�������
�	�
�
�
�
�
��
��
����������&�"�&�,�(�!���������#/�3�<�<�>�2�>�a����>�2�I�+�1���8�#�+��
�
�2�y���R�Z�Z�\�Q�&�M��3�
��3�?�?�#:�#:����0�0�;�;�N�K�����<�<�*�*�9�5�J�)�"�)�)�+��:J��K��'�x���s�|�|�'>�'>�u�'E�'N�P��(�A8��!�!�A8�JZ8��!�!�Z8�|
l7��*�*�l7�^XA��"�"�XA�v�nJ�=�9�9�nJ�b	t(��!�!�t(�n	����W�R��)�+B�C�]%��]%�D�]%�@6�Y�6�����W�R��)�+B�C�	6�j�	6�D�	6�t�8�$�$�t�n����W�R��)�+@�A�8#�X�&�&�8#�B�8#�v&:�h�'�'�&:�R�������"9�:�,�8�$�$�,�;�,�*�8�$�$�*�>����W�R��-�/D�E�'*�X�&�&�'*�F�'*�Z�I���.�/�1�4�?��y��� 0�1�Q�6�?��y��� 8�9�Q�>��
����'�=�?���������*�7�9�J'�X�&�&�J'�9�?�J'�Z���"��"�@����W�R��)�&�(�e+��!�!�e+�(�e+�P����S�\�\�W�,�.D�E� B�h�'�'� B�F� B�F�������"E�F�}*�H�%�%�}*�G�}*�@����W�R��(�*<�=�#0��!�!�#0�>�#0�J��������(�*@�A�DA�x�(�(�DA�B�DA�L��������(�*@�A�E0�(�#�#�E0�B�E0�N����S�\�\�W�,�.D�E�wK�X�&�&�wK�F�wK�t����S�\�\�W�,�.D�E�,D��)�)�,D�F�,D�^����R�W�W��_�&9�:�,�(�+�+�,�;�,�^����W�R��,�.C�D�9+�H�%�%�9+�E�9+�x����S�\�\�W�,�.D�E�
���nB��)�)�nB��F�nB�`����S�\�\�W�,�.D�E�8��*�*�8�F�8�B����S�\�\�W�,�.D�E�T@�8�$�$�T@�F�T@�n���"�8�,�,�"��"�>7�h�'�'�7� 1�(�+�+�1�$�����GJ�x� � �GJ��GJ�T�����z,��"�"�z,��z,�~����O�P�����W�R��,�.F�G�/��"�"�/�H�Q�/�����W�R��/�N�G�B�
�4N�>�@�1�8�,�,�1�@�1�,����W�R��,�.H�I�U�8�3�3�U�J�U�p
� ����1�3�?�A� �����1�b�)�NG�X�.�.�NG�*�A�NG�b����W�R�!4�5�7V�W�:/�H�%�%�:/�X�:/�z����W�R��0�2L�M������2�&�2�x�(�(�2�'�N�2�����W�R��+�-B�C������1�b�)�N�8�$�$�N�*�D�N�bF@�8�$�$�F@�PD�H�%�%�D������v>��*�*�v>��v>�r?(�(�+�+�?(�D����W�R��0�D�F������&�&�(D�E���������(�*S�T�
4�H�%�%�
4�U�F�F�
4�*�8�$�$�*�D�8�$�$�D�$_�(�#�#�_�D7F��"�"�7F�t
/��"�"�
/� �����9B��!�!�9B��9B�|�2�y��*�z�*��z���H�M�M�O���{W���H������E������G���3���^�$���I����+�"�{�{�*�G�n�+��
���D��s~�k/�k=�"l�'l�>l�l�l.�m�/k:�9k:�=l�l�l�l�l�	l+�*l+�.m�m�m�m

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists