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

�Ke����ddlZddlZddlZddlZddlZddlmZddlmZGd�dej	��Z
Gd�dej	��ZejGd�d	ej	����Z
ed
krej��dSdS)�N)�support)�
script_helperc��eZdZd�ZdS)�GeneralTestc�V�tjd��}tj|��dS)Nz_test_atexit.py)r�findfiler�run_test_script)�self�scripts  �:/usr/local/apps/python3/lib/python3.11/test/test_atexit.py�test_generalzGeneralTest.test_generals*���!�"3�4�4���%�f�-�-�-�-�-�N)�__name__�
__module__�__qualname__r
�rrrr
s#������.�.�.�.�.rrc��eZdZd�Zd�ZdS)�FunctionalTestc��tjd��}tjd|��}|�|j������ddg��|�|j	��dS)Nz�
            import atexit

            def f(msg):
                print(msg)

            atexit.register(f, "one")
            atexit.register(f, "two")
        �-c�two�one�
�textwrap�dedentr�assert_python_ok�assertEqual�out�decode�
splitlines�assertFalse�err�r
�code�ress   r�
test_shutdownzFunctionalTest.test_shutdownsz���� �
�
���,�T�4�8�8���������)�)�4�4�6�6����G�G�G������!�!�!�!�!rc��tjd��}tjd|��}|�|j������ddg��|�|j	��dS)Na@
            import sys
            import atexit as atexit1
            del sys.modules['atexit']
            import atexit as atexit2
            del sys.modules['atexit']

            assert atexit2 is not atexit1

            atexit1.register(print, "atexit1")
            atexit2.register(print, "atexit2")
        r�atexit2�atexit1rr#s   r�test_atexit_instancesz$FunctionalTest.test_atexit_instances s{���� �
�
���,�T�4�8�8���������)�)�4�4�6�6��I�8N�O�O�O������!�!�!�!�!rN)rrrr&r*rrrrrs2������
"�
"�
"�"�"�"�"�"rrc�b�eZdZd�Zd�Zejeed��d��d���Z	dS)�SubinterpreterTestc��tj��}tjd��}t	j|��}|�|d��|�tj��|��dS)Nz�
            import atexit
            def f():
                pass
            atexit.register(f)
            del atexit
        r��atexit�_ncallbacksrrr�run_in_subinterpr�r
�nr$�rets    r�test_callbacks_leakz&SubinterpreterTest.test_callbacks_leak6su��
�� � ���� �
�
���&�t�,�,������a� � � �����+�-�-�q�1�1�1�1�1rc��tj��}tjd��}t	j|��}|�|d��|�tj��|��dS)Nz�
            import atexit
            def f():
                pass
            atexit.register(f)
            atexit.__atexit = atexit
        rr.r2s    r�test_callbacks_leak_refcyclez/SubinterpreterTest.test_callbacks_leak_refcycleFsu��
�� � ���� �
�
���&�t�,�,������a� � � �����+�-�-�q�1�1�1�1�1r�pipezrequires os.pipe()c�h�d}tj��\}}tjd�|����}tj|��}tj|��|�tj	|t|����|��tj|��dS)NsThe test has passed!z�
            import os
            import atexit
            def callback():
                os.write({:d}, b"The test has passed!")
            atexit.register(callback)
        )�osr8rr�formatrr1�closer�read�len)r
�expected�r�wr$r4s      r�(test_callback_on_subinterpreter_teardownz;SubinterpreterTest.test_callback_on_subinterpreter_teardownUs���+���w�y�y���1��� �
�F�1�I�I�
����&�t�,�,��
������������C��M�M�2�2�H�=�=�=�
�������rN)
rrrr5r7�unittest�
skipUnless�hasattrr:rBrrrr,r,3sk������2�2�2� 
2�
2�
2��X�����V�,�,�.B�C�C���D�C���rr,�__main__)r/r:�sysrrC�testr�test.supportr�TestCaserr�cpython_onlyr,r�mainrrr�<module>rMs��
�
�
�
�	�	�	�	�
�
�
�
���������������&�&�&�&�&�&�.�.�.�.�.�(�#�.�.�.� "� "� "� "� "�X�&� "� "� "�F	��2�2�2�2�2��*�2�2���2�j�z����H�M�O�O�O�O�O��r