U
    /dX                     @   s   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d Zdd Ze
jjed	d
dd Ze
jjed	d
dd Ze
jjed	d
dd Ze
jjed	d
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                  C   sf   t  } zJdD ]@}t   t| tt  | t   t| tt  | qW 5 | r`t   X d S NTF)gc	isenabledenabler   r   disable)	gc_statusstate r   B/tmp/pip-unpacked-wheel-9gxwnfpp/scipy/_lib/tests/test__gcutils.pytest_set_gc_state   s    r   c                  C   s   t  } zdD ]}t| dD ]n}t| tt  | W 5 Q R X tt  | t| tt  | t|  W 5 Q R X tt  | qqW 5 | rt   X d S r   )r
   r   r   r   r   r   )r   Z	pre_stateZ
with_stater   r   r   test_gc_state   s    

r   zTest not meaningful on PyPy)reasonc                  C   s   G dd d} dD ]j}t |X t| ddd}t|jd ~W 5 Q R X t| dddd W 5 Q R X tt | W 5 Q R X qd S )	Nc                   @   s   e Zd ZdddZdS )z"test_assert_deallocated.<locals>.Cmynamec                 S   s
   || _ d S Nname)selfZarg0Zarg1r   r   r   r   __init__6   s    z+test_assert_deallocated.<locals>.C.__init__N)r   __name__
__module____qualname__r   r   r   r   r   C5   s   r   r	   r      zanother namez
third namer   )r   r   r   r   r
   r   )r   Z
gc_currentcr   r   r   test_assert_deallocated2   s    

r"   c               
   C   s<   G dd d} t t t| }W 5 Q R X W 5 Q R X d S )Nc                   @   s   e Zd ZdS )z(test_assert_deallocated_nodel.<locals>.CN)r   r   r   r   r   r   r   r   F   s   r   pytestZraisesr   r   r   r!   r   r   r   test_assert_deallocated_nodelD   s    
r&   c               
   C   s>   G dd d} t t t| }~W 5 Q R X W 5 Q R X d S )Nc                   @   s   e Zd Zdd ZdS )z+test_assert_deallocated_circular.<locals>.Cc                 S   s
   | | _ d S r   Z	_circularr   r   r   r   r   U   s    z4test_assert_deallocated_circular.<locals>.C.__init__Nr   r   r   r   r   r   T   s   r   r#   r%   r   r   r    test_assert_deallocated_circularR   s    
r)   c               
   C   s<   G dd d} t t t|  W 5 Q R X W 5 Q R X d S )Nc                   @   s   e Zd Zdd ZdS )z,test_assert_deallocated_circular2.<locals>.Cc                 S   s
   | | _ d S r   r'   r(   r   r   r   r   `   s    z5test_assert_deallocated_circular2.<locals>.C.__init__Nr   r   r   r   r   r   _   s   r   r#   )r   r   r   r   !test_assert_deallocated_circular2]   s    
r*   )__doc__r
   Zscipy._lib._gcutilsr   r   r   r   r   Znumpy.testingr   r$   r   r   markZskipifr"   r&   r)   r*   r   r   r   r   <module>   s   



