
    e!h                        d Z ddlZddlmZ ddlmZmZmZmZm	Z	 ddl
mZ ddlZej                  d        Zd Zd Zej"                  j%                  e	d	
      d        Zej"                  j%                  e	d	
      d        Zej"                  j%                  e	d	
      d        Zej"                  j%                  e	d	
      d        Zy)z> Test for assert_deallocated context manager and gc utilities
    NLock)set_gc_stategc_stateassert_deallocatedReferenceErrorIS_PYPY)assert_equalc                      t               S Nr        f/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/scipy/_lib/tests/test__gcutils.pygc_lockr      s	    6Mr   c                    | 5  t        j                         }	 dD ]|  }t        j                          t        |       t	        t        j                         |       t        j
                          t        |       t	        t        j                         |       ~ 	 |rt        j                          	 d d d        y # |rt        j                          w w xY w# 1 sw Y   y xY wNTF)gc	isenabledenabler   r
   disable)r   	gc_statusstates      r   test_set_gc_stater      s    	 LLN	
	& 4		U#R\\^U3

U#R\\^U34 		  		  s#   CBB;C;CCC c           	      ~   | 5  t        j                         }	 dD ]  }t        |       dD ]  }t        |      5  t	        t        j                         |       d d d        t	        t        j                         |       t        |      5  t	        t        j                         |       t        |        d d d        t	        t        j                         |         	 |rt        j
                          	 d d d        y # 1 sw Y   xY w# 1 sw Y   XxY w# |rt        j
                          w w xY w# 1 sw Y   y xY wr   )r   r   r   r   r
   r   )r   r   	pre_state
with_states       r   test_gc_stater   #   s   	 LLN		* <	Y'"/ 
<J!*- A$R\\^Z@A !;!*- 5$R\\^Z@$^45 !;
<< 		% A A
5 5
 		 # sQ   D3 DC?	1D	+D	4*DD3?DDDDD00D33D<zTest not meaningful on PyPy)reasonc           	          G d d      }| 5  dD ]{  }t        |      5  t        |ddd      5 }t        |j                  d       ~d d d        t        |ddd      5  	 d d d        t        t	        j
                         |       d d d        } 	 d d d        y # 1 sw Y   TxY w# 1 sw Y   GxY w# 1 sw Y   xY w# 1 sw Y   y xY w)	Nc                       e Zd ZddZy)"test_assert_deallocated.<locals>.Cc                     || _         y r   name)selfarg0arg1r%   s       r   __init__z+test_assert_deallocated.<locals>.C.__init__>   s	    DIr   N)myname__name__
__module____qualname__r)   r   r   r   Cr"   =   s    	r   r/   r   r      zanother namez
third namer$   )r   r   r
   r%   r   r   )r   r/   
gc_currentcs       r   test_assert_deallocatedr3   :   s      
 
9' 		9J*% 9'1a@ A 8 (1alC R\\^Z89 9		9
9 
9  9 9
9 
9sQ   B<B0B	B0B$	&B0
B<B!B0$B-)B00B95B<<Cc                       G d d      } t        j                  t              5  t        |       5 }	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nc                       e Zd Zy)(test_assert_deallocated_nodel.<locals>.CN)r,   r-   r.   r   r   r   r/   r6   O   s    r   r/   pytestraisesr   r   )r/   _s     r   test_assert_deallocated_nodelr;   M   sV     	~	&   " 	a	 	 	 !   AAAA	AAc                       G d d      } t        j                  t              5  t        |       5 }~d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nc                       e Zd Zd Zy)+test_assert_deallocated_circular.<locals>.Cc                     | | _         y r   	_circularr&   s    r   r)   z4test_assert_deallocated_circular.<locals>.C.__init__^   	    !DNr   Nr+   r   r   r   r/   r?   ]       	"r   r/   r7   )r/   r2   s     r    test_assert_deallocated_circularrF   [   sV    " " 
~	& " 	a	 	 	 s!   AAAA	AAc                       G d d      } t        j                  t              5  t        |       5  	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nc                       e Zd Zd Zy),test_assert_deallocated_circular2.<locals>.Cc                     | | _         y r   rA   rC   s    r   r)   z5test_assert_deallocated_circular2.<locals>.C.__init__i   rD   r   Nr+   r   r   r   r/   rI   h   rE   r   r/   r7   )r/   s    r   !test_assert_deallocated_circular2rK   f   sT    " " 
~	& " 		 	 	 r<   )__doc__r   	threadingr   scipy._lib._gcutilsr   r   r   r   r	   numpy.testingr
   r8   fixturer   r   r   markskipifr3   r;   rF   rK   r   r   r   <module>rS      s    	 : : '    . G$AB9 C9$ G$AB
 C
 G$AB C G$AB Cr   