HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/greenlet/tests/__pycache__/test_tracing.cpython-310.pyc
o

���g: �@s�ddlmZddlZddlZddlZddlmZddlmZeo$eed�dfZ	Gdd	�d	e
�ZGd
d�de�Z
Gdd
�d
e�ZGdd�de�Zdd�ZGdd�de�Zedkr]e��dSdS)�)�print_functionN�)�TestCase)�PY312�gettotalrefcountz%Broken on debug builds of Python 3.12c@seZdZdS)�	SomeErrorN)�__name__�
__module__�__qualname__�rr�F/usr/local/lib/python3.10/dist-packages/greenlet/tests/test_tracing.pyrsrc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�GreenletTracerNFcCsg|_||_dS�N)�actions�error_on_trace)�selfrrrr�__init__s
zGreenletTracer.__init__cGs|j�|�|jrt�dSr)r�appendrr�r�argsrrr�__call__s�zGreenletTracer.__call__cC�t�|�|_|jSr)�greenlet�settrace�oldtracer�rrrr�	__enter__�zGreenletTracer.__enter__cG�t�|j�dSr)rrrrrrr�__exit__"�zGreenletTracer.__exit__)F�rr	r
rrrrrrrrrr
s
r
c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestGreenletTracingz*
    Tests of ``greenlet.settrace()``
    c	Cs�t��}dd�}dd�}t��}t�|�}|��t�|�}|�t|j�Wd�n1s/wY|�|d||ffd||ffd||ffd||ffg�dS)NcSsdSrrrrrr�dummy-�z:TestGreenletTracing.test_a_greenlet_tracing.<locals>.dummycSst��r)rrrrr�dummyexc/�z=TestGreenletTracing.test_a_greenlet_tracing.<locals>.dummyexc�switch�throw)r�
getcurrentr
r'�assertRaisesr�assertEqual)r�mainr#r%r�g1�g2rrr�test_a_greenlet_tracing+s

�




�z+TestGreenletTracing.test_a_greenlet_tracingcs�t����fdd�}t�|�}|��tdd��}|�t|j�|�t��d�Wd�n1s2wY|�|d�|ffg�dS)Ncs���dSr)r'r�r,rrr#AszDTestGreenletTracing.test_b_exception_disables_tracing.<locals>.dummyT)rr')rr)r'r
r*rr+�gettrace)rr#�grrr0r�!test_b_exception_disables_tracing?s
�

�z5TestGreenletTracing.test_b_exception_disables_tracingcCs:t�}|�t�|�Wd�dS1swYdSr)r
rr)r�tracerrrr�test_set_same_tracer_twiceMs"�z.TestGreenletTracing.test_set_same_tracer_twiceN)rr	r
�__doc__r/r3r5rrrrr"&s
r"c@s0eZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
�PythonTracerNcCs
g|_dSr)rrrrrrZs
zPythonTracer.__init__cCs|j�||jjf�dSr)rr�f_code�co_name)r�frame�event�argrrrr]szPythonTracer.__call__cCrr)�sys�
setprofilerrrrrrrarzPythonTracer.__enter__cGrr)r=r>rrrrrrer zPythonTracer.__exit__r!rrrrr7Wsr7cCsdS�N�*rrrrr�tpt_callbackhr$rAc@sxeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Ze
je�dd��Ze
je�dd��ZdS)�TestPythonTracingz�
    Tests of the interaction of ``sys.settrace()``
    with greenlet facilities.

    NOTE: Most of this is probably CPython specific.
    NcCs@t��}t�Wd�n1swY|�|gd��dS)N)��returnr��callrA�rDrA�rFr��c_callr)r7rAr+)rrrrr�test_trace_events_trivialus�
z+TestPythonTracing.test_trace_events_trivialcCs4t��
}|��Wd�|S1swY|Sr)r7r'�r�gletrrrr�
_trace_switch�s

��zTestPythonTracing._trace_switchcCs|�|�}|�|gd��dS)N)	rC)rJrN)rF�runrErG�rDrO)�c_returnrNrHrI)rNr+rLrrr�$_check_trace_events_func_already_set�s
z6TestPythonTracing._check_trace_events_func_already_setcCsdd�}|�t�|��dS)NcS�t�Sr�rArrrrrO�r&zOTestPythonTracing.test_trace_events_into_greenlet_func_already_set.<locals>.run)rRr�rrOrrr�0test_trace_events_into_greenlet_func_already_set�szBTestPythonTracing.test_trace_events_into_greenlet_func_already_setcCs"Gdd�dtj�}|�|��dS)Nc@seZdZdd�ZdS)zQTestPythonTracing.test_trace_events_into_greenlet_subclass_already_set.<locals>.XcSrSrrTrrrrrO�r&zUTestPythonTracing.test_trace_events_into_greenlet_subclass_already_set.<locals>.X.runN�rr	r
rOrrrr�X�srX)rrR�rrXrrr�4test_trace_events_into_greenlet_subclass_already_set�szFTestPythonTracing.test_trace_events_into_greenlet_subclass_already_setcCs,|��t�|��|�|jgd��dS)N)rCrErGrPrErGrHrI)r'rArr+r)rr2r4rrr�/_check_trace_events_from_greenlet_sets_profiler�szATestPythonTracing._check_trace_events_from_greenlet_sets_profilercs(t���fdd�}|�t�|���dS)Nc����t�Sr�rrAr�r4rrrO��zQTestPythonTracing.test_trace_events_from_greenlet_func_sets_profiler.<locals>.run)r7r[rrUrr^r�2test_trace_events_from_greenlet_func_sets_profiler�s
�zDTestPythonTracing.test_trace_events_from_greenlet_func_sets_profilercs.t��G�fdd�dtj�}|�|���dS)NcseZdZ�fdd�ZdS)zSTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profiler.<locals>.Xcr\rr]rr^rrrO�r_zWTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profiler.<locals>.X.runNrWrr^rrrX�srX)r7rr[rYrr^r�6test_trace_events_from_greenlet_subclass_sets_profiler�szHTestPythonTracing.test_trace_events_from_greenlet_subclass_sets_profilercsnt��d�d���fdd�}��fdd�}t�|��t�|�����}|�|d�t�|��jgd��dS)Ncs ���t����t�dSr?)rrAr'r�r.r4rr�g1_run�s
zPTestPythonTracing.test_trace_events_multiple_greenlets_switching.<locals>.g1_runcs t����t����dSr)rArr'r�r-r4rr�g2_run�szPTestPythonTracing.test_trace_events_multiple_greenlets_switching.<locals>.g2_runr@)	rCrErG�rJrc)rFrerErGrHrI�r7rr'r+rAr�rrcre�xr�r-r.r4r�.test_trace_events_multiple_greenlets_switching�s

z@TestPythonTracing.test_trace_events_multiple_greenlets_switchingcs~t��d�d���fdd�}��fdd�}t�|��t�|�����������}|�|d�t�|��jgd��dS)Ncs.t��j�����t����t�dSr?)rr)�parentr'rrArrbrrrc�szYTestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings.<locals>.g1_runcs.t��j��t����t����dSr)rr)rlr'rArrrdrrres
zYTestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings.<locals>.g2_runr@)rCrErGrfrErGrHrIrgrhrrjr�7test_trace_events_multiple_greenlets_switching_siblings�s

zITestPythonTracing.test_trace_events_multiple_greenlets_switching_siblings)rr	r
r6�maxDiffrKrNrRrVrZr[r`ra�unittest�skipIf�DEBUG_BUILD_PY312rkrmrrrrrBks		
%rB�__main__)�
__future__rr=rro�rr�hasattrrq�	Exceptionr�objectr
r"r7rArBrr,rrrr�<module>s&�18�