Sindbad~EG File Manager

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

�

'Μg�m��f�ddlZddlZddlZddlZddlZddlmZddlZddlZddl	m
Z
ddlmZddlm
Z
ejd�Zejd�Zd�Zd&d	�Zd&d
�Zej(d��Zd�ZGd
�dej.�ZGd�dej.�ZGd�dej.�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�d e�Z!Gd!�d"e�Z"Gd#�d$e�Z#e$d%k(rejJ�yy)'�N)�dedent)�support)�
import_helper)�
script_helper�_xxsubinterpreters�	_testcapic��tj�\}}|jdd�}td|�d|�d��}|t	|d��fS)N�
z
                z-
        import contextlib
        with open(zg, 'w', encoding="utf-8") as spipe:
            with contextlib.redirect_stdout(spipe):
                z	
        �utf-8��encoding)�os�pipe�replacer�open)�script�r�w�indented�wrappeds     �9/usr/local/lib/python3.12/test/test__xxsubinterpreters.py�_captured_scriptrs^��
�7�7�9�D�A�q��~�~�d�$8�9�H����#���
�	�	�
�G��D��W�-�-�-�c��t|�\}}|5tj|||�|j�cddd�S#1swYyxYw�N)r�interpreters�
run_string�read)�interp�request�sharedr�rpipes     r�_run_outputr#!s8��$�W�-�M�F�E�	�������7��z�z�|�
���s�'A�Ac��|�tj}tj|d��D]}tj	|�s�ytd��)NF)�errorzinterp is not running)r�
SHORT_TIMEOUT�sleeping_retryr�
is_running�RuntimeError)r�timeout�_s   r�_wait_for_interp_to_runr,(sJ�����'�'��
�
#�
#�G�5�
9���"�"�6�*��:��2�3�3rc#�<��K�tj�\�}��fd�}tj|��}|j	�t��d��t
|dd��5}|jd�ddd�|j�y#1swY�xYw�w)Nc�L��tj�td��d���y)Nz7
            # wait for "signal"
            with open(zG, encoding="utf-8") as rpipe:
                rpipe.read()
            )rrr)rrs��r�runz_running.<locals>.run8s.��������4��c�
�0�)�	r��targetrrr�done)	rr�	threading�Thread�startr,r�write�join)rrr/�t�spipers`    @r�_runningr:5sq�����
�7�7�9�D�A�q��	����$�A��G�G�I��F�#�	�	
�a��w�	'�5�
���F��
(��F�F�H�
(�	'�s�A!B�%B�7B�B�Bc��tj�D]}|dk(r�		tj|�� y#t$rY�-wxYw)Nr)r�list_all�destroyr)��ids r�clean_up_interpretersr@JsF���#�#�%��
��7��	�� � ��$�	&��
�	��	�s�7�	A�Ac��eZdZd�Zy)�TestBasec��t�yr)r@��selfs r�tearDownzTestBase.tearDownVs���rN)�__name__�
__module__�__qualname__rF�rrrBrBTs�� rrBc��eZdZd�Zd�Zy)�IsShareableTestsc��gd�}|D]@}|j|�5|jtj|��ddd��By#1swY�MxYw)N)N�spam�spam�
i����)�subTest�
assertTruer�is_shareable)rE�
shareables�objs   r�test_default_shareablesz(IsShareableTests.test_default_shareables_sJ���
��C����c�"���� �-�-�c�2�4�#�"��"�"�s�%A�A	c�V�Gd�d�}Gd�dt�}ddtdttt�t	�d||d	�|d
�g}|D]I}|jt
|��5|jtj|��ddd��Ky#1swY�VxYw)Nc��eZdZd�Zd�Zy)�3IsShareableTests.test_not_shareable.<locals>.Cheesec��||_yr��name)rEr\s  r�__init__z<IsShareableTests.test_not_shareable.<locals>.Cheese.__init__ps	�� ��	rc��|jSrr[rDs r�__str__z;IsShareableTests.test_not_shareable.<locals>.Cheese.__str__rs���y�y� rN)rGrHrIr]r_rJrr�CheeserYos��
!�
!rr`c��eZdZy)�5IsShareableTests.test_not_shareable.<locals>.SubBytesN)rGrHrIrJrr�SubBytesrbus��1rrcTF.gY@�WensleydalerN)
�bytes�NotImplemented�type�object�	ExceptionrQ�repr�assertFalserrS)rEr`rc�not_shareablesrUs     r�test_not_shareablez#IsShareableTests.test_not_shareablens���	!�	!�	2�u�	2�
�������������}�%���!���""�C����d�3�i�(�� � � �-�-�c�2�4�)�(�"�(�(�s�/%B�B(	N)rGrHrIrVrmrJrrrLrL]s��
4�4rrLc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ShareableTypeTestsc��|D]|}|j|�5tj|�}tj|�}|j	||�|jt
|�t
|��ddd��~y#1swY��xYwr)rQr�get_crossinterp_data�restore_crossinterp_data�assertEqual�assertIsrg)rE�valuesrU�xid�gots     r�_assert_valuesz!ShareableTypeTests._assert_values�sm���C����c�"��4�4�S�9���8�8��=��� � ��c�*��
�
�d�3�i��c��3�#�"��"�"�s�A!B�B	c���dD]X}|j|�5tj|�}tj|�}|j	||�ddd��Zy#1swY�exYw)Nr)rQrrqrrrt)rErUrvrws    r�test_singletonsz"ShareableTypeTests.test_singletons�sW���C����c�"��4�4�S�9���8�8��=���
�
�c�3�'�#�"��"�"�s�=A�A(	c�*�|jddg�y)NrNi'�rxrDs r�
test_typeszShareableTypeTests.test_types�s��������	rc�H�|jd�tdd�D��y)Nc3�DK�|]}|jddd�����y�w)��littleT)�signedN)�to_bytes)�.0�is  r�	<genexpr>z0ShareableTypeTests.test_bytes.<locals>.<genexpr>�s'����5�%3���J�J�q�(�4�J�@�%3�s� ����)rx�rangerDs r�
test_byteszShareableTypeTests.test_bytes�s#�����5�%*�2�s�^�5�	5rc�*�|jgd��y)N)zhello worldu你好世界�r|rDs r�	test_strszShareableTypeTests.test_strs�s�����?�@rc��|jtjtdd�tj
tj
dz
g��y)Nr�r��)rx�	itertools�chainr��sys�maxsizerDs r�test_intzShareableTypeTests.test_int�s<�����I�O�O�E�"�c�N�-0�[�[�3�;�;�,��:J�,K�M�	Nrc�2�tjdztjdz
ddzg}|D]O}|j|�5|jt�5t
j
|�ddd�ddd��Qy#1swY�xYw#1swY�hxYw)Nr�r���)r�r�rQ�assertRaises�
OverflowErrorrrq)rE�intsr�s   r�test_non_shareable_intz)ShareableTypeTests.test_non_shareable_int�sw���K�K�!�O�
�[�[�L�1��
�t�G�
��
�A����a���&�&�}�5��2�2�1�5�6�!���5�5��!��s$�B
�B�.B
�B
�B
�
B	N)
rGrHrIrxrzr}r�r�r�r�rJrrroro�s'��4�(��5�A�N�	6rroc��eZdZd�Zy)�ModuleTestsc�@�ttj�d�y)Nz*import _xxsubinterpreters as _interpreters)r#r�createrDs r�test_import_in_interpreterz&ModuleTests.test_import_in_interpreter�s������!�8�	
rN)rGrHrIr�rJrrr�r��s��
rr�c��eZdZd�Zd�Zd�Zy)�ListAllTestsc�z�tj�}tj�}|j||g�yr)r�get_mainr<rs)rE�main�idss   r�test_initialzListAllTests.test_initial�s0���$�$�&���#�#�%������t�f�%rc���tj�}tj�}tj�}tj�}|j	||||g�yr)rr�r�r<rs�rEr��first�secondr�s     r�test_after_creatingz ListAllTests.test_after_creating�sQ���$�$�&���#�#�%���$�$�&���#�#�%������t�U�F�3�4rc��tj�}tj�}tj�}tj|�tj	�}|j|||g�yr)rr�r�r=r<rsr�s     r�test_after_destroyingz"ListAllTests.test_after_destroying�s\���$�$�&���#�#�%���$�$�&�����U�#��#�#�%������t�V�n�-rN)rGrHrIr�r�r�rJrrr�r��s��&�
5�.rr�c��eZdZd�Zd�Zy)�GetCurrentTestsc��tj�}tj�}|j||�|j	|tj
�yr)rr��get_currentrs�assertIsInstance�
InterpreterID)rEr��curs   r�	test_mainzGetCurrentTests.test_main�sD���$�$�&���&�&�(������d�#����c�<�#=�#=�>rc�&�tj�}tj�}t|t	d��}t|j
��}tj�\}}|j||�|j||�y)Nz�
            import _xxsubinterpreters as _interpreters
            cur = _interpreters.get_current()
            print(cur)
            assert isinstance(cur, _interpreters.InterpreterID)
            )
rr�r�r#r�int�stripr<rs�assertNotEqual)rEr�r�outr�r+�expecteds       r�test_subinterpreterz#GetCurrentTests.test_subinterpreter�sz���$�$�&���$�$�&���&�&�*�#����#�)�)�+���"�+�+�-���8�����h�'����C��&rN)rGrHrIr�r�rJrrr�r��s��?�'rr�c��eZdZd�Zd�Zy)�GetMainTestsc��tj�\}tj�}|j||�|j	|tj
�yr)rr<r�rsr�r�)rEr�r�s   r�test_from_mainzGetMainTests.test_from_main�sF��!�*�*�,�
���$�$�&������x�(����d�L�$>�$>�?rc���tj�\}tj�}t|t	d��}t|j
��}|j||�y)Nz�
            import _xxsubinterpreters as _interpreters
            main = _interpreters.get_main()
            print(main)
            assert isinstance(main, _interpreters.InterpreterID)
            )rr<r�r#rr�r�rs)rEr�rr�r�s     r�test_from_subinterpreterz%GetMainTests.test_from_subinterpretersZ��!�*�*�,�
���$�$�&���&�&�*�#����3�9�9�;�������x�(rN)rGrHrIr�r�rJrrr�r��s
��@�
)rr�c�Z�eZdZd�Zej
d�d��Zd�Zd�Zd�Z	d�Z
y)	�IsRunningTestsc�t�tj�}|jtj|��yr)rr�rRr()rEr�s  rr�zIsRunningTests.test_mains'���$�$�&������/�/��5�6rzFails on FreeBSDc�D�tj�}|jtj|��t	|�5|jtj|��ddd�|jtj|��y#1swY�.xYwr)rr�rkr(r:rR�rErs  rr�z"IsRunningTests.test_subinterpreterso���$�$�&������0�0��8�9�
�f�
��O�O�L�3�3�F�;�<������0�0��8�9��
�s�%B�Bc��tj�}t|td|�d���}|j	|j�d�y)Nz`
            import _xxsubinterpreters as _interpreters
            if _interpreters.is_running(zZ):
                print(True)
            else:
                print(False)
            �True)rr�r#rrsr�)rErr�s   rr�z'IsRunningTests.test_from_subinterpretersO���$�$�&���&�&�.)�)/��1
�*�#���	
�������f�-rc���tj�}tj|�|jt�5tj|�ddd�y#1swYyxYwr)rr�r=r�r)r(r�s  r�test_already_destroyedz%IsRunningTests.test_already_destroyed)sF���$�$�&�����V�$�
�
�
�|�
,��#�#�F�+�-�
,�
,���A�A'c��|jt�5tjd�ddd�y#1swYyxYw�Ni@B)r�r)rr(rDs r�test_does_not_existz"IsRunningTests.test_does_not_exist/s*��
�
�
�|�
,��#�#�I�.�-�
,�
,���5�>c��|jt�5tjd�ddd�y#1swYyxYw�Nr�)r��
ValueErrorrr(rDs r�test_bad_idzIsRunningTests.test_bad_id3s*��
�
�
�z�
*��#�#�B�'�+�
*�
*�r�N)rGrHrIr��unittest�skipr�r�r�r�r�rJrrr�r�s;��7��X�]�]�%�&�:�'�:�	.�,�/�(rr�c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�InterpreterIDTestsc�h�tjdd��}|jt|�d�y)NrPT��force)rr�rsr��rEr?s  r�
test_with_intz InterpreterIDTests.test_with_int:s+��
�
'�
'��$�
'�
7������R��"�%rc��Gd�dt�}tj|�d��}|jt	|�d�y)Nc��eZdZd�Zy)�.InterpreterIDTests.test_coerce_id.<locals>.Intc��y�NrPrJrDs r�	__index__z8InterpreterIDTests.test_coerce_id.<locals>.Int.__index__As��rN)rGrHrIr�rJrr�Intr�@s��
rr�Tr�rP)�strrr�rsr�)rEr�r?s   r�test_coerce_idz!InterpreterIDTests.test_coerce_id?s;��	�#�	��
'�
'���T�
'�
:������R��"�%rc���|jttjt	��|jttjd�|jttjd�|jttjd�|jt
tjd�|jttjd�y)Ng$@�10s10r�l)r��	TypeErrorrr�rhr�r�rDs rr�zInterpreterIDTests.test_bad_idGs������)�\�%?�%?���J����)�\�%?�%?��F����)�\�%?�%?��F����)�\�%?�%?��G����*�l�&@�&@�"�E����-��)C�)C�U�Krc���tj�}|jt�5tj	t|�dz�ddd�y#1swYyxYw)Nr�)rr�r�r)r�r�r�s  rr�z&InterpreterIDTests.test_does_not_existOs@��
�
 �
 �
"��
�
�
�|�
,��&�&�s�2�w��{�3�-�
,�
,�s�"A�Ac�h�tjdd��}|jt|�d�y)NrPTr�r�)rr�rsr�r�s  r�test_strzInterpreterIDTests.test_strTs+��
�
'�
'��$�
'�
7������R��$�'rc�h�tjdd��}|jt|�d�y)NrPTr�zInterpreterID(10))rr�rsrjr�s  r�	test_reprzInterpreterIDTests.test_reprXs,��
�
'�
'��$�
'�
7������b��#6�7rc��tj�}tjt|��}tj�}|j	||k(�|j	||k(�|j	|t|�k(�|j	t|�|k(�|j	|tt|��k(�|j	tt|��|k(�|j
|tt|��dzk(�|j
|tt|��k(�|j
|ddzk(�|j
|td�k(�|j
|dk(�|j
||k(�|j
||k7�|j
||k7�|j	||k7�y)Ng�������?r�r��infrO)rr�r�r�rR�floatrkr��rE�id1�id2�id3s    r�
test_equalityz InterpreterIDTests.test_equality\sl���!�!�#���(�(��S��2���!�!�#������s�
�#�����s�
�#�����s�3�x��(�����C��C��(�����u�S��X��.�/�����c�#�h��3�.�/������c�#�h��#� 5�5�6������C��H�
�-�.������4���(������e��,�-�������'�������$�������$�������$�����s�
�#rN)
rGrHrIr�r�r�r�r�r�r�rJrrr�r�8s&��&�
&�L�4�
(�8�$rr�c�`�eZdZd�Zej
d�d��Zd�Zd�Zd�Z	d�Z
d�Zy	)
�CreateTestsc��tj�}|j|tj�|j	|tj��yr)rr�r�r��assertInr<r�s  r�test_in_mainzCreateTests.test_in_mainus=��
�
 �
 �
"�����b�,�"<�"<�=��
�
�b�,�/�/�1�2rz*enable this test when working on pystate.cc���t�}td�D]<}tj�}tj	|�|j|��>|j
t|�d�y)N�d)�setr�rr�r=�addrs�len)rE�seenr+r?s    r�test_unique_idzCreateTests.test_unique_id{sT���u���s��A��$�$�&�B�� � ��$��H�H�R�L��
	
����T��C�(rc�"���tj��d���fd�}tj|��}�5|j�ddd�|j	�|j�tj��y#1swY�>xYw)Nc�n��tj���j��j�yr)rr��acquire�release)r?�locks��r�fz%CreateTests.test_in_thread.<locals>.f�s#����$�$�&�B��L�L�N��L�L�Nrr0)r3�Lockr4r5r7r�rr<)rErr8r?rs   @@r�test_in_threadzCreateTests.test_in_thread�sd����~�~���
��	�
���A�&��
�
�G�G�I��	�����
�
�b�,�/�/�1�2��T�s�B�Bc��tj�\}tj�}t|t	d��}t|j
��}|jttj��|||h�y)Nz�
            import _xxsubinterpreters as _interpreters
            id = _interpreters.create()
            print(id)
            assert isinstance(id, _interpreters.InterpreterID)
            )	rr<r�r#rr�r�rsr�)rEr�r�r�r�s     r�test_in_subinterpreterz"CreateTests.test_in_subinterpreter�so���%�%�'����!�!�#���#�v�'� ����#�)�)�+�������\�2�2�4�5��c�3�7G�Hrc�8���tj�\}tj��d���fd�}tj|��}|j�|j
�|jttj��|��h�y)Nc�b��t�td��}t|j���y)Nz�
                import _xxsubinterpreters as _interpreters
                id = _interpreters.create()
                print(id)
                )r#rr�r�)r�r�r�s ��rrz6CreateTests.test_in_threaded_subinterpreter.<locals>.f�s-����c�6�+�$��C�
�c�i�i�k�"�Crr0)	rr<r�r3r4r5r7rsr�)rEr�rr8r�r�s    @@r�test_in_threaded_subinterpreterz+CreateTests.test_in_threaded_subinterpreter�st����%�%�'����!�!�#����	#�
���A�&��	���	�	��������\�2�2�4�5��c�3�7G�Hrc�n�ttj��}g}td�D]'}tj	�}|j|��)|D]}tj
|��tj	�}|jttj��||hz�y�N�)r�rr<r�r��appendr=rs�rE�beforer�r+r?s     r�test_after_destroy_allz"CreateTests.test_after_destroy_all�s����\�*�*�,�-�����q��A��$�$�&�B��J�J�r�N���B�� � ��$���
 �
 �
"������\�2�2�4�5�v���}�Erc��ttj��}tj�}tj�}tj�}tj	|�tj	|�tj�}|jttj��|||hz�yr)r�rr<r�r=rs)rErr�r�r�r?s      r�test_after_destroy_somez#CreateTests.test_after_destroy_some�s����\�*�*�,�-���!�!�#���!�!�#���!�!�#�����S�!����S�!�
�
 �
 �
"������\�2�2�4�5�v��S�	�7I�JrN)rGrHrIr�r�r�rr
rrrrrJrrr�r�ssE��3��X�]�]�?�@�)�A�)�
3�I�I�&F�Krr�c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�DestroyTestsc���tj�}tj�}tj�}|j|tj��tj	|�|j|tj��|j|tj��|j|tj��yr)rr�r�r<r=�assertNotInr�s    r�test_onezDestroyTests.test_one�s����!�!�#���!�!�#���!�!�#���
�
�c�<�0�0�2�3����S�!�����l�3�3�5�6��
�
�c�<�0�0�2�3��
�
�c�<�0�0�2�3rc��ttj��}t�}td�D]'}tj	�}|j|��)|j
ttj��||z�|D]}tj|��|j
ttj��|�yr)r�rr<r�r�r�rsr=rs     r�test_allzDestroyTests.test_all�s����\�*�*�,�-���e���q��A��$�$�&�B��G�G�B�K��	
����\�2�2�4�5�v��|�D��B�� � ��$������\�2�2�4�5�v�>rc�*���tj�\��jt�5tj	��ddd���fd�}tj|��}|j�|j�y#1swY�FxYw)Nc����jt�5tj��ddd�y#1swYyxYwr�r�r)rr=)r�rEs��rrz!DestroyTests.test_main.<locals>.f�s+����"�"�<�0��$�$�T�*�1�0�0�s�6�?r0)	rr<r�r)r=r3r4r5r7)rErr8r�s`  @rr�zDestroyTests.test_main�sf����%�%�'���
�
�
�|�
,�� � ��&�-�	+�
���A�&��	���	�	����-�
,�s�B	�	Bc���tj�}tj|�|jt�5tj|�ddd�y#1swYyxYwr)rr�r=r�r)r�s  rr�z#DestroyTests.test_already_destroyed�sF��
�
 �
 �
"�����R� �
�
�
�|�
,�� � ��$�-�
,�
,�r�c��|jt�5tjd�ddd�y#1swYyxYwr�r"rDs rr�z DestroyTests.test_does_not_exist�s*��
�
�
�|�
,�� � ��+�-�
,�
,�r�c��|jt�5tjd�ddd�y#1swYyxYwr�)r�r�rr=rDs rr�zDestroyTests.test_bad_id�s*��
�
�
�z�
*�� � ��$�+�
*�
*�r�c��tj�\}tj�}td|�d��}tj	||�|jt
tj��||h�y)Nzo
            import _xxsubinterpreters as _interpreters
            try:
                _interpreters.destroy(zD)
            except RuntimeError:
                pass
            �rr<r�rrrsr�)rEr�r?rs    r�test_from_currentzDestroyTests.test_from_currentst���%�%�'���
�
 �
 �
"���'�(*�d�+
����	����F�+�����\�2�2�4�5��b�z�Brc�(�tj�\}tj�}tj�}td|�d��}tj	||�|jt
tj��||h�y)NzZ
            import _xxsubinterpreters as _interpreters
            _interpreters.destroy(z)
            r')rEr�r�r�rs     r�test_from_siblingzDestroyTests.test_from_siblings����%�%�'����!�!�#���!�!�#���#�#&�%�(
����	����V�,�����\�2�2�4�5��c�{�Crc���tj���fd�}tj|��}|j	�|j�y)Nc�0��tj��yr)rr=r>s�rrz.DestroyTests.test_from_other_thread.<locals>.fs���� � ��$rr0)rr�r3r4r5r7)rErr8r?s   @r�test_from_other_threadz#DestroyTests.test_from_other_threads:���
�
 �
 �
"��	%�
���A�&��	���	�	���rc��tj�\}tj�}t|�5|j	tj|�d|�d���|j
td|�d���5tj|�ddd�|j	tj|��ddd�y#1swY�6xYw#1swYyxYw)NzInterp z& should be running before destruction.)�msgz%Should not be able to destroy interp z while it's still running.)	rr<r�r:rRr(r�r)r=)rEr�rs   r�test_still_runningzDestroyTests.test_still_running%s����%�%�'����$�$�&��
�f�
��O�O�L�3�3�F�;�")�&��1W� X�
�
Z��"�"�<�)N�v�h�Vp�'q�#�s��$�$�V�,�s�
�O�O�L�3�3�F�;�<��
�s�s��	�
�s$�AC�<C�,C�C	�C�CN)
rGrHrIrrr�r�r�r�r(r*r-r0rJrrrr�s6��4�	?��%�,�%�C�
D��
=rrc� ��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
j�d��Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zej(dd��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zej@d�d��Z!�xZ"S)�RunStringTestsc�T��t�|��tj�|_yr)�super�setUprr�r?)rE�	__class__s �rr5zRunStringTests.setUp4s���
��
���%�%�'��rc���td�\}}|5tj|j|�|j	�}ddd�|jd�y#1swY�xYw)N�print("it worked!", end="")�
it worked!)rrrr?rrs)rEr�filer�s    r�test_successzRunStringTests.test_success8sR��'�(E�F����
��#�#�D�G�G�V�4��)�)�+�C��	
����l�+�	�T�s�1A�A&c����td�\�}|5��fd�}tj|��}|j�|j	�|j�}ddd��j
d�y#1swY�xYw)Nr8c�F��tj�j��yr)rrr?)rrEs��rrz(RunStringTests.test_in_thread.<locals>.fCs����'�'�����8rr0r9)rr3r4r5r7rrs)rEr:rr8r�rs`    @rr
zRunStringTests.test_in_thread@sh���'�(E�F����
�
9�� � ��*�A�
�G�G�I�
�F�F�H��)�)�+�C��	
����l�+��T�s�A
A;�;Bc���tj�}td�\}}|5tj||�|j	�}ddd�|jd�y#1swY�xYw)Nz�
            import threading
            def f():
                print('it worked!', end='')

            t = threading.Thread(target=f)
            t.start()
            t.join()
            r9�rr�rrrrs)rE�	subinterprr:r�s     r�test_create_threadz!RunStringTests.test_create_threadMsb�� �'�'�)�	�'�)�������#�#�I�v�6��)�)�+�C��	
����l�+�	�T�s�'A'�'A0c�t�|jd�5d}tjd��}td|�d��\}}|5tj	||�|j�}ddd�|j
|�ddd�|jd�5tjd��}td	�\}}|5tj	||�|j�}ddd�|j
d
�ddd�y#1swY��xYw#1swY��xYw#1swY�<xYw#1swYyxYw)N�isolated�spam spam spam spam spamT)rCa<
                import threading
                def f():
                    print('it worked!', end='')

                try:
                    t = threading.Thread(target=f, daemon=True)
                    t.start()
                    t.join()
                except RuntimeError:
                    print('z', end='')
                znot isolatedFz�
                import threading
                def f():
                    print('it worked!', end='')

                t = threading.Thread(target=f, daemon=True)
                t.start()
                t.join()
                r9)rQrr�rrrrs�rEr�r@rr:r�s      r�test_create_daemon_threadz(RunStringTests.test_create_daemon_thread^s��
�\�\�*�
%�1�H�$�+�+�T�+�:�I�+�
1�%�:�&�-��L�F�D���'�'�	�6�:��i�i�k���
���S�(�+�'&�*�\�\�.�
)�$�+�+�U�+�;�I�+�-��L�F�D���'�'�	�6�:��i�i�k���
���S�,�/�*�
)�
���&�
%��@���*�
)�sF�-D�'D
�&D�'D.�'D"�'D.�
D	�D�D�"D+	�'D.�.D7c	���tj�}gd�}|D]B}|j|�5tj|d|�d�t	|����ddd��Dy#1swY�OxYw)N)NrOrN�*zassert(obj == �))rU)r!)rr�rQr�dict)rEr�objectsrUs    r�test_shareable_typesz#RunStringTests.test_shareable_types�sg���$�$�&��
���C����c�"��'�'��$�S�G�1�-��C�=�(��#�"��"�"�s�'A!�!A*	c���d}tj�}td|�d��\}}|5tj||�|j	�}ddd�|j|�y#1swY�xYw)NrDz�
            import os, sys
            try:
                os.execl(sys.executable)
            except RuntimeError:
                print('z', end='')
            r?rEs      r�test_os_execzRunStringTests.test_os_exec�sx��-�� �'�'�)�	�'�-�
!�z�"
�)�������#�#�I�v�6��)�)�+�C��	
����h�'�	�T�s�'A-�-A6c��ddl}|jdd��5}|jd�|j�d}t	d|j
�d|�d	��}tj|j|�|jd�|j�}|j||�ddd�y#1swYyxYw)
Nrzw+rrr�rDz�
                import os
                try:
                    os.fork()
                except RuntimeError:
                    with open('zE', 'w', encoding='utf-8') as out:
                        out.write('z')
                )�tempfile�NamedTemporaryFiler6�flushrr\rrr?�seekrrs)rErPr:r�r�contents      r�	test_forkzRunStringTests.test_fork�s����
�
(�
(���
(�
@�D��J�J�r�N��J�J�L�1�H��! �
!%�	�	�{�+$�$,�:�.�
��F�
�#�#�D�G�G�V�4��I�I�a�L��i�i�k�G����W�h�/�#A�
@�
@�s�BB4�4B=c���t|j�5|jt�5tj|jd�ddd�ddd�y#1swY�xYw#1swYyxYw)N�
print("spam"))r:r?r�r)rrrDs r�test_already_runningz#RunStringTests.test_already_running�sM��
�d�g�g�
��"�"�<�0��'�'�����A�1��
�0�0���
�s"�A*�!A�
A*�A'	�#A*�*A3c���d}|tj�vr|dz
}|tj�vr�|jt�5tj	|d�ddd�y#1swYyxYw)Nrr�rW)rr<r�r)rr�s  rr�z"RunStringTests.test_does_not_exist�s^��
���L�)�)�+�+��!�G�B��L�)�)�+�+�
�
�
�|�
,��#�#�B��8�-�
,�
,�s�
A*�*A3c��|jt�5tjdd�ddd�y#1swYyxYw)Nr�rW)r�r�rrrDs r�
test_error_idzRunStringTests.test_error_id�s,��
�
�
�z�
*��#�#�B��8�+�
*�
*���6�?c��|jt�5tjdd�ddd�y#1swYyxYw)NrOrW)r�r�rrrDs rr�zRunStringTests.test_bad_id�s,��
�
�
�y�
)��#�#�F�O�<�*�
)�
)�r\c��|jt�5tj|jd�ddd�y#1swYyxYwr��r�r�rrr?rDs r�test_bad_scriptzRunStringTests.test_bad_script�s0��
�
�
�y�
)��#�#�D�G�G�R�0�*�
)�
)���!A�A	c��|jt�5tj|jd�ddd�y#1swYyxYw)Ns
print("spam")r_rDs r�test_bytes_for_scriptz$RunStringTests.test_bytes_for_script�s1��
�
�
�y�
)��#�#�D�G�G�-=�>�*�
)�
)�rac#�lK�|jtj�5}d��ddd�|�A|jt	j
�j
d�dt	|��y|jt	j
�dj||��y#1swY��xYw�w)N�:rz{}: {})r�r�RunFailedErrorrsr��	exception�split�format)rE�exctyper/�caughts    r�assert_run_failedz RunStringTests.assert_run_failed�s�����
�
�
�|�:�:�
;�v��<��;����S��!1�!1�2�8�8��=�a�@� ��\�
+�
���S��!1�!1�2�%�_�_�W�c�:�
<�
<�
;�s� B4�B(�BB4�(B1�-B4c��|jt�5tj|jd�ddd�y#1swYyxYw)Nzprint("spam")rl�SyntaxErrorrrr?rDs r�test_invalid_syntaxz"RunStringTests.test_invalid_syntax�s0��
�
#�
#�K�
0��#�#�D�G�G�^�<�1�
0�
0�rac��|jtd�5tj|jd�ddd�y#1swYyxYw)NrOzraise Exception("spam"))rlrirrr?rDs r�test_failurezRunStringTests.test_failure�s3��
�
#�
#�I�v�
6��#�#�D�G�G�-F�G�7�
6�
6���!A�A
c��|jtd�5tj|jd�ddd�y#1swYyxYw)N�42zraise SystemExit(42))rl�
SystemExitrrr?rDs r�test_SystemExitzRunStringTests.test_SystemExit�s3��
�
#�
#�J��
5��#�#�D�G�G�-C�D�6�
5�
5�rrc�R�|jt�5tj|jtd��ddd�|jtd�5tj|jtd��ddd�y#1swY�RxYw#1swYyxYw)NzG
                import sys
                sys.exit()
                rtzI
                import sys
                sys.exit(42)
                )rlrurrr?rrDs r�
test_sys_exitzRunStringTests.test_sys_exit�s���
�
#�
#�J�
/��#�#�D�G�G�V�5�.�
�0��
#�
#�J��
5��#�#�D�G�G�V�5�.�
�6�
5�
0�
/��6�
5�s�*B�*B�B�B&c��tj�\}}dddd�}td|�d��}tj	|j
||�t
|d�5}tj|�}ddd�|jdd�|j|d	d
�|j|dd�|j|d
�y#1swY�]xYw)N�hams-1)rO�eggs�cheddarz�
            eggs = int(eggs)
            spam = 42
            result = spam + eggs

            ns = dict(vars())
            del ns['__builtins__']
            import pickle
            with open(�C, 'wb') as chan:
                pickle.dump(ns, chan)
            �rbrOrHr{r��result�)r|)rrrrrr?r�pickle�loadrs�assertIsNone�rErrr!r�chan�nss       r�test_with_sharedzRunStringTests.test_with_shared�s����w�w�y���1������
���c�
�
�
��	��������8�
�!�T�]�d����T�"�B��	
����F��R�(�����F��R�(�����H��r�*����"�Y�-�(�
�]�s�C�Cc�8�tj|jtd��ddi}td�}tj|j||�t	j
�\}}td|�d��}tj|j|�t
|d�5}tj|�}ddd�|jddd	�|j|d
dd�|j|dd�y#1swY�OxYw)Nzj
            spam = 'eggs'
            ns1 = dict(vars())
            del ns1['__builtins__']
            rOrzzL
            ns2 = dict(vars())
            del ns2['__builtins__']
        zr
            ns = dict(vars())
            del ns['__builtins__']
            import pickle
            with open(r}r~�ns1r{�ns2)
rrr?rrrrr�r�rs)rEr!rrrr�r�s       r�test_shared_overwritesz%RunStringTests.test_shared_overwritess���������1�*�	��&�!����
��	��������8��w�w�y���1����c�
�	���	�������0�
�!�T�]�d����T�"�B��	
����E��6�*�F�3�����E��6�*�F�3�����F��V�,��]�s�,D�Dc�0�tj�\}}ddi}td|�d��}tj	|j
||�t
|d�5}tj|�}ddd�|jdd�y#1swY�xYw)NrGsnot __main__z�
            spam = 42

            ns = dict(vars())
            del ns['__builtins__']
            import pickle
            with open(r}r~)
rrrrrr?rr�r�rsr�s       r�#test_shared_overwrites_default_varsz2RunStringTests.test_shared_overwrites_default_vars6s����w�w�y���1��o�.�����c�
�
���	��������8�
�!�T�]�d����T�"�B��	
����J���9��]�s�B�Bc�|�tj�\}}tj|jtd|�d���t
|d�5}tj|�}ddd�tj�\}}tj|jtd|�d���t
|d�5}tj|�}ddd�|jd�|jd|�|jd�|jd|�y#1swY��xYw#1swY�^xYw)Nz�
            spam = True

            ns = dict(vars())
            del ns['__builtins__']
            import pickle
            with open(zd, 'wb') as chan:
                pickle.dump(ns, chan)
            del ns, pickle, chan
            r~z�
            eggs = False

            ns = dict(vars())
            del ns['__builtins__']
            import pickle
            with open(r}rOr{)rrrrr?rrr�r�r�r)rErrr�r�r�s      r�test_main_reusedzRunStringTests.test_main_reusedIs���w�w�y���1��������5��c�
�
	1�	*�		��!�T�]�d��+�+�d�#�C���w�w�y���1��������5��c�
�
1�*�	��!�T�]�d��+�+�d�#�C��	
�
�
�f�c�"������%��
�
�f�c�"��
�
�f�c�"�'�]���]�s�D&�?D2�&D/�2D;c
�r�tj�\}}td|�d��}tj	|j
|�t
|d�5}tj|�}ddd�jd�|jd�|j|diddddd��y#1swY�ExYw)	Nz�
            spam = 42

            ns = dict(vars())
            ns['__builtins__'] = str(ns['__builtins__'])
            import pickle
            with open(r}r~�__builtins__�
__loader__�__main__rH)rG�__annotations__�__doc__�__package__�__spec__rO)rrrrrr?rr�r��poprs)rErrrr�r�s      r� test_execution_namespace_is_mainz/RunStringTests.test_execution_namespace_is_mainjs����w�w�y���1����c�
�
���	�������0�
�!�T�]�d����T�"�B��	���~��
���|������"�!�����
�	��]�s�B-�-B6zblocking foreverc�2�td�}tj�5}tj|d|�}tj
|�5}|j
�}ddd�ddd�|jd�y#1swY�$xYw#1swY�(xYw)Na�
        from textwrap import dedent
        import threading
        import _xxsubinterpreters as _interpreters
        id = _interpreters.create()
        def f():
            _interpreters.run_string(id, dedent('''
                import time
                # Give plenty of time for the main interpreter to finish.
                time.sleep(1_000_000)
                '''))

        t = threading.Thread(target=f)
        t.start()
        rr)rr�temp_dirr�make_script�spawn_python�waitrs)rEr�dirname�filename�proc�retcodes      r�test_still_running_at_exitz)RunStringTests.test_still_running_at_exit�s~����
���
�
�
�7�$�0�0��(�F�K�H��+�+�H�5���)�)�+��6� �
	
����!�$�6�5�� �
�s#�-B
�
B�B
�B
	�B
�
Br)#rGrHrIr5r;r
rArFrLrNr�
requires_forkrUrXr�r[r�r`rc�
contextlib�contextmanagerrlrorqrvrxr�r�r�r�r�r�r�r��
__classcell__)r6s@rr2r22s����(�,�,�,�"%0�N� (� �W����0��0�*B�
9�9�=�1�?����<��<�=�
H�E��)�8-�<:�&#�B�8�X�]�]�%�&�%�'�%rr2r�r)&r�r�rr�r��textwraprr3r��testr�test.supportrr�
import_modulerrrr#r,r�r:r@�TestCaserBrLror�r�r�r�r�r�r�rr2rGr�rJrr�<module>r�sF����	�
�
�����&�&�+�}�*�*�+?�@��'�M�'�'��4�	�
	.��
4����
��
�(� �x� � � �/4�x�(�(�/4�d.6��*�*�.6�b
�(�
�.�8�.�.'�h�'�.)�8�)�*&(�X�&(�R8$��8$�vZK�(�ZK�z_=�8�_=�Dj%�X�j%�Z�z���H�M�M�O�r

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