a
    ze                     @   sJ  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rFe-  dS )W    )supportNwrapsc                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	tracecontextz/Context manager that traces its enter and exit.c                 C   s   || _ || _d S Noutputvalueselfr   r	    r   ,/usr/lib/python3.9/test/test_sys_settrace.py__init__   s    ztracecontext.__init__c                 C   s   | j | j d S r   r   appendr	   r   r   r   r   	__enter__   s    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____doc__r   r   r   r   r   r   r   r      s   r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.c                 C   s   || _ || _d S r   r   r
   r   r   r   r      s    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      s   r   c                 C  s   | D ]
}|V  qdS )z0Convert an iterable to an asynchronous iterator.Nr   )iterablexr   r   r   	asynciter$   s    r   c                   C   s   dS N   r   r   r   r   r   basic+   s    r"   )r   callr!   liner!   returnc                  C   s   d} ~ d} d S r    r   r   r   r   r   arigo_example0;   s    r*   )r#   r%      r&      r&   r.   r(   c                  C   s   d} ~ d} d S r    r   r)   r   r   r   arigo_example1H   s    r0   c                  C   s   d} ~ d} d S r    r   r)   r   r   r   arigo_example2U   s    r1   )r#   r%   r+      r&      r&   r5   r(   c                  C   s   d} ~ d} d S r    r   r)   r   r   r   one_instr_lineg   s    r7   )r#   r%   r+      r&   r9   r(   c                  C   s$   d} t dD ]}|rd} qd} qd S Nr!   r,   range)r   ar   r   r   no_pop_topsr   s
    r?   )
r#   r%   r+   r8      r&   r+   r8   r2   r+   )r,   r(   c                  C   s   d} | st  qd}d S r    )Zbla)yr   r   r   r   no_pop_blocks   s    rC   )r#   r%   r+   r2   r3   r(   c                  C   s   d} d S r    r   r)   r   r   r   called   s    rE   c                   C   s
   t   d S r   )rE   r   r   r   r   r$      s    r$   )r#   r%   r$   r&   rI   r(   r'   c                   C   s   t d S r   	Exceptionr   r   r   r   raises   s    rM   c                   C   s"   z
t   W n ty   Y n0 d S r   )rM   rL   r   r   r   r   
test_raise   s    
rN   )r#   r%   r+   rF   rH   rI   	exceptionrJ   r,   rP   r8   r2   rD   c                 C   s   t |  | t  j_d S r   )syssettrace	_getframef_backf_traceZ	tracefuncr   r   r   _settrace_and_return   s    
rX   c                 C   s   t |  d S r   )rX   rW   r   r   r   settrace_and_return   s    rY   r'   c                 C   s   t |  | t  j_td S r   )rR   rS   rT   rU   rV   RuntimeErrorrW   r   r   r   _settrace_and_raise   s    
r[   c                 C   s$   zt |  W n ty   Y n0 d S r   )r[   rZ   rW   r   r   r   settrace_and_raise   s    r\   )rQ   r8   r2   rD   c                  C   s   d} d}| |kr| d }n d S )Nr.   r!   r   )r>   br   r   r   ireturn_example   s
    
r^   )r#   r%   r+   r8   r2   r@   rA   r(   c                  C   s<   t dd} zd}| | }|d7 }qW n ty6   Y n0 d S )Nr   r9   r!   r=   
IndexError)itemsir]   r   r   r   tightloop_example   s    
rd   )r#   r%   r+   r8   r-   r-   r-   r-   )r.   rP   r@   r4   r6   c                  C   s4   t dd} zd}| | }qW n ty.   Y n0 d S )Nr!   r3   r   r`   )rb   rc   r   r   r   tighterloop_example   s    
re   )r#   r%   r+   r8   r2   r2   r2   r2   )r3   rP   r-   r@   r_   c                   c   s   z
dV  W n0 d S )NTr   r   r   r   r   generator_function  s    rf   c                  C   s    t t } tdD ]} | }qd S )N
   )anyrf   r=   )r   rB   r   r   r   generator_example  s    
ri   )
r#   r+   ir$   r&   r&   rn   r(   )rn   r$   rn   rP   )r&   )rq   r(   r-   r@   rg   r/   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   rs   rt   r   r   r   r   +  s    zTracer.__init__c                 C   s(   | j d ur| j |_| jd ur$| j|_d S r   )rs   f_trace_linesrt   f_trace_opcodes)r   framer   r   r   _reconfigure_frame0  s    

zTracer._reconfigure_framec                 C   s"   |  | | j|j|f | jS r   ry   ru   r   f_linenotracer   rx   eventargr   r   r   r|   6  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>=      z)Tracer.traceWithGenexp.<locals>.<genexpr>r!   rz   r}   r   r   r   traceWithGenexp;  s    
zTracer.traceWithGenexp)NN)r   r   r   r   ry   r|   r   r   r   r   r   rr   *  s   
rr   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#dAS )BTraceTestCasec                 C   s(   t  | _t   | tjt  d S r   )gc	isenabledusing_gcdisable
addCleanuprR   rS   gettracer   r   r   r   setUpF  s    
zTraceTestCase.setUpc                 C   s   | j rt  d S r   )r   r   enabler   r   r   r   tearDownK  s    zTraceTestCase.tearDownc                   C   s   t  S )z@Helper to allow test subclasses to configure tracers differentlyrr   r   r   r   r   make_tracerO  s    zTraceTestCase.make_tracerc              
      sN    fdd|D }||krJ|  ddtdd |D dd |D   d S )Nc                    s   g | ]\}}|  |fqS r   r   )r   leline_offsetr   r   
<listcomp>U  r   z0TraceTestCase.compare_events.<locals>.<listcomp>z"events did not match expectation:

c                 S   s   g | ]}t |qS r   strr   r   r   r   r   r   Y  r   c                 S   s   g | ]}t |qS r   r   r   r   r   r   r   Z  r   )failjoindifflibZndiff)r   r   ru   expected_eventsr   r   r   compare_eventsT  s    zTraceTestCase.compare_eventsc                 C   s<   |   }t|j |  td  | |jj|j| d S r   )r   rR   rS   r|   r   __code__co_firstlinenoru   )r   funcru   tracerr   r   r   run_and_compare\  s    

zTraceTestCase.run_and_comparec                 C   s   |  ||j d S r   )r   ru   r   r   r   r   r   run_testd  s    zTraceTestCase.run_testc                 C   s6   |   }||j td  | |jj|j|j d S r   )r   r|   rR   rS   r   r   r   ru   )r   r   r   r   r   r   	run_test2g  s    


zTraceTestCase.run_test2c                 C   s   t d  d S r   rR   rS   r   r   r   r   test_set_and_retrieve_nonen  s    
z(TraceTestCase.test_set_and_retrieve_nonec              	   C   s2   dd }t | zW t d  nt d  0 d S )Nc                  W   s   d S r   r   )argsr   r   r   fns  s    z4TraceTestCase.test_set_and_retrieve_func.<locals>.fnr   )r   r   r   r   r   test_set_and_retrieve_funcr  s
    
z(TraceTestCase.test_set_and_retrieve_funcc                 C   s   |  t d S r   )r   r"   r   r   r   r   test_01_basic|  s    zTraceTestCase.test_01_basicc                 C   s   |  t d S r   )r   r*   r   r   r   r   test_02_arigo0~  s    zTraceTestCase.test_02_arigo0c                 C   s   |  t d S r   )r   r0   r   r   r   r   test_02_arigo1  s    zTraceTestCase.test_02_arigo1c                 C   s   |  t d S r   )r   r1   r   r   r   r   test_02_arigo2  s    zTraceTestCase.test_02_arigo2c                 C   s   |  t d S r   )r   r7   r   r   r   r   test_03_one_instr  s    zTraceTestCase.test_03_one_instrc                 C   s   |  t d S r   )r   rC   r   r   r   r   test_04_no_pop_blocks  s    z#TraceTestCase.test_04_no_pop_blocksc                 C   s   |  t d S r   )r   r?   r   r   r   r   test_05_no_pop_tops  s    z!TraceTestCase.test_05_no_pop_topsc                 C   s   |  t d S r   )r   r$   r   r   r   r   test_06_call  s    zTraceTestCase.test_06_callc                 C   s   |  t d S r   )r   rN   r   r   r   r   test_07_raise  s    zTraceTestCase.test_07_raisec                 C   s   |  t d S r   )r   rY   r   r   r   r   test_08_settrace_and_return  s    z)TraceTestCase.test_08_settrace_and_returnc                 C   s   |  t d S r   )r   r\   r   r   r   r   test_09_settrace_and_raise  s    z(TraceTestCase.test_09_settrace_and_raisec                 C   s   |  t d S r   )r   r^   r   r   r   r   test_10_ireturn  s    zTraceTestCase.test_10_ireturnc                 C   s   |  t d S r   )r   rd   r   r   r   r   test_11_tightloop  s    zTraceTestCase.test_11_tightloopc                 C   s   |  t d S r   )r   re   r   r   r   r   test_12_tighterloop  s    z!TraceTestCase.test_12_tighterloopc                 C   sH   |  t |  }t|j t  td  | tjj|j	tj	 d S r   )
r   ri   r   rR   rS   r   r   r   r   ru   )r   r   r   r   r   test_13_genexp  s    


zTraceTestCase.test_13_genexpc                 C   s   dd }|  |g d d S )Nc                  S   s   d} dS )NFr   r   r)   r   r   r   onliners  s    z2TraceTestCase.test_14_onliner_if.<locals>.onliners)r#   r%   r8   r:   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 Nr,   r<   r)   r   r   r   for_example  s    z0TraceTestCase.test_15_loops.<locals>.for_example)r#   r%   r+   r%   r+   r%   r'   c                  S   s   d} | dkr| d8 } qd S )Nr,   r   r!   r   r)   r   r   r   while_example  s    z2TraceTestCase.test_15_loops.<locals>.while_example)r#   r+   r8   r2   r8   r2   r8   r:   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   )rR   rT   rV   )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   s   dd }|  |g d d S )Nc               
   S   sT   z<zt W n. t y8 }  z d}d}W Y d } ~ n
d } ~ 0 0 W n t yN   Y n0 d S )N	SomethingrK   )r   r   rB   r   r   r   r     s    z4TraceTestCase.test_18_except_with_name.<locals>.func)
r#   r%   r+   r8   r9   rP   r2   r-   )   r&   )	   r&   )r   r(   r   r   r   r   r   test_18_except_with_name  s    z&TraceTestCase.test_18_except_with_namec                 C   s   dd }|  |g d d S )Nc                  S   s4   zzt W d} nd} 0 W n t y.   d}Y n0 d S )Nr      rK   )rB   r]   r   r   r   r     s    z7TraceTestCase.test_19_except_with_finally.<locals>.func)	r#   r%   r+   r8   r   r-   r@   r4   r6   r   r   r   r   r   test_19_except_with_finally  s    	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yV   Y n0 | 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     s    zKTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__init__c                 S   s   | S r   r   r   r   r   r   	__aiter__  s    zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__aiter__c                    s(   zt | jW S  ty"   tY n0 d S 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   rB   )r   r   r   
doit_async  s    z8TraceTestCase.test_20_async_for_loop.<locals>.doit_asyncc              	      s:     }z"t |  |d  W t d  nt d  0 d S r   rR   rS   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(   rj   rk   rm   ro   r!   rP   r+   r%   rj   rk   rm   ro   r   r+   r%   rj   rk   rm   ro   r   r+   r%   rj   rk   rm   rp   )rG   r&   rH   rO   rJ   r   r8   r:   r   r|   rL   r   r   r   ru   r   r   r   ru   r   )r   r   r   test_20_async_for_loop  s    )
z$TraceTestCase.test_20_async_for_loopc                    sj   dd   fddfdd}|   }g d}z||j W n tyP   Y n0 | jj|j| d S )Nc                   S  s
   dV  d S )NrI   r   r   r   r   r   	async_gen_  s    z7TraceTestCase.test_21_async_for_else.<locals>.async_genc                     s&   da   2 z3 d H W } da q
6 da d S Nr,   r3   rA   )r>   rc   )r   r   r   
async_testb  s    z8TraceTestCase.test_21_async_for_else.<locals>.async_testc              	      s:     }z"t |  |d  W t d  nt d  0 d S r   r   r   )r   r   r   r   j  s
    
z1TraceTestCase.test_21_async_for_else.<locals>.run)r#   r+   r8   rF   rH   rJ   r   r2   r8   )rI   r$   rJ   r   r@   r_   r   r   r   )r   r   r   test_21_async_for_else]  s    
z$TraceTestCase.test_21_async_for_elseN)$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   B  sB   

		Lr   c                       s,   e Zd ZdZ fddZedd Z  ZS )SkipLineEventsTraceTestCasez8Repeat the trace tests, but with per-line events skippedc                    s"   dd |D }t  ||| d S )Nc                 S   s   g | ]}|d  dkr|qS r%   r   r   r   r   r   r   r     r   z>SkipLineEventsTraceTestCase.compare_events.<locals>.<listcomp>)superr   )r   r   ru   r   Zskip_line_events	__class__r   r   r     s    z*SkipLineEventsTraceTestCase.compare_eventsc                   C   s
   t ddS )NF)rs   r   r   r   r   r   r     s    z'SkipLineEventsTraceTestCase.make_tracerr   r   r   r   r   r   r   __classcell__r   r   r   r   r     s   r   c                       s,   e Zd ZdZ fddZedd Z  ZS )TraceOpcodesTestCasez;Repeat the trace tests, but with per-opcodes events enabledc                    sF   dd |D }t |dkr2| jt |t |dd t ||| d S )Nc                 S   s   g | ]}|d  dkr|qS )r!   Zopcoder   r   r   r   r   r     r   z7TraceOpcodesTestCase.compare_events.<locals>.<listcomp>r!   z)No 'opcode' events received by the tracer)msg)lenZ
assertLessr   r   )r   r   ru   r   Zskip_opcode_eventsr   r   r   r     s    z#TraceOpcodesTestCase.compare_eventsc                   C   s
   t ddS )NT)rt   r   r   r   r   r   r     s    z TraceOpcodesTestCase.make_tracerr   r   r   r   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   rR   rS   r   r   r   r   r   r     s    zRaisingTraceFuncTestCase.setUpc                 C   s   || j krtn| jS dS )zXA trace function that raises an exception in response to a
        specific trace event.N)raiseOnEvent
ValueErrorr|   r}   r   r   r   r|     s    
zRaisingTraceFuncTestCase.tracec                 C   s    | j dkrd}d| }ndS dS )zThe function to trace; raises an exception if that's the case
        we're testing, so that the 'exception' trace event fires.rP   r   r!   N)r   )r   r   rB   r   r   r   r     s    

zRaisingTraceFuncTestCase.fc              	   C   sx   || _ zPtt d D ]:}t| j z|   W n tyF   Y q0 | d qW n t	yr   | d Y n0 dS )zTTests that an exception raised in response to the given event is
        handled OK.r!   zexception not raised!zrecursion counter not resetN)
r   r=   rR   getrecursionlimitrS   r|   r   r   r   rZ   )r   r~   rc   r   r   r   run_test_for_event  s    z+RaisingTraceFuncTestCase.run_test_for_eventc                 C   s   |  d d S )Nr$   r   r   r   r   r   	test_call  s    z"RaisingTraceFuncTestCase.test_callc                 C   s   |  d d S )Nr&   r   r   r   r   r   	test_line  s    z"RaisingTraceFuncTestCase.test_linec                 C   s   |  d d S )Nr(   r   r   r   r   r   test_return  s    z$RaisingTraceFuncTestCase.test_returnc                 C   s   |  d d S NrP   r   r   r   r   r   test_exception  s    z'RaisingTraceFuncTestCase.test_exceptionc                    s\   dd   fddt  z
   W n" tyL   dd l}|  Y n0 | d d S )Nc                  S   s   t dD ]} t|  qd S )Nr.   )r=   printr   r   r   r   r     s    z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.fc                    s&   |dkr"| j  jjd kr"tdS )Nr&   r,   zi am crashing)r{   r   r   rZ   )rx   whyextrar   gr   r   r    s
    z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.gr   zexception not propagated)rR   rS   rZ   r   Zcollectr   )r   r   r   r  r   test_trash_stack  s    

z)RaisingTraceFuncTestCase.test_trash_stackc              	      sf   dd } fdd t  }z6t   z
|  W n tyF   Y n0 W t | nt | 0 d S )Nc                  S   s   d} | j  d S )Nr   )Zno_such_attrr)   r   r   r   r     s    z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.fc                    s"   |dkr|\}}} |t  S r  )ZassertIsInstancerL   )rx   r~   r   typerP   r|   r  r   r   r   r    s    
z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g)rR   r   rS   AttributeError)r   r   Zexistingr   r
  r   test_exception_arguments  s    

z1RaisingTraceFuncTestCase.test_exception_argumentsN)r   r   r   r   r|   r   r   r   r   r   r  r  r  r   r   r   r   r     s   	r   c                   @   s"   e Zd ZdZd	ddZdd ZdS )

JumpTracerz>Defines a trace function that jumps from one place to another.r&   Fc                 C   s6   |j | _|| _|| _|| _|r"d n| jj| _d| _d S )NF)r   codejumpFromjumpTor~   r   	firstLinedone)r   functionr  r  r~   	decoratedr   r   r   r   	  s    zJumpTracer.__init__c                 C   s   | j r
d S | jd u r4|j| jkr4|dkr4|jd | _|| jkr| jr|j| j| j kr|}|d urv|j| jkrv|j}qZ|d urz| j| j |_W n t	y   | j|_Y n0 d| _ | j
S )Nr&   r!   T)r  r  f_coder  r{   r~   r  rU   r  	TypeErrorr|   )r   rx   r~   r   r   r   r   r   r|     s&    zJumpTracer.traceN)r&   F)r   r   r   r   r   r|   r   r   r   r   r    s
     
	r  c              
   C   sJ   z|  d W n6 tyD } z|  dt|v  W Y d }~n
d }~0 0 d S )Nr,   Zinteger)r   r   r   r   r   r   r   r   no_jump_to_non_integers,  s    r  c               
   C   sV   zt  j} | j| _W n2 tyH } zdt|vr4 W Y d }~nd }~0 0 tdd S )Nr|   z'Trace-function-less jump failed to fail)rR   rT   rU   r{   r   r   AssertionError)Zprevious_framer   r   r   r   no_jump_without_trace_function4  s    
r  c                   @   s  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d~f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[eddddgdd Z\eddg dd Z]edkdg ddd Z^eddddgdd Z_eddg dd Z`edkdg ddd ZadS )JumpTestCasec                 C   s    |  tjt  td  d S r   r   r   r   r   r   r   C  s    zJumpTestCase.setUpc                 C   s.   ||kr*|  dt| d d t|  d S )NzOutputs don't match:
Expected: r   z
Received: )r   repr)r   expectedZreceivedr   r   r   compare_jump_outputG  s    z JumpTestCase.compare_jump_outputNr&   Fc           
      C   s~   t |||||}t|j g }	|d u r2||	 n2| j|  ||	 W d    n1 sZ0    Y  td  | ||	 d S r   )r  rR   rS   r|   assertRaisesRegexr  
r   r   r  r  r  errorr~   r  r   r   r   r   r   r   M  s    
&
zJumpTestCase.run_testc           
      C   s   t |||||}t|j g }	|d u r8t||	 n8| j|  t||	 W d    n1 sf0    Y  td  td  | ||	 d S r   )	r  rR   rS   r|   asyncior   r  Zset_event_loop_policyr  r   r   r   r   run_async_testZ  s    ,

zJumpTestCase.run_async_testc                    s    fdd}|S )zqDecorator that creates a test that makes a jump
        from one place to another in the following code.
        c                    s"   t   fdd}|S )Nc              	      s   | j  dd d S NT)r!  r~   r  )r   r   r!  r~   r  r   r  r  r   r   testm  s    z7JumpTestCase.jump_test.<locals>.decorator.<locals>.testr   r   r&  r!  r~   r  r  r  r   r   	decoratorl  s    z)JumpTestCase.jump_test.<locals>.decoratorr   r  r  r  r!  r~   r*  r   r(  r   	jump_testh  s    zJumpTestCase.jump_testc                    s    fdd}|S )z~Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        c                    s"   t   fdd}|S )Nc              	      s   | j  dd d S r$  )r#  r   r%  r   r   r&  y  s    z=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.testr   r'  r(  r)  r   r*  x  s    z/JumpTestCase.async_jump_test.<locals>.decoratorr   r+  r   r(  r   async_jump_testt  s    zJumpTestCase.async_jump_testr!   r9   c                 C   s"   |  d |  d |  d d S Nr!   r,   r9   r   r   r   r   r   test_jump_simple_forwards  s    

z&JumpTestCase.test_jump_simple_forwardsr,   )r!   r!   r,   c                 C   s   |  d |  d d S r;   r/  r0  r   r   r   test_jump_simple_backwards  s    
z'JumpTestCase.test_jump_simple_backwardsr.   c                 C   s6   dD ]"}|  d dD ]}|  d qq|  d d S )Nr!   r,   r,   r9   r3   r.   r/  r   rc   jr   r   r   test_jump_out_of_block_forwards  s
    
z,JumpTestCase.test_jump_out_of_block_forwardsrA   )r!   r9   r.   r!   r9   r.   rA   r5   c                 C   sJ   |  d dD ],}|  d dD ]}|  d q |  d q|  d d S )Nr!   r   r9   )r,   r.   rA   r5   r/  r5  r   r   r    test_jump_out_of_block_backwards  s    

z-JumpTestCase.test_jump_out_of_block_backwardsr3   c                    sH   dD ]>}t ddg2 z 3 d H W }| d | d q6 | d qd S )Nr   r!   r,   r9   r3   r.   r   r   r   rc   r   r   r   )test_jump_out_of_async_for_block_forwards  s
    
z6JumpTestCase.test_jump_out_of_async_for_block_forwards)r,   r3   r,   r3   r.   rA   c                    sP   dD ]F}|  d tdg2 z 3 d H W }|  d |  d q6 |  d qd S )Nr   r,   r!   r3   r.   rA   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   s   |  d |  d d S )Nr!   r9   r/  r0  r   r   r   test_jump_to_codeless_line  s    
z'JumpTestCase.test_jump_to_codeless_line)r!   r,   r9   c                 C   s"   |  d |  d |  d d S r.  r/  r0  r   r   r   test_jump_to_same_line  s    

z#JumpTestCase.test_jump_to_same_liner   c                 C   s   zH|  d W |  d z|  d W |  d n|  d 0 |  d n<|  d z|  d W |  d n|  d 0 |  d 0 d S )Nr,   r3   rA   r   r   r/  r0  r   r   r   test_jump_in_nested_finally  s    

z(JumpTestCase.test_jump_in_nested_finallyr5    c              	   C   sR   z,|  d dd  W |  d |  d d S |  d |  d 0 |  d d S )Nr,   r!   r   rA   r5   r   r/  r0  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 0 |  d d S z|  d W |  d n|  d 0 |  d n<|  d z|  d W |  d n|  d 0 |  d 0 |  d d S )	Nr,   r!   r   rA   r   rg   rC     r/  r0  r   r   r   test_jump_in_nested_finally_3  s*    


 
z*JumpTestCase.test_jump_in_nested_finally_3Zunreachablec              	   C   s   zL|  d W |  d |  d d S z|  d W |  d q|  d 0 nH|  d |  d    Y d S z|  d W |  d n|  d 0 0 |  d d S )Nr,   r3   r.   r   rg   rD  r/  r0  r   r   r   5test_no_jump_over_return_try_finally_in_finally_block  s"    



zBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_blockc                 C   s$   |  d |  d q
|  d d S )Nr!   r9   r3   r/  r0  r   r   r    test_no_jump_infinite_while_loop  s    
z-JumpTestCase.test_no_jump_infinite_while_loopc                 C   s.   d}|  d |dkr*|  d |d7 }qd S )Nr!   r,   r3   r/  r:  r   r   r   #test_jump_forwards_into_while_block  s
    

z0JumpTestCase.test_jump_forwards_into_while_block)r9   r9   r9   r.   c                 C   s.   d}|dkr |  d |d7 }q|  d d S )Nr!   r,   r9   r.   r/  r:  r   r   r   $test_jump_backwards_into_while_block  s
    

z1JumpTestCase.test_jump_backwards_into_while_blockc                 C   sB   t | d | d W d    n1 s*0    Y  | d d S r.  r   r   r0  r   r   r   $test_jump_forwards_out_of_with_block	  s    (z1JumpTestCase.test_jump_forwards_out_of_with_blockc              	      sV   t | d4 I d H   | d W d   I d H  qH1 I d H s>0    Y  | d d S r.  r   r   r0  r   r   r   *test_jump_forwards_out_of_async_with_block  s    4z7JumpTestCase.test_jump_forwards_out_of_async_with_block)r!   r,   r!   r,   r9   rI   c                 C   sB   |  d t| d |  d W d    n1 s40    Y  d S r.  r   r   r0  r   r   r   %test_jump_backwards_out_of_with_block  s    
z2JumpTestCase.test_jump_backwards_out_of_with_blockc              	      sV   |  d t| d4 I d H   |  d W d   I d H  qR1 I d H sH0    Y  d S r.  r   r   r0  r   r   r   +test_jump_backwards_out_of_async_with_block  s    
z8JumpTestCase.test_jump_backwards_out_of_async_with_blockc              	   C   s4   z|  d W |  d n|  d 0 |  d d S Nr,   r3   r.   r/  r0  r   r   r   +test_jump_forwards_out_of_try_finally_block!  s    z8JumpTestCase.test_jump_forwards_out_of_try_finally_block)r!   r!   r9   r.   c              	   C   s4   |  d z|  d W |  d n|  d 0 d S Nr!   r9   r.   r/  r0  r   r   r   ,test_jump_backwards_out_of_try_finally_block)  s    
z9JumpTestCase.test_jump_backwards_out_of_try_finally_blockc                 C   s6   z|  d W n   |  d  Y n0 |  d d S r   r/  r0  r   r   r   *test_jump_forwards_out_of_try_except_block1  s    
z7JumpTestCase.test_jump_forwards_out_of_try_except_block)r!   r!   r9   c                 C   s6   |  d z|  d W n   |  d  Y n0 d S rT  r/  r0  r   r   r   +test_jump_backwards_out_of_try_except_block:  s    

z8JumpTestCase.test_jump_backwards_out_of_try_except_block)r3   r5   r   c                 C   s\   zdd  W n@ t y2   | d | d Y n tyL   | d Y n0 | d d S Nr!   r   r3   r.   r5   r   ZeroDivisionErrorr   FloatingPointErrorr0  r   r   r   test_jump_between_except_blocksC  s    
z,JumpTestCase.test_jump_between_except_blocks)r3   rA   r5   c                 C   sF   zdd  W n*   |  d |  d |  d Y n0 |  d d S )Nr!   r   r3   r.   rA   r5   r/  r0  r   r   r   test_jump_within_except_blockN  s    

z*JumpTestCase.test_jump_within_except_block)r!   r3   r.   rn   c                 C   sv   |  d t| d |  d W d    n1 s40    Y  t| d |  d W d    n1 sh0    Y  d S Nr!   r,   r9   r3   r.   rN  r0  r   r   r   test_jump_across_withX  s
    
(z"JumpTestCase.test_jump_across_withc              	      s   |  d t| d4 I d H   |  d W d   I d H  qR1 I d H sH0    Y  t| d4 I d H   |  d W d   I d H  q1 I d H s0    Y  d S r^  rP  r0  r   r   r   test_jump_across_async_with`  s
    
4z(JumpTestCase.test_jump_across_async_with)r!   r9   r.   rA   c              	   C   s`   |  d dD ]B}t| d |  d W d    n1 s<0    Y  |  d q|  d d S Nr!   r   r9   r3   r.   rA   rN  r:  r   r   r   ,test_jump_out_of_with_block_within_for_blockh  s    
(z9JumpTestCase.test_jump_out_of_with_block_within_for_blockc              
      st   |  d dD ]V}t| d4 I d H   |  d W d   I d H  qZ1 I d H sP0    Y  |  d q|  d d S ra  rP  r:  r   r   r   2test_jump_out_of_async_with_block_within_for_blockq  s    
4z?JumpTestCase.test_jump_out_of_async_with_block_within_for_block)r!   r,   r9   r.   rI   rA   c              	   C   s   |  d t| dN t| d |  d W d    n1 s@0    Y  |  d W d    n1 sh0    Y  |  d d S Nr!   r,   r9   r3   r.   rA   rN  r0  r   r   r   -test_jump_out_of_with_block_within_with_blockz  s    
((z:JumpTestCase.test_jump_out_of_with_block_within_with_blockc              
      s   |  d t| db t| d4 I d H   |  d W d   I d H  q^1 I d H sT0    Y  |  d W d    n1 s|0    Y  |  d d S rd  )r   r   r   r0  r   r   r   3test_jump_out_of_async_with_block_within_with_block  s    
4(z@JumpTestCase.test_jump_out_of_async_with_block_within_with_block)r,   r3   rA   r5   c                 C   s   zL|  d W t| d |  d W d    n1 s80    Y  |  d n@t| d |  d W d    n1 sx0    Y  |  d 0 |  d d S Nr,   r3   r.   rA   r5   rN  r0  r   r   r   0test_jump_out_of_with_block_within_finally_block  s    ((z=JumpTestCase.test_jump_out_of_with_block_within_finally_blockc                    s   z`|  d W t| d4 I d H   |  d W d   I d H  qV1 I d H sL0    Y  |  d nTt| d4 I d H   |  d W d   I d H  q1 I d H s0    Y  |  d 0 |  d d S rg  rP  r0  r   r   r   6test_jump_out_of_async_with_block_within_finally_block  s    44zCJumpTestCase.test_jump_out_of_async_with_block_within_finally_blockr   )r!   r9   r.   rC  rD  c                 C   sz   |  d dD ]\}|  d dD ]>}|  d z"dD ]}|  d q4W |  d q |  d 0 q |  d q|  d	 d S )
Nr!   r   r9   r3  r.   r   rg   rC  rD  r/  )r   rc   r6  kr   r   r   &test_jump_out_of_complex_nested_blocks  s    


z3JumpTestCase.test_jump_out_of_complex_nested_blocks)r!   r,   r.   c                 C   sL   |  d t| d}|  d W d    n1 s40    Y  |  d d S Nr!   r,   r3   r.   rN  r   r   r   r   r    test_jump_out_of_with_assignment  s
    

(z-JumpTestCase.test_jump_out_of_with_assignmentc              	      s`   |  d t| d4 I d H  }|  d W d   I d H  qR1 I d H sH0    Y  |  d d S rl  rP  rm  r   r   r   &test_jump_out_of_async_with_assignment  s
    
4z3JumpTestCase.test_jump_out_of_async_with_assignment)r!   rA   r   r   c              	   C   s\   |  d z6|  d | s*W |  d d S |  d W |  d n|  d 0 |  d d S )Nr!   r9   r   rA   r   r/  r0  r   r   r   *test_jump_over_return_in_try_finally_block  s    


z7JumpTestCase.test_jump_over_return_in_try_finally_block)r!   r9   r   rg   rC     c              	   C   sr   |  d |  d z4|  d | s2W |  d qd|  d W |  d n|  d 0 |  d qdq
|  d d S )Nr!   r9   r.   rg   r   rC  rq  r/  r0  r   r   r   )test_jump_over_break_in_try_finally_block  s    




z6JumpTestCase.test_jump_over_break_in_try_finally_blockc                 C   sF   |  d | s$dD ]}|  d qn|  d |  d |  d d S Nr!   r4  r3   rA   r5   r   r/  r:  r   r   r   $test_jump_over_for_block_before_else  s    


z1JumpTestCase.test_jump_over_for_block_before_elsec                    sV   |  d | s4tdg2 z3 d H W }|  d q6 n|  d |  d |  d d S Nr!   r9   r3   rA   r5   r   r<  r:  r   r   r   *test_jump_over_async_for_block_before_else  s    


z7JumpTestCase.test_jump_over_async_for_block_before_elseZafterc                 C   s   |  d |  d d S r;   r/  r0  r   r   r   test_no_jump_too_far_forwards  s    
z*JumpTestCase.test_no_jump_too_far_forwardsrI   beforec                 C   s   |  d |  d d S r;   r/  r0  r   r   r   test_no_jump_too_far_backwards  s    
z+JumpTestCase.test_no_jump_too_far_backwardsexceptc                 C   s,   z|  d W n   |  d  Y n0 d S Nr,   r3   r/  r0  r   r   r   test_no_jump_to_except_1  s
    
z%JumpTestCase.test_no_jump_to_except_1c                 C   s2   z|  d W n ty,   |  d  Y n0 d S r{  r   r   r0  r   r   r   test_no_jump_to_except_2  s
    
z%JumpTestCase.test_no_jump_to_except_2c              
   C   sF   z|  d W n2 ty@ } z|  d |W Y d }~n
d }~0 0 d S r{  r}  r  r   r   r   test_no_jump_to_except_3  s
    
z%JumpTestCase.test_no_jump_to_except_3c              
   C   sJ   z|  d W n6 ttfyD } z|  d |W Y d }~n
d }~0 0 d S r{  )r   r   rZ   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!   r3  r9   r/  r:  r   r   r   $test_no_jump_forwards_into_for_block  s    
z1JumpTestCase.test_no_jump_forwards_into_for_blockc                    s4   |  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 )Nr3  r,   r9   r/  r:  r   r   r   %test_no_jump_backwards_into_for_block*  s    z2JumpTestCase.test_no_jump_backwards_into_for_blockc                    s4   t ddg2 z3 d H W }| d q6 | d d S r.  r9  r:  r   r   r   +test_no_jump_backwards_into_async_for_block0  s    z8JumpTestCase.test_no_jump_backwards_into_async_for_blockc                 C   sB   |  d t| d |  d W d    n1 s40    Y  d S r.  rN  r0  r   r   r   %test_no_jump_forwards_into_with_block6  s    
z2JumpTestCase.test_no_jump_forwards_into_with_blockc              	      sV   |  d t| d4 I d H   |  d W d   I d H  qR1 I d H sH0    Y  d S r.  rP  r0  r   r   r   +test_no_jump_forwards_into_async_with_block<  s    
z8JumpTestCase.test_no_jump_forwards_into_async_with_block)r!   r,   rq   c                 C   sB   t | d | d W d    n1 s*0    Y  | d d S r.  rJ  r0  r   r   r   &test_no_jump_backwards_into_with_blockB  s    (z3JumpTestCase.test_no_jump_backwards_into_with_blockc              	      sV   t | d4 I d H   | d W d   I d H  qH1 I d H s>0    Y  | d d S r.  rL  r0  r   r   r   ,test_no_jump_backwards_into_async_with_blockH  s    4z9JumpTestCase.test_no_jump_backwards_into_async_with_blockc              	   C   s4   |  d z|  d W |  d n|  d 0 d S rT  r/  r0  r   r   r   ,test_no_jump_forwards_into_try_finally_blockN  s    
z9JumpTestCase.test_no_jump_forwards_into_try_finally_blockc              	   C   s4   z|  d W |  d n|  d 0 |  d d S rR  r/  r0  r   r   r   -test_no_jump_backwards_into_try_finally_blockV  s    z:JumpTestCase.test_no_jump_backwards_into_try_finally_blockc                 C   s6   |  d z|  d W n   |  d  Y n0 d S rT  r/  r0  r   r   r   +test_no_jump_forwards_into_try_except_block^  s    

z8JumpTestCase.test_no_jump_forwards_into_try_except_blockc                 C   s6   z|  d W n   |  d  Y n0 |  d d S r   r/  r0  r   r   r   ,test_no_jump_backwards_into_try_except_blockg  s    
z9JumpTestCase.test_no_jump_backwards_into_try_except_blockc              
   C   sn   zdd  W nR t y2   | d | d Y n. ty^ } z| d W Y d }~n
d }~0 0 | d d S rX  rY  r  r   r   r   $test_no_jump_between_except_blocks_2q  s    
 z1JumpTestCase.test_no_jump_between_except_blocks_2c              	   C   s4   |  d z|  d W |  d n|  d 0 d S rT  r/  r0  r   r   r   test_jump_into_finally_block|  s    
z)JumpTestCase.test_jump_into_finally_block)r,   rA   r5   c              	   C   sR   z,|  d |  d W |  d |  d n|  d |  d 0 |  d d S )Nr,   r9   r.   rA   r5   r/  r0  r   r   r   +test_jump_into_finally_block_from_try_block  s    


z8JumpTestCase.test_jump_into_finally_block_from_try_block)r!   r9   r!   r9   r.   c              	   C   s4   |  d z|  d W |  d n|  d 0 d S rT  r/  r0  r   r   r   test_jump_out_of_finally_block  s    
z+JumpTestCase.test_jump_out_of_finally_blockzinto an 'except'c                 C   s4   |  d z|  d W n   |  d Y n0 d S rT  r/  r0  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 n ty4   |  d Y n0 d S rT  r   rL   r0  r   r   r   (test_no_jump_into_qualified_except_block  s
    
z5JumpTestCase.test_no_jump_into_qualified_except_block)r,   r.   rA   c                 C   sJ   z|  d |  d W n"   |  d |  d  Y n0 |  d d S Nr,   r9   r.   rA   r   r/  r0  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   sP   z|  d |  d W n( ty@   |  d |  d  Y n0 |  d d S r  )r   rZ  r0  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!   r9   rA   zout of an 'except'c                 C   sF   |  d z|  d dd  W n    |  d |  d Y n0 d S Nr!   r9   r   rA   r5   r/  r0  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 n& tyF   |  d |  d Y n0 d S r  r  r0  r   r   r   *test_no_jump_out_of_qualified_except_block  s    


z7JumpTestCase.test_no_jump_out_of_qualified_except_block)r!   r,   r.   rI   c                 C   sv   |  d t| d |  d W d    n1 s40    Y  t| d |  d W d    n1 sh0    Y  d S r^  rN  r0  r   r   r   test_jump_between_with_blocks  s
    
(z*JumpTestCase.test_jump_between_with_blocksc              	      s   |  d t| d4 I d H   |  d W d   I d H  qR1 I d H sH0    Y  t| d4 I d H   |  d W d   I d H  q1 I d H s0    Y  d S r^  rP  r0  r   r   r   #test_jump_between_async_with_blocks  s
    
4z0JumpTestCase.test_jump_between_async_with_blocksc              	   C   sV   z$|  d W |  d |  d d S |  d |  d    Y d S 0 |  d d S )Nr,   r3   r.   r5   r/  r0  r   r   r   -test_no_jump_over_return_out_of_finally_block  s    



z:JumpTestCase.test_no_jump_over_return_out_of_finally_blockc                 C   sF   |  d | s$dD ]}|  d qn|  d |  d |  d d S rs  r/  r:  r   r   r   'test_no_jump_into_for_block_before_else  s    


z4JumpTestCase.test_no_jump_into_for_block_before_elsec                    sV   |  d | s4tdg2 z3 d H W }|  d q6 n|  d |  d |  d d S ru  r<  r:  r   r   r   -test_no_jump_into_async_for_block_before_else  s    


z:JumpTestCase.test_no_jump_into_async_for_block_before_elsec                 C   s   |  tdddg d S )Nr,   ZSpamT)r   r  r   r   r   r   test_no_jump_to_non_integers   s    z)JumpTestCase.test_no_jump_to_non_integersc                 C   s
   t   d S 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   r,   i  r   )r   r   )r   dr   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   r  r   r   fake_function   s   r  r,   r   r   )r,   r9   r,   r9   r3   )compiler  rR   rS   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~   r!  c                    s*     d  fdd}|    d d S )Nr!   c                      s     d d S )Nr9   r/  r   r0  r   r   nested-  s    z3JumpTestCase.test_no_jump_from_call.<locals>.nestedr.   r/  )r   r  r   r0  r   test_no_jump_from_call)  s    
z#JumpTestCase.test_no_jump_from_callr(   z'can only jump from a 'line' trace eventc                 C   s   |  d d S r    r/  r0  r   r   r   test_no_jump_from_return_event2  s    
z+JumpTestCase.test_no_jump_from_return_eventrP   c                 C   s   |  d dd  d S )Nr!   r   r/  r0  r   r   r   !test_no_jump_from_exception_event8  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 )Nr,   r9   r/  r   r0  r   r   gen@  s    
z.JumpTestCase.test_jump_from_yield.<locals>.genr.   )r   r   )r   r  r   r0  r   test_jump_from_yield>  s    
z!JumpTestCase.test_jump_from_yieldc                 C   s*   |  d dd tdD }|  d d S )Nr!   c                 S   s   g | ]}|qS r   r   r   rc   r   r   r   r   I  r   z@JumpTestCase.test_jump_forward_over_listcomp.<locals>.<listcomp>rg   r9   r   r=   rm  r   r   r   test_jump_forward_over_listcompF  s    
z,JumpTestCase.test_jump_forward_over_listcompc                 C   s   d}dd t dD }d}d S )Nr!   c                 S   s   g | ]}|qS r   r   r  r   r   r   r   Q  r   zAJumpTestCase.test_jump_backward_over_listcomp.<locals>.<listcomp>rg   r9   r<   r   r>   r   cr   r   r    test_jump_backward_over_listcompN  s    z-JumpTestCase.test_jump_backward_over_listcomp)r,   r5   r,   c                 C   sD   d}|  d |rd S dd tdD }d}|  d |  d d S )	NFr,   c                 S   s   g | ]}|qS r   r   r  r   r   r   r   Z  r   zDJumpTestCase.test_jump_backward_over_listcomp_v2.<locals>.<listcomp>r.   rA   r5   r   r  r   flagr   r   r   r   #test_jump_backward_over_listcomp_v2T  s    

z0JumpTestCase.test_jump_backward_over_listcomp_v2c                    s4   |  d dd ttd2 I d H }|  d d S )Nr!   c                    s   g | z3 d H W }|q6 S r   r   r  r   r   r   r   b  r   zFJumpTestCase.test_jump_forward_over_async_listcomp.<locals>.<listcomp>rg   r9   r   r   r=   rm  r   r   r   %test_jump_forward_over_async_listcomp_  s    
z2JumpTestCase.test_jump_forward_over_async_listcompc                    s(   d}dd t td2 I d H }d}d S )Nr!   c                    s   g | z3 d H W }|q6 S r   r   r  r   r   r   r   h  r   zGJumpTestCase.test_jump_backward_over_async_listcomp.<locals>.<listcomp>rg   r9   )r   r=   r  r   r   r   &test_jump_backward_over_async_listcompe  s    z3JumpTestCase.test_jump_backward_over_async_listcompc                    sN   d}|  d |rd S dd ttd2 I d H }d}|  d |  d d S )	NFr,   c                    s   g | z3 d H W }|q6 S r   r   r  r   r   r   r   q  r   zJJumpTestCase.test_jump_backward_over_async_listcomp_v2.<locals>.<listcomp>r.   rA   r5   r   r  r  r   r   r   )test_jump_backward_over_async_listcomp_v2k  s    

z6JumpTestCase.test_jump_backward_over_async_listcomp_v2)Nr&   F)Nr&   F)Nr&   )Nr&   )br   r   r   r   r  r   r#  r,  r-  r1  r2  r7  r8  r;  r=  r>  r?  r@  rZ  rB  rE  r   rF  rG  rH  rI  rK  rM  rO  rQ  rS  rU  rV  rW  r\  r]  r_  r`  rb  rc  re  rf  rh  ri  rk  rn  ro  rp  rr  rt  rv  rw  ry  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  B  sp    
  






	






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

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

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

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



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















r  __main__).r&  r   ZunittestrR   r   r   	functoolsr   r"  r   r   r   r"   ru   r*   r0   r1   r7   r?   rC   rE   r$   rM   rN   rX   rY   r[   r\   r^   rd   re   rf   ri   rr   ZTestCaser   r   Zcpython_onlyr   r   r  r  r  r  r   mainr   r   r   r   <module>   s   


	
	






		



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