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.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@�(eZdZdZdd�Zdd�Zdd�ZdS)	�tracecontextz/Context manager that traces its enter and exit.cC�||_||_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__�__doc__rrrrrrrr
�
rc@r)	�asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.cCrr	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)rrrrrr!r"rrrrr rr cCs�|D]}|VqdS)z0Convert an iterable to an asynchronous iterator.Nr)�iterable�xrrr�	asynciter%s��r%cCsdS�N�rrrrr�basic,�r()�r�call�r'�line�r'�returncC�d}~	d}dSr&r�r$rrr�arigo_example0;�r2)r*r,��r-��r-��r-�r9r/cCr0r&rr1rrr�arigo_example1Ir3r;cCr0r&rr1rrr�arigo_example2Ws
r<)r*r,r4r6��r-��r-�r@r/cCsd}~d}dSr&rr1rrr�one_instr_linejsrB�r*r,r4r6�r7r/cCs$d}td�D]	}|r
d}qd}qdS�Nr'r5��range)r$�arrr�no_pop_topsus�rI)
r*r,r4r6��r-r4r6r=r4�r5r/cCsd}|st|rd}dSr&)Zbla)�yr$rrr�
no_pop_blocks�s
�rN�r*r,r4r=�r>r/cCsd}dSr&rr1rrr�called�srQcC�
t�dSr	)rQrrrrr+�s
r+)r*r,����r+����r-�rVr/r.cCst�r	��	Exceptionrrrr�raises�r)rZcCs"zt�WdStyYdSwr	)rZrYrrrr�
test_raise�s
�r[)r*r,r4rSrU�rV�	exceptionrW�r5r]r6r=rPcCst�|�|t��j_dSr	)�sys�settrace�	_getframe�f_back�f_trace�Z	tracefuncrrr�_settrace_and_return�s
recCst|�dSr	)rerdrrr�settrace_and_return�srfr.cCst�|�|t��j_t�r	)r_r`rarbrc�RuntimeErrorrdrrr�_settrace_and_raise�s
rhcCs$zt|�WdStyYdSwr	)rhrgrdrrr�settrace_and_raise�s
�ri)r^r6r=rPcCs"d}d}||kr|d}dS	dS)Nr9r'r)rH�brrr�ireturn_example�s
rk�r*r,r4r6r=rPcCs8tdd�}zd}	||}|d7}q	tyYdSw)Nrr7r'�rG�
IndexError)�items�irjrrr�tightloop_example�s
��rq)r*r,r4r6r=r8r=r8r=r8r=r8)r9r]rJr?rAcCs.tdd�}zd}||}qtyYdSw)Nr'r>rrm)rorprrr�tighterloop_example�s

�rr)r*r,r4r6r=r=r=r=)r>r]r8rJ�rKr/ccs�zdVWdSw)NTrrrrr�generator_functions
�rtcCs tt��}td�D]}|}q	dS)N�
)�anyrtrG)r$rMrrr�generator_examples
�rw)
r*r4����r+����r-����r-�r}r/)r}r+�r}r]����r-�r�r/r8rJrur:c@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.tearDowncCst�S)z@Helper to allow test subclasses to configure tracers differently�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�t��dus
J�dSr	�r_r`r�rrrr�test_set_and_retrieve_nonets
z(TraceTestCase.test_set_and_retrieve_nonec	Cs@dd�}t�|�zt��|usJ�Wt�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��zTraceTestCase.test_01_basiccCr�r	)r�r2rrrr�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�rBrrrr�test_03_one_instr�r�zTraceTestCase.test_03_one_instrcCr�r	)r�rNrrrr�test_04_no_pop_blocks�r�z#TraceTestCase.test_04_no_pop_blockscCr�r	)r�rIrrrr�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�r[rrrr�
test_07_raise�r�zTraceTestCase.test_07_raisecCr�r	)r�rfrrrr�test_08_settrace_and_return�r�z)TraceTestCase.test_08_settrace_and_returncCr�r	)r�rirrrr�test_09_settrace_and_raise�r�z(TraceTestCase.test_09_settrace_and_raisecCr�r	)r�rkrrrr�test_10_ireturn�r�zTraceTestCase.test_10_ireturncCr�r	)r�rqrrrr�test_11_tightloop�r�zTraceTestCase.test_11_tightloopcCr�r	)r�rrrrrr�test_12_tighterloop�r�z!TraceTestCase.test_12_tighterloopcCsH|�t�|��}t�|j�t�t�d�|�tjj|j	tj	�dSr	)
r�rwr�r_r`r�r�r�r�r�)rr�rrr�test_13_genexp�s


�zTraceTestCase.test_13_genexpcC�dd�}|�|gd��dS)NcSsd}dS)NTFrrr1rrr�onliners�sz2TraceTestCase.test_14_onliner_if.<locals>.onliners)r*r,r6rD�r�)rr�rrr�test_14_onliner_if�s
�z TraceTestCase.test_14_onliner_ifcCs4dd�}|�|gd��dd�}|�|gd��dS)NcSstd�D]}qdS�Nr5rFr1rrr�for_example�s�z0TraceTestCase.test_15_loops.<locals>.for_example)r*r,r4r,r4r,r.cSs$d}|dkr|d8}|dksdSdS)Nr5rr'rr1rrr�
while_example�s�z2TraceTestCase.test_15_loops.<locals>.while_example)r*r4r6r=r6r=r6rDr�)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_rarc)�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	rX)r�r$rMrrrr��s���z4TraceTestCase.test_18_except_with_name.<locals>.func)
r*r,r4r6�r7r]r=r8��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�rX)rMrjrrrr�s
�z7TraceTestCase.test_19_except_with_finally.<locals>.func)	r*r,r4r6r�r8rJr?rAr�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$rM)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/rxrzr|r~�r'r]r4r,rxrzr|r~r�r4r,rxrzr|r~r�r4r,rxrzr|r�rTr-rUr\rWr�r6rD)r�r�rYr�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	rF)�nrprrr�arangeds��zGTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.arangec�s,��d�2z
3dHW}|dkrdSq6dS)Nr7�dr�rp�rrrr�gs���zBTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.f)r*r,rSrUr�r�r�r4r,�r�r+rUr�r�r�r4r,rrUr�r�r�r4r,rrUrWr�r.)
r�r_r`r�r�rYr�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,r4rLr�r�rrr�test_21_repeated_pass�s�z#TraceTestCase.test_21_repeated_passcCr�)NcSszdD]}qWdSYdS)Nrr'r5rrrrrr��s

z3TraceTestCase.test_loop_in_try_except.<locals>.funcrCr�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,r4rJrsr�r�rrr�test_try_except_no_exception���z*TraceTestCase.test_try_except_no_exceptioncCr�)NcSs,td�D]
}td�D]}||}q
q|dkS)Nr5r'rF)rp�jrHrrrr��s

�z-TraceTestCase.test_nested_loops.<locals>.func)r*r,r4r6r4r6r4r,r4r6r4r6r4r,r=rPr�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,r4r6r=r4r6r=r8r�)r�r/r�r�rrr�
test_if_break��
�zTraceTestCase.test_if_breakcCr�)NcSstd\}}}}ztd�D]}zd}|dkrWd}n	d}Wd}qd}wWnd}Y|dkr6|dkr6|dks8J�dS)	N)r'r'r'rr7r9rrur��r'rF)rH�c�drprrrr��s�� z6TraceTestCase.test_break_through_finally.<locals>.func)r*r,r4r6r=r8rJr��rur-r6r=r8rJr?r��
r-�rr/r�r�rrr�test_break_through_finally���z(TraceTestCase.test_break_through_finallycCr�)NcSsld\}}}}}ztd�D]}zd}|dkrWd}qd}Wd}qd}wWnd}Y||||fdks4J�dS)	N)r'r'r'r'rr5r9rrur�r)r9r�rur'rF)rHrjrrrprrrr�s��z9TraceTestCase.test_continue_through_finally.<locals>.func)r*r,r4r6r=r8rJr�rr6r=r8rJr?rr6rrr�r�rrr�test_continue_through_finallyr z+TraceTestCase.test_continue_through_finallycCr�)NcSs
zWdSwr�rrrrrr�Bsz7TraceTestCase.test_return_through_finally.<locals>.funcrOr�r�rrr�test_return_through_finally@rz)TraceTestCase.test_return_through_finallycCr�)NcSs6zzddWWdStyYWdSwYdS)Nr5rrK)rnrrrrr�Qs��z;TraceTestCase.test_try_except_with_wrong_type.<locals>.func)r*r,r4r^r6rJrsr�r�rrr�test_try_except_with_wrong_typeOrz-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,r4r6r=r8rJr?r6rDr�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,r4r6r=r8rJr6rDr�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,r4r6r=r8r:r�r�rrr�test_break_to_break���z!TraceTestCase.test_break_to_breakcCr�)NcSs0d}}|dkr|dkrd}dSd}dSd}dS)Nr'r>rKr�r)rHrjr$rM�zrrrr��sz+TraceTestCase.test_nested_ifs.<locals>.funcrlr�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>.funcTFrCr�r�rr0r�test_nested_ifs_with_and�s�z&TraceTestCase.test_nested_ifs_with_andcCr�)NcSs>d}z	ddWd}dSty|dkrt��Yd}dSw)NZhellor7r�raiser@)�ZeroDivisionError�
ValueError)r$r�rrrr��s
���z.TraceTestCase.test_nested_try_if.<locals>.func�	r*r,r4r6r�r=r8r?rAr�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�rrrrrrrrrr3��r3c�.���
	Wd�dS1swYdSr	rr�r3rrr��s"�z1TraceTestCase.test_if_false_in_with.<locals>.func)r*r,�r{r+r|r~r4r,rSrUrWr.r�r�rr>r�test_if_false_in_with�s
�z#TraceTestCase.test_if_false_in_withcCr�)NcSs zWdStytYdSwr	)rY�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>.Ar7r�r'r5N)rrrrHrrrrr1sr1r)r1rrrr�rz9TraceTestCase.test_implicit_return_in_class.<locals>.func)r*r,)r'r+r,r4r6rDr.r�r�rrr�test_implicit_return_in_classr*z+TraceTestCase.test_implicit_return_in_classcCr�)Nc
SsHzzWWdSty}zWYd}~WdSd}~wwty#YdSwr	rX)�exrrrr� s���z+TraceTestCase.test_try_in_try.<locals>.funcrCr�r�rrr�test_try_in_tryr�zTraceTestCase.test_try_in_trycCsddd�}|�|gd��dS)Nrr'cSs |r
|r|rdS	dSdS	dSr	r)rH�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@r:)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;rrrrr3Cr<r3c	s:dD]}���	Wd�dS1swYqdS)N�r'r5rrr>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,r4r?r|r~r6r4rSrUrWr=rP)r*r,)r�r+)���r-)rKr/r4r,r�r�r�r.r�)rrIrJrr>r�test_early_exit_withAs��z"TraceTestCase.test_early_exit_withcs(dd���fdd�}|�|gd��dS)NcSs0|rz	d|dW|StyY|Sw|Sr&�r6r1rrr�fooqs��z;TraceTestCase.test_flow_converges_on_same_line.<locals>.foocstd�D]}�|�qdSr�rFr�rNrrr�y�
�z<TraceTestCase.test_flow_converges_on_same_line.<locals>.func)r*r,r4�r�r+�i����r-rUrWr,r4rQrR)ryr-rz)r{r]r|rrUrWr,r.r�r�rrOr� 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'�donerM)r$�errorrrrr��s
�
���zCTraceTestCase.test_no_tracing_of_named_except_cleanup.<locals>.funcr8r�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�rr	rrr
rrrr!r"r#r&r(r)r,r4r9r@rBrCrErGrLrSrVrrrrr�Hsr


		L4$%.$r�c�,eZdZdZ�fdd�Zedd��Z�ZS)�SkipLineEventsTraceTestCasez8Repeat the trace tests, but with per-line events skippedcs"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�rrrrr�rWr��
__classcell__rrr]rrY�s
rYcrX)�TraceOpcodesTestCasez;Repeat the trace tests, but with per-opcodes events enabledcsFdd�|D�}t|�dkr|jt|�t|�dd�t��|||�dS)NcSrZ)r'Zopcoderr[rrrr��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_tracerrarrr]rrc�s
rcc@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�|jS)zXA trace function that raises an exception in response to a
        specific trace event.)�raiseOnEventr7r�r�rrrr��s
zRaisingTraceFuncTestCase.tracecCs|jdkr
d}d|}dSdS)zThe function to trace; raises an exception if that's the case
        we're testing, so that the 'exception' trace event fires.r]rr'N)ri)rr$rMrrrr��s
zRaisingTraceFuncTestCase.fc	Csx||_z)tt��d�D]}t�|j�z|��Wn	ty#Yqw|�d�qWdSt	y;|�d�YdSw)zTTests that an exception raised in response to the given event is
        handled OK.r'zexception not raised!zrecursion counter not resetN)
rirGr_�getrecursionlimitr`r�r�r7r�rg)rr�rprrr�run_test_for_event�s���z+RaisingTraceFuncTestCase.run_test_for_eventcC�|�d�dS)Nr+�rkrrrr�	test_call�r�z"RaisingTraceFuncTestCase.test_callcCrl�Nr-rmrrrr�	test_line�r�z"RaisingTraceFuncTestCase.test_linecCrl)Nr/rmrrrr�test_return�r�z$RaisingTraceFuncTestCase.test_returncCrl�Nr]rmrrrr�test_exception�r�z'RaisingTraceFuncTestCase.test_exceptioncs^dd����fdd��t���z��Wnty'ddl}|��YdSw|�d�dS)NcSstd�D]}t|�qdS)Nr9)rG�printrrrrr��rPz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.fcs&|dkr|j�jjdkrtd���S)Nr-r5z
i am crashing)r�r�r�rg)r��why�extra�r��grrrx�sz4RaisingTraceFuncTestCase.test_trash_stack.<locals>.grzexception not propagated)r_r`rgr�Zcollectr�)rr�rrwr�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_attrr1rrrr�s
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.fcs"|dkr|\}}}��|t��Srr)�assertIsInstancerY)r�r�r��typer]r��rxrrrrxs
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)r7ZassertRaisesr_r`ZassertIsr])rr�Zcaughtrrr�*test_line_event_raises_before_opcode_event!s
�zCRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_eventN)rrrr�r�r�rkrnrprqrsryr~r�rrrrrf�s	rfc@s&eZdZdZ		d	dd�Zdd�ZdS)
�
JumpTracerz>Defines a trace function that jumps from one place to another.r-FcCs6|j|_||_||_||_|rdn|jj|_d|_dS)NF)r��code�jumpFrom�jumpTor�r��	firstLinerT)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)rTr��f_coder�r�r�r�rbr��	TypeErrorr�)rr�r�r�r�rrrr�@s&��zJumpTracer.traceN)r-F)rrrrrr�rrrrr�4s
�	r�c
CsJz|�d�WdSty$}z|�dt|�v�WYd}~dSd}~ww)Nr5Zinteger)rr7r��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_rarbr�r7r��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	rgrrrrr�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�rUr�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)zqDecorator that creates a test that makes a jump
        from one place to another in the following code.
        c�"t��������fdd��}|S)Nc	�|j������dd�dS�NT)rUr�r�)r�r�rUr�r�r�r�r�rr�test��
�z7JumpTestCase.jump_test.<locals>.decorator.<locals>.testr�r�r��rUr�r�r�r��r�r�	decorator��z)JumpTestCase.jump_test.<locals>.decoratorr�r�r�r�rUr�r�rr�r�	jump_test��zJumpTestCase.jump_testcr�)z~Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        cr�)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'r7cC�"|�d�|�d�|�d�dS�Nr'r5r7�r�rrrr�test_jump_simple_forwards��

z&JumpTestCase.test_jump_simple_forwardsr5)r'r'r5cC�|�d�|�d�dSrEr�r�rrr�test_jump_simple_backwards��
z'JumpTestCase.test_jump_simple_backwardsr9cCs6dD]}|�d�dD]}|�d�qq|�d�dS)NrHr5�r7r>r9r��rrprrrr�test_jump_out_of_block_forwards�s
�z,JumpTestCase.test_jump_out_of_block_forwardsrK)r'r7r9r'r7r9rKr@cCsJ|�d�dD]}|�d�dD]}|�d�q|�d�q|�d�dS)Nr'r�r7)r5r9rKr@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'r5r7r>r9�r%r�rrprrr�)test_jump_out_of_async_for_block_forwards�s�
��z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r5r>r5r>r9rKc�sR�dD]#}|�d�tdg�2z3dHW}|�d�|�d�q6|�d�qdS)Nr�r5r'r>r9rK�rr%r�rrr�*test_jump_out_of_async_for_block_backwards�s�

��z7JumpTestCase.test_jump_out_of_async_for_block_backwardscCr�)Nr'r7r�r�rrr�test_jump_to_codeless_line�s
z'JumpTestCase.test_jump_to_codeless_line)r'r5r7cCr�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)Nr5r>rKr�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)Nr5r'rrKr@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)Nr5r'rrKr�rur�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�Nr5r>r9r�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'Tr7r�r�rrr� test_no_jump_infinite_while_loop s

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

�z0JumpTestCase.test_jump_forwards_into_while_block)r7r7r7r9cCs4d}|dkr|�d�|d7}|dks|�d�dS)Nr'r5r7r9r�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��r rr�rrr�*test_jump_forwards_out_of_async_with_block=�
�(�z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r'r5r'r5r7rVcC�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��rr r�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'r7r9c	C�2|�d�z
|�d�W|�d�dS|�d�w�Nr'r7r9r�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�Nr5r>rKr�r�rrr�*test_jump_forwards_out_of_try_except_block_�
z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r'r'r7cC�.|�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>r9r@r��r6r�FloatingPointErrorr�rrr�test_jump_between_except_blocksqs
�z,JumpTestCase.test_jump_between_except_blocks)r>rKr@cCsBzddWn|�d�|�d�|�d�Y|�d�dS)Nr'rr>r9rKr@r�r�rrr�test_jump_within_except_block|s

z*JumpTestCase.test_jump_within_except_block)r'r>r9r}cC�x|�d�t|d��
|�d�Wd�n1swYt|d��|�d�Wd�dS1s5wYdS�Nr'r5r7r>r9r�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'r7r9rKc	Cs`|�d�dD]!}t|d��
|�d�Wd�n1swY|�d�q|�d�dS�Nr'r�r7r>r9rKr�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'r5r7r9rVrKc	Cs�|�d�t|d��'t|d��
|�d�Wd�n1s wY|�d�Wd�n1s4wY|�d�dS�Nr'r5r7r>r9rKr�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�)rrr r�rrr�3test_jump_out_of_async_with_block_within_with_block�s�
(��z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r5r>rKr@cCs�z&|�d�Wt|d��
|�d�Wd�n1swY|�d�n t|d��
|�d�Wd�n1s<wY|�d�w|�d�dS�Nr5r>r9rKr@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'r7r9r�rcCsx|�d�dD]-}|�d�dD]}|�d�zdD]}|�d�qW|�d�q|�d�w|�d�q|�d	�dS)
Nr'r�r7rHr9r�rur�rr�)rrpr�krrr�&test_jump_out_of_complex_nested_blocks�s


�z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r'r5r9cCsL|�d�t|d��
}|�d�Wd�n1swY|�d�dS�Nr'r5r>r9r��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'rKr�r�c	Cs\|�d�z|�d�|sW|�d�dS|�d�W|�d�n|�d�w|�d�dS)Nr'r7r�rKr�r�r�rrr�*test_jump_over_return_in_try_finally_block�s

�z7JumpTestCase.test_jump_over_return_in_try_finally_block)r'r7r�rur�rc	Csr|�d�	|�d�z|�d�|sW|�d�n|�d�W|�d�n|�d�w|�d�	|�d�dS)	Nr'Tr7r9rur�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>rKr@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'r7r>rKr@r�r�r�rrr�*test_jump_over_async_for_block_before_else��
�

z7JumpTestCase.test_jump_over_async_for_block_before_elsecCr�rEr�r�rrr�test_no_jump_too_far_forwards!r�z*JumpTestCase.test_no_jump_too_far_forwardsrV�beforecCr�rEr�r�rrr�test_no_jump_too_far_backwards&r�z+JumpTestCase.test_no_jump_too_far_backwards�exceptcCs$z|�d�WdS|�d���Nr5r>r�r�rrr�test_no_jump_to_except_1,s

z%JumpTestCase.test_no_jump_to_except_1cCs,z|�d�WdSty|�d��wr�rr7r�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)rr7rgr�rrr�test_no_jump_to_except_4Ds
��z%JumpTestCase.test_no_jump_to_except_4ZintocCs"|�d�dD]}|�d�qdS)Nr'rHr7r�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)NrHr5r7r�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'r5r�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)r5rKr@c	CsRz|�d�|�d�W|�d�|�d�n|�d�|�d�w|�d�dS)Nr5r7r9rKr@r�r�rrr�+test_jump_into_finally_block_from_try_block�s


�z8JumpTestCase.test_jump_into_finally_block_from_try_block)r'r7r'r7r9c	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��rrYr�rrr�(test_no_jump_into_qualified_except_block�s
�z5JumpTestCase.test_no_jump_into_qualified_except_block)r5r9rKcCsDz|�d�|�d�Wn|�d�|�d��|�d�dS�Nr5r7r9rKr�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()rr6r�rrr�7test_no_jump_into_qualified_except_block_from_try_block�s


�zDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block)r'r7rKzout of an 'except'cCsD|�d�z|�d�ddWdS|�d�|�d�YdS�Nr'r7rrKr@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'r5r9rVcCr�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)Nr5ZSpamT)r�r�rrrr�test_no_jump_to_non_integers/rhz)JumpTestCase.test_no_jump_to_non_integerscCrRr	)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�r5i�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_functionOsr7r>r'r)r5r7r5r7r>)�compiler�r_r`r�r�r�)rr7r�r�rr6r�test_jump_to_firstlinenoEs�

z%JumpTestCase.test_jump_to_firstlinenor+z5can't jump from the 'call' trace event of a new frame)r�rUcs*��d��fdd�}|���d�dS)Nr'cs��d�dS)Nr7r�rr�rr�nested\r�z3JumpTestCase.test_no_jump_from_call.<locals>.nestedr9r�)rr:rr�r�test_no_jump_from_callXs
z#JumpTestCase.test_no_jump_from_callr/z'can only jump from a 'line' trace eventcCrlr&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)Nr5r7r�rr�rr�genos�

z.JumpTestCase.test_jump_from_yield.<locals>.genr9)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�rprrrr�x�z@JumpTestCase.test_jump_forward_over_listcomp.<locals>.<listcomp>rur7�rrGr�rrr�test_jump_forward_over_listcompus
z,JumpTestCase.test_jump_forward_over_listcompcCsd}dd�td�D�}d}dS)Nr'cSr@rrrArrrr��rBzAJumpTestCase.test_jump_backward_over_listcomp.<locals>.<listcomp>rur7rF�rrHr$rrrr� test_jump_backward_over_listcomp}sz-JumpTestCase.test_jump_backward_over_listcomp)r5r@r5cCsDd}|�d�|rdSdd�td�D�}d}|�d�|�d�dS)	NFr5cSr@rrrArrrr��rBzDJumpTestCase.test_jump_backward_over_listcomp_v2.<locals>.<listcomp>r9rKr@r�rC�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	rrArrrr����zFJumpTestCase.test_jump_forward_over_async_listcomp.<locals>.<listcomp>rur7�rr%rGr�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�rJr	rrArrrr��rKzGJumpTestCase.test_jump_backward_over_async_listcomp.<locals>.<listcomp>rur7)r%rGrErrr�&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)	NFr5c�rJr	rrArrrr��rKzJJumpTestCase.test_jump_backward_over_async_listcomp_v2.<locals>.<listcomp>r9rKr@r�rLrGrrr�)test_jump_backward_over_async_listcomp_v2�s�

z6JumpTestCase.test_jump_backward_over_async_listcomp_v2)Nr-Fro)brrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r6r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr	rr
rrrrrrrrrrrrrrrr r!r"r#r$r%r'r)r*r,r-r.r/r0r1r2r3r4r5r9r;r<r=r?rDrFrIrMrNrOrrrrr�psr
�

�





	






















	






	
	

























	



	







	
	


	




�
�









r�c@r�)�
TestEdgeCasescCr�r	rgrrrrr��r�zTestEdgeCases.setUpcs�dd�}dd��G�fdd�d�}t�|��t���}t�|�|�|jj|j�|�|jj	t
�Wd�n1s<wY|�t��|�dS)NcWr�r	rr�rrrrN�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`r�rQrr�__del__�r�z0TestEdgeCases.test_reentrancy.<locals>.A.__del__N)rrrrRrTrrSrrr1�sr1)r_r`rZcatch_unraisable_exceptionZassertEqualZ
unraisable�objectrTrz�	exc_valuergr�)rrNr1�cmrrSr�test_reentrancy�s

�zTestEdgeCases.test_reentrancycCs&dd�}t�|�~t�t���dS)NcWr�r	rr�rrrrN�r)z+TestEdgeCases.test_same_object.<locals>.foor�)rrNrrr�test_same_object�s
zTestEdgeCases.test_same_objectN)rrrr�rXrYrrrrrP�srP�__main__)1r�rZunittestZ
unittest.mockrr_r�r��	functoolsrr�rr r%r(r�r2r;r<rBrIrNrQr+rZr[rerfrhrirkrqrrrtrwr�ZTestCaser�rYZcpython_onlyrcrfr�r�r�r�rPr�mainrrrr�<module>s�



	








	



��hn&<
&�