o
    RcL                     @   s>   d dl Z d dlZd dlZd dlZd dlZG dd dejZdS )    Nc                   @   s6   e Zd Zdd Zejrdd Zdd Zdd Zd	S d	S )
GCTestsc                 C   sB   t ttj }t  | | d u  | tj	tj	 d S N)
weakrefrefgreenlet
getcurrentswitchgccollect
assertTrueassertFalsegarbage)selfo r   8D:\Flask\env\Lib\site-packages\greenlet/tests/test_gc.pytest_dead_circular_ref
   s   zGCTests.test_dead_circular_refc                 C   sT   G dd dt j }| }||_t|}t  | | d u  | tjtj d S )Nc                   @   s   e Zd ZdS )z9GCTests.test_circular_greenlet.<locals>.circular_greenletN)__name__
__module____qualname__r   r   r   r   circular_greenlet   s    r   )	r   r   r   r   r	   r
   r   r   r   )r   r   r   r   r   r   test_circular_greenlet   s   
zGCTests.test_circular_greenletc                 C   sN   G dd dt j }| }t|}t  | | d u  | tjtj d S )Nc                   @   s   e Zd Zdd Zdd ZdS )z4GCTests.test_inactive_ref.<locals>.inactive_greenletc                 S   s   t j j| | jd d S )N)run)r   __init__r   r   r   r   r   r      s   z=GCTests.test_inactive_ref.<locals>.inactive_greenlet.__init__c                 S      d S r   r   r   r   r   r   r   "      z8GCTests.test_inactive_ref.<locals>.inactive_greenlet.runN)r   r   r   r   r   r   r   r   r   inactive_greenlet   s    r   )r   r   r   r	   r
   r   r   r   )r   r   r   r   r   r   test_inactive_ref   s   
zGCTests.test_inactive_refc                    sd   G dd dt  g }t  fdd}t|}||_|| |  ~~t  t  d S )Nc                   @   s   e Zd Zdd ZdS )z;GCTests.test_finalizer_crash.<locals>.object_with_finalizerc                 S   r   r   r   r   r   r   r   __del__<   r   zCGCTests.test_finalizer_crash.<locals>.object_with_finalizer.__del__N)r   r   r   r   r   r   r   r   object_with_finalizer;   s    r    c                      s.     t  _z  W t  `d S t  `w r   )r   r   objectr   r   r    parentr   r   greenlet_body@   s   
z3GCTests.test_finalizer_crash.<locals>.greenlet_body)r!   r   r   arrayappendr   r	   r
   )r   r%   r$   gr   r"   r   test_finalizer_crash*   s   

zGCTests.test_finalizer_crashN)	r   r   r   r   r   ZGREENLET_USE_GCr   r   r(   r   r   r   r   r   	   s    
r   )r	   sysZunittestr   r   ZTestCaser   r   r   r   r   <module>   s    