Sindbad~EG File Manager

Current Path : /proc/2233733/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2233733/root/usr/local/lib/python3.12/test/__pycache__/test_finalization.cpython-312.pyc

�

'Μg�:��b�dZddlZddlZddlZddlZ	ddlmZ	ddlmZddl	m
Z
Gd�d	�ZGd
�de�ZeGd�d
e��Z
eGd�de��ZGd�de�ZGd�de�ZGd�d�ZGd�deej$�ZGd�d�ZGd�dee�ZGd�dee�ZGd�dee�ZGd �d!eej$�ZGd"�d#�ZGd$�d%ee�ZGd&�d'ee�ZGd(�d)ee�ZGd*�d+eej$�ZGd,�d-e�ZeGd.�d/e��ZeGd0�d1e��Z eGd2�d3ee��Z!e
jDGd4�d5eej$��Z#e$d6k(rejJ�yy#e$rd�ZY���wxYw#e$rd�ZY���wxYw)7zB
Tests for object finalization semantics, as outlined in PEP 442.
�N)�with_tp_delc�$�Gd�dt�}|S)Nc��eZdZd�Zy)�with_tp_del.<locals>.Cc��td��)Nzrequires _testcapi.with_tp_del��	TypeError��cls�args�kwargss   �3/usr/local/lib/python3.12/test/test_finalization.py�__new__zwith_tp_del.<locals>.C.__new__s��� @�A�A�N��__name__�
__module__�__qualname__r�rr�Crs��
Brr)�object�rrs  rrr
s��	B��	B��r)�
without_gcc��Gd�d�}|S)Nc��eZdZd�Zy)�without_gc.<locals>.Cc��td��)Nzrequires _testcapi.without_gcrr
s   rrzwithout_gc.<locals>.C.__new__s��� ?�@�@rNrrrrrrs��
Arrrrs  rrrs��	A�	A��r)�supportc�x�eZdZdZgZgZgZgZdZdZ	e
d��Ze
ejd���Zd�Zd�Zd�Zy	)
�NonGCSimpleBasezd
    The base class for all the objects under test, equipped with various
    testing features.
    Frc�8�|jj�|jj�tjj�tj
�|jj�|jj�y�N)�	survivors�clear�errors�gc�garbage�collect�	del_calls�tp_del_calls�rs r�_cleanupzNonGCSimpleBase._cleanup.s]���
�
�����
�
����
�
�
����
�
�
���
�
��������� rc#�K�tj�5|jj�|jj�dt
_	d��|jr|jd�	dt
_|j�	ddd�y#dt
_|j�wxYw#1swYyxYw�w)zI
        A context manager to use around all finalization tests.
        FNrT)	r�
disable_gcr)r$r*r �	_cleaningr%r,r+s r�testzNonGCSimpleBase.test7s������
�
�
!��M�M���!����"�"�$�(-�O�%�
���:�:��*�*�Q�-�'��-1��)�����"�
!��-1��)������"�
!�s5�C	�AB=�B�8B=�	C	�B:�:B=�=C�C	c��y)z8
        Check the object is sane (non-broken).
        Nr��selfs r�check_sanityzNonGCSimpleBase.check_sanityI��rc�
�	|jsE|jjt|��|j	�|j�yy#t$r%}|jj|�Yd}~yd}~wwxYw)z�
        PEP 442 finalizer.  Record that this was called, check the
        object is in a sane state, and invoke a side effect.
        N)r/r)�append�idr4�side_effect�	Exceptionr%�r3�es  r�__del__zNonGCSimpleBase.__del__Nsh��
	"��>�>����%�%�b��h�/��!�!�#�� � �"�"���	"��K�K���q�!�!��	"���AA�	B�A=�=Bc��y)z6
        A side effect called on destruction.
        Nrr2s rr9zNonGCSimpleBase.side_effect[r5rN)rrr�__doc__r#r)r*r%r/�	__slots__�classmethodr,�
contextlib�contextmanagerr0r4r=r9rrrr r sj���
�I��I��L�
�F��I��I��!��!��������� �
"�rr c��eZdZd�Zd�Zy)�
SimpleBasec�$�t|�|_yr")r8�id_r2s r�__init__zSimpleBase.__init__cs
���d�8��rc�8�|jt|�k(sJ�yr")rHr8r2s rr4zSimpleBase.check_sanityfs���x�x�2�d�8�#�#�#rN)rrrrIr4rrrrFrFas���$rrFc��eZdZdZy)�NonGCrN)rrrrArrrrLrLjs���IrrLc��eZdZdZd�Zy)�NonGCResurrectorrc�:�|jj|�y�zF
        Resurrect self by storing self in a class-wide list.
        N�r#r7r2s rr9zNonGCResurrector.side_effectr���	
�����d�#rN)rrrrAr9rrrrNrNns���I�$rrNc��eZdZy)�SimpleN�rrrrrrrTrTx���rrTc��eZdZd�Zy)�SimpleResurrectorc�:�|jj|�yrPrQr2s rr9zSimpleResurrector.side_effect~rRrN�rrrr9rrrrXrX|s��$rrXc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�TestBasec�Z�tjdd|_gtjddyr")r&r'�old_garbager2s r�setUpzTestBase.setUp�s���:�:�a�=�����
�
�1�
rc��	|jtjg�|`tj�y#|`tj�wxYwr")�assertEqualr&r'r^r(r2s r�tearDownzTestBase.tearDown�s=��	����R�Z�Z��,�� ��J�J�L��� ��J�J�L�s	� 9�Ac�h�|jttj�t|��yr")ra�sortedrFr)�r3�idss  r�assert_del_callszTestBase.assert_del_calls�s!������
� 4� 4�5�v�c�{�Crc�h�|jttj�t|��yr")rardrFr*res  r�assert_tp_del_callszTestBase.assert_tp_del_calls�s!������
� 7� 7�8�&��+�Frc�v�|jtd�tjD��t|��y)Nc3�2K�|]}t|����y�wr"�r8��.0�xs  r�	<genexpr>z,TestBase.assert_survivors.<locals>.<genexpr>�s����D�/C�!��1��/C���)rardrFr#res  r�assert_survivorszTestBase.assert_survivors�s'������D�z�/C�/C�D�D�f�S�k�Rrc�v�|jtd�tjD��t|��y)Nc3�2K�|]}t|����y�wr"rlrms  rrpz*TestBase.assert_garbage.<locals>.<genexpr>�s����:�z�!��1��z�rq)rardr&r'res  r�assert_garbagezTestBase.assert_garbage�s%������:�r�z�z�:�:�F�3�K�Hrc�@�tjj�yr")rFr#r$r2s r�clear_survivorszTestBase.clear_survivors�s�����"�"�$rN)
rrrr_rbrgrirrrurwrrrr\r\�s)����D�G�S�I�%rr\c�d�eZdZdZd�Zd�Zejd��Zejd��Z	y)�SimpleFinalizationTestz.
    Test finalization without refcycles.
    c��tj�5t�}t|�g}t	j
|�}~t
j�|j|�|jg�|j|�d�t
j�|j|�|jg�ddd�y#1swYyxYwr")rFr0rTr8�weakref�refr&r(rgrr�assertIs�r3�srf�wrs    r�test_simplez"SimpleFinalizationTest.test_simple�s���
�_�_�
���A��a�5�'�C����Q��B���J�J�L��!�!�#�&��!�!�"�%��M�M�"�$��%��J�J�L��!�!�#�&��!�!�"�%��
�
���B0C�Cc��tj�5t�}t|�g}t	j
|�}~t
j�|j|�|j|�|j|�d�|j�t
j�|j|�|jg�ddd�|j�d�y#1swY�!xYwr")
rFr0rXr8r{r|r&r(rgrr�assertIsNotrwr}r~s    r�test_simple_resurrectz,SimpleFinalizationTest.test_simple_resurrect�s���
�_�_�
�!�#�A��a�5�'�C����Q��B���J�J�L��!�!�#�&��!�!�#�&����R�T�4�(�� � �"��J�J�L��!�!�#�&��!�!�"�%��	
�
�
�b�d�D�!��
�s�CC5�5C>c��tj�5t�}|jt	j
|��t
|�g}~t	j�|j|�|jg�t	j�|j|�|jg�ddd�y#1swYyxYwr")
rFr0rL�assertFalser&�
is_trackedr8r(rgrr�r3rrfs   r�test_non_gcz"SimpleFinalizationTest.test_non_gc�s���
�_�_�
���A����R�]�]�1�-�.��a�5�'�C���J�J�L��!�!�#�&��!�!�"�%��J�J�L��!�!�#�&��!�!�"�%��
�
�s�B(C�Cc���tj�5t�}|jt	j
|��t
|�g}~t	j�|j|�|j|�|j�t	j�|j|dz�|j|�ddd�y#1swYyxYw�N�)rFr0rNr�r&r�r8r(rgrrrwr�s   r�test_non_gc_resurrectz,SimpleFinalizationTest.test_non_gc_resurrect�s���
�_�_�
� �"�A����R�]�]�1�-�.��a�5�'�C���J�J�L��!�!�#�&��!�!�#�&�� � �"��J�J�L��!�!�#��'�*��!�!�#�&��
�
�s�B;C�C"N)
rrrr@r�r�r�cpython_onlyr�r�rrrryry�sE���&�"� 
���&��&�
���'��'rryc�(��eZdZ�fd�Z�fd�Z�xZS)�
SelfCycleBasec�0��t�|��||_yr")�superrIr|�r3�	__class__s �rrIzSelfCycleBase.__init__�s���
������rc�B��t�|��|j|usJ�yr")r�r4r|r�s �rr4zSelfCycleBase.check_sanity�s ���
�����x�x�4���r)rrrrIr4�
__classcell__�r�s@rr�r��s���� � rr�c��eZdZy)�SimpleSelfCycleNrUrrrr�r��rVrr�c��eZdZy)�SelfCycleResurrectorNrUrrrr�r��rVrr�c��eZdZd�Zy)�SuicidalSelfCyclec��d|_y)�7
        Explicitly break the reference cycle.
        N)r|r2s rr9zSuicidalSelfCycle.side_effect�s����rNrZrrrr�r��s��rr�c�"�eZdZdZd�Zd�Zd�Zy)�SelfCycleFinalizationTestzX
    Test finalization of an object having a single cyclic reference to
    itself.
    c��tj�5t�}t|�g}t	j
|�}~t
j�|j|�|jg�|j|�d�t
j�|j|�|jg�ddd�y#1swYyxYwr")rFr0r�r8r{r|r&r(rgrrr}r~s    rr�z%SelfCycleFinalizationTest.test_simples���
�_�_�
��!�A��a�5�'�C����Q��B���J�J�L��!�!�#�&��!�!�"�%��M�M�"�$��%��J�J�L��!�!�#�&��!�!�"�%��
�
�r�c��tj�5t�}t|�g}t	j
|�}~t
j�|j|�|j|�|j|�d�|j�t
j�|j|�|jg�|j|�d�ddd�y#1swYyxYwr")rFr0r�r8r{r|r&r(rgrrr}rwr~s    rr�z/SelfCycleFinalizationTest.test_simple_resurrects���
�_�_�
�$�&�A��a�5�'�C����Q��B���J�J�L��!�!�#�&��!�!�#�&��M�M�"�$��%�
� � �"��J�J�L��!�!�#�&��!�!�"�%��M�M�"�$��%�!�
�
�s�CC5�5C>c���tj�5t�}t|�g}t	j
|�}~t
j�|j|�|jg�|j|�d�t
j�|j|�|jg�|j|�d�ddd�y#1swYyxYwr")rFr0r�r8r{r|r&r(rgrrr}r~s    r�test_simple_suicidez-SelfCycleFinalizationTest.test_simple_suicide%s����_�_�
�!�#�A��a�5�'�C����Q��B���J�J�L��!�!�#�&��!�!�"�%��M�M�"�$��%��J�J�L��!�!�#�&��!�!�"�%��M�M�"�$��%��
�
�s�CC%�%C.N)rrrr@r�r�r�rrrr�r��s���
&�&�(&rr�c�$��eZdZd�Z�fd�Z�xZS)�ChainedBasec�.�d|_||_||_y)NF��suicided�left�right)r3r�s  r�chainzChainedBase.chain9s����
���	���
rc�N��t�|��|jr|j�J�|j�J�y|j}|jr|j�J�|j|usJ�|j}|jr|j�J�y|j|usJ�yr")r�r4r�r�r�)r3r�r�r�s   �rr4zChainedBase.check_sanity>s����
�����=�=��9�9�$�$�$��:�:�%�%�%��9�9�D��}�}��z�z�)�)�)��z�z�T�)�)�)��J�J�E��~�~��z�z�)�)�)��z�z�T�)�)�)r)rrrr�r4r�r�s@rr�r�7s����
*�*rr�c��eZdZy)�
SimpleChainedNrUrrrr�r�OrVrr�c��eZdZy)�ChainedResurrectorNrUrrrr�r�RrVrr�c��eZdZd�Zy)�SuicidalChainedc�.�d|_d|_d|_y)r�TNr�r2s rr9zSuicidalChained.side_effectWs����
���	���
rNrZrrrr�r�Us��rr�c�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�CycleChainFinalizationTestz�
    Test finalization of a cyclic chain.  These tests are similar in
    spirit to the self-cycle tests above, but the collectable object
    graph isn't trivial anymore.
    c��|D�cgc]	}|���}}tt|��D]}||j||dz
��|Scc}w)N�)�range�lenr�)r3�classesr�nodes�is     r�build_chainz&CycleChainFinalizationTest.build_chaingsM��")�*�'�3���'��*��s�5�z�"�A��!�H�N�N�5��1��:�&�#����+s�A
c�*�t|�}tj�5|j|�}|D�cgc]
}t	|���}}|D�cgc]}tj|���}}~tj�|j|�|jg�|j|D�cgc]	}|���c}dg|z�tj�|j|�ddd�ycc}wcc}wcc}w#1swYyxYwr")r�rFr0r�r8r{r|r&r(rgrrra)r3r��Nr�rrf�wrsr�s        r�check_non_resurrecting_chainz7CycleChainFinalizationTest.check_non_resurrecting_chainms�����L��
�_�_�
��$�$�W�-�E�"'�(�%�Q�2�a�5�%�C�(�+0�1�5�a�7�;�;�q�>�5�C�1���J�J�L��!�!�#�&��!�!�"�%����S�1�S�r�b�d�S�1�D�6�A�:�>��J�J�L��!�!�#�&��
��(��1��
2��
�s5�D	�C:�D	�C?�*AD	�2D
�1D	�:D	�	Dc���t|�}tj�5|j|�}t|�}|D�cgc]
}t	|���}}|D�cgc]}t|t�s�t	|��� }}|D�cgc]}tj|���}}~tj�|j|�|j|�|j|D�cgc]	}|���c}dg|z�|j�tj�|j|�|jg�ddd�ycc}wcc}wcc}wcc}w#1swYyxYwr")r�rFr0r�r8�
isinstancerXr{r|r&r(rgrrrarw)	r3r�r�r�rrf�survivor_idsr�r�s	         r�check_resurrecting_chainz3CycleChainFinalizationTest.check_resurrecting_chain{s%����L��
�_�_�
��$�$�W�-�E��E�
�A�"'�(�%�Q�2�a�5�%�C�(�+0�U�5�a�J�q�BS�4T�B�q�E�5�L�U�+0�1�5�a�7�;�;�q�>�5�C�1���J�J�L��!�!�#�&��!�!�,�/����S�1�S�r�b�d�S�1�D�6�A�:�>�� � �"��J�J�L��!�!�#�&��!�!�"�%��
��)��U��1��2��
�sI�!E#�E�E#�E�/
E�<E#�E�AE#�&E
�4AE#�E#�#E,c�6�|jtgdz�y�N�)r�r�r2s r�test_homogenousz*CycleChainFinalizationTest.test_homogenous�s���)�)�=�/�A�*=�>rc�6�|jtgdz�yr�)r�r�r2s r�test_homogenous_resurrectz4CycleChainFinalizationTest.test_homogenous_resurrect�s���%�%�'9�&:�Q�&>�?rc�6�|jtgdz�yr�)r�r�r2s r�test_homogenous_suicidalz3CycleChainFinalizationTest.test_homogenous_suicidal�s���)�)�?�*;�a�*?�@rc�@�|jttgdz�yr��r�r�r�r2s r�test_heterogenous_suicidal_onez9CycleChainFinalizationTest.test_heterogenous_suicidal_one�s���)�)�?�M�*J�Q�*N�Orc�L�|jtgdztgdzz�yr�r�r2s r�test_heterogenous_suicidal_twoz9CycleChainFinalizationTest.test_heterogenous_suicidal_two�s'���)�)�
���!�]�O�a�$7�7�	9rc�@�|jttgdz�yr�)r�r�r�r2s r�test_heterogenous_resurrect_onez:CycleChainFinalizationTest.test_heterogenous_resurrect_one�s���%�%�'9�=�&I�A�&M�Nrc�J�|jtttgdz�yr��r�r�r�r�r2s r�test_heterogenous_resurrect_twoz:CycleChainFinalizationTest.test_heterogenous_resurrect_two�s ���%�%�
���@�1�D�	Frc�b�|jtgdztgdzztgdzz�yr�r�r2s r�!test_heterogenous_resurrect_threez<CycleChainFinalizationTest.test_heterogenous_resurrect_three�s6���%�%�
� �1�$�
���':�:�o�=N�QR�=R�R�	TrN)rrrr@r�r�r�r�r�r�r�r�r�r�r�rrrr�r�`sD����'�&�&?�@�A�P�9�O�F�Trr�c��eZdZd�Zd�Zy)�
LegacyBasec���	|js5|jjt|��|j	�yy#t
$r%}|jj|�Yd}~yd}~wwxYwr")r/r)r7r8r4r:r%r;s  rr=zLegacyBase.__del__�s^��	"��>�>����%�%�b��h�/��!�!�#�"���	"��K�K���q�!�!��	"�s�AA�	A2�
A-�-A2c�
�	|jsE|jjt|��|j	�|j�yy#t$r%}|jj|�Yd}~yd}~wwxYw)zJ
        Legacy (pre-PEP 442) finalizer, mapped to a tp_del slot.
        N)r/r*r7r8r4r9r:r%r;s  r�
__tp_del__zLegacyBase.__tp_del__�sj��	"��>�>��!�!�(�(��D��2��!�!�#�� � �"�"���	"��K�K���q�!�!��	"�r>N)rrrr=r�rrrr�r��s��"�
"rr�c��eZdZy)�LegacyNrUrrrr�r�����rr�c��eZdZd�Zy)�LegacyResurrectorc�:�|jj|�yrPrQr2s rr9zLegacyResurrector.side_effect�rRrNrZrrrr�r��s��$rr�c��eZdZy)�LegacySelfCycleNrUrrrr�r��r�rr�c�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)�LegacyFinalizationTestz5
    Test finalization of objects with a tp_del.
    c���tjj�tj�t�|��yr")r&r'r$r(r�rbr�s �rrbzLegacyFinalizationTest.tearDown�s)���	�
�
����
�
�
��
���rc���tj�5t�}t|�g}t	j
|�}~t
j�|j|�|j|�|jg�|j|�d�t
j�|j|�|j|�ddd�y#1swYyxYwr")rFr0r�r8r{r|r&r(rgrirrr}r~s    r�test_legacyz"LegacyFinalizationTest.test_legacy�s���
�_�_�
���A��a�5�'�C����Q��B���J�J�L��!�!�#�&��$�$�S�)��!�!�"�%��M�M�"�$��%��J�J�L��!�!�#�&��$�$�S�)��
�
�s�CC�C(c�L�tj�5t�}t|�g}t	j
|�}~t
j�|j|�|j|�|j|�|j|�d�|j�t
j�|j|�|j|dz�|j|�ddd�|j�d�y#1swY�!xYwr�)
rFr0r�r8r{r|r&r(rgrirrr}rwr~s    r�test_legacy_resurrectz,LegacyFinalizationTest.test_legacy_resurrect�s���
�_�_�
�!�#�A��a�5�'�C����Q��B���J�J�L��!�!�#�&��$�$�S�)��!�!�#�&��M�M�"�$��%�� � �"��J�J�L��!�!�#�&��$�$�S�1�W�-��!�!�#�&�� 	
�
�
�b�d�D�!�!�
�s�C%D�D#c��tj�5t�}t|�g}t	j
|�}~t
j�|jg�|jg�|jg�|j|�|j|�d�dtjd_ddd�|jg�|j�d�y#1swY�2xYw)Nr)rFr0r�r8r{r|r&r(rgrirrrur�r'r}r~s    r�test_legacy_self_cyclez-LegacyFinalizationTest.test_legacy_self_cycles���
�_�_�
��!�A��a�5�'�C����Q��B���J�J�L��!�!�"�%��$�$�R�(��!�!�"�%�����$����R�T�4�(� $�B�J�J�q�M���	
���B���
�
�b�d�D�!��
�s�B4C:�:D)	rrrr@rbr�r�r�r�r�s@rr�r��s�����
*�"�&"rr��__main__)&r@rCr&�unittestr{�	_testcapir�ImportErrorrr0rr rFrLrNrTrXr\�TestCaseryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�mainrrr�<module>r�s����	����%��$��?�?�D$��$���O�����$��$��$�	�Z�	�$�
�$�%�%�<>'�X�x�'8�'8�>'�B � �	�m�V�	�	�=�*;�	��
�v��7&��(�*;�*;�7&�t*�*�0	�K��	�	��&7�	��k�6��GT��8�+<�+<�GT�Z"��"�0
�	�Z�	�
�	�
�$�
�$�
�$�
�	�m�Z�	�
�	�	���>"�X�x�'8�'8�>"��>"�B�z���H�M�M�O���[���������s"�F�F"�F�F�"F.�-F.

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