
    UgX                     v   d Z ddlZddlmZmZmZmZmZ ddlm	Z	 ddl
Z
d Zd Ze
j                            ed          d	             Ze
j                            ed          d
             Ze
j                            ed          d             Ze
j                            ed          d             ZdS )z> Test for assert_deallocated context manager and gc utilities
    N)set_gc_stategc_stateassert_deallocatedReferenceErrorIS_PYPY)assert_equalc                     t          j                    } 	 dD ]}t          j                     t          |           t	          t          j                    |           t          j                     t          |           t	          t          j                    |           	 | rt          j                     d S d S # | rt          j                     w w xY wNTF)gc	isenabledenabler   r   disable)	gc_statusstates     ]/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/scipy/_lib/tests/test__gcutils.pytest_set_gc_stater      s    I
" 	0 	0EIKKK///JLLL////	0  	IKKKKK	 	9 	IKKKK	s   BB: :Cc                     t          j                    } 	 dD ]}t          |           dD ]}t          |          5  t	          t          j                    |           d d d            n# 1 swxY w Y   t	          t          j                    |           t          |          5  t	          t          j                    |           t          |            d d d            n# 1 swxY w Y   t	          t          j                    |           	 | rt          j                     d S d S # | rt          j                     w w xY wr
   )r   r   r   r   r   r   )r   	pre_state
with_states      r   test_gc_stater      s   I& 	8 	8I###+ 
8 
8
j)) = = <<<= = = = = = = = = = = = = = = R\^^Y777j)) 1 1 <<< Z0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R\^^Y7777
8	8  	IKKKKK	 	9 	IKKKK	sR   &D* "A)D* )A--D* 0A-13D* $2C"D* "C&&D* )C&*&D* *EzTest not meaningful on PyPy)reasonc                      G d d          } dD ]}t          |          5  t          | ddd          5 }t          |j        d           ~d d d            n# 1 swxY w Y   t          | ddd          5  	 d d d            n# 1 swxY w Y   t          t	          j                    |           d d d            n# 1 swxY w Y   d S )	Nc                       e Zd ZddZdS )"test_assert_deallocated.<locals>.Cmynamec                     || _         d S Nname)selfarg0arg1r    s       r   __init__z+test_assert_deallocated.<locals>.C.__init__6   s    DIII    N)r   __name__
__module____qualname__r$    r%   r   Cr   5   s(        	 	 	 	 	 	r%   r+   r   r      zanother namez
third namer   )r   r   r   r    r   r   )r+   
gc_currentcs      r   test_assert_deallocatedr/   2   s           $ 	5 	5
j!! 	5 	5#Aq!^<< QV^444               $Aq!,???                444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5	5 	5sX   B;AB;AB;AB;5B7B;BB;
B$B;;B?	B?	c                       G d d          } t          j        t                    5  t          |           5 }	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd ZdS )(test_assert_deallocated_nodel.<locals>.CN)r'   r(   r)   r*   r%   r   r+   r2   F   s        r%   r+   pytestraisesr   r   )r+   _s     r   test_assert_deallocated_nodelr7   D   s          	~	&	&    "" 	a	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 3   AAAA			AA		AA!$A!c                       G d d          } t          j        t                    5  t          |           5 }~d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS )+test_assert_deallocated_circular.<locals>.Cc                     | | _         d S r   	_circularr!   s    r   r$   z4test_assert_deallocated_circular.<locals>.C.__init__U       !DNNNr%   Nr&   r*   r%   r   r+   r;   T   #        	" 	" 	" 	" 	"r%   r+   r3   )r+   r.   s     r    test_assert_deallocated_circularrB   R   s   " " " " " " " " 
~	&	&  "" 	a	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s3   AAAA			AA		AA!$A!c                       G d d          } t          j        t                    5  t          |           5  	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS ),test_assert_deallocated_circular2.<locals>.Cc                     | | _         d S r   r=   r?   s    r   r$   z5test_assert_deallocated_circular2.<locals>.C.__init__`   r@   r%   Nr&   r*   r%   r   r+   rE   _   rA   r%   r+   r3   )r+   s    r   !test_assert_deallocated_circular2rG   ]   s   " " " " " " " " 
~	&	&  "" 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 r8   )__doc__r   scipy._lib._gcutilsr   r   r   r   r   numpy.testingr   r4   r   r   markskipifr/   r7   rB   rG   r*   r%   r   <module>rM      so    				: : : : : : : : : : : : : : ' & & & & &     , G$ABB5 5 CB5" G$ABB
 
 CB
 G$ABB  CB G$ABB  CB  r%   