HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_sys_settrace.cpython-310.opt-2.pyc
o

�i��@slddlmZddlZddlmZddlZddlZddlZddlm	Z	ddl
Z
Gdd�d�ZGdd�d�Zd	d
�Z
dd�Zgd
�e_dd�Zgd�e_dd�Zgd�e_dd�Zgd�e_dd�Zgd�e_dd�Zgd�e_dd�Zgd�e_dd �Zd!d"�Zgd#�e_d$d%�Zd&d'�Zgd(�e_d)d*�Zd+d,�Zd-ge_d.d/�Zd0d1�Zgd2�e_d3d4�Zgd5�e_d6d7�Zgd8�e_d9d:�Z gd;�e _d<d=�Z!d>d?�Z"gd@�dAdBgdCdAdDge"_GdEdF�dF�Z#GdGdH�dHej$�Z%GdIdJ�dJe%�Z&ej'GdKdL�dLe%��Z(GdMdN�dNej$�Z)GdOdP�dP�Z*dQdR�Z+dSdT�Z,GdUdV�dVej$�Z-GdWdX�dXej$�Z.e/dYk�r4e�0�dSdS)Z�)�supportN)�	MagicMock��wrapsc@�&eZdZ	dd�Zdd�Zdd�ZdS)�tracecontextcC�||_||_dS�N��output�value��selfrr�r�3/usr/local/lib/python3.10/test/test_sys_settrace.py�__init__�
ztracecontext.__init__cCs|j�|j�dSr	�r�appendr�rrrr�	__enter__�ztracecontext.__enter__cGs|j�|j�dSr	r�r�exc_inforrr�__exit__sztracecontext.__exit__N)�__name__�
__module__�__qualname__rrrrrrrr
�
rc@r)�asynctracecontextcCrr	r
r
rrrrrzasynctracecontext.__init__c�s�|j�|j�dSr	rrrrr�
__aenter__s�zasynctracecontext.__aenter__c�s�|j�|j�dSr	rrrrr�	__aexit__"s�zasynctracecontext.__aexit__N)rrrrr r!rrrrrrrcCs�	|D]}|VqdSr	r)�iterable�xrrr�	asynciter%s
��r$cCsdS�N�rrrrr�basic,�r')�r�call�r&�line�r&�returncC�d}~	d}dSr%r�r#rrr�arigo_example0;�r1)r)r+��r,��r,��r,�r8r.cCr/r%rr0rrr�arigo_example1Ir2r:cCr/r%rr0rrr�arigo_example2Ws
r;)r)r+r3r5��r,��r,�r?r.cCsd}~d}dSr%rr0rrr�one_instr_linejsrA�r)r+r3r5�r6r.cCs$d}td�D]	}|r
d}qd}qdS�Nr&r4��range)r#�arrr�no_pop_topsus�rH)
r)r+r3r5��r,r3r5r<r3�r4r.cCsd}|st|rd}dSr%)Zbla)�yr#rrr�
no_pop_blocks�s
�rM�r)r+r3r<�r=r.cCsd}dSr%rr0rrr�called�srPcC�
t�dSr	)rPrrrrr*�s
r*)r)r+����r*����r,�rUr.r-cCst�r	��	Exceptionrrrr�raises�r(rYcCs"zt�WdStyYdSwr	)rYrXrrrr�
test_raise�s
�rZ)r)r+r3rRrT�rU�	exceptionrV�r4r\r5r<rOcCst�|�|t��j_dSr	)�sys�settrace�	_getframe�f_back�f_trace�Z	tracefuncrrr�_settrace_and_return�s
rdcCst|�dSr	)rdrcrrr�settrace_and_return�srer-cCst�|�|t��j_t�r	)r^r_r`rarb�RuntimeErrorrcrrr�_settrace_and_raise�s
rgcCs$zt|�WdStyYdSwr	)rgrfrcrrr�settrace_and_raise�s
�rh)r]r5r<rOcCs"d}d}||kr|d}dS	dS)Nr8r&r)rG�brrr�ireturn_example�s
rj�r)r+r3r5r<rOcCs8tdd�}zd}	||}|d7}q	tyYdSw)Nrr6r&�rF�
IndexError)�items�irirrr�tightloop_example�s
��rp)r)r+r3r5r<r7r<r7r<r7r<r7)r8r\rIr>r@cCs.tdd�}zd}||}qtyYdSw)Nr&r=rrl)rnrorrr�tighterloop_example�s

�rq)r)r+r3r5r<r<r<r<)r=r\r7rI�rJr.ccs�zdVWdSw)NTrrrrr�generator_functions
�rscCs tt��}td�D]}|}q	dS)N�
)�anyrsrF)r#rLrrr�generator_examples
�rv)
r)r3����r*����r,����r,�r|r.)r|r*�r|r\����r,�r�r.r7rIrtr9c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�TracerNcCs||_||_g|_dSr	)�trace_line_events�trace_opcode_events�events)rr�r�rrrr1s
zTracer.__init__cCs,|jdur	|j|_|jdur|j|_dSdSr	)r��
f_trace_linesr��f_trace_opcodes)r�framerrr�_reconfigure_frame6s


�zTracer._reconfigure_framecCs"|�|�|j�|j|f�|jSr	�r�r�r�f_lineno�trace�rr��event�argrrrr�<s
zTracer.tracecCs0|�|�dd�dD�|j�|j|f�|jS)Ncss�|]}|VqdSr	r)�.0�orrr�	<genexpr>Cs�z)Tracer.traceWithGenexp.<locals>.<genexpr>�r&r�r�rrr�traceWithGenexpAs
zTracer.traceWithGenexp)NN)rrrrr�r�r�rrrrr�0s

r�c@s�eZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:doS)p�
TraceTestCasecCs(t��|_t��|�tjt���dSr	)�gc�	isenabled�using_gc�disable�
addCleanupr^r_�gettracerrrr�setUpLs
zTraceTestCase.setUpcCs|jr	t��dSdSr	)r�r��enablerrrr�tearDownQs�zTraceTestCase.tearDowncCs	t�Sr	�r�rrrr�make_tracerUszTraceTestCase.make_tracerc
sR�fdd�|D�}||kr'|�dd�t�dd�|D�dd�|D����dSdS)Ncsg|]
\}}|�|f�qSrr)r��l�e��line_offsetrr�
<listcomp>[�z0TraceTestCase.compare_events.<locals>.<listcomp>z"events did not match expectation:
�
cS�g|]}t|��qSr��str�r�r#rrrr�_�cSr�rr�r�rrrr�`r�)�fail�join�difflibZndiff)rr�r��expected_eventsrr�r�compare_eventsZs����zTraceTestCase.compare_eventscCs<|��}t�|j�|�t�d�|�|jj|j|�dSr	)r�r^r_r�r��__code__�co_firstlinenor�)r�funcr��tracerrrr�run_and_comparebs

�zTraceTestCase.run_and_comparecCs|�||j�dSr	)r�r��rr�rrr�run_testjrzTraceTestCase.run_testcCs6|��}||j�t�d�|�|jj|j|j�dSr	)r�r�r^r_r�r�r�r�)rr�r�rrr�	run_test2ms


�zTraceTestCase.run_test2cCst�d�dSr	�r^r_rrrr�test_set_and_retrieve_nonet�z(TraceTestCase.test_set_and_retrieve_nonec	Cs0dd�}t�|�zWt�d�dSt�d�w)NcW�dSr	r��argsrrr�fnyr(z4TraceTestCase.test_set_and_retrieve_func.<locals>.fnr�)rr�rrr�test_set_and_retrieve_funcxs
z(TraceTestCase.test_set_and_retrieve_funccC�|�t�dSr	)r�r'rrrr�
test_01_basic�r�zTraceTestCase.test_01_basiccCr�r	)r�r1rrrr�test_02_arigo0�r�zTraceTestCase.test_02_arigo0cCr�r	)r�r:rrrr�test_02_arigo1�r�zTraceTestCase.test_02_arigo1cCr�r	)r�r;rrrr�test_02_arigo2�r�zTraceTestCase.test_02_arigo2cCr�r	)r�rArrrr�test_03_one_instr�r�zTraceTestCase.test_03_one_instrcCr�r	)r�rMrrrr�test_04_no_pop_blocks�r�z#TraceTestCase.test_04_no_pop_blockscCr�r	)r�rHrrrr�test_05_no_pop_tops�r�z!TraceTestCase.test_05_no_pop_topscCr�r	)r�r*rrrr�test_06_call�r�zTraceTestCase.test_06_callcCr�r	)r�rZrrrr�
test_07_raise�r�zTraceTestCase.test_07_raisecCr�r	)r�rerrrr�test_08_settrace_and_return�r�z)TraceTestCase.test_08_settrace_and_returncCr�r	)r�rhrrrr�test_09_settrace_and_raise�r�z(TraceTestCase.test_09_settrace_and_raisecCr�r	)r�rjrrrr�test_10_ireturn�r�zTraceTestCase.test_10_ireturncCr�r	)r�rprrrr�test_11_tightloop�r�zTraceTestCase.test_11_tightloopcCr�r	)r�rqrrrr�test_12_tighterloop�r�z!TraceTestCase.test_12_tighterloopcCsH|�t�|��}t�|j�t�t�d�|�tjj|j	tj	�dSr	)
r�rvr�r^r_r�r�r�r�r�)rr�rrr�test_13_genexp�s


�zTraceTestCase.test_13_genexpcC�dd�}|�|gd��dS)NcSsd}dS)NTFrrr0rrr�onliners�sz2TraceTestCase.test_14_onliner_if.<locals>.onliners)r)r+r5rC�r�)rr�rrr�test_14_onliner_if�s
�z TraceTestCase.test_14_onliner_ifcCs4dd�}|�|gd��dd�}|�|gd��dS)NcSstd�D]}qdS�Nr4rEr0rrr�for_example�s�z0TraceTestCase.test_15_loops.<locals>.for_example)r)r+r3r+r3r+r-cSs$d}|dkr|d8}|dksdSdS)Nr4rr&rr0rrr�
while_example�s�z2TraceTestCase.test_15_loops.<locals>.while_example)r)r3r5r<r5r<r5rCr�)rr�r�rrr�
test_15_loops�s�
�zTraceTestCase.test_15_loopscCs&i}td|�|�|dgd��dS)Nadef f():
































































































































































































































































    pass�f)r))�r,)r�r.)�execr�)r�	namespacerrr�test_16_blank_lines�s
�z!TraceTestCase.test_16_blank_linescCsdd�}|�|ddg�dS)NcSsdt��_d}dSr�)r^r`rb)�linenorrrr��s
z0TraceTestCase.test_17_none_f_trace.<locals>.funcr)r+r�r�rrr�test_17_none_f_trace�s��z"TraceTestCase.test_17_none_f_tracecCr�)Nc
Ss6zzt�ty}z�d}~wwtyYdSwr	rW)r�r#rLrrrr��s���z4TraceTestCase.test_18_except_with_name.<locals>.func)
r)r+r3r5�r6r\r<r7��r,)�	r,)r�r.r�r�rrr�test_18_except_with_name�s�z&TraceTestCase.test_18_except_with_namecCr�)NcSs&zzt�d}wtyd}YdSw)NZ	Something�rW)rLrirrrr�s
�z7TraceTestCase.test_19_except_with_finally.<locals>.func)	r)r+r3r5r�r7rIr>r@r�r�rrr�test_19_except_with_finally�	�z)TraceTestCase.test_19_except_with_finallycspGdd�d���fdd���fdd�}|��}gd�}z||j�Wn	ty+Ynw|��jj|j|�dS)Nc@�$eZdZdd�Zdd�Zdd�ZdS)zBTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrappercSst|�|_dSr	)�iter�_it)r�objrrrrr�zKTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__init__cS�|Sr	rrrrr�	__aiter__r(zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__aiter__c�s"�zt|j�WStyt�wr	)�nextr��
StopIteration�StopAsyncIterationrrrr�	__anext__s��zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__anext__N)rrrrr�r�rrrr�AsyncIteratorWrappersr�c�s&��d�2z3dHW}|}q6d}dS)N�abc�*r)Zletterr#rL)r�rr�
doit_async%s
��z8TraceTestCase.test_20_async_for_loop.<locals>.doit_asyncc	s8��}zt�|�|�d�Wt�d�dSt�d�wr	)r^r_�send)r�r#)r�rr�run*s

z1TraceTestCase.test_20_async_for_loop.<locals>.run)(r)r+)i�r*)���r,)r�r.�i����r*����r,�r�r.rwryr{r}�r&r\r3r+rwryr{r}r�r3r+rwryr{r}r�r3r+rwryr{r~�rSr,rTr[rVr�r5rC)r�r�rXr�r�r�r�)rr�r�r�r)r�r�r�test_20_async_for_loops
)�
�z$TraceTestCase.test_20_async_for_loopc	s�dd���fdd�}|��}|�}zz
t�|j�|�d�Wn	ty(YnwWt�d�nt�d�wgd�}|�|jj|j	|�dS)NcSs�t|�D]}|VqdSr	rE)�nrorrr�arangeds��zGTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.arangec�s,��d�2z
3dHW}|dkrdSq6dS)Nr6�dr�ro�rrrr�gs���zBTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.f)r)r+rRrTrr�r�r3r+�r�r*rTrr�r�r3r+rrTrr�r�r3r+rrTrVr�r-)
r�r^r_r�r�rXr�r�r�r�)rr�r��coror�rrr�)test_async_for_backwards_jump_has_no_linecs ��
�z7TraceTestCase.test_async_for_backwards_jump_has_no_linecCr�)NcSs	dSr	rrrrrr��sz1TraceTestCase.test_21_repeated_pass.<locals>.func�r)r+r3rKr�r�rrr�test_21_repeated_pass�s�z#TraceTestCase.test_21_repeated_passcCr�)NcSszdD]}qWdSYdS)Nrr&r4rrrrrr��s

z3TraceTestCase.test_loop_in_try_except.<locals>.funcrBr�r�rrr�test_loop_in_try_except�s�z%TraceTestCase.test_loop_in_try_exceptcCr�)NcSszzWWdSYWdSwr	rrrrrr��s�z8TraceTestCase.test_try_except_no_exception.<locals>.func)r)r+r3rIrrr�r�rrr�test_try_except_no_exception���z*TraceTestCase.test_try_except_no_exceptioncCr�)NcSs,td�D]
}td�D]}||}q
q|dkS)Nr4r&rE)ro�jrGrrrr��s

�z-TraceTestCase.test_nested_loops.<locals>.func)r)r+r3r5r3r5r3r+r3r5r3r5r3r+r<rOr�r�rrr�test_nested_loops���zTraceTestCase.test_nested_loopscCr�)NcSs*ddg}|r|��}|r	|S|sd}|S)Nr&r�c��pop)�seqrrrrr��s�z)TraceTestCase.test_if_break.<locals>.func)r)r+r3r5r<r3r5r<r7r�)r�r.r�r�rrr�
test_if_break��
�zTraceTestCase.test_if_breakcCr�)NcSs^d\}}}}z td�D]}zd}|dkrWd}WdSd}Wd}qd}wWdSd}YdS)N)r&r&r&rr6r8rrtr��rE)rG�c�drorrrr��s��
z6TraceTestCase.test_break_through_finally.<locals>.func)r)r+r3r5r<r7rIr��rtr,r5r<r7rIr>r��
r,�rr.r�r�rrr�test_break_through_finally���z(TraceTestCase.test_break_through_finallycCr�)NcSsZd\}}}}}ztd�D]}zd}|dkrWd}qd}Wd}qd}wWdSd}YdS)N)r&r&r&r&rr4r8rrtr�rrE)rGrirrrorrrr�s��
z9TraceTestCase.test_continue_through_finally.<locals>.func)r)r+r3r5r<r7rIr�rr5r<r7rIr>rr5rrr�r�rrr�test_continue_through_finallyrz+TraceTestCase.test_continue_through_finallycCr�)NcSs
zWdSwr�rrrrrr�Bsz7TraceTestCase.test_return_through_finally.<locals>.funcrNr�r�rrr�test_return_through_finally@rz)TraceTestCase.test_return_through_finallycCr�)NcSs6zzddWWdStyYWdSwYdS)Nr4rrJ)rmrrrrr�Qs��z;TraceTestCase.test_try_except_with_wrong_type.<locals>.func)r)r+r3r]r5rIrrr�r�rrr�test_try_except_with_wrong_typeOr
z-TraceTestCase.test_try_except_with_wrong_typecCr�)NcSs"d}dg}|r|��|r	qdSr%r��TRUEr#rrrr�ds�z3TraceTestCase.test_break_to_continue1.<locals>.func)
r)r+r3r5r<r7rIr>r5rCr�r�rrr�test_break_to_continue1b�	�z%TraceTestCase.test_break_to_continue1cCr�)NcSs*d}dg}|r|��|rnq|sdSdSr%rr#rrrr�{s�z3TraceTestCase.test_break_to_continue2.<locals>.func)	r)r+r3r5r<r7rIr5rCr�r�rrr�test_break_to_continue2yrz%TraceTestCase.test_break_to_continue2cCr�)NcSsd}|r|r		dSdSdSr%r)r$rrrr��s�z/TraceTestCase.test_break_to_break.<locals>.func)r)r+r3r5r<r7r9r�r�rrr�test_break_to_break���z!TraceTestCase.test_break_to_breakcCr�)NcSs0d}}|dkr|dkrd}dSd}dSd}dS)Nr&r=rJr�r)rGrir#rL�zrrrr��sz+TraceTestCase.test_nested_ifs.<locals>.funcrkr�r�rrr�test_nested_ifs�rzTraceTestCase.test_nested_ifscs0���fdd�}d��d�|�|gd��dS)Ncs4�r�r�r
trdSdSdSdStrtrdSdSdS)NFT)�D�E�Fr��A�B�Crrr��s��z4TraceTestCase.test_nested_ifs_with_and.<locals>.funcTFrBr�r�rr/r�test_nested_ifs_with_and�s�z&TraceTestCase.test_nested_ifs_with_andcCr�)NcSs>d}z	ddWd}dSty|dkrt��Yd}dSw)NZhellor6r�raiser?)�ZeroDivisionError�
ValueError)r#r�rrrr��s
���z.TraceTestCase.test_nested_try_if.<locals>.func�	r)r+r3r5r�r<r7r>r@r�r�rrr�test_nested_try_if�r&z TraceTestCase.test_nested_try_ifcs.Gdd�d���fdd�}|�|gd��dS)Nc@�eZdZdd�Zdd�ZdS)z.TraceTestCase.test_if_false_in_with.<locals>.CcSr�r	rrrrrr�r(z8TraceTestCase.test_if_false_in_with.<locals>.C.__enter__cWr�r	rr�rrrr�r(z7TraceTestCase.test_if_false_in_with.<locals>.C.__exit__N�rrrrrrrrrr2��r2c�.���
	Wd�dS1swYdSr	rr�r2rrr��s"�z1TraceTestCase.test_if_false_in_with.<locals>.func)r)r+�rzr*r{r}r3r+rRrTrVr-r�r�rr=r�test_if_false_in_with�s
�z#TraceTestCase.test_if_false_in_withcCr�)NcSs zWdStytYdSwr	)rX�Xrrrrr��s

�z7TraceTestCase.test_if_false_in_try_except.<locals>.funcr	r�r�rrr�test_if_false_in_try_except�r)z)TraceTestCase.test_if_false_in_try_exceptcCr�)NcSsGdd�d�}dS)Nc@s eZdZddkrdZdSdZdS)zDTraceTestCase.test_implicit_return_in_class.<locals>.func.<locals>.Ar6r�r&r4N)rrrrGrrrrr0sr0r)r0rrrr�rz9TraceTestCase.test_implicit_return_in_class.<locals>.func)r)r+)r&r*r+r3r5rCr-r�r�rrr�test_implicit_return_in_classr)z+TraceTestCase.test_implicit_return_in_classcCr�)Nc
SsHzzWWdSty}zWYd}~WdSd}~wwty#YdSwr	rW)�exrrrr� s���z+TraceTestCase.test_try_in_try.<locals>.funcrBr�r�rrr�test_try_in_tryr�zTraceTestCase.test_try_in_trycCsddd�}|�|gd��dS)Nrr&cSs |r
|r|rdS	dSdS	dSr	r)rG�pr*rrrr�1s�z/TraceTestCase.test_if_in_if_in_if.<locals>.funcr	)rr&r&r�r�rrr�test_if_in_if_in_if0s

�z!TraceTestCase.test_if_in_if_in_ifcsJGdd�d���fdd�}�fdd�}|�|gd��|�|gd��dS)	Nc@r9)z-TraceTestCase.test_early_exit_with.<locals>.CcSr�r	rrrrrrDr(z7TraceTestCase.test_early_exit_with.<locals>.C.__enter__cWr�r	rr�rrrrFr(z6TraceTestCase.test_early_exit_with.<locals>.C.__exit__Nr:rrrrr2Cr;r2c	s:dD]}���	Wd�dS1swYqdS)N�r&r4rrr=rr�
func_breakIs��z6TraceTestCase.test_early_exit_with.<locals>.func_breakcr<r	rrr=rr�func_returnOs$�z7TraceTestCase.test_early_exit_with.<locals>.func_return)
r)r+r3r>r{r}r5r3rRrTrVr<rO)r)r+)r�r*)���r,)rJr.r3r+r�r�r�r-r�)rrHrIrr=r�test_early_exit_withAs��z"TraceTestCase.test_early_exit_withcs(dd���fdd�}|�|gd��dS)NcSs0|rz	d|dW|StyY|Sw|Sr%�r5r0rrr�fooqs��z;TraceTestCase.test_flow_converges_on_same_line.<locals>.foocstd�D]}�|�qdSr�rEr�rMrrr�y�
�z<TraceTestCase.test_flow_converges_on_same_line.<locals>.func)r)r+r3�r�r*�i����r,rTrVr+r3rPrQ)rxr,ry)rzr\r{r�rTrVr+r-r�r�rrNr� test_flow_converges_on_same_lineos
�z.TraceTestCase.test_flow_converges_on_same_linecCr�)Nc
Ss@d}zd|WdSty}z
|r�WYd}~dSd}~ww)Nrr&�donerL)r#�errorrrrr��s
�
���zCTraceTestCase.test_no_tracing_of_named_except_cleanup.<locals>.funcr7r�r�rrr�'test_no_tracing_of_named_except_cleanup�r&z5TraceTestCase.test_no_tracing_of_named_except_cleanupN);rrrr�r��staticmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrrrr r!r"r%r'r(r+r3r8r?rArBrDrFrKrRrUrrrrr�Hsr


		L4$%.$r�c�*eZdZ	�fdd�Zedd��Z�ZS)�SkipLineEventsTraceTestCasecs"dd�|D�}t��|||�dS)NcS�g|]
}|ddkr|�qSr+r�r�r�rrrr��r�z>SkipLineEventsTraceTestCase.compare_events.<locals>.<listcomp>)�superr�)rr�r�r�Zskip_line_events��	__class__rrr��sz*SkipLineEventsTraceTestCase.compare_eventscC�
tdd�S)NF)r�r�rrrrr���
z'SkipLineEventsTraceTestCase.make_tracer�rrrr�rVr��
__classcell__rrr\rrX�s
rXcrW)�TraceOpcodesTestCasecsFdd�|D�}t|�dkr|jt|�t|�dd�t��|||�dS)NcSrY)r&ZopcoderrZrrrr��r�z7TraceOpcodesTestCase.compare_events.<locals>.<listcomp>r&z)No 'opcode' events received by the tracer)�msg)�lenZ
assertLessr[r�)rr�r�r�Zskip_opcode_eventsr\rrr��s�z#TraceOpcodesTestCase.compare_eventscCr^)NT)r�r�rrrrr��r_z TraceOpcodesTestCase.make_tracerr`rrr\rrb�s
rbc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�RaisingTraceFuncTestCasecCs|�tjt���dSr	�r�r^r_r�rrrrr���zRaisingTraceFuncTestCase.setUpcCs	||jkrt�|jSr	)�raiseOnEventr6r�r�rrrr��s
zRaisingTraceFuncTestCase.tracecCs 	|jdkrd}d|}dSdS)Nr\rr&)rh)rr#rLrrrr��s

zRaisingTraceFuncTestCase.fc	Csz	||_z)tt��d�D]}t�|j�z|��Wn	ty$Yq
w|�d�q
WdSt	y<|�d�YdSw)Nr&zexception not raised!zrecursion counter not reset)
rhrFr^�getrecursionlimitr_r�r�r6r�rf)rr�rorrr�run_test_for_event�s���z+RaisingTraceFuncTestCase.run_test_for_eventcC�|�d�dS)Nr*�rjrrrr�	test_call�r�z"RaisingTraceFuncTestCase.test_callcCrk�Nr,rlrrrr�	test_line�r�z"RaisingTraceFuncTestCase.test_linecCrk)Nr.rlrrrr�test_return�r�z$RaisingTraceFuncTestCase.test_returncCrk�Nr\rlrrrr�test_exception�r�z'RaisingTraceFuncTestCase.test_exceptioncs^dd����fdd��t���z��Wnty'ddl}|��YdSw|�d�dS)NcSstd�D]}t|�qdS)Nr8)rF�printrrrrr��rOz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.fcs&|dkr|j�jjdkrtd���S)Nr,r4z
i am crashing)r�r�r�rf)r��why�extra�r��grrrw�sz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.grzexception not propagated)r^r_rfr�Zcollectr�)rr�rrvr�test_trash_stack�s

�z)RaisingTraceFuncTestCase.test_trash_stackc	stdd�}��fdd��t��}z$t���z|�Wn	ty#Yn	wWt�|�dSWt�|�dSt�|�w)NcSsd}|jdS)Nr)Zno_such_attrr0rrrr�s
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.fcs"|dkr|\}}}��|t��Srq)�assertIsInstancerX)r�r�r��typer\r��rwrrrrws
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g)r^r�r_�AttributeError)rr�Zexistingrr{r�test_exception_argumentss

���z1RaisingTraceFuncTestCase.test_exception_argumentscsjtd����fdd��dd�}|�t��}t���|�Wd�n1s'wY|�|j��dS)NzBOOM!cs|dkr��d|_�S)Nr,T)r�)r�r�r��r\r�rrr�#szRRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.tracecSr�r	rrrrrr�(r(zNRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.f)r6ZassertRaisesr^r_ZassertIsr\)rr�Zcaughtrr~r�*test_line_event_raises_before_opcode_event!s
�zCRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_eventN)rrrr�r�r�rjrmrorprrrxr}rrrrrre�s	rec@s$eZdZ			ddd�Zdd�ZdS)	�
JumpTracerr,FcCs6|j|_||_||_||_|rdn|jj|_d|_dS)NF)r��code�jumpFrom�jumpTor�r��	firstLinerS)r�functionr�r�r��	decoratedrrrr7s
zJumpTracer.__init__cCs�|jrdS|jdur|j|jkr|dkr|jd|_||jkrd|jdurd|j|j|jkrd|}|durF|j|jkrF|j}|durF|j|jks9|durdz	|j|j|_Wn
t	y`|j|_Ynwd|_|j
S)Nr,r&T)rSr��f_coder�r�r�r�rar��	TypeErrorr�)rr�r�r�r�rrrr�@s&��zJumpTracer.traceN)r,F)rrrrr�rrrrr�4s
�	r�c
CsJz|�d�WdSty$}z|�dt|�v�WYd}~dSd}~ww)Nr4Zinteger)rr6r��rr�rrr�no_jump_to_non_integersZs ��r�c
CsRzt��j}|j|_Wtd��ty(}zdt|�vr�WYd}~dSd}~ww)Nr�z'Trace-function-less jump failed to fail)r^r`rar�r6r��AssertionError)Zprevious_framer�rrr�no_jump_without_trace_functionbs

����r�c@s�eZdZdd�Zdd�Z		d�dd	�Z		d�d
d�Zd�dd
�Zd�dd�Zedddg�dd��Z	eddgd��dd��Z
eddddg�dd��Zeddgd��dd��Zeddddg�d d!��Z
eddgd"��d#d$��Zedddg�d%d&��Zeddgd'��d(d)��Zedd*dd*g�d+d,��Zedd-dd-ged.f�d/d0��Zedd1dd1ged.f�d2d3��Zedd1ddged4f�d5d6��Zedddged4f�d7d8��Zeddddg�d9d:��Zeddgd;��d<d=��Zeddddg�d>d?��Zeddddg�d@dA��ZeddgdB��dCdD��ZeddgdB��dEdF��Zedddg�dGdH��ZeddgdI��dJdK��Zedddg�dLdM��Z eddgdN��dOdP��Z!edd-gdQ��dRdS��Z"eddgdT��dUdV��Z#eddgdW��dXdY��Z$eddgdW��dZd[��Z%eddgd\��d]d^��Z&eddgd\��d_d`��Z'eddgda��dbdc��Z(eddgda��ddde��Z)eddgdf��dgdh��Z*eddgdf��didj��Z+edkd1gdl��dmdn��Z,eddgdo��dpdq��Z-eddgdo��drds��Z.eddgdt��dudv��Z/eddkgdw��dxdy��Z0edd-d-dkg�dzd{��Z1edd-d-dkg�d|d}��Z2edddged4f�d~d��Z3edd�dged�f�d�d���Z4edddged�f�d�d���Z5edddged�f�d�d���Z6edddged�f�d�d���Z7edddged�f�d�d���Z8eddged�f�d�d���Z9eddged�f�d�d���Z:eddddged�f�d�d���Z;eddddged�f�d�d���Z<eddged�f�d�d���Z=eddged�f�d�d���Z>eddgd��ed�f�d�d���Z?eddgd��ed�f�d�d���Z@eddged�f�d�d���ZAeddddged�f�d�d���ZBeddged�f�d�d���ZCedddged�f�d�d���ZDedd-dged�f�d�d���ZEedddg�d�d���ZFeddgd���d�d���ZGeddgd���d�d���ZHeddged�f�d�d���ZIeddged�f�d�d���ZJeddgd��ed�f�d�d���ZKedddged�f�d�d���ZLed-dgd��ed�f�d�d���ZMed-dgd��ed�f�d�d���ZNeddgd���d�dÄ�ZOeddgd���d�dń�ZPedd-ddged4f�d�dDŽ�ZQed-dddged�f�d�dɄ�ZRed-dddged�f�d�d˄�ZSd�d̈́ZTd�dτZUd�dфZVd�dӄZWedddgd�ed�fd֍d�d؄�ZXedddgd�ed�fd֍d�d܄�ZYedddgd�ed�fd֍d�d߄�ZZeddddgd�d�d�d��Z[eddddg�d�d��Z\eddg�d�d��Z]edkdgd��d�d��Z^eddddg�d�d��Z_eddg�d�d��Z`edkdgd��d�d��ZadS)��JumpTestCasecC� |�tjt���t�d�dSr	rfrrrrr�q�zJumpTestCase.setUpcCs2||kr|�dt|�ddt|��dSdS)NzOutputs don't match:
Expected: r�z
Received: )r��repr)r�expectedZreceivedrrr�compare_jump_outputus���
��z JumpTestCase.compare_jump_outputNr,Fc
Cs~t|||||�}t�|j�g}	|dur||	�n|j|��||	�Wd�n1s-wYt�d�|�||	�dSr	)r�r^r_r��assertRaisesRegexr��
rr�r�r�r�rTr�r�r�rrrrr�{s

�
zJumpTestCase.run_testc
Cs�t|||||�}t�|j�g}	|durt�||	��n|j|��t�||	��Wd�n1s3wYt�d�t�d�|�||	�dSr	)	r�r^r_r��asyncior�r�Zset_event_loop_policyr�r�rrr�run_async_test�s�

zJumpTestCase.run_async_testc�	�����fdd�}|S)Nc�"t��������fdd��}|S)Nc	�|j������dd�dS�NT)rTr�r�)r�r�rTr�r�r�r�r�rr�test��
�z7JumpTestCase.jump_test.<locals>.decorator.<locals>.testr�r�r��rTr�r�r�r��r�r�	decorator��z)JumpTestCase.jump_test.<locals>.decoratorr�r�r�r�rTr�r�rr�r�	jump_test��zJumpTestCase.jump_testcr�)Ncr�)Nc	r�r�)r�rr�rrr��r�z=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.testrr�r�r�rr��r�z/JumpTestCase.async_jump_test.<locals>.decoratorrr�rr�r�async_jump_test�r�zJumpTestCase.async_jump_testr&r6cC�"|�d�|�d�|�d�dS�Nr&r4r6�r�rrrr�test_jump_simple_forwards��

z&JumpTestCase.test_jump_simple_forwardsr4)r&r&r4cC�|�d�|�d�dSrDr�r�rrr�test_jump_simple_backwards��
z'JumpTestCase.test_jump_simple_backwardsr8cCs6dD]}|�d�dD]}|�d�qq|�d�dS)NrGr4�r6r=r8r��rrorrrr�test_jump_out_of_block_forwards�s
�z,JumpTestCase.test_jump_out_of_block_forwardsrJ)r&r6r8r&r6r8rJr?cCsJ|�d�dD]}|�d�dD]}|�d�q|�d�q|�d�dS)Nr&r�r6)r4r8rJr?r�r�rrr� test_jump_out_of_block_backwards�s

z-JumpTestCase.test_jump_out_of_block_backwardsr=c�sJ�dD]}tddg�2z3dHW}|�d�|�d�q6|�d�qdS)Nr�r&r4r6r=r8�r$r�rrorrr�)test_jump_out_of_async_for_block_forwards�s�
��z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r4r=r4r=r8rJc�sR�dD]#}|�d�tdg�2z3dHW}|�d�|�d�q6|�d�qdS)Nr�r4r&r=r8rJ�rr$r�rrr�*test_jump_out_of_async_for_block_backwards�s�

��z7JumpTestCase.test_jump_out_of_async_for_block_backwardscCr�)Nr&r6r�r�rrr�test_jump_to_codeless_line�s
z'JumpTestCase.test_jump_to_codeless_line)r&r4r6cCr�r�r�r�rrr�test_jump_to_same_line�r�z#JumpTestCase.test_jump_to_same_liner�cCs�z%|�d�W|�d�z|�d�W|�d�n|�d�w|�d�dS|�d�z|�d�W|�d�n|�d�w|�d�w)Nr4r=rJr�r�r�r�rrr�test_jump_in_nested_finally�s

�z(JumpTestCase.test_jump_in_nested_finallyr?�c	CsDz|�d�ddW|�d�|�d�dS|�d�|�d�w)Nr4r&rrJr?r�r�rrr�test_jump_in_nested_finally_2�s


�z*JumpTestCase.test_jump_in_nested_finally_2�cCs�z)|�d�ddW|�d�z|�d�W|�d�n|�d�w|�d�dS|�d�z|�d�W|�d�n|�d�w|�d�w)Nr4r&rrJr�rtr�r�r�rrr�test_jump_in_nested_finally_3s


�z*JumpTestCase.test_jump_in_nested_finally_3Zafterc	C�Fz|�d�W|�d�|�d�dS|�d�|�d�YdS�Nr4r=r8r�r�rrr�5test_no_jump_over_return_try_finally_in_finally_block�


�
zBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_blockcCs|�d�	|�d�q)Nr&Tr6r�r�rrr� test_no_jump_infinite_while_loop s

�z-JumpTestCase.test_no_jump_infinite_while_loopcCs8d}|�d�|dkr|�d�|d7}|dksdSdS)Nr&r4r=r�r�rrr�#test_jump_forwards_into_while_block's

�z0JumpTestCase.test_jump_forwards_into_while_block)r6r6r6r8cCs4d}|dkr|�d�|d7}|dks|�d�dS)Nr&r4r6r8r�r�rrr�$test_jump_backwards_into_while_block/s
�z1JumpTestCase.test_jump_backwards_into_while_blockcC�Bt|d��
|�d�Wd�n1swY|�d�dSr��rrr�rrr�$test_jump_forwards_out_of_with_block7��z1JumpTestCase.test_jump_forwards_out_of_with_blockc	��X�t|d�4IdH�|�d�Wd�IdHn1IdHs wY|�d�dSr��rrr�rrr�*test_jump_forwards_out_of_async_with_block=�
�(�z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r&r4r&r4r6rUcC�D|�d�t|d��|�d�Wd�dS1swYdSr��rrr�rrr�%test_jump_backwards_out_of_with_blockC�
"�z2JumpTestCase.test_jump_backwards_out_of_with_blockc	��Z�|�d�t|d�4IdH�|�d�Wd�IdHdS1IdHs&wYdSr��rrr�rrr�+test_jump_backwards_out_of_async_with_blockI�
�
.�z8JumpTestCase.test_jump_backwards_out_of_async_with_blockc	C�4z|�d�W|�d�n|�d�w|�d�dSr�r�r�rrr�+test_jump_forwards_out_of_try_finally_blockO�z8JumpTestCase.test_jump_forwards_out_of_try_finally_block)r&r&r6r8c	C�2|�d�z
|�d�W|�d�dS|�d�w�Nr&r6r8r�r�rrr�,test_jump_backwards_out_of_try_finally_blockW�
z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockcC�0z|�d�Wn	|�d��|�d�dS�Nr4r=rJr�r�rrr�*test_jump_forwards_out_of_try_except_block_�
z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r&r&r6cC�.|�d�z|�d�WdS|�d��r�r�r�rrr�+test_jump_backwards_out_of_try_except_blockh�

z8JumpTestCase.test_jump_backwards_out_of_try_except_block)r=r?r�cCs\zddWn ty|�d�|�d�Ynty&|�d�Ynw|�d�dS�Nr&rr=r8r?r��r5r�FloatingPointErrorr�rrr�test_jump_between_except_blocksqs
�z,JumpTestCase.test_jump_between_except_blocks)r=rJr?cCsBzddWn|�d�|�d�|�d�Y|�d�dS)Nr&rr=r8rJr?r�r�rrr�test_jump_within_except_block|s

z*JumpTestCase.test_jump_within_except_block)r&r=r8r|cC�x|�d�t|d��
|�d�Wd�n1swYt|d��|�d�Wd�dS1s5wYdS�Nr&r4r6r=r8r�r�rrr�test_jump_across_with��
�"�z"JumpTestCase.test_jump_across_withc	���|�d�t|d�4IdH�|�d�Wd�IdHn1IdHs%wYt|d�4IdH�|�d�Wd�IdHdS1IdHsJwYdSr�r�r�rrr�test_jump_across_async_with���
(�.�z(JumpTestCase.test_jump_across_async_with)r&r6r8rJc	Cs`|�d�dD]!}t|d��
|�d�Wd�n1swY|�d�q|�d�dS�Nr&r�r6r=r8rJr�r�rrr�,test_jump_out_of_with_block_within_for_block�s
�z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc
�sv�|�d�dD]+}t|d�4IdH�|�d�Wd�IdHn1IdHs)wY|�d�q|�d�dSr�r�r�rrr�2test_jump_out_of_async_with_block_within_for_block�s�
(�z?JumpTestCase.test_jump_out_of_async_with_block_within_for_block)r&r4r6r8rUrJc	Cs�|�d�t|d��'t|d��
|�d�Wd�n1s wY|�d�Wd�n1s4wY|�d�dS�Nr&r4r6r=r8rJr�r�rrr�-test_jump_out_of_with_block_within_with_block�s
��z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc
�s��|�d�t|d��1t|d�4IdH�|�d�Wd�IdHn1IdHs+wY|�d�Wd�n1s?wY|�d�dSr�)rrrr�rrr�3test_jump_out_of_async_with_block_within_with_block�s�
(��z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r4r=rJr?cCs�z&|�d�Wt|d��
|�d�Wd�n1swY|�d�n t|d��
|�d�Wd�n1s<wY|�d�w|�d�dS�Nr4r=r8rJr?r�r�rrr�0test_jump_out_of_with_block_within_finally_block�s���z=JumpTestCase.test_jump_out_of_with_block_within_finally_blockc�s��z0|�d�Wt|d�4IdH�|�d�Wd�IdHn1IdHs'wY|�d�n*t|d�4IdH�|�d�Wd�IdHn1IdHsQwY|�d�w|�d�dSr�r�r�rrr�6test_jump_out_of_async_with_block_within_finally_block�s�(��(�zCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr�)r&r6r8r�rcCsx|�d�dD]-}|�d�dD]}|�d�zdD]}|�d�qW|�d�q|�d�w|�d�q|�d	�dS)
Nr&r�r6rGr8r�rtr�rr�)rror�krrr�&test_jump_out_of_complex_nested_blocks�s


�z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r&r4r8cCsL|�d�t|d��
}|�d�Wd�n1swY|�d�dS�Nr&r4r=r8r��rr#rrr� test_jump_out_of_with_assignment�s

�z-JumpTestCase.test_jump_out_of_with_assignmentc	�sb�|�d�t|d�4IdH�}|�d�Wd�IdHn1IdHs%wY|�d�dSr�r�r�rrr�&test_jump_out_of_async_with_assignment�s�
(�z3JumpTestCase.test_jump_out_of_async_with_assignment)r&rJr�r�c	Cs\|�d�z|�d�|sW|�d�dS|�d�W|�d�n|�d�w|�d�dS)Nr&r6r�rJr�r�r�rrr�*test_jump_over_return_in_try_finally_block�s

�z7JumpTestCase.test_jump_over_return_in_try_finally_block)r&r6r�rtr�rc	Csr|�d�	|�d�z|�d�|sW|�d�n|�d�W|�d�n|�d�w|�d�	|�d�dS)	Nr&Tr6r8rtr�r�rr�r�rrr�)test_jump_over_break_in_try_finally_block�s


�
z6JumpTestCase.test_jump_over_break_in_try_finally_blockcC�F|�d�|sdD]}|�d�q	n
|�d�|�d�|�d�dS�Nr&r�r=rJr?r�r�r�rrr�$test_jump_over_for_block_before_else	�
�

z1JumpTestCase.test_jump_over_for_block_before_elsec��X�|�d�|stdg�2z3dHW}|�d�q
6n
|�d�|�d�|�d�dS�Nr&r6r=rJr?r�r�r�rrr�*test_jump_over_async_for_block_before_else��
�

z7JumpTestCase.test_jump_over_async_for_block_before_elsecCr�rDr�r�rrr�test_no_jump_too_far_forwards!r�z*JumpTestCase.test_no_jump_too_far_forwardsrU�beforecCr�rDr�r�rrr�test_no_jump_too_far_backwards&r�z+JumpTestCase.test_no_jump_too_far_backwards�exceptcCs$z|�d�WdS|�d���Nr4r=r�r�rrr�test_no_jump_to_except_1,s

z%JumpTestCase.test_no_jump_to_except_1cCs,z|�d�WdSty|�d��wr�rr6r�rrr�test_no_jump_to_except_24s
�z%JumpTestCase.test_no_jump_to_except_2c
Cs8z|�d�WdSty}z|�d�|�d}~wwrrr�rrr�test_no_jump_to_except_3<s
��z%JumpTestCase.test_no_jump_to_except_3c
Cs<z|�d�WdSttfy}z|�d�|�d}~wwr)rr6rfr�rrr�test_no_jump_to_except_4Ds
��z%JumpTestCase.test_no_jump_to_except_4ZintocCs"|�d�dD]}|�d�qdS)Nr&rGr6r�r�rrr�$test_no_jump_forwards_into_for_blockLs
�z1JumpTestCase.test_no_jump_forwards_into_for_blockc�s6�|�d�tddg�2z3dHW}|�d�q6dSr�r�r�rrr�*test_no_jump_forwards_into_async_for_blockRs�
�z7JumpTestCase.test_no_jump_forwards_into_async_for_blockcCs"dD]}|�d�q|�d�dS)NrGr4r6r�r�rrr�%test_no_jump_backwards_into_for_blockYsz2JumpTestCase.test_no_jump_backwards_into_for_blockc�s6�tddg�2z3dHW}|�d�q6|�d�dSr�r�r�rrr�+test_no_jump_backwards_into_async_for_block_s
��z8JumpTestCase.test_no_jump_backwards_into_async_for_blockcCr�r�r�r�rrr�%test_no_jump_forwards_into_with_blocker�z2JumpTestCase.test_no_jump_forwards_into_with_blockc	�r�r�r�r�rrr�+test_no_jump_forwards_into_async_with_blockkr�z8JumpTestCase.test_no_jump_forwards_into_async_with_block)r&r4r�cCr�r�r�r�rrr�&test_no_jump_backwards_into_with_blockqr�z3JumpTestCase.test_no_jump_backwards_into_with_blockc	�r�r�r�r�rrr�,test_no_jump_backwards_into_async_with_blockwr�z9JumpTestCase.test_no_jump_backwards_into_async_with_blockc	Cr�r�r�r�rrr�,test_no_jump_forwards_into_try_finally_block}r�z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockc	Cr�r�r�r�rrr�-test_no_jump_backwards_into_try_finally_block�r�z:JumpTestCase.test_no_jump_backwards_into_try_finally_blockcCr�r�r�r�rrr�+test_no_jump_forwards_into_try_except_block�r�z8JumpTestCase.test_no_jump_forwards_into_try_except_blockcCr�r�r�r�rrr�,test_no_jump_backwards_into_try_except_block�r�z9JumpTestCase.test_no_jump_backwards_into_try_except_blockc
CsnzddWn)ty|�d�|�d�Ynty/}z|�d�WYd}~nd}~ww|�d�dSr�r�r�rrr�$test_no_jump_between_except_blocks_2�s
��z1JumpTestCase.test_no_jump_between_except_blocks_2c	Cr�r�r�r�rrr�test_jump_into_finally_block�r�z)JumpTestCase.test_jump_into_finally_block)r4rJr?c	CsRz|�d�|�d�W|�d�|�d�n|�d�|�d�w|�d�dS)Nr4r6r8rJr?r�r�rrr�+test_jump_into_finally_block_from_try_block�s


�z8JumpTestCase.test_jump_into_finally_block_from_try_block)r&r6r&r6r8c	Cr�r�r�r�rrr�test_jump_out_of_finally_block�r�z+JumpTestCase.test_jump_out_of_finally_blockzinto an 'except'cCs2|�d�z|�d�WdS|�d�YdSr�r�r�rrr�#test_no_jump_into_bare_except_block�s

z0JumpTestCase.test_no_jump_into_bare_except_blockcCs:|�d�z|�d�WdSty|�d�YdSwr��rrXr�rrr�(test_no_jump_into_qualified_except_block�s
�z5JumpTestCase.test_no_jump_into_qualified_except_block)r4r8rJcCsDz|�d�|�d�Wn|�d�|�d��|�d�dS�Nr4r6r8rJr�r�r�rrr�2test_no_jump_into_bare_except_block_from_try_block�s


z?JumpTestCase.test_no_jump_into_bare_except_block_from_try_blockcCsLz|�d�|�d�Wnty|�d�|�d��w|�d�dSr')rr5r�rrr�7test_no_jump_into_qualified_except_block_from_try_block�s


�zDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block)r&r6rJzout of an 'except'cCsD|�d�z|�d�ddWdS|�d�|�d�YdS�Nr&r6rrJr?r�r�rrr�%test_no_jump_out_of_bare_except_block�s


z2JumpTestCase.test_no_jump_out_of_bare_except_blockcCsL|�d�z|�d�ddWdSty%|�d�|�d�YdSwr*r%r�rrr�*test_no_jump_out_of_qualified_except_block�s


�z7JumpTestCase.test_no_jump_out_of_qualified_except_block)r&r4r8rUcCr�r�r�r�rrr�test_jump_between_with_blocks�r�z*JumpTestCase.test_jump_between_with_blocksc	�r�r�r�r�rrr�#test_jump_between_async_with_blocksr�z0JumpTestCase.test_jump_between_async_with_blocksc	Cr�r�r�r�rrr�-test_no_jump_over_return_out_of_finally_blockr�z:JumpTestCase.test_no_jump_over_return_out_of_finally_blockcCrrr�r�rrr�'test_no_jump_into_for_block_before_elserz4JumpTestCase.test_no_jump_into_for_block_before_elsec�rrr�r�rrr�-test_no_jump_into_async_for_block_before_else$r	z:JumpTestCase.test_no_jump_into_async_for_block_before_elsecCs|�tdddg�dS)Nr4ZSpamT)r�r�rrrr�test_no_jump_to_non_integers/rgz)JumpTestCase.test_no_jump_to_non_integerscCrQr	)r�rrrr�#test_no_jump_without_trace_function2s
z0JumpTestCase.test_no_jump_without_trace_functioncCs0i}tdd|�|d}|�|dddg�dS)Na�def f(output):        # line 0
            x = 0                     # line 1
            y = 1                     # line 2
            '''                       # line 3
            %s                        # lines 4-1004
            '''                       # line 1005
            x += 1                    # line 1006
            output.append(x)          # line 1007
            return)a�







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































r�r4i�r)r�r�)rrr�rrr�test_large_function7s��	z JumpTestCase.test_large_functioncsjtddd��G�fdd�d�}t|dd�}t�|j�dgi}t�|�t�d�|�gd	�|d�dS)
Nzd
# Comments don't count.
output.append(2)  # firstlineno is here.
output.append(3)
output.append(4)
z
<fake module>r�cseZdZ�ZdS)z<JumpTestCase.test_jump_to_firstlineno.<locals>.fake_functionN)rrrr�r�r�rr�
fake_functionOsr6r=r&r)r4r6r4r6r=)�compiler�r^r_r�r�r�)rr6r�r�rr5r�test_jump_to_firstlinenoEs�

z%JumpTestCase.test_jump_to_firstlinenor*z5can't jump from the 'call' trace event of a new frame)r�rTcs*��d��fdd�}|���d�dS)Nr&cs��d�dS)Nr6r�rr�rr�nested\r�z3JumpTestCase.test_no_jump_from_call.<locals>.nestedr8r�)rr9rr�r�test_no_jump_from_callXs
z#JumpTestCase.test_no_jump_from_callr.z'can only jump from a 'line' trace eventcCrkr%r�r�rrr�test_no_jump_from_return_eventas
z+JumpTestCase.test_no_jump_from_return_eventr\cCs|�d�dddS)Nr&rr�r�rrr�!test_no_jump_from_exception_eventgs
z.JumpTestCase.test_no_jump_from_exception_event)r�cs$�fdd�}t|����d�dS)Nc3s���d�dVdS)Nr4r6r�rr�rr�genos�

z.JumpTestCase.test_jump_from_yield.<locals>.genr8)r�r)rr=rr�r�test_jump_from_yieldms
z!JumpTestCase.test_jump_from_yieldcCs*|�d�dd�td�D�}|�d�dS)Nr&cS�g|]}|�qSrr�r�rorrrr�x�z@JumpTestCase.test_jump_forward_over_listcomp.<locals>.<listcomp>rtr6�rrFr�rrr�test_jump_forward_over_listcompus
z,JumpTestCase.test_jump_forward_over_listcompcCsd}dd�td�D�}d}dS)Nr&cSr?rrr@rrrr��rAzAJumpTestCase.test_jump_backward_over_listcomp.<locals>.<listcomp>rtr6rE�rrGr#rrrr� test_jump_backward_over_listcomp}sz-JumpTestCase.test_jump_backward_over_listcomp)r4r?r4cCsDd}|�d�|rdSdd�td�D�}d}|�d�|�d�dS)	NFr4cSr?rrr@rrrr��rAzDJumpTestCase.test_jump_backward_over_listcomp_v2.<locals>.<listcomp>r8rJr?r�rB�r�flagr#rrr�#test_jump_backward_over_listcomp_v2�s

z0JumpTestCase.test_jump_backward_over_listcomp_v2c�s6�|�d�dd�ttd��2�IdH}|�d�dS)Nr&c���g|z3dHW}|�q6Sr	rr@rrrr����zFJumpTestCase.test_jump_forward_over_async_listcomp.<locals>.<listcomp>rtr6�rr$rFr�rrr�%test_jump_forward_over_async_listcomp�s�
z2JumpTestCase.test_jump_forward_over_async_listcompc�s*�d}dd�ttd��2�IdH}d}dS)Nr&c�rIr	rr@rrrr��rJzGJumpTestCase.test_jump_backward_over_async_listcomp.<locals>.<listcomp>rtr6)r$rFrDrrr�&test_jump_backward_over_async_listcomp�s�z3JumpTestCase.test_jump_backward_over_async_listcompc�sP�d}|�d�|rdSdd�ttd��2�IdH}d}|�d�|�d�dS)	NFr4c�rIr	rr@rrrr��rJzJJumpTestCase.test_jump_backward_over_async_listcomp_v2.<locals>.<listcomp>r8rJr?r�rKrFrrr�)test_jump_backward_over_async_listcomp_v2�s�

z6JumpTestCase.test_jump_backward_over_async_listcomp_v2)Nr,Frn)brrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r5r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr
rrrrrrrrrrrrrrrrrr r!r"r#r$r&r(r)r+r,r-r.r/r0r1r2r3r4r8r:r;r<r>rCrErHrLrMrNrrrrr�psr
�

�





	






















	






	
	

























	



	







	
	


	




�
�









r�c@r�)�
TestEdgeCasescCr�r	rfrrrrr��r�zTestEdgeCases.setUpcs�dd�}dd��G�fdd�d�}t�|��t���}t�|�|�|jj|j�|�|jj	t
�Wd�n1s<wY|�t��|�dS)NcWr�r	rr�rrrrM�r(z*TestEdgeCases.test_reentrancy.<locals>.foocWr�r	rr�rrr�bar�r(z*TestEdgeCases.test_reentrancy.<locals>.barcs eZdZdd�Z�fdd�ZdS)z(TestEdgeCases.test_reentrancy.<locals>.AcWr�r	r)rr�rrr�__call__�r(z1TestEdgeCases.test_reentrancy.<locals>.A.__call__cst���dSr	r�r�rPrr�__del__�r�z0TestEdgeCases.test_reentrancy.<locals>.A.__del__N)rrrrQrSrrRrrr0�sr0)r^r_rZcatch_unraisable_exceptionZassertEqualZ
unraisable�objectrSry�	exc_valuerfr�)rrMr0�cmrrRr�test_reentrancy�s

�zTestEdgeCases.test_reentrancycCs&dd�}t�|�~t�t���dS)NcWr�r	rr�rrrrM�r(z+TestEdgeCases.test_same_object.<locals>.foo)r^r_r�)rrMrrr�test_same_object�s
zTestEdgeCases.test_same_objectN)rrrr�rWrXrrrrrO�srO�__main__)1r�rZunittestZ
unittest.mockrr^r�r��	functoolsrr�rrr$r'r�r1r:r;rArHrMrPr*rYrZrdrergrhrjrprqrsrvr�ZTestCaser�rXZcpython_onlyrbrer�r�r�r�rOr�mainrrrr�<module>s�



	








	



��hn&<
&�