o
    g                     @   sN  d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlZG dd dZ	G dd dZ
dd	 Zd
d Zg de_dd Zg de_dd Zg de_dd Zg de_dd Zg de_dd Zg de_dd Zg de_dd Zd d! Zg d"e_d#d$ Zd%d& Zg d'e_d(d) Zd*d+ Zd,ge_d-d. Zd/d0 Zg d1e_d2d3 Zg d4e_d5d6 Zg d7e_d8d9 Zg d:e_d;d< Zd=d> Z g d?d@dAgdB  d@dCg e _G dDdE dEZ!G dFdG dGej"Z#G dHdI dIe#Z$ej%G dJdK dKe#Z&G dLdM dMej"Z'G dNdO dOZ(dPdQ Z)dRdS Z*G dTdU dUej"Z+e,dVkr%e-  dS dS )W    )supportNwrapsc                   @   &   e Zd Z	 dd Zdd Zdd ZdS )tracecontextc                 C      || _ || _d S Noutputvalueselfr
   r    r   L/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_sys_settrace.py__init__      
ztracecontext.__init__c                 C   s   | j | j d S r   r
   appendr   r   r   r   r   	__enter__      ztracecontext.__enter__c                 G   s   | j | j  d S r   r   r   exc_infor   r   r   __exit__   s   ztracecontext.__exit__N)__name__
__module____qualname__r   r   r   r   r   r   r   r      
    r   c                   @   r   )asynctracecontextc                 C   r   r   r	   r   r   r   r   r      r   zasynctracecontext.__init__c                    s   | j | j d S r   r   r   r   r   r   
__aenter__   s   zasynctracecontext.__aenter__c                    s   | j | j  d S r   r   r   r   r   r   	__aexit__!   s   zasynctracecontext.__aexit__N)r   r   r   r   r   r    r   r   r   r   r      r   r   c                 C  s   	 | D ]}|V  qd S r   r   )iterablexr   r   r   	asynciter$   s
   r#   c                   C   s   dS N   r   r   r   r   r   basic+      r&   )r   callr%   liner%   returnc                  C      d} ~ 	 d} d S Nr%   r   r   r"   r   r   r   arigo_example0:      r1   )r(   r*      r+      r+      r+   r8   r-   c                  C   r.   r/   r   r0   r   r   r   arigo_example1H   r2   r:   c                  C   r.   r$   r   r0   r   r   r   arigo_example2V   s
   r;   )r(   r*   r3   r5      r+      r+   r?   r-   c                  C   s   d} ~ d} d S r$   r   r0   r   r   r   one_instr_linei   s   rA   r(   r*   r3   r5   r6   r-   c                  C   s$   d} t dD ]	}|rd} qd} qd S Nr%   r4   range)r"   ar   r   r   no_pop_topst   s   rH   )
r(   r*   r3   r5      r+   r3   r5   r<   r3   r4   r-   c                  C   s   d} | st  | rd}d S r$   )Zbla)yr"   r   r   r   no_pop_blocks   s
   rM   r(   r*   r3   r<   r=   r-   c                  C   s   d} d S r$   r   r0   r   r   r   called   s   rP   c                   C   
   t   d S r   )rP   r   r   r   r   r)      s   
r)   )r(   r*   r)   r+   rU   r-   r,   c                   C   s   t r   	Exceptionr   r   r   r   raises   r'   rY   c                   C   s"   zt   W d S  ty   Y d S w r   )rY   rX   r   r   r   r   
test_raise   s
   rZ   )r(   r*   r3   rR   rT   rU   	exceptionrV   r4   r\   r5   r<   rO   c                 C   s   t |  | t  j_d S r   )syssettrace	_getframef_backf_traceZ	tracefuncr   r   r   _settrace_and_return   s   
rd   c                 C   s   t |  d S r   )rd   rc   r   r   r   settrace_and_return   s   re   r,   c                 C   s   t |  | t  j_tr   )r^   r_   r`   ra   rb   RuntimeErrorrc   r   r   r   _settrace_and_raise   s   
rg   c                 C   s$   zt |  W d S  ty   Y d S w r   )rg   rf   rc   r   r   r   settrace_and_raise   s
   rh   )r]   r5   r<   rO   c                  C   s"   d} d}| |kr| d }d S 	 d S )Nr8   r%   r   )rG   br   r   r   ireturn_example   s
   rj   r(   r*   r3   r5   r<   rO   c                  C   s8   t dd} zd}	 | | }|d7 }q	 ty   Y d S w )Nr   r6   r%   rF   
IndexError)itemsiri   r   r   r   tightloop_example   s   
rp   )r(   r*   r3   r5   r<   r7   r<   r7   r<   r7   r<   r7   )r8   r\   rI   r>   r@   c                  C   s.   t dd} zd}| | }q ty   Y d S w )Nr%   r=   r   rl   )rn   ro   r   r   r   tighterloop_example   s   

rq   )r(   r*   r3   r5   r<   r<   r<   r<   )r=   r\   r7   rI   rJ   r-   c                   c   s    zdV  W d S w )NTr   r   r   r   r   generator_function  s
   rs   c                  C   s    t t } tdD ]} | }q	d S )N
   )anyrs   rF   )r"   rL   r   r   r   generator_example  s   
rv   )
r(   r3   r)   r+   r+   r|   r-   )r|   r)   r|   r\   )r+   )r   r-   r7   rI   rt   r9   c                   @   s.   e Zd Zd
ddZdd Zdd Zdd	 ZdS )TracerNc                 C   s   || _ || _g | _d S r   )trace_line_eventstrace_opcode_eventsevents)r   r   r   r   r   r   r   0  s   
zTracer.__init__c                 C   s,   | j d ur	| j |_| jd ur| j|_d S d S r   )r   f_trace_linesr   f_trace_opcodes)r   framer   r   r   _reconfigure_frame5  s
   

zTracer._reconfigure_framec                 C   s"   |  | | j|j|f | jS r   r   r   r   f_linenotracer   r   eventargr   r   r   r   ;  s   
zTracer.tracec                 C   s0   |  | dd dD  | j|j|f | jS )Nc                 s   s    | ]}|V  qd S r   r   ).0or   r   r   	<genexpr>B  s    z)Tracer.traceWithGenexp.<locals>.<genexpr>r%   r   r   r   r   r   traceWithGenexp@  s   
zTracer.traceWithGenexp)NN)r   r   r   r   r   r   r   r   r   r   r   r   /  s
    
r   c                   @   s  e Zd Zdd Zdd Zedd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: 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 Z9dmS )nTraceTestCasec                 C   s(   t  | _t   | tjt  d S r   )gc	isenabledusing_gcdisable
addCleanupr^   r_   gettracer   r   r   r   setUpK  s   
zTraceTestCase.setUpc                 C   s   | j r	t  d S d S r   )r   r   enabler   r   r   r   tearDownP  s   zTraceTestCase.tearDownc                   C   s   	 t  S r   r   r   r   r   r   make_tracerT  s   zTraceTestCase.make_tracerc              
      sR    fdd|D }||kr'|  ddtdd |D dd |D   d S d S )Nc                    s   g | ]
\}}|  |fqS r   r   )r   leline_offsetr   r   
<listcomp>Z      z0TraceTestCase.compare_events.<locals>.<listcomp>z"events did not match expectation:

c                 S      g | ]}t |qS r   strr   r"   r   r   r   r   ^      c                 S   r   r   r   r   r   r   r   r   _  r   )failjoindifflibZndiff)r   r   r   expected_eventsr   r   r   compare_eventsY  s   zTraceTestCase.compare_eventsc                 C   s<   |   }t|j |  td  | |jj|j| d S r   )r   r^   r_   r   r   __code__co_firstlinenor   )r   funcr   tracerr   r   r   run_and_comparea  s   

zTraceTestCase.run_and_comparec                 C   s   |  ||j d S r   )r   r   r   r   r   r   r   run_testi  r   zTraceTestCase.run_testc                 C   s6   |   }||j td  | |jj|j|j d S r   )r   r   r^   r_   r   r   r   r   )r   r   r   r   r   r   	run_test2l  s   


zTraceTestCase.run_test2c                 C   s   t d  d S r   r^   r_   r   r   r   r   test_set_and_retrieve_nones     z(TraceTestCase.test_set_and_retrieve_nonec              	   C   s0   dd }t | zW t d  d S t d  w )Nc                  W      d S r   r   argsr   r   r   fnx  r'   z4TraceTestCase.test_set_and_retrieve_func.<locals>.fnr   )r   r   r   r   r   test_set_and_retrieve_funcw  s   
z(TraceTestCase.test_set_and_retrieve_funcc                 C      |  t d S r   )r   r&   r   r   r   r   test_01_basic  r   zTraceTestCase.test_01_basicc                 C   r   r   )r   r1   r   r   r   r   test_02_arigo0  r   zTraceTestCase.test_02_arigo0c                 C   r   r   )r   r:   r   r   r   r   test_02_arigo1  r   zTraceTestCase.test_02_arigo1c                 C   r   r   )r   r;   r   r   r   r   test_02_arigo2  r   zTraceTestCase.test_02_arigo2c                 C   r   r   )r   rA   r   r   r   r   test_03_one_instr  r   zTraceTestCase.test_03_one_instrc                 C   r   r   )r   rM   r   r   r   r   test_04_no_pop_blocks  r   z#TraceTestCase.test_04_no_pop_blocksc                 C   r   r   )r   rH   r   r   r   r   test_05_no_pop_tops  r   z!TraceTestCase.test_05_no_pop_topsc                 C   r   r   )r   r)   r   r   r   r   test_06_call  r   zTraceTestCase.test_06_callc                 C   r   r   )r   rZ   r   r   r   r   test_07_raise  r   zTraceTestCase.test_07_raisec                 C   r   r   )r   re   r   r   r   r   test_08_settrace_and_return  r   z)TraceTestCase.test_08_settrace_and_returnc                 C   r   r   )r   rh   r   r   r   r   test_09_settrace_and_raise  r   z(TraceTestCase.test_09_settrace_and_raisec                 C   r   r   )r   rj   r   r   r   r   test_10_ireturn  r   zTraceTestCase.test_10_ireturnc                 C   r   r   )r   rp   r   r   r   r   test_11_tightloop  r   zTraceTestCase.test_11_tightloopc                 C   r   r   )r   rq   r   r   r   r   test_12_tighterloop  r   z!TraceTestCase.test_12_tighterloopc                 C   sH   |  t |  }t|j t  td  | tjj|j	tj	 d S r   )
r   rv   r   r^   r_   r   r   r   r   r   )r   r   r   r   r   test_13_genexp  s   


zTraceTestCase.test_13_genexpc                 C      dd }|  |g d d S )Nc                  S   s   d} dS )NTFr   r   r0   r   r   r   onliners  s   z2TraceTestCase.test_14_onliner_if.<locals>.onliners)r(   r*   r5   rC   r   )r   r   r   r   r   test_14_onliner_if  s
   z TraceTestCase.test_14_onliner_ifc                 C   s4   dd }|  |g d dd }|  |g d d S )Nc                  S   s   t dD ]} qd S Nr4   rE   r0   r   r   r   for_example  s   z0TraceTestCase.test_15_loops.<locals>.for_example)r(   r*   r3   r*   r3   r*   r,   c                  S   s$   d} | dkr| d8 } | dksd S d S )Nr4   r   r%   r   r0   r   r   r   while_example  s   z2TraceTestCase.test_15_loops.<locals>.while_example)r(   r3   r5   r<   r5   r<   r5   rC   r   )r   r   r   r   r   r   test_15_loops  s   
zTraceTestCase.test_15_loopsc                 C   s&   i }t d| | |d g d d S )Na  def f():
































































































































































































































































    passf)r(   )  r+   )r   r-   )execr   )r   	namespacer   r   r   test_16_blank_lines  s   
z!TraceTestCase.test_16_blank_linesc                 C   s   dd }|  |ddg d S )Nc                  S   s   d t  _d} d S r   )r^   r`   rb   )linenor   r   r   r     s   
z0TraceTestCase.test_17_none_f_trace.<locals>.funcr(   r*   r   r   r   r   r   test_17_none_f_trace  s   z"TraceTestCase.test_17_none_f_tracec                 C   r   )Nc               
   S   s6   zzt  t y }  z d } ~ ww  t y   Y d S w )N	SomethingrW   )r   r"   rL   r   r   r   r     s   z4TraceTestCase.test_18_except_with_name.<locals>.func)
r(   r*   r3   r5   r6   r\   r<   r7      r+   )	   r+   )r   r-   r   r   r   r   r   test_18_except_with_name  s   z&TraceTestCase.test_18_except_with_namec                 C   r   )Nc                  S   s&   zzt d} w  t y   d}Y d S w )Nr      rW   )rL   ri   r   r   r   r     s   
z7TraceTestCase.test_19_except_with_finally.<locals>.func)	r(   r*   r3   r5   r   r7   rI   r>   r@   r   r   r   r   r   test_19_except_with_finally     	z)TraceTestCase.test_19_except_with_finallyc                    sp   G dd d  fddfdd}|   }g d}z||j W n	 ty+   Y nw | jj|j| d S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )zBTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapperc                 S   s   t || _d S r   )iter_it)r   objr   r   r   r     r   zKTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__init__c                 S      | S r   r   r   r   r   r   	__aiter__  r'   zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__aiter__c                    s"   zt | jW S  ty   tw r   )nextr   StopIterationStopAsyncIterationr   r   r   r   	__anext__  s   zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__anext__N)r   r   r   r   r   r   r   r   r   r   AsyncIteratorWrapper  s    r   c                     s&    d2 z3 d H W } | }q6 d}d S )Nabc*   r   )Zletterr"   rL   )r   r   r   
doit_async$  s
   z8TraceTestCase.test_20_async_for_loop.<locals>.doit_asyncc              	      s8     }zt |  |d  W t d  d S t d  w r   )r^   r_   send)r   r"   )r   r   r   run)  s
   
z1TraceTestCase.test_20_async_for_loop.<locals>.run)(r(   r*   )ir)   )r+   )r   r-   ir)   r+   r   r-   rw   ry   r{   r}   r%   r\   r3   r*   rw   ry   r{   r}   r   r3   r*   rw   ry   r{   r}   r   r3   r*   rw   ry   r{   r~   rS   r+   rT   r[   rV   r   r5   rC   )r   r   rX   r   r   r   r   )r   r   r   r   r   )r   r   r   test_20_async_for_loop  s   )
z$TraceTestCase.test_20_async_for_loopc                 C   r   )Nc                   S   s   	 d S r   r   r   r   r   r   r   c  s   z1TraceTestCase.test_21_repeated_pass.<locals>.funcr(   r*   r3   rK   r   r   r   r   r   test_21_repeated_passb  s   z#TraceTestCase.test_21_repeated_passc                 C   r   )Nc                  S   s   zdD ]} qW dS    Y dS )Nr   r%   r4   r   ro   r   r   r   r   p  s
   
z3TraceTestCase.test_loop_in_try_except.<locals>.funcrB   r   r   r   r   r   test_loop_in_try_exceptm  s   z%TraceTestCase.test_loop_in_try_exceptc                 C   r   )Nc                   S   s   zzW W d S    Y W d S w r   r   r   r   r   r   r     s   z8TraceTestCase.test_try_except_no_exception.<locals>.func)r(   r*   r3   rI   rr   r   r   r   r   r   test_try_except_no_exception~     z*TraceTestCase.test_try_except_no_exceptionc                 C   r   )Nc                  S   s,   t dD ]} t dD ]}| | }q
q|dkS )Nr4   r%   rE   )ro   jrG   r   r   r   r     s
   
z-TraceTestCase.test_nested_loops.<locals>.func)r(   r*   r3   r5   r3   r5   r3   r*   r3   r5   r3   r5   r3   r*   r<   rO   r   r   r   r   r   test_nested_loops     zTraceTestCase.test_nested_loopsc                 C   r   )Nc                  S   s*   ddg} | r|   }|r	 |S | sd}|S )Nr%   r   c   pop)seqnr   r   r   r     s   z)TraceTestCase.test_if_break.<locals>.func)r(   r*   r3   r5   r<   r3   r5   r<   r7   r   )r   r-   r   r   r   r   r   test_if_break     
zTraceTestCase.test_if_breakc                 C   r   )Nc                  S   s^   d\} }}}z t dD ]}zd} |dkrW d} W d S d} W d}qd}w W d S    d}Y d S )N)r%   r%   r%   r  r6   r8   r   rt   r      rE   )rG   cdro   r   r   r   r     s   
z6TraceTestCase.test_break_through_finally.<locals>.func)r(   r*   r3   r5   r<   r7   rI   r   rt   r+   r5   r<   r7   rI   r>   r     r+   r  r-   r   r   r   r   r   test_break_through_finally     z(TraceTestCase.test_break_through_finallyc                 C   r   )Nc                  S   sZ   d\} }}}}zt dD ]}zd} |dkrW d}qd}W d}qd}w W d S    d}Y d S )N)r%   r%   r%   r%   r  r4   r8   r   rt   r   r  rE   )rG   ri   r  r  ro   r   r   r   r     s   
z9TraceTestCase.test_continue_through_finally.<locals>.func)r(   r*   r3   r5   r<   r7   rI   r   r  r5   r<   r7   rI   r>   r  r5   r  r  r   r   r   r   r   test_continue_through_finally  r  z+TraceTestCase.test_continue_through_finallyc                 C   r   )Nc                   S   s
   zW dS w r   r   r   r   r   r   r     s   z7TraceTestCase.test_return_through_finally.<locals>.funcrN   r   r   r   r   r   test_return_through_finally  r  z)TraceTestCase.test_return_through_finallyc                 C   r   )Nc                   S   s6   zzdd  W W dS  t y   Y W dS w    Y dS )Nr4   r   rJ   )rm   r   r   r   r   r     s   z;TraceTestCase.test_try_except_with_wrong_type.<locals>.func)r(   r*   r3   r]   r5   rI   rr   r   r   r   r   r   test_try_except_with_wrong_type  r  z-TraceTestCase.test_try_except_with_wrong_typec                 C   r   )Nc                  S   s"   d} dg}|r|   | r	 qd S r$   r	  TRUEr"   r   r   r   r   /  s   z3TraceTestCase.test_break_to_continue1.<locals>.func)
r(   r*   r3   r5   r<   r7   rI   r>   r5   rC   r   r   r   r   r   test_break_to_continue1-     	z%TraceTestCase.test_break_to_continue1c                 C   r   )Nc                  S   s*   d} dg}|r|   | rqq|sd S d S r$   r	  r  r   r   r   r   F  s   z3TraceTestCase.test_break_to_continue2.<locals>.func)	r(   r*   r3   r5   r<   r7   rI   r5   rC   r   r   r   r   r   test_break_to_continue2D  r  z%TraceTestCase.test_break_to_continue2c                 C   r   )Nc                  S   s   d} | r| r		 d S d S d S r$   r   )r  r   r   r   r   ]  s   z/TraceTestCase.test_break_to_break.<locals>.func)r(   r*   r3   r5   r<   r7   r9   r   r   r   r   r   test_break_to_break[     z!TraceTestCase.test_break_to_breakc                 C   r   )Nc                  S   s0   d } }| dkr|dkrd}d S d}d S d}d S )Nr%   r=   rJ   r   r   )rG   ri   r"   rL   zr   r   r   r   o  s   z+TraceTestCase.test_nested_ifs.<locals>.funcrk   r   r   r   r   r   test_nested_ifsm  r  zTraceTestCase.test_nested_ifsc                    s0    fdd}d  d|  |g d d S )Nc                      s4    rrr
t rdS d S d S dS trtrdS d S d S )NFT)DEFr   ABCr   r   r     s   z4TraceTestCase.test_nested_ifs_with_and.<locals>.funcTFrB   r   r   r   r'  r   test_nested_ifs_with_and  s   z&TraceTestCase.test_nested_ifs_with_andc                 C   r   )Nc                  S   s>   d} z	dd  W d}d S  t y   | dkrt Y d}d S w )NZhellor6   r   raiser?   )ZeroDivisionError
ValueError)r"   r   r   r   r   r     s   
z.TraceTestCase.test_nested_try_if.<locals>.func	r(   r*   r3   r5   r   r<   r7   r>   r@   r   r   r   r   r   test_nested_try_if  r  z TraceTestCase.test_nested_try_ifc                    s.   G dd d  fdd}|  |g d d S )Nc                   @      e Zd Zdd Zdd ZdS )z.TraceTestCase.test_if_false_in_with.<locals>.Cc                 S   r   r   r   r   r   r   r   r     r'   z8TraceTestCase.test_if_false_in_with.<locals>.C.__enter__c                  W   r   r   r   r   r   r   r   r     r'   z7TraceTestCase.test_if_false_in_with.<locals>.C.__exit__Nr   r   r   r   r   r   r   r   r   r*        r*  c                      .     
 	 W d    d S 1 sw   Y  d S NFr   r   r*  r   r   r     s   "z1TraceTestCase.test_if_false_in_with.<locals>.func)r(   r*   rz   r)   r{   r}   r3   r*   rR   rT   rV   r,   r   r   r   r6  r   test_if_false_in_with  s
   z#TraceTestCase.test_if_false_in_withc                 C   r   )Nc                   S   s    zW d S  t y   t Y d S w r5  )rX   Xr   r   r   r   r     s
   
z7TraceTestCase.test_if_false_in_try_except.<locals>.funcr   r   r   r   r   r   test_if_false_in_try_except  r!  z)TraceTestCase.test_if_false_in_try_exceptc                 C   r   )Nc                  S   s   G dd d} d S )Nc                   @   s    e Zd Zddk rdZdS dZdS )zDTraceTestCase.test_implicit_return_in_class.<locals>.func.<locals>.Ar6   r   r%   r4   N)r   r   r   rG   r   r   r   r   r(    s    r(  r   )r(  r   r   r   r     r   z9TraceTestCase.test_implicit_return_in_class.<locals>.func)r(   r*   )r%   r)   r*   r3   r5   rC   r,   r   r   r   r   r   test_implicit_return_in_class  r!  z+TraceTestCase.test_implicit_return_in_classc                 C   r   )Nc               
   S   sH   zzW W d S  t y }  zW Y d } ~ W d S d } ~ ww  t y#   Y d S w r   rW   )exr   r   r   r     s   z+TraceTestCase.test_try_in_try.<locals>.funcrB   r   r   r   r   r   test_try_in_try  r   zTraceTestCase.test_try_in_tryc                 C   s   ddd}|  |g d d S )Nr   r%   c                 S   s    |r| r|rd S 	 d S d S 	 d S r   r   )rG   pr"  r   r   r   r     s   z/TraceTestCase.test_if_in_if_in_if.<locals>.funcr   )r   r%   r%   r   r   r   r   r   test_if_in_if_in_if  s   

z!TraceTestCase.test_if_in_if_in_ifc                    sJ   G dd d  fdd} fdd}|  |g d |  |g d d S )	Nc                   @   r1  )z-TraceTestCase.test_early_exit_with.<locals>.Cc                 S   r   r   r   r   r   r   r   r     r'   z7TraceTestCase.test_early_exit_with.<locals>.C.__enter__c                  W   r   r   r   r   r   r   r   r     r'   z6TraceTestCase.test_early_exit_with.<locals>.C.__exit__Nr2  r   r   r   r   r*    r3  r*  c               	      s:   dD ]}    	 W d     d S 1 sw   Y  qd S )Nr%   r4   r   r  r6  r   r   
func_break  s   z6TraceTestCase.test_early_exit_with.<locals>.func_breakc                      r4  r   r   r   r6  r   r   func_return  s   $z7TraceTestCase.test_early_exit_with.<locals>.func_return)r(   r*   r3   r7  r{   r}   r5   r3   rR   rT   rV   r<   rO   )r(   r*   )r   r)   )r+   )rC  r-   r3   r*   r   r   r   r,   r   )r   rA  rB  r   r6  r   test_early_exit_with  s   z"TraceTestCase.test_early_exit_withc                    s(   dd   fdd}|  |g d d S )Nc                 S   s0   | rz	d| d   W | S  t y   Y | S w | S r$   r-  r0   r   r   r   foo<  s   z;TraceTestCase.test_flow_converges_on_same_line.<locals>.fooc                     s   t dD ]}  |  qd S r   rE   r  rF  r   r   r   D     
z<TraceTestCase.test_flow_converges_on_same_line.<locals>.func)r(   r*   r3   r   r)   ir+   rT   rV   r*   r3   rI  rJ  )rx   r+   ry   )rz   r\   r{   r   rT   rV   r*   r,   r   r   r   rG  r    test_flow_converges_on_same_line:  s
   z.TraceTestCase.test_flow_converges_on_same_linec                 C   r   )Nc               
   S   s@   d} zd|   W dS  t y } z
| r W Y d }~dS d }~ww )Nr   r%   donerE  )r"   errorr   r   r   r   `  s   

zCTraceTestCase.test_no_tracing_of_named_except_cleanup.<locals>.funcr/  r   r   r   r   r   'test_no_tracing_of_named_except_cleanup^  r  z5TraceTestCase.test_no_tracing_of_named_except_cleanupN):r   r   r   r   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   r   r   r  r  r  r  r  r  r  r  r  r  r   r#  r+  r0  r8  r:  r;  r=  r?  rD  rK  rN  r   r   r   r   r   G  sp    

		L$%.$r   c                       *   e Zd Z	  fddZedd Z  ZS )SkipLineEventsTraceTestCasec                    s"   dd |D }t  ||| d S )Nc                 S      g | ]
}|d  dkr|qS r*   r   r   r   r   r   r   r   y  r   z>SkipLineEventsTraceTestCase.compare_events.<locals>.<listcomp>)superr   )r   r   r   r   Zskip_line_events	__class__r   r   r   x  s   z*SkipLineEventsTraceTestCase.compare_eventsc                   C   
   t ddS )NF)r   r   r   r   r   r   r   |     
z'SkipLineEventsTraceTestCase.make_tracerr   r   r   r   rO  r   __classcell__r   r   rU  r   rQ  u  s
    rQ  c                       rP  )TraceOpcodesTestCasec                    sF   dd |D }t |dkr| jt |t |dd t ||| d S )Nc                 S   rR  )r%   Zopcoder   rS  r   r   r   r     r   z7TraceOpcodesTestCase.compare_events.<locals>.<listcomp>r%   z)No 'opcode' events received by the tracer)msg)lenZ
assertLessrT  r   )r   r   r   r   Zskip_opcode_eventsrU  r   r   r     s   z#TraceOpcodesTestCase.compare_eventsc                   C   rW  )NT)r   r   r   r   r   r   r     rX  z TraceOpcodesTestCase.make_tracerrY  r   r   rU  r   r[    s
    r[  c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )RaisingTraceFuncTestCasec                 C   s   |  tjt  d S r   r   r^   r_   r   r   r   r   r   r        zRaisingTraceFuncTestCase.setUpc                 C   s   	 || j krt| jS r   )raiseOnEventr.  r   r   r   r   r   r     s   
zRaisingTraceFuncTestCase.tracec                 C   s    	 | j dkrd}d| }d S dS )Nr\   r   r%   )ra  )r   r"   rL   r   r   r   r     s
   
zRaisingTraceFuncTestCase.fc              	   C   sz   	 || _ z)tt d D ]}t| j z|   W n	 ty$   Y qw | d qW d S  t	y<   | d Y d S w )Nr%   zexception not raised!zrecursion counter not reset)
ra  rF   r^   getrecursionlimitr_   r   r   r.  r   rf   )r   r   ro   r   r   r   run_test_for_event  s   z+RaisingTraceFuncTestCase.run_test_for_eventc                 C      |  d d S )Nr)   rc  r   r   r   r   	test_call  r   z"RaisingTraceFuncTestCase.test_callc                 C   rd  Nr+   re  r   r   r   r   	test_line  r   z"RaisingTraceFuncTestCase.test_linec                 C   rd  )Nr-   re  r   r   r   r   test_return  r   z$RaisingTraceFuncTestCase.test_returnc                 C   rd  Nr\   re  r   r   r   r   test_exception  r   z'RaisingTraceFuncTestCase.test_exceptionc                    s^   dd   fddt  z   W n ty'   dd l}|  Y d S w | d d S )Nc                  S   s   t dD ]} t|  qd S )Nr8   )rF   printr  r   r   r   r     rH  z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.fc                    s&   |dkr| j  jjd krtdS )Nr+   r4   zi am crashing)r   r   r   rf   )r   whyextrar   gr   r   rp    s
   z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.gr   zexception not propagated)r^   r_   rf   r   Zcollectr   )r   r   r   ro  r   test_trash_stack  s   

z)RaisingTraceFuncTestCase.test_trash_stackc              	      st   dd } fdd t  }z$t   z|  W n	 ty#   Y n	w W t | d S W t | d S t | w )Nc                  S   s   d} | j  d S )Nr   )Zno_such_attrr0   r   r   r   r     s   
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.fc                    s"   |dkr|\}}} |t  S rj  )ZassertIsInstancerX   )r   r   r   typer\   r   rp  r   r   r   rp    s   
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g)r^   r   r_   AttributeError)r   r   existingr   rs  r   test_exception_arguments  s   

z1RaisingTraceFuncTestCase.test_exception_argumentsN)r   r   r   r   r   r   rc  rf  rh  ri  rk  rq  rv  r   r   r   r   r^    s    	r^  c                   @   s$   e Zd Z	 		dddZdd ZdS )	
JumpTracerr+   Fc                 C   s6   |j | _|| _|| _|| _|rd n| jj| _d| _d S r5  )r   codejumpFromjumpTor   r   	firstLinerL  )r   functionry  rz  r   	decoratedr   r   r   r     s   
zJumpTracer.__init__c                 C   s   | j rd S | jd u r|j| jkr|dkr|jd | _|| jkrd| jd urd|j| j| j krd|}|d urF|j| jkrF|j}|d urF|j| jks9|d urdz	| j| j |_W n t	y`   | j|_Y nw d| _ | j
S )Nr+   r%   T)rL  r{  f_coderx  r   r   ry  ra   rz  	TypeErrorr   )r   r   r   r   r   r   r   r   r     s*   zJumpTracer.traceN)r+   F)r   r   r   r   r   r   r   r   r   rw    s    
	rw  c              
   C   sJ   z|  d W d S  ty$ } z|  dt|v  W Y d }~d S d }~ww )Nr4   Zinteger)r   r.  r   r
   r   r   r   r   no_jump_to_non_integers  s    r  c               
   C   sR   zt  j} | j| _W td ty( } zdt|vr W Y d }~d S d }~ww )Nr   z'Trace-function-less jump failed to fail)r^   r`   ra   r   r.  r   AssertionError)Zprevious_framer   r   r   r   no_jump_without_trace_function  s   

r  c                   @   sB  e Zd Zdd Zdd Z		ddd	Z		dd
dZdddZdddZedddgdd Z	eddg ddd Z
eddddgdd Zeddg ddd Zeddddgd d! Zeddg d"d#d$ Zedddgd%d& Zeddg d'd(d) Zedd*dd*gd+d, Zedd-dd-ged.fd/d0 Zedd1dd1ged.fd2d3 Zedd1ddged4fd5d6 Zedddged4fd7d8 Zeddddgd9d: Zeddg d;d<d= Zeddddgd>d? Zeddddgd@dA Zeddg dBdCdD Zeddg dBdEdF ZedddgdGdH Zeddg dIdJdK ZedddgdLdM Z eddg dNdOdP Z!edd-g dQdRdS Z"eddg dTdUdV Z#eddg dWdXdY Z$eddg dWdZd[ Z%eddg d\d]d^ Z&eddg d\d_d` Z'eddg dadbdc Z(eddg daddde Z)eddg dfdgdh Z*eddg dfdidj Z+edkd1g dldmdn Z,eddg dodpdq Z-eddg dodrds Z.eddg dtdudv Z/eddkg dwdxdy Z0edd-d-dkgdzd{ Z1edd-d-dkgd|d} Z2edddged4fd~d Z3edddgedfdd Z4edddgedfdd Z5edddgedfdd Z6edddgedfdd Z7edddgedfdd Z8eddg edfdd Z9eddg edfdd Z:eddddgedfdd Z;eddddgedfdd Z<eddg edfdd Z=eddg edfdd Z>eddg dedfdd Z?eddg dedfdd Z@eddg edfdd ZAeddddgedfdd ZBeddg edfdd ZCedddgedfdd ZDedd-dgedfdd ZEedddgdd ZFeddg ddd ZGeddg ddd ZHeddg edfdd ZIeddg edfdd ZJeddg dedfdd ZKedddgedfdd ZLed-dg dedfdd ZMed-dg dedfdd ZNeddg dddÄ ZOeddg dddń ZPedd-ddged4fddǄ ZQed-dddgedfddɄ ZRed-dddgedfdd˄ ZSdd̈́ ZTddτ ZUddф ZVddӄ ZWedddgdedfd֍dd؄ ZXedddgdedfd֍dd܄ ZYedddgdedfd֍dd߄ ZZeddddgdddd Z[dS )JumpTestCasec                 C   s    |  tjt  td  d S r   r_  r   r   r   r   r   .  s   zJumpTestCase.setUpc                 C   s2   ||kr|  dt| d d t|  d S d S )NzOutputs don't match:
Expected: r   z
Received: )r   repr)r   expectedZreceivedr   r   r   compare_jump_output2  s   
z JumpTestCase.compare_jump_outputNr+   Fc           
      C   s~   t |||||}t|j g }	|d u r||	 n| j|  ||	 W d    n1 s-w   Y  td  | ||	 d S r   )rw  r^   r_   r   assertRaisesRegexr  
r   r   ry  rz  r  rM  r   r}  r   r
   r   r   r   r   8  s   


zJumpTestCase.run_testc           
      C   s   t |||||}t|j g }	|d u rt||	 n| j|  t||	 W d    n1 s3w   Y  td  td  | ||	 d S r   )	rw  r^   r_   r   asyncior   r  Zset_event_loop_policyr  r  r   r   r   run_async_testE  s   

zJumpTestCase.run_async_testc                       	  fdd}|S )Nc                    "   t   fdd}|S )Nc              	         | j  dd d S NT)rM  r   r}  )r   r   rM  r   r  r   ry  rz  r   r   testX     
z7JumpTestCase.jump_test.<locals>.decorator.<locals>.testr   r   r  rM  r   r  ry  rz  r   r   	decoratorW     z)JumpTestCase.jump_test.<locals>.decoratorr   ry  rz  r  rM  r   r  r   r  r   	jump_testS     zJumpTestCase.jump_testc                    r  )Nc                    r  )Nc              	      r  r  )r  r   r  r   r   r  d  r  z=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.testr   r  r  r  r   r  c  r  z/JumpTestCase.async_jump_test.<locals>.decoratorr   r  r   r  r   async_jump_test_  r  zJumpTestCase.async_jump_testr%   r6   c                 C   "   |  d |  d |  d d S Nr%   r4   r6   r   r
   r   r   r   test_jump_simple_forwardsm     

z&JumpTestCase.test_jump_simple_forwardsr4   )r%   r%   r4   c                 C      |  d |  d d S rD   r  r  r   r   r   test_jump_simple_backwardss     
z'JumpTestCase.test_jump_simple_backwardsr8   c                 C   s6   dD ]}|  d dD ]}|  d qq|  d d S )Nr@  r4   r6   r=   r8   r  r
   ro   r  r   r   r   test_jump_out_of_block_forwardsx  s   
z,JumpTestCase.test_jump_out_of_block_forwardsrJ   )r%   r6   r8   r%   r6   r8   rJ   r?   c                 C   sJ   |  d dD ]}|  d dD ]}|  d q|  d q|  d d S )Nr%   r   r6   )r4   r8   rJ   r?   r  r  r   r   r    test_jump_out_of_block_backwards  s   

z-JumpTestCase.test_jump_out_of_block_backwardsr=   c                    sJ   dD ]}t ddg2 z3 d H W }| d | d q6 | d qd S )Nr   r%   r4   r6   r=   r8   r#   r   r
   ro   r   r   r   )test_jump_out_of_async_for_block_forwards  s   
z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r4   r=   r4   r=   r8   rJ   c                    sR   dD ]#}|  d tdg2 z3 d H W }|  d |  d q6 |  d qd S )Nr   r4   r%   r=   r8   rJ   r   r#   r  r   r   r   *test_jump_out_of_async_for_block_backwards  s   

z7JumpTestCase.test_jump_out_of_async_for_block_backwardsc                 C   r  )Nr%   r6   r  r  r   r   r   test_jump_to_codeless_line  s   
z'JumpTestCase.test_jump_to_codeless_line)r%   r4   r6   c                 C   r  r  r  r  r   r   r   test_jump_to_same_line  r  z#JumpTestCase.test_jump_to_same_liner   c                 C   s   z%|  d W |  d z|  d W |  d n|  d w |  d d S |  d z|  d W |  d n|  d w |  d w )Nr4   r=   rJ   r   r   r  r  r   r   r   test_jump_in_nested_finally  s   

z(JumpTestCase.test_jump_in_nested_finallyr?    c              	   C   sD   z|  d dd  W |  d |  d d S |  d |  d w )Nr4   r%   r   rJ   r?   r   r  r  r   r   r   test_jump_in_nested_finally_2  s   


z*JumpTestCase.test_jump_in_nested_finally_2   c                 C   s   z)|  d dd  W |  d z|  d W |  d n|  d w |  d d S |  d z|  d W |  d n|  d w |  d w )	Nr4   r%   r   rJ   r   rt   r  r  r  r  r   r   r   test_jump_in_nested_finally_3  s   


z*JumpTestCase.test_jump_in_nested_finally_3Zafterc              	   C   F   z|  d W |  d |  d d S |  d |  d    Y d S )Nr4   r=   r8   r   rt   r  r  r  r   r   r   5test_no_jump_over_return_try_finally_in_finally_block     



zBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_blockc                 C   s   |  d 	 |  d q)Nr%   Tr6   r=   r  r  r   r   r    test_no_jump_infinite_while_loop  s   

z-JumpTestCase.test_no_jump_infinite_while_loopc                 C   s8   d}|  d |dkr|  d |d7 }|dksd S d S )Nr%   r4   r=   r  r  r   r   r   #test_jump_forwards_into_while_block  s   

z0JumpTestCase.test_jump_forwards_into_while_block)r6   r6   r6   r8   c                 C   s4   d}|dkr|  d |d7 }|dks|  d d S )Nr%   r4   r6   r8   r  r  r   r   r   $test_jump_backwards_into_while_block  s   
z1JumpTestCase.test_jump_backwards_into_while_blockc                 C   B   t | d | d W d    n1 sw   Y  | d d S r  r   r   r  r   r   r   $test_jump_forwards_out_of_with_block     z1JumpTestCase.test_jump_forwards_out_of_with_blockc              	      X   t | d4 I d H  | d W d   I d H  q%1 I d H s w   Y  | d d S r  r   r   r  r   r   r   *test_jump_forwards_out_of_async_with_block  
   (z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r%   r4   r%   r4   r6   rU   c                 C   D   |  d t| d |  d W d    d S 1 sw   Y  d S r  r   r   r  r   r   r   %test_jump_backwards_out_of_with_block      
"z2JumpTestCase.test_jump_backwards_out_of_with_blockc              	      Z   |  d t| d4 I d H  |  d W d   I d H  d S 1 I d H s&w   Y  d S r  r   r   r  r   r   r   +test_jump_backwards_out_of_async_with_block  
   
.z8JumpTestCase.test_jump_backwards_out_of_async_with_blockc              	   C   4   z|  d W |  d n|  d w |  d d S Nr4   r=   r8   r  r  r   r   r   +test_jump_forwards_out_of_try_finally_block     z8JumpTestCase.test_jump_forwards_out_of_try_finally_block)r%   r%   r6   r8   c              	   C   2   |  d z|  d W |  d d S |  d w Nr%   r6   r8   r  r  r   r   r   ,test_jump_backwards_out_of_try_finally_block     
z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockc                 C   0   z|  d W n	   |  d  |  d d S Nr4   r=   rJ   r  r  r   r   r   *test_jump_forwards_out_of_try_except_block     
z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r%   r%   r6   c                 C   .   |  d z|  d W d S    |  d  r  r  r  r   r   r   +test_jump_backwards_out_of_try_except_block%     

z8JumpTestCase.test_jump_backwards_out_of_try_except_block)r=   r?   r   c                 C   s\   zdd  W n  t y   | d | d Y n ty&   | d Y nw | d d S Nr%   r   r=   r8   r?   r   r-  r   FloatingPointErrorr  r   r   r   test_jump_between_except_blocks.  s   
z,JumpTestCase.test_jump_between_except_blocks)r=   rJ   r?   c                 C   sB   zdd  W n   |  d |  d |  d Y |  d d S )Nr%   r   r=   r8   rJ   r?   r  r  r   r   r   test_jump_within_except_block9  s   

z*JumpTestCase.test_jump_within_except_block)r%   r=   r8   r|   c                 C   x   |  d t| d |  d W d    n1 sw   Y  t| d |  d W d    d S 1 s5w   Y  d S Nr%   r4   r6   r=   r8   r  r  r   r   r   test_jump_across_withC     
"z"JumpTestCase.test_jump_across_withc              	         |  d t| d4 I d H  |  d W d   I d H  q*1 I d H s%w   Y  t| d4 I d H  |  d W d   I d H  d S 1 I d H sJw   Y  d S r  r  r  r   r   r   test_jump_across_async_withK     
(.z(JumpTestCase.test_jump_across_async_with)r%   r6   r8   rJ   c              	   C   s`   |  d dD ]!}t| d |  d W d    n1 sw   Y  |  d q|  d d S Nr%   r   r6   r=   r8   rJ   r  r  r   r   r   ,test_jump_out_of_with_block_within_for_blockS  s   
z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc              
      sv   |  d dD ]+}t| d4 I d H  |  d W d   I d H  q.1 I d H s)w   Y  |  d q|  d d S r  r  r  r   r   r   2test_jump_out_of_async_with_block_within_for_block\  s   
(z?JumpTestCase.test_jump_out_of_async_with_block_within_for_block)r%   r4   r6   r8   rU   rJ   c              	   C   s   |  d t| d' t| d |  d W d    n1 s w   Y  |  d W d    n1 s4w   Y  |  d d S Nr%   r4   r6   r=   r8   rJ   r  r  r   r   r   -test_jump_out_of_with_block_within_with_blocke  s   
z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc              
      s   |  d t| d1 t| d4 I d H  |  d W d   I d H  q01 I d H s+w   Y  |  d W d    n1 s?w   Y  |  d d S r  )r   r   r   r  r   r   r   3test_jump_out_of_async_with_block_within_with_blockn  s   
(z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r4   r=   rJ   r?   c                 C   s   z&|  d W t| d |  d W d    n1 sw   Y  |  d n t| d |  d W d    n1 s<w   Y  |  d w |  d d S Nr4   r=   r8   rJ   r?   r  r  r   r   r   0test_jump_out_of_with_block_within_finally_blockw  s   z=JumpTestCase.test_jump_out_of_with_block_within_finally_blockc                    s   z0|  d W t| d4 I d H  |  d W d   I d H  q,1 I d H s'w   Y  |  d n*t| d4 I d H  |  d W d   I d H  qV1 I d H sQw   Y  |  d w |  d d S r  r  r  r   r   r   6test_jump_out_of_async_with_block_within_finally_block  s   ((zCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr   )r%   r6   r8   r  r  c                 C   sx   |  d dD ]-}|  d dD ]}|  d zdD ]}|  d qW |  d q|  d w |  d q|  d	 d S )
Nr%   r   r6   r@  r8   r   rt   r  r  r  )r
   ro   r  kr   r   r   &test_jump_out_of_complex_nested_blocks  s   


z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r%   r4   r8   c                 C   sL   |  d t| d}|  d W d    n1 sw   Y  |  d d S Nr%   r4   r=   r8   r  r
   r"   r   r   r    test_jump_out_of_with_assignment  s   

z-JumpTestCase.test_jump_out_of_with_assignmentc              	      sb   |  d t| d4 I d H }|  d W d   I d H  q*1 I d H s%w   Y  |  d d S r  r  r  r   r   r   &test_jump_out_of_async_with_assignment  s   
(z3JumpTestCase.test_jump_out_of_async_with_assignment)r%   rJ   r   r   c              	   C   s\   |  d z|  d | sW |  d d S |  d W |  d n|  d w |  d d S )Nr%   r6   r   rJ   r   r  r  r   r   r   *test_jump_over_return_in_try_finally_block  s   

z7JumpTestCase.test_jump_over_return_in_try_finally_block)r%   r6   r   rt   r  r  c              	   C   sr   |  d 	 |  d z|  d | sW |  d q2|  d W |  d n|  d w |  d 	 |  d d S )	Nr%   Tr6   r8   rt   r   r  r  r  r  r   r   r   )test_jump_over_break_in_try_finally_block  s   



z6JumpTestCase.test_jump_over_break_in_try_finally_blockc                 C   D   |  d | sdD ]}|  d q	|  d |  d |  d d S Nr%   r  r=   rJ   r?   r   r  r  r   r   r   $test_jump_over_for_block_before_else     


z1JumpTestCase.test_jump_over_for_block_before_elsec                    X   |  d | stdg2 z3 d H W }|  d q6 n
|  d |  d |  d d S Nr%   r6   r=   rJ   r?   r   r  r  r   r   r   *test_jump_over_async_for_block_before_else     


z7JumpTestCase.test_jump_over_async_for_block_before_elsec                 C   r  rD   r  r  r   r   r   test_no_jump_too_far_forwards  r  z*JumpTestCase.test_no_jump_too_far_forwardsrU   beforec                 C   r  rD   r  r  r   r   r   test_no_jump_too_far_backwards  r  z+JumpTestCase.test_no_jump_too_far_backwardsexceptc                 C   s$   z|  d W d S    |  d  Nr4   r=   r  r  r   r   r   test_no_jump_to_except_1  s
   
z%JumpTestCase.test_no_jump_to_except_1c                 C   s,   z|  d W d S  ty   |  d  w r  r   r.  r  r   r   r   test_no_jump_to_except_2  s   
z%JumpTestCase.test_no_jump_to_except_2c              
   C   s8   z|  d W d S  ty } z|  d |d }~ww r  r  r  r   r   r   test_no_jump_to_except_3  s   
z%JumpTestCase.test_no_jump_to_except_3c              
   C   s<   z|  d W d S  ttfy } z|  d |d }~ww r  )r   r.  rf   r  r   r   r   test_no_jump_to_except_4  s   
z%JumpTestCase.test_no_jump_to_except_4Zintoc                 C   s"   |  d dD ]}|  d qd S )Nr%   r@  r6   r  r  r   r   r   $test_no_jump_forwards_into_for_block	  s   
z1JumpTestCase.test_no_jump_forwards_into_for_blockc                    s6   |  d tddg2 z3 d H W }|  d q6 d S r  r  r  r   r   r   *test_no_jump_forwards_into_async_for_block  s   
z7JumpTestCase.test_no_jump_forwards_into_async_for_blockc                 C   s"   dD ]}|  d q|  d d S )Nr@  r4   r6   r  r  r   r   r   %test_no_jump_backwards_into_for_block  s   z2JumpTestCase.test_no_jump_backwards_into_for_blockc                    s6   t ddg2 z3 d H W }| d q6 | d d S r  r  r  r   r   r   +test_no_jump_backwards_into_async_for_block  s
   z8JumpTestCase.test_no_jump_backwards_into_async_for_blockc                 C   r  r  r  r  r   r   r   %test_no_jump_forwards_into_with_block"  r  z2JumpTestCase.test_no_jump_forwards_into_with_blockc              	      r  r  r  r  r   r   r   +test_no_jump_forwards_into_async_with_block(  r  z8JumpTestCase.test_no_jump_forwards_into_async_with_block)r%   r4   r   c                 C   r  r  r  r  r   r   r   &test_no_jump_backwards_into_with_block.  r  z3JumpTestCase.test_no_jump_backwards_into_with_blockc              	      r  r  r  r  r   r   r   ,test_no_jump_backwards_into_async_with_block4  r  z9JumpTestCase.test_no_jump_backwards_into_async_with_blockc              	   C   r  r  r  r  r   r   r   ,test_no_jump_forwards_into_try_finally_block:  r  z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockc              	   C   r  r  r  r  r   r   r   -test_no_jump_backwards_into_try_finally_blockB  r  z:JumpTestCase.test_no_jump_backwards_into_try_finally_blockc                 C   r  r  r  r  r   r   r   +test_no_jump_forwards_into_try_except_blockJ  r  z8JumpTestCase.test_no_jump_forwards_into_try_except_blockc                 C   r  r  r  r  r   r   r   ,test_no_jump_backwards_into_try_except_blockS  r  z9JumpTestCase.test_no_jump_backwards_into_try_except_blockc              
   C   sn   zdd  W n) t y   | d | d Y n ty/ } z| d W Y d }~nd }~ww | d d S r  r  r  r   r   r   $test_no_jump_between_except_blocks_2]  s   
z1JumpTestCase.test_no_jump_between_except_blocks_2c              	   C   r  r  r  r  r   r   r   test_jump_into_finally_blockh  r  z)JumpTestCase.test_jump_into_finally_block)r4   rJ   r?   c              	   C   sR   z|  d |  d W |  d |  d n|  d |  d w |  d d S )Nr4   r6   r8   rJ   r?   r  r  r   r   r   +test_jump_into_finally_block_from_try_blockp  s   


z8JumpTestCase.test_jump_into_finally_block_from_try_block)r%   r6   r%   r6   r8   c              	   C   r  r  r  r  r   r   r   test_jump_out_of_finally_blockz  r  z+JumpTestCase.test_jump_out_of_finally_blockzinto an 'except'c                 C   s2   |  d z|  d W d S    |  d Y d S r  r  r  r   r   r   #test_no_jump_into_bare_except_block  s
   
z0JumpTestCase.test_no_jump_into_bare_except_blockc                 C   s:   |  d z|  d W d S  ty   |  d Y d S w r  r   rX   r  r   r   r   (test_no_jump_into_qualified_except_block  s   
z5JumpTestCase.test_no_jump_into_qualified_except_block)r4   r8   rJ   c                 C   sD   z|  d |  d W n   |  d |  d  |  d d S Nr4   r6   r8   rJ   r   r  r  r   r   r   2test_no_jump_into_bare_except_block_from_try_block  s   


z?JumpTestCase.test_no_jump_into_bare_except_block_from_try_blockc                 C   sL   z|  d |  d W n ty   |  d |  d  w |  d d S r  )r   r-  r  r   r   r   7test_no_jump_into_qualified_except_block_from_try_block  s   


zDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block)r%   r6   rJ   zout of an 'except'c                 C   sD   |  d z|  d dd  W d S    |  d |  d Y d S Nr%   r6   r   rJ   r?   r  r  r   r   r   %test_no_jump_out_of_bare_except_block  s   


z2JumpTestCase.test_no_jump_out_of_bare_except_blockc                 C   sL   |  d z|  d dd  W d S  ty%   |  d |  d Y d S w r  r  r  r   r   r   *test_no_jump_out_of_qualified_except_block  s   


z7JumpTestCase.test_no_jump_out_of_qualified_except_block)r%   r4   r8   rU   c                 C   r  r  r  r  r   r   r   test_jump_between_with_blocks  r  z*JumpTestCase.test_jump_between_with_blocksc              	      r  r  r  r  r   r   r   #test_jump_between_async_with_blocks  r  z0JumpTestCase.test_jump_between_async_with_blocksc              	   C   r  )Nr4   r=   r8   r?   r  r  r   r   r   -test_no_jump_over_return_out_of_finally_block  r  z:JumpTestCase.test_no_jump_over_return_out_of_finally_blockc                 C   r  r  r  r  r   r   r   'test_no_jump_into_for_block_before_else  r  z4JumpTestCase.test_no_jump_into_for_block_before_elsec                    r  r  r  r  r   r   r   -test_no_jump_into_async_for_block_before_else  r  z:JumpTestCase.test_no_jump_into_async_for_block_before_elsec                 C   s   |  tdddg d S )Nr4   ZSpamT)r   r  r   r   r   r   test_no_jump_to_non_integers  r`  z)JumpTestCase.test_no_jump_to_non_integersc                 C   rQ   r   )r  r   r   r   r   #test_no_jump_without_trace_function  s   
z0JumpTestCase.test_no_jump_without_trace_functionc                 C   s0   i }t dd | |d }| |dddg d S )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   r4   i  r   )r   r   )r   r  r   r   r   r   test_large_function  s   	z JumpTestCase.test_large_functionc                    sj   t ddd G  fddd}t|dd}t|j dg i}t | td  | g d	|d  d S )
Nzd
# Comments don't count.
output.append(2)  # firstlineno is here.
output.append(3)
output.append(4)
z<fake module>r   c                       s   e Zd Z ZdS )z<JumpTestCase.test_jump_to_firstlineno.<locals>.fake_functionN)r   r   r   r   r   rx  r   r   fake_function  s    r+  r=   r%   r
   )r4   r6   r4   r6   r=   )compilerw  r^   r_   r   r   r  )r   r+  r   r   r   r*  r   test_jump_to_firstlineno  s   

z%JumpTestCase.test_jump_to_firstlinenor)   z5can't jump from the 'call' trace event of a new frame)r   rM  c                    s*     d  fdd}|    d d S )Nr%   c                      s     d d S )Nr6   r  r   r  r   r   nested  r   z3JumpTestCase.test_no_jump_from_call.<locals>.nestedr8   r  )r
   r.  r   r  r   test_no_jump_from_call  s   
z#JumpTestCase.test_no_jump_from_callr-   z'can only jump from a 'line' trace eventc                 C   rd  r$   r  r  r   r   r   test_no_jump_from_return_event  s   
z+JumpTestCase.test_no_jump_from_return_eventr\   c                 C   s   |  d dd  d S r/   r  r  r   r   r   !test_no_jump_from_exception_event$  s   
z.JumpTestCase.test_no_jump_from_exception_event)r   c                    s$    fdd}t |   d d S )Nc                   3   s      d dV  d S )Nr4   r6   r  r   r  r   r   gen,  s   

z.JumpTestCase.test_jump_from_yield.<locals>.genr8   )r   r   )r
   r2  r   r  r   test_jump_from_yield*  s   
z!JumpTestCase.test_jump_from_yield)Nr+   Frg  )\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  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  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#  r$  r%  r&  r'  r(  r)  r-  r/  r0  r1  r3  r   r   r   r   r  -  sZ   







	






















	






	
	

























	



	







	
	


	






r  __main__).r  r   Zunittestr^   r   r   	functoolsr   r  r   r   r#   r&   r   r1   r:   r;   rA   rH   rM   rP   r)   rY   rZ   rd   re   rg   rh   rj   rp   rq   rs   rv   r   ZTestCaser   rQ  Zcpython_onlyr[  r^  rw  r  r  r  r   mainr   r   r   r   <module>   s   



	








	


      4`&      
