
    <e9                       d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlm	Z	 d dl
Z
d dlmZ  ej        d            G d d	          Z G d
 d          Zd Zd Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zg de_        d Zd Zg de_        d Zd Zg de_        d  Zd! Zd"ge_        d# Zd$ Z g d%e _        d& Z!g d'e!_        d( Z"g d)e"_        d* Z#g d+e#_        d, Z$d- Z%g d.d/d0gd1z  z   d/d2gz   e%_         G d3 d4          Z& G d5 d6ej'                  Z(g d7Z) G d8 d9e(          Z*ej+         G d: d;e(                      Z, G d< d=ej'                  Z- G d> d?          Z.d@ Z/dA Z0 G dB dCej'                  Z1 G dD dEej'                  Z2 G dF dGej'                  Z3e4dHk    r ej5                     dS dS )I    )supportN)	MagicMockwraps)import_helperT)modulec                   $    e Zd ZdZd Zd Zd ZdS )tracecontextz/Context manager that traces its enter and exit.c                 "    || _         || _        d S Noutputvalueselfr   r   s      -/usr/lib/python3.11/test/test_sys_settrace.py__init__ztracecontext.__init__       


    c                 D    | j                             | j                   d S r   r   appendr   r   s    r   	__enter__ztracecontext.__enter__   s     4:&&&&&r   c                 F    | j                             | j                    d S r   r   r   exc_infos     r   __exit__ztracecontext.__exit__   s"    DJ;'''''r   N)__name__
__module____qualname____doc__r   r   r    r   r   r
   r
      sG        99  ' ' '( ( ( ( (r   r
   c                   $    e Zd ZdZd Zd Zd ZdS )asynctracecontextz>Asynchronous context manager that traces its aenter and aexit.c                 "    || _         || _        d S r   r   r   s      r   r   zasynctracecontext.__init__   r   r   c                 H   K   | j                             | j                   d S r   r   r   s    r   
__aenter__zasynctracecontext.__aenter__!   s$      4:&&&&&r   c                 J   K   | j                             | j                    d S r   r   r   s     r   	__aexit__zasynctracecontext.__aexit__$   s&      DJ;'''''r   N)r   r    r!   r"   r   r(   r*   r#   r   r   r%   r%      sG        HH  ' ' '( ( ( ( (r   r%   c                   K   | D ]}|W V  dS )z0Convert an iterable to an asynchronous iterator.Nr#   )iterablexs     r   	asynciterr.   '   s,         r   c                      dS N   r#   r#   r   r   basicr2   .   s    1r   )r   callr1   liner1   returnc                      d} ~ 	 d} d S r0   r#   r-   s    r   arigo_example0r;   =       	A		AAAr   )r3   r5      r6      r6      r6   rB   r8   c                      d} ~ 	 d} d S r0   r#   r:   s    r   arigo_example1rE   K   r<   r   c                      d} ~ 	 d} d S r0   r#   r:   s    r   arigo_example2rG   Y   s    	A	 4r   )r3   r5   r=   r?      r6      r6   rK   r8   c                      d} ~ d} d S r0   r#   r:   s    r   one_instr_linerN   l   s    	A		AAAr   r3   r5   r=   r?   r@   r8   c                  <    d} t          d          D ]	}|rd} d} 
d S Nr1   r>   range)r-   as     r   no_pop_topsrV   w   s<    	A1XX   	AAAA	 r   )
r3   r5   r=   r?      r6   r=   r?   rH   r=   r>   r8   c                  $    d} | s	t            | 	d}d S r0   )bla)yr-   s     r   no_pop_blocksr]      s'    	A   	AAAr   r3   r5   r=   rH   rI   r8   c                  
    d} d S r0   r#   r:   s    r   calledra      s    	AAAr   c                  "    t                       d S r   )ra   r#   r   r   r4   r4      s    
HHHHHr   )r3   r5   r4   r6   rf   r8   r7   c                      t           r   	Exceptionr#   r   r   raisesrk      s    
Or   c                  F    	 t                       d S # t          $ r Y d S w xY wr   )rk   rj   r#   r   r   
test_raiserm      s6       s    
  )r3   r5   r=   rc   re   rf   	exceptionrg   r>   ro   r?   rH   r_   c                 h    t          j        |            | t          j                    j        _        d S r   )syssettrace	_getframef_backf_trace	tracefuncs    r   _settrace_and_returnry      s)    L%.CMOO"""r   c                 $    t          |            d S r   )ry   rw   s    r   settrace_and_returnr{      s    #####r   r7   c                 r    t          j        |            | t          j                    j        _        t
          r   )rr   rs   rt   ru   rv   RuntimeErrorrw   s    r   _settrace_and_raiser~      s)    L%.CMOO"
r   c                 H    	 t          |            d S # t          $ r Y d S w xY wr   )r~   r}   rw   s    r   settrace_and_raiser      s=    I&&&&&   s    
!!)rp   r?   rH   r_   c                  (    d} d}| |k    r| dz   }d S d S )NrB   r1   r#   )rU   bs     r   ireturn_exampler      s'    	A	AAvvaCr   r3   r5   r=   r?   rH   r_   c                  h    t          dd          } 	 d}	 | |         }|dz  }# t          $ r Y d S w xY w)Nr   r@   r1   rT   
IndexError)itemsir   s      r   tightloop_exampler      sV    !QKKE	aA!Q$!	   s   # 
11)r3   r5   r=   r?   rH   rA   rH   rA   rH   rA   rH   rA   )rB   ro   rW   rJ   rL   c                  \    t          dd          } 	 d}| |         }	# t          $ r Y d S w xY w)Nr1   rI   r   r   )r   r   s     r   tighterloop_exampler     sG    !QKKE1X   s    
++)r3   r5   r=   r?   rH   rH   rH   rH   )rI   ro   rA   rW   rX   r8   c               #       K   	 dV  	 d S # w xY wNTr#   r#   r   r   generator_functionr     s%      


					s    c                  d    t          t                                } t          d          D ]} | }d S )N
   )anyr   rT   )r-   r\   s     r   generator_exampler     s>      !!A 2YY   r   )
r3   r=   r4   r6   r6   r   r8   )r   r4   r   ro   r6   r   r8   rA   rW   r   rC   c                   (    e Zd ZddZd Zd Zd ZdS )TracerNc                 0    || _         || _        g | _        d S r   )trace_line_eventstrace_opcode_eventsevents)r   r   r   s      r   r   zTracer.__init__3  s    !2#6 r   c                 V    | j         | j         |_        | j        | j        |_        d S d S r   )r   f_trace_linesr   f_trace_opcodes)r   frames     r   _reconfigure_framezTracer._reconfigure_frame8  s8    !-"&"8E#/$($<E!!! 0/r   c                 |    |                      |           | j                            |j        |f           | j        S r   r   r   r   f_linenotracer   r   eventargs       r   r   zTracer.trace>  s;    &&&ENE2333zr   c                     |                      |           d dD              | j                            |j        |f           | j        S )Nc              3      K   | ]}|V  d S r   r#   ).0os     r   	<genexpr>z)Tracer.traceWithGenexp.<locals>.<genexpr>E  s"      qr   r1   r   r   s       r   traceWithGenexpzTracer.traceWithGenexpC  sO    &&&CENE2333zr   )NN)r   r    r!   r   r   r   r   r#   r   r   r   r   2  sU           
= = =  
    r   r   c                      e Zd Zd Zd Zed             Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z=d; Z>d< Z?d= Z@d> ZAd? ZBd@ ZCdA ZDdB ZEdC ZFeGjH        dD             ZIdE ZJeGjH        dF             ZKdG ZLdHS )ITraceTestCasec                     t          j                    | _        t          j                     |                     t
          j        t          j                               d S r   )gc	isenabledusing_gcdisable
addCleanuprr   rs   gettracer   s    r   setUpzTraceTestCase.setUpN  s<    

clnn55555r   c                 >    | j         rt          j                     d S d S r   )r   r   enabler   s    r   tearDownzTraceTestCase.tearDownS  s%    = 	IKKKKK	 	r   c                      t                      S )z@Helper to allow test subclasses to configure tracers differentlyr   r#   r   r   make_tracerzTraceTestCase.make_tracerW  s     xxr   c           
          fd|D             }||k    rT|                      dd                    t          j        d |D             d |D                                 z              d S d S )Nc                 $    g | ]\  }}|z
  |fS r#   r#   )r   leline_offsets      r   
<listcomp>z0TraceTestCase.compare_events.<locals>.<listcomp>]  s&    <<<6Aq1{?A&<<<r   z"events did not match expectation:

c                 ,    g | ]}t          |          S r#   strr   r-   s     r   r   z0TraceTestCase.compare_events.<locals>.<listcomp>a  s    (I(I(IAQ(I(I(Ir   c                 ,    g | ]}t          |          S r#   r   r   s     r   r   z0TraceTestCase.compare_events.<locals>.<listcomp>b  s    (@(@(@AQ(@(@(@r   )failjoindifflibndiff)r   r   r   expected_eventss    `  r   compare_eventszTraceTestCase.compare_events\  s    <<<<V<<<_$$II5		'-(I(I(I(I(I(@(@(@(@(@B B C CCD D D D D %$r   c                     |                                  }t          j        |j                    |             t          j        d            |                     |j        j        |j        |           d S r   )r   rr   rs   r   r   __code__co_firstlinenor   )r   funcr   tracers       r   run_and_comparezTraceTestCase.run_and_compared  sp    !!##V\"""TDM8"M6	3 	3 	3 	3 	3r   c                 <    |                      ||j                   d S r   )r   r   r   r   s     r   run_testzTraceTestCase.run_testl  s     T4;/////r   c                     |                                  } ||j                   t          j        d            |                     |j        j        |j        |j                   d S r   )r   r   rr   rs   r   r   r   r   )r   r   r   s      r   	run_test2zTraceTestCase.run_test2o  sg    !!##V\TDM8"M4;	8 	8 	8 	8 	8r   c                 .    t          j        d            d S r   rr   rs   r   s    r   test_set_and_retrieve_nonez(TraceTestCase.test_set_and_retrieve_nonev  s    Tr   c                     d }t          j        |           	 t          j        d            d S # t          j        d            w xY w)Nc                      d S r   r#   argss    r   fnz4TraceTestCase.test_set_and_retrieve_func.<locals>.fn{      Dr   r   )r   r   s     r   test_set_and_retrieve_funcz(TraceTestCase.test_set_and_retrieve_funcz  sV    	 	 	 	R	 LCLs   Ac                 :    |                      t                     d S r   )r   r2   r   s    r   test_01_basiczTraceTestCase.test_01_basic  s    er   c                 :    |                      t                     d S r   )r   r;   r   s    r   test_02_arigo0zTraceTestCase.test_02_arigo0      n%%%%%r   c                 :    |                      t                     d S r   )r   rE   r   s    r   test_02_arigo1zTraceTestCase.test_02_arigo1  r   r   c                 :    |                      t                     d S r   )r   rG   r   s    r   test_02_arigo2zTraceTestCase.test_02_arigo2  r   r   c                 :    |                      t                     d S r   )r   rN   r   s    r   test_03_one_instrzTraceTestCase.test_03_one_instr  r   r   c                 :    |                      t                     d S r   )r   r]   r   s    r   test_04_no_pop_blocksz#TraceTestCase.test_04_no_pop_blocks  s    m$$$$$r   c                 :    |                      t                     d S r   )r   rV   r   s    r   test_05_no_pop_topsz!TraceTestCase.test_05_no_pop_tops  s    k"""""r   c                 :    |                      t                     d S r   )r   r4   r   s    r   test_06_callzTraceTestCase.test_06_call  s    dr   c                 :    |                      t                     d S r   )r   rm   r   s    r   test_07_raisezTraceTestCase.test_07_raise  s    j!!!!!r   c                 :    |                      t                     d S r   )r   r{   r   s    r   test_08_settrace_and_returnz)TraceTestCase.test_08_settrace_and_return  s    *+++++r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_09_settrace_and_raisez(TraceTestCase.test_09_settrace_and_raise  s    )*****r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_10_ireturnzTraceTestCase.test_10_ireturn  s    o&&&&&r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_11_tightloopzTraceTestCase.test_11_tightloop  s    '(((((r   c                 :    |                      t                     d S r   )r   r   r   s    r   test_12_tighterloopz!TraceTestCase.test_12_tighterloop  s    )*****r   c                 B   |                      t                     |                                 }t          j        |j                   t                       t          j        d            |                     t          j        j        |j	        t          j	                   d S r   )
r   r   r   rr   rs   r   r   r   r   r   )r   r   s     r   test_13_genexpzTraceTestCase.test_13_genexp  s    '(((
 !!##V+,,,T-6E"M+<+C	E 	E 	E 	E 	Er   c                 <    d }|                      |g d           d S )Nc                  
    d} dS )NTFr   r#   r:   s    r   onlinersz2TraceTestCase.test_14_onliner_if.<locals>.onliners  s    Q1r   )r3   r5   r?   rP   r   )r   r  s     r   test_14_onliner_ifz TraceTestCase.test_14_onliner_if  sG    	 	 	 	  	 	 	 	 	r   c                 r    d }|                      |g d           d }|                      |g d           d S )Nc                  *    t          d          D ]} d S Nr>   rS   r:   s    r   for_examplez0TraceTestCase.test_15_loops.<locals>.for_example  s$    1XX   r   )r3   r5   r=   r5   r=   r5   r7   c                  0    d} | dk    r| dz  } | dk    d S d S )Nr>   r   r1   r#   r:   s    r   while_examplez2TraceTestCase.test_15_loops.<locals>.while_example  s,    Aa%%Q a%%%%%%r   )r3   r=   r?   rH   r?   rH   r?   rP   r  )r   r  r  s      r   test_15_loopszTraceTestCase.test_15_loops  s    	 	 	 	  	 	 		 	 	
 	  		 		 		 		 		r   c                 f    i }t          d|           |                     |d         g d           d S )Na  def f():
































































































































































































































































    passf)r3   )  r6   )r  r8   execr   )r   	namespaces     r   test_16_blank_linesz!TraceTestCase.test_16_blank_lines  sP    	3Y???cN  	 	 	 	 	r   c                 <    d }|                      |ddg           d S )Nc                  :    d t          j                    _        d} d S r  )rr   rt   rv   )linenos    r   r   z0TraceTestCase.test_17_none_f_trace.<locals>.func  s    &*CMOO#FFFr   r3   r5   r  r   s     r   test_17_none_f_tracez"TraceTestCase.test_17_none_f_trace  sB    	 	 	 	T	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  \    	 	 t           # t           $ r}  d } ~ ww xY w# t           $ r Y d S w xY wr   ri   )r   r-   r\   s      r   r   z4TraceTestCase.test_18_except_with_name.<locals>.func  sW    $#O  $ $ $$    s   
 
 
++)
r3   r5   r=   r?   r@   ro   rH   rA      r6   )	   r6   )r+  r8   r  r   s     r   test_18_except_with_namez&TraceTestCase.test_18_except_with_name  sF    		 		 		 	T	 	 	
	 
	 
	 
	 
	r   c                 <    d }|                      |g d           d S )Nc                  H    	 	 t           # d} w xY w# t           $ r d}Y d S w xY w)N	Something   ri   )r\   r   s     r   r   z7TraceTestCase.test_19_except_with_finally.<locals>.func  sE    $#O#AOOOO   s   
  !!)	r3   r5   r=   r?   r(  rA   rW   rJ   rL   r  r   s     r   test_19_except_with_finallyz)TraceTestCase.test_19_except_with_finally  sF    	 	 	 	T  		 		 		 		 		r   c                      G d d          fdfd}|                                  }g d}	  ||j                   n# t          $ r Y nw xY w|                     j        j        |j        |           d S )Nc                        e Zd Zd Zd Zd ZdS )BTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapperc                 .    t          |          | _        d S r   )iter_it)r   objs     r   r   zKTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__init__  s    99r   c                     | S r   r#   r   s    r   	__aiter__zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__aiter__      r   c                 Z   K   	 t          | j                  S # t          $ r t          w xY wr   )nextr7  StopIterationStopAsyncIterationr   s    r   	__anext__zLTraceTestCase.test_20_async_for_loop.<locals>.AsyncIteratorWrapper.__anext__!  s:      ->>)$ - - -,,-s    *N)r   r    r!   r   r:  r@  r#   r   r   AsyncIteratorWrapperr4    sA        % % %  - - - - -r   rA  c                  <   K    d          2 3 d {V } | }
6 d}d S )Nabc*   r#   )letterr-   r\   rA  s      r   
doit_asyncz8TraceTestCase.test_20_async_for_loop.<locals>.doit_async'  sO       4 4U ; ;       f !<AAAs   c                                  }	 t          j        |            |                    d            t          j        d            d S # t          j        d            w xY wr   )rr   rs   send)r   r-   rF  s     r   runz1TraceTestCase.test_20_async_for_loop.<locals>.run,  s^    
A#V$$$tT"""""T""""s   )A A")(r3   r5   )ir4   )r6   )rJ  r8   ir4   r6   rM  r8   r   r   r   r   r1   ro   r=   r5   r   r   r   r   rO  r=   r5   r   r   r   r   rO  r=   r5   r   r   r   r   rd   r6   re   rn   rg   rO  r?   rP   )r   r   rj   r   r   r   r   )r   rI  r   r   rA  rF  s       @@r   test_20_async_for_loopz$TraceTestCase.test_20_async_for_loop  s    	- 	- 	- 	- 	- 	- 	- 	-	 	 	 	 	
	# 	# 	# 	# 	# !!##( ( (R	C 	 	 	D	J/>"M6	3 	3 	3 	3 	3s   A 
AAc                    d fd}|                                  } |            }	 t          j        |j                   |                    d            n# t
          $ r Y nw xY wt          j        d            n# t          j        d            w xY wg d}|                     |j        j        |j	        |           d S )Nc                8   K   t          |           D ]}|W V  d S r   rS   )nr   s     r   arangezGTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.arangef  s2      1XX   r   c                  F   K    d          2 3 d {V } | dk    r d S 6 d S )Nr@   d   r#   )r   rU  s    r   r  zBTraceTestCase.test_async_for_backwards_jump_has_no_line.<locals>.fi  sU      !6!99       as77EE  %99s    )r3   r5   rc   re   r   r   rO  r=   r5   r   r4   re   r   r   rO  r=   r5   rX  re   r   r   rO  r=   r5   rX  re   rg   rO  r7   )
r   rr   rs   r   rH  rj   r   r   r   r   )r   r  r   coror   rU  s        @r   )test_async_for_backwards_jump_has_no_linez7TraceTestCase.test_async_for_backwards_jump_has_no_linee  s    	 	 		 	 	 	 	
 !!##qss	L&&&IIdOOOO 	 	 	D	 LCL
 
 
< 	AJ5"M6	3 	3 	3 	3 	3s)   .A A= 
A%"A= $A%%A= =Bc                 <    d }|                      |g d           d S )Nc                      	 d S r   r#   r#   r   r   r   z1TraceTestCase.test_21_repeated_pass.<locals>.func  s
    Dr   r3   r5   r=   rY   r  r   s     r   test_21_repeated_passz#TraceTestCase.test_21_repeated_pass  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  "    	 dD ]} dS #  Y dS xY w)Nr#   r1   r>   r#   r   s    r   r   z3TraceTestCase.test_loop_in_try_except.<locals>.func  s)    !!AAqqqs   	 rO   r  r   s     r   test_loop_in_try_exceptz%TraceTestCase.test_loop_in_try_except  sF    	 	 	 	T  	 	 	 	 	r   c                 B    fd|                      g d           d S )Nc                  D    	 	 	 	 	  j         dk    r	 n#  Y nxY wd S # w xY wNFFred)r   r   s   r   r   z8TraceTestCase.test_try_except_no_exception.<locals>.func  sI      =F** s     	r3   r5   r=   rW   rJ   r   r6      r6      r6   rm  r8   r  r   s    @r   test_try_except_no_exceptionz*TraceTestCase.test_try_except_no_exception  Q    	 	 	 	 	  	T  		 		 		 		 		r   c                 <    d }|                      |g d           d S )Nc                  R    	 	 	 	 t           #  Y nxY w	 n# w xY wn#  Y nxY wd S # w xY wr   ri   r#   r   r   r   z6TraceTestCase.test_try_exception_in_else.<locals>.func  sU     #O	AA
 BBBBBs(       $ $ &)r3   r5   r=   r?   rJ   r)  )r*  ro   ri  rj     r6   rl  rn  r  r   s     r   test_try_exception_in_elsez(TraceTestCase.test_try_exception_in_else  sF    	 	 	  	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  `    t          d          D ]} t          d          D ]}| |z   }|dk    S )Nr>   r1   rS   )r   jrU   s      r   r   z-TraceTestCase.test_nested_loops.<locals>.func  sE    1XX  q  AAAA6Mr   )r3   r5   r=   r?   r=   r?   r=   r5   r=   r?   r=   r?   r=   r5   rH   r_   r  r   s     r   test_nested_loopszTraceTestCase.test_nested_loops  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  H    ddg} | r|                                  }|rn| d}|S )Nr1   r   c   pop)seqrT  s     r   r   z)TraceTestCase.test_if_break.<locals>.func  sA    a&C GGII   
 Hr   )r3   r5   r=   r?   rH   r=   r?   rH   rA   r)  r*  r8   r  r   s     r   test_if_breakzTraceTestCase.test_if_break  sF    	 	 	 	T
 
 
	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      d\  } }}}	 t          d          D ]}	 d} |dk    r	 d} d S d} d}# d}w xY wd S #  d}Y d S xY w)N)r1   r1   r1   r|  r@   rB   r   r   r*  rt  rS   )rU   cdr   s       r   r   z6TraceTestCase.test_break_through_finally.<locals>.func'  s    $JAq!Q
q  Aq55!  B s    7 .7 .7 27 >)r3   r5   r=   r?   rH   rA   rW   r)  ri  r?   rH   rA   rW   rJ   ri     r6   r  r8   r  r   s     r   test_break_through_finallyz(TraceTestCase.test_break_through_finally%  sF    	1 	1 	1 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      d\  } }}}}	 t          d          D ]}	 d} |dk    r	 d}d}d}# d}w xY wd S #  d}Y d S xY w)N)r1   r1   r1   r1   r|  r>   rB   r   r   r*  rt  rS   )rU   r   r  r  r   s        r   r   z9TraceTestCase.test_continue_through_finally.<locals>.funcK  s    *MAq!Q
q  Aq55$  B s    6 -6 -6 16 =)r3   r5   r=   r?   rH   rA   rW   r)  ri  r?   rH   rA   rW   rJ   ri  r?   r  r  r  r   s     r   test_continue_through_finallyz+TraceTestCase.test_continue_through_finallyI  sF    	1 	1 	1 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      	 	 dS # w xY wr  r#   r#   r   r   r   z7TraceTestCase.test_return_through_finally.<locals>.funcp  s    s   r^   r  r   s     r   test_return_through_finallyz)TraceTestCase.test_return_through_finallyn  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  D    	 ddz   n# t           $ r Y nw xY wdS #  Y dS xY w)Nr>   r   rX   )r   r#   r   r   r   z;TraceTestCase.test_try_except_with_wrong_type.<locals>.func  sH    !    qqqqqqqqs     
  )r3   r5   r=   rp   r?   rW   r   r  r   s     r   test_try_except_with_wrong_typez-TraceTestCase.test_try_except_with_wrong_type}  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  D    d} dg}|r|                                  | r	 d S r0   r}  TRUEr-   s     r   r   z3TraceTestCase.test_break_to_continue1.<locals>.func  s;    DA  	 r   )
r3   r5   r=   r?   rH   rA   rW   rJ   r?   rP   r  r   s     r   test_break_to_continue1z%TraceTestCase.test_break_to_continue1  sF    	 	 	 	T	 	 	
	 
	 
	 
	 
	r   c                 <    d }|                      |g d           d S )Nc                  L    d} dg}|r|                                  | rn|d S d S r0   r}  r  s     r   r   z3TraceTestCase.test_break_to_continue2.<locals>.func  sO    DA        r   )	r3   r5   r=   r?   rH   rA   rW   r?   rP   r  r   s     r   test_break_to_continue2z%TraceTestCase.test_break_to_continue2  sF    	 	 	 	T  		 		 		 		 		r   c                 <    d }|                      |g d           d S )Nc                      d} | r| r	 d S d S r0   r#   )r  s    r   r   z/TraceTestCase.test_break_to_break.<locals>.func  s)    D   r   )r3   r5   r=   r?   rH   rA   rC   r  r   s     r   test_break_to_breakz!TraceTestCase.test_break_to_break  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  :    dx} }| dk    r|dk    rd}d S d}d S d}d S )Nr1   rI   rX   r*  r#   )rU   r   r-   r\   zs        r   r   z+TraceTestCase.test_nested_ifs.<locals>.func  s8    IAAvv66AAAAAAr   r   r  r   s     r   test_nested_ifszTraceTestCase.test_nested_ifs  sF    	 	 	 	T  	 	 	 	 	r   c                 V    fd}dxd|                      |g d           d S )Nc                  V     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F)ABCs   r   r   z4TraceTestCase.test_nested_ifs_with_and.<locals>.func  sk      ! ) )#(5) )) ) !5 q t   r   TFrO   r  )r   r   r  r  r  s     @@@r   test_nested_ifs_with_andz&TraceTestCase.test_nested_ifs_with_and  sk    		 		 		 		 		 		 		 AT  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  d    d} 	 ddz   n$# t           $ r | dk    rt                      Y nw xY wd}d S )Nhellor@   r   raiserK   )ZeroDivisionError
ValueError)r-   r  s     r   r   z.TraceTestCase.test_nested_try_if.<locals>.func  sW    A'!$ ' ' '<<$,,&  <' AAAs   
 ++	r3   r5   r=   r?   r(  rH   rA   rJ   rL   r  r   s     r   test_nested_try_ifz TraceTestCase.test_nested_try_if  F    	 	 	 	T  		 		 		 		 		r   c                 \     G d d          fd}|                      |g d           d S )Nc                       e Zd Zd Zd ZdS ).TraceTestCase.test_if_false_in_with.<locals>.Cc                     | S r   r#   r   s    r   r   z8TraceTestCase.test_if_false_in_with.<locals>.C.__enter__  r;  r   c                      d S r   r#   r   s    r   r   z7TraceTestCase.test_if_false_in_with.<locals>.C.__exit__      r   Nr   r    r!   r   r   r#   r   r   r  r    2              r   r  c                  P                  5  	 d d d            d S # 1 swxY w Y   d S r   r#   r  s   r   r   z1TraceTestCase.test_if_false_in_with.<locals>.func  sx                       s   )r3   r5   r   r4   r   r   r=   r5   rc   re   rg   r7   r  )r   r   r  s     @r   test_if_false_in_withz#TraceTestCase.test_if_false_in_with  sy    	 	 	 	 	 	 	 		 	 	 	 	
 	T
 
 
	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  8    	 d S # t           $ r t           Y d S w xY wr   )rj   Xr#   r   r   r   z7TraceTestCase.test_if_false_in_try_except.<locals>.func-  s7        s   r]  r  r   s     r   test_if_false_in_try_exceptz)TraceTestCase.test_if_false_in_try_except+  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                        G d d          } d S )Nc                   &    e Zd Zddk     rdZdS dZdS )DTraceTestCase.test_implicit_return_in_class.<locals>.func.<locals>.Ar@   r+  r1   r>   N)r   r    r!   rU   r#   r   r   r  r  =  s%        q55AAAAAAr   r  r#   )r  s    r   r   z9TraceTestCase.test_implicit_return_in_class.<locals>.func<  s4             r   r3   r5   )r1   r4   r5   r=   r?   rP   r7   r  r   s     r   test_implicit_return_in_classz+TraceTestCase.test_implicit_return_in_class:  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  \    	 	 d S # t           $ r} Y d } ~ d S d } ~ ww xY w# t           $ r Y d S w xY wr   ri   exs    r   r   z+TraceTestCase.test_try_in_try.<locals>.funcN  s_    D    DDDDD   s   
  
++rO   r  r   s     r   test_try_in_tryzTraceTestCase.test_try_in_tryM  sF    	 	 	 	T  	 	 	 	 	r   c                 r    d }|                      |g d           d }|                      |g d           d S )Nc                  f    	 	 t           # t          $ r} Y d } ~ d S d } ~ ww xY w# t           $ r Y d S w xY wr   )	TypeErrorr  r  s    r   r   z:TraceTestCase.test_try_in_try_with_exception.<locals>.func`  s_    #O!   AAAAA      
 
" " 
00	r3   r5   r=   r?   r(  rH   rW   rJ   rL   c                  f    	 	 t           # t           $ r} Y d } ~ d S d } ~ ww xY w# t          $ r Y d S w xY wr   r  r  r  s    r   r   z:TraceTestCase.test_try_in_try_with_exception.<locals>.funct  s`    $$!   AAAAA   r  )r3   r5   r=   r?   r(  rH   rA   rC   r  r   s     r   test_try_in_try_with_exceptionz,TraceTestCase.test_try_in_try_with_exception^  s    	 	 	 	T  		 		 			 	 	 	T  	 	 	 	 	r   c                 >    dd}|                      |g d           d S )Nr   r1   c                     |r
| r|rd S d S d S d S r   r#   )rU   pr  s      r   r   z/TraceTestCase.test_if_in_if_in_if.<locals>.func  s5       	  r   r]  )r   r1   r1   r  r   s     r   test_if_in_if_in_ifz!TraceTestCase.test_if_in_if_in_if  sK    	 	 	 	 	T  	 	 	 	 	r   c                      G d d          fd}fd}|                      |g d           |                      |g d           d S )Nc                       e Zd Zd Zd ZdS )-TraceTestCase.test_early_exit_with.<locals>.Cc                     | S r   r#   r   s    r   r   z7TraceTestCase.test_early_exit_with.<locals>.C.__enter__  r;  r   c                      d S r   r#   r   s    r   r   z6TraceTestCase.test_early_exit_with.<locals>.C.__exit__  r  r   Nr  r#   r   r   r  r    r  r   r  c                  Z    dD ]&}              5  	 d d d             n# 1 swxY w Y   'd S )Nr1   r>   r#   )r   r  s    r   
func_breakz6TraceTestCase.test_early_exit_with.<locals>.func_break  s      QSS                  Ds   #	#	c                  P                  5  	 d d d            d S # 1 swxY w Y   d S r   r#   r  s   r   func_returnz7TraceTestCase.test_early_exit_with.<locals>.func_return  sv                       s   )r3   r5   r=   r  r   r   r?   r=   rc   re   rg   rH   r_   )r3   r5   )rJ  r4   )r6   )r  r8   r=   r5   rK  rL  rN  r7   r  )r   r  r  r  s      @r   test_early_exit_withz"TraceTestCase.test_early_exit_with  s    	 	 	 	 	 	 	 		 	 	 	 		 	 	 	 	 	Z  	 	 	 	[
 
 
	 	 	 	 	r   c                 H    d fd}|                      |g d           d S )Nc                 >    | r	 d| dz
  z   n# t           $ r Y nw xY w| S r0   r  r:   s    r   fooz;TraceTestCase.test_flow_converges_on_same_line.<locals>.foo  sC     q1uIII(   DHs    
c                  B    t          d          D ]}  |            d S r  rS   )r   r  s    r   r   z<TraceTestCase.test_flow_converges_on_same_line.<locals>.func  s1    1XX  A r   )r3   r5   r=   rM  r4   ir6   re   rg   r5   r=   r  r  )r   r6   r   )r   ro   r   rP  re   rg   r5   r7   r  )r   r   r  s     @r    test_flow_converges_on_same_linez.TraceTestCase.test_flow_converges_on_same_line  s`    	 	 		 	 	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  L    d} 	 d| z   n# t           $ r}| r Y d }~nd }~ww xY wdS )Nr   r1   doner  )r-   errors     r   r   zCTraceTestCase.test_no_tracing_of_named_except_cleanup.<locals>.func  sa    A!$         6s   
 
!!r  r  r   s     r   'test_no_tracing_of_named_except_cleanupz5TraceTestCase.test_no_tracing_of_named_except_cleanup  sF    	 	 	 	T	 	 			 		 		 		 		r   c                 \     G d d          fd}|                      |g d           d S )Nc                       e Zd Zd Zd ZdS )DTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtxc                     | S r   r#   r   s    r   r   zNTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtx.__enter__  r;  r   c                     d S r   r#   )r   excinfos     r   r   zMTraceTestCase.test_tracing_exception_raised_in_with.<locals>.NullCtx.__exit__  r  r   Nr  r#   r   r   NullCtxr    r  r   r  c                  |    	               5  ddz   d d d            d S # 1 swxY w Y   d S # t           $ r Y d S w xY wNr1   r   r  )r  s   r   r   zATraceTestCase.test_tracing_exception_raised_in_with.<locals>.func  s    WYY  aCC                 $   s$   
-  - $- $- 
;;)r3   r5   r=   r  r   r   r?   r(  r=   rc   re   rg   rH   rA   rC   r  )r   r   r  s     @r   %test_tracing_exception_raised_in_withz3TraceTestCase.test_tracing_exception_raised_in_with   sy    	 	 	 	 	 	 	 		 	 	 	 	 	T  	 	 	 	 	r   c                 B    fd|                      g d           d S )Nc                  v    	 n!# xg ct           % x n nn X x Y ncY w xY w	 	 	  j        dk    r	 d S # w xY wre  )rj   r   rg  s   r   r   z=TraceTestCase.test_try_except_star_no_exception.<locals>.func"  sx      I      =F**s   6 "6 8rh  r  r   s    @r   !test_try_except_star_no_exceptionz/TraceTestCase.test_try_except_star_no_exception   rp  r   c                 <    d }|                      |g d           d S )Nc                  d    	 n'# xg ct           % x} d } ~ nd } ~  nn X x Y ncY w xY w	 d S # w xY wr   ri   r   s    r   r   zCTraceTestCase.test_try_except_star_named_no_exception.<locals>.func?  sf      I     s   - '	- /)r3   r5   r=   rW   r)  r  r  r   s     r   'test_try_except_star_named_no_exceptionz5TraceTestCase.test_try_except_star_named_no_exception=  sF    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  r    	 t          d          # xg ct           % x n nn X x Y ncY w xY wd S # w xY wr  r  r#   r   r   r   zATraceTestCase.test_try_except_star_exception_caught.<locals>.funcS  sc     mm#  J    
 s    /4 6r3   r5   r=   rp   r?   rH   r)  r  r  r   s     r   %test_try_except_star_exception_caughtz3TraceTestCase.test_try_except_star_exception_caughtQ  F    	 	 	 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                  ~    	 t          d          # xg ct           % x} d } ~ nd } ~  nn X x Y ncY w xY wd S # w xY wr  r  r  s    r   r   zGTraceTestCase.test_try_except_star_named_exception_caught.<locals>.funci  sl     mm#  J    
 s    5: <r  r  r   s     r   +test_try_except_star_named_exception_caughtz9TraceTestCase.test_try_except_star_named_exception_caughtg  r
  r   c                 <    d }|                      |g d           d S )Nc                      	 	 t          d          # xg ct          % x n nn X x Y d S cY w xY w# t           $ r Y d S w xY wNr@   r  r#   r   r   r   zETraceTestCase.test_try_except_star_exception_not_caught.<locals>.func  s    $Q--'  	    A       s    14 4 
AAr  r  r   s     r   )test_try_except_star_exception_not_caughtz7TraceTestCase.test_try_except_star_exception_not_caught}  r  r   c                 <    d }|                      |g d           d S )Nc                      	 	 t          d          # xg ct          % x} d } ~ nd } ~  nn X x Y d S cY w xY w# t           $ r Y d S w xY wr  r  r  s    r   r   zKTraceTestCase.test_try_except_star_named_exception_not_caught.<locals>.func  s    $Q--'  	    AAAA       s    7: : 
AAr  r  r   s     r   /test_try_except_star_named_exception_not_caughtz=TraceTestCase.test_try_except_star_named_exception_not_caught  r  r   c                 <    d }|                      |g d           d S )Nc                     	 	 t          dt          d          t          d          g          # xg ct          % x} d } ~ nd } ~  nn t          % x n nn t          % x   n X x Y ncY w xY wnh# xg ct          % xM 	 t          d          # xg ct          % x n nn t          % x} d } ~ nd } ~  nn X x Y ncY w xY wn nn X x Y ncY w xY wdS )NegrB   zbad typerm  r   )ExceptionGroupr  r  OSErrorr  s    r   r   z7TraceTestCase.test_try_except_star_nested.<locals>.func  s   	(#A	*(=(=>@ @ @  	    AAAA    A"      J    #B--'      B!    BBBB 1s9   ,/ 4A2#A$	$	A2-A6 6CB/CC	C)r3   r5   r=   r?   rH   rA   r?   r(  rW   rJ   r)  ri  rj  rs  r  rl  )rm  ro   )   r6   )   r6   )   r6   )   r6   )r  r8   r  r   s     r   test_try_except_star_nestedz)TraceTestCase.test_try_except_star_nested  sF    	 	 	* 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                      	 d  d S )Nc                     dS r  r#   r:   s    r   <lambda>zATraceTestCase.test_notrace_lambda.<locals>.func.<locals>.<lambda>  s    a r   r#   r#   r   r   r   z/TraceTestCase.test_notrace_lambda.<locals>.func  s    KKAr   rO   r  r   s     r   test_notrace_lambdaz!TraceTestCase.test_notrace_lambda  sF    	 	 	
 	T  	 	 	 	 	r   c                 <    d }|                      |g d           d S )Nc                        G d d          } d S )Nc                       e Zd ZdZd ZdS )PTraceTestCase.test_class_creation_with_docstrings.<locals>.func.<locals>.Class_1z the docstring. 2c                     d| _         dS )z Another docstring. 4rB   N)rU   r   s    r   r   zYTraceTestCase.test_class_creation_with_docstrings.<locals>.func.<locals>.Class_1.__init__  s    DFFFr   N)r   r    r!   r"   r   r#   r   r   Class_1r'    s)        ''    r   r)  r#   )r)  s    r   r   z?TraceTestCase.test_class_creation_with_docstrings.<locals>.func  s4             r   r  r  r   s     r   #test_class_creation_with_docstringsz1TraceTestCase.test_class_creation_with_docstrings  sF    	 	 	 	T  	 	 	 	 	r   c                 @   t          j        d          }d fd}g d}g }|                    |            |             t          j        d            |j        j        fd|D             }|                     ||           |                     ||           d S )N	_testcapic               3      K   dV  d S r0   r#   r#   r   r   genzFTraceTestCase.test_no_line_event_after_creating_generator.<locals>.gen  s      GGGGGr   c                  "                 D ]} d S r   r#   )_r.  s    r   r   zGTraceTestCase.test_no_line_event_after_creating_generator.<locals>.func  s'       r   )r3   r=   r5   rc   re   rg   rH   r5   )rf   r4   rg   r7   c                 <    g | ]\  }}}|z
  t           |         fS r#   )EVENT_NAMES)r   whatr6   r   
start_lines       r   r   zMTraceTestCase.test_no_line_event_after_creating_generator.<locals>.<listcomp>  s=     
 
 
!tS *_k$/0
 
 
r   )	r   import_modulesettrace_to_recordrr   rs   r   r   assertEqualr   )r   r,  r   EXPECTED_EVENTSr   r.  r4  s        @@r   +test_no_line_event_after_creating_generatorz9TraceTestCase.test_no_line_event_after_creating_generator  s    
 "/<<		 	 		 	 	 	 	
 
 
  $$V,,,ddfffcl46H6H6H]1

 
 
 
%+
 
 
 	111T?33333r   c                 *   dfd}	 |t          j                    _        t          j        |           t	          g            |                     d           n# t          $ r~}d}|j        }t          |           |r#|j	        j
        j        dk    r|dz  }|j        }|#|dk    r|                     d           n|dk    r|                     d           Y d }~nd }~ww xY wt          j        d            d S # t          j        d            w xY w)	NFc                 (    s	dt           t          S r   )rj   r  )r   r   r   raiseds      r   
error_oncez5TraceTestCase.test_settrace_error.<locals>.error_once)  s      Lr   No exception raisedr   test_settrace_errorr1   Traceback is missing frame"Traceback has frame more than once)rr   rt   rv   rs   lenr   rj   __traceback__printtb_framef_codeco_nametb_next)r   r=  r  counttbr<  s        @r   r?  z!TraceTestCase.test_settrace_error&  sJ   	 	 	 	 		&0CMOO#L$$$GGG II+,,,,  	@ 	@ 	@E!B"III  ;%-1FFFQJEZ    zz		67777		>???	@ LCLs0   ;A C< 
C#%A4CC< C##C< <Dc                    t          j        d          }	 |                    g            t          g            |                     d           n|# t
          $ ro}d}|j        }|r#|j        j        j	        dk    r|dz  }|j
        }|#|dk    r|                     d           n|dk    r|                     d           Y d }~nd }~ww xY wt          j        d            d S # t          j        d            w xY w)Nr,  r>  r   test_testcapi_settrace_errorr1   r@  rA  )r   r5  settrace_to_errorrB  r   rj   rC  rE  rF  rG  rH  rr   rs   )r   r,  r  rI  rJ  s        r   rL  z*TraceTestCase.test_testcapi_settrace_errorE  s(    "/<<		''+++GGG II+,,,,  
	@ 
	@ 
	@E!B  ;%-1OOOQJEZ    zz		67777		>???
	@ LCLs/   $A C" 
C	A%C?C" C		C" "C8c                 |    i }t          dddz  d|           |d         }g d}|                     ||           d S )Nzdef f():              # line 0
            x = 0                     # line 1
            y = 1                     # line 2
            r   i   zn                        # lines 3 through (1 << 16)
            x += 1                    #
            returnr  )r3   r5   r=   )i  r6   )  r6   )rO  r8   r  )r   r  r  r8  s       r   test_very_large_functionz&TraceTestCase.test_very_large_function^  so    
 ))),
 ./	0 	0 	0 cF
 
 
 	Q00000r   N)Mr   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,  r1  rQ  rZ  r^  rb  ro  ru  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   cpython_onlyr9  r?  rL  rP  r#   r   r   r   r   J  s}       6 6 6
     \D D D3 3 30 0 08 8 8& & &    & & && & && & && & &% % %# # #  " " ", , ,+ + +' ' ') ) )+ + +E E E
 
 
  >      0  *J3 J3 J3X23 23 23h	 	 	  "  :  @  4  2" " "H# # #J    &  .  .  $  (  .  ,  4    &  "' ' 'R  ", , ,\" " "H  ,  @  :  (  ,  ,  ,  ,- - -^    & )4 )4 )4V  >   01 1 1 1 1r   r   )r4   ro   r6   r8   c                   8     e Zd ZdZ fdZed             Z xZS )SkipLineEventsTraceTestCasez8Repeat the trace tests, but with per-line events skippedc                 f    d |D             }t                                          |||           d S )Nc                 *    g | ]}|d          dk    |S r5   r#   r   r   s     r   r   z>SkipLineEventsTraceTestCase.compare_events.<locals>.<listcomp>  s!    III!!A$&..A...r   )superr   )r   r   r   r   skip_line_events	__class__s        r   r   z*SkipLineEventsTraceTestCase.compare_events  s:    IIIII{F4DEEEEEr   c                  "    t          d          S )NF)r   r   r#   r   r   r   z'SkipLineEventsTraceTestCase.make_tracer  s    ....r   r   r    r!   r"   r   rQ  r   __classcell__rZ  s   @r   rT  rT  }  s^        BBF F F F F / / \/ / / / /r   rT  c                   8     e Zd ZdZ fdZed             Z xZS )TraceOpcodesTestCasez;Repeat the trace tests, but with per-opcodes events enabledc                     d |D             }t          |          dk    r2|                     t          |          t          |          d           t                                          |||           d S )Nc                 *    g | ]}|d          dk    |S )r1   opcoder#   rW  s     r   r   z7TraceOpcodesTestCase.compare_events.<locals>.<listcomp>  s&    DDDA1Q483C3Ca3C3C3Cr   r1   z)No 'opcode' events received by the tracer)msg)rB  
assertLessrX  r   )r   r   r   r   skip_opcode_eventsrZ  s        r   r   z#TraceOpcodesTestCase.compare_events  s}    DDDDDv;;??OOC 233S[[ K  M M M{,>PPPPPr   c                  "    t          d          S )NT)r   r   r#   r   r   r   z TraceOpcodesTestCase.make_tracer  s    $////r   r\  r^  s   @r   r`  r`    s^        EEQ Q Q Q Q 0 0 \0 0 0 0 0r   r`  c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )RaisingTraceFuncTestCasec                 h    |                      t          j        t          j                               d S r   r   rr   rs   r   r   s    r   r   zRaisingTraceFuncTestCase.setUp  s$    clnn55555r   c                 4    || j         k    rt          | j        S )zXA trace function that raises an exception in response to a
        specific trace event.)raiseOnEventr  r   r   s       r   r   zRaisingTraceFuncTestCase.trace  s      D%%%:r   c                 .    | j         dk    r	d}d|z  }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.ro   r   r1   N)rm  )r   r-   r\   s      r   r  zRaisingTraceFuncTestCase.f  s)     ++A!AAA1r   c                 T   || _         	 t          t          j                    dz             D ]U}t          j        | j                   	 |                                  |                     d           F# t          $ r Y Rw xY wdS # t          $ r |                     d           Y dS w xY w)zTTests that an exception raised in response to the given event is
        handled OK.r1   zexception not raised!zrecursion counter not resetN)
rm  rT   rr   getrecursionlimitrs   r   r  r   r  r}   )r   r   r   s      r   run_test_for_eventz+RaisingTraceFuncTestCase.run_test_for_event  s     "
	53022Q677 7 7TZ(((7FFHHH II56666 "   D	7 7  	5 	5 	5II3444444	5s5   >B A2B 2
A?<B >A??B B'&B'c                 0    |                      d           d S )Nr4   rq  r   s    r   	test_callz"RaisingTraceFuncTestCase.test_call      '''''r   c                 0    |                      d           d S Nr6   rs  r   s    r   	test_linez"RaisingTraceFuncTestCase.test_line  ru  r   c                 0    |                      d           d S )Nr8   rs  r   s    r   test_returnz$RaisingTraceFuncTestCase.test_return  s    )))))r   c                 0    |                      d           d S Nro   rs  r   s    r   test_exceptionz'RaisingTraceFuncTestCase.test_exception  s    ,,,,,r   c                     d fdt          j                   	               |                     d           d S # t          $ r dd l} |j                     Y d S w xY w)Nc                  H    t          d          D ]} t          |            d S )NrB   )rT   rD  ra  s    r   r  z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.f  s.    1XX  a r   c                 b    |dk    r'| j         j        j        dz   k    rt          d          S )Nr6   r>   zi am crashing)r   r   r   r}   )r   whyextrar  gs      r   r  z4RaisingTraceFuncTestCase.test_trash_stack.<locals>.g  s6    v!*";a"???"?333Hr   zexception not propagatedr   )rr   rs   r   r}   r   collect)r   r   r  r  s     @@r   test_trash_stackz)RaisingTraceFuncTestCase.test_trash_stack  s    	 	 		 	 	 	 	 	 	Q	2ACCC II011111  	 	 	IIIBJLLLLLL	s   
A A#"A#c                      d } fdt          j                    }	 t          j                   	  |             n# t          $ r Y nw xY wt          j        |           d S # t          j        |           w xY w)Nc                      d} | j          d S )Nr   )no_such_attrr:   s    r   r  z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.f  s    ANNNNr   c                 V    |dk    r!|\  }}}                     |t                     S r|  )assertIsInstancerj   )r   r   r   typero   r   r  r   s         r   r  z<RaisingTraceFuncTestCase.test_exception_arguments.<locals>.g  s5    $$),&i%%i;;;Hr   )rr   r   rs   AttributeError)r   r  existingr  s   `  @r   test_exception_argumentsz1RaisingTraceFuncTestCase.test_exception_arguments  s    	 	 		 	 	 	 	 	 <>>	#LOOO!    L"""""CL""""s-   A& 
A  A&  
A
A& AA& &A<c                    t          d          fdd }|                     t                     5 }t          j                    |             d d d            n# 1 swxY w Y   |                     |j                   d S )NzBOOM!c                 &    |dk    rd| _         S )Nr6   T)r   )r   r   r   ro   r   s      r   r   zRRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.trace  s    $(E!Lr   c                      d S r   r#   r#   r   r   r  zNRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event.<locals>.f  r   r   )r  assertRaisesrr   rs   assertIsro   )r   r  caughtro   r   s      @@r   *test_line_event_raises_before_opcode_eventzCRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event  s    w''		 	 	 	 	 	
	 	 	z** 	fLACCC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	f&	22222s   A  A$'A$N)r   r    r!   r   r   r  rq  rt  rx  rz  r}  r  r  r  r#   r   r   ri  ri    s        6 6 6    5 5 5"( ( (( ( (* * *- - -2 2 2,# # #,3 3 3 3 3r   ri  c                   $    e Zd ZdZ	 	 ddZd ZdS )
JumpTracerz>Defines a trace function that jumps from one place to another.r6   Fc                     |j         | _        || _        || _        || _        |rd n| j        j        | _        d| _        d S )NF)r   codejumpFromjumpTor   r   	firstLiner  )r   functionr  r  r   	decorateds         r   r   zJumpTracer.__init__
  sA    %	 
!*H	0H			r   c                    | j         rd S | j        %|j        | j        k    r|dk    r|j        dz
  | _        || j        k    r| j        |j        | j        | j        z   k    rh|}|)|j        | j        k    r|j        }||j        | j        k    |9	 | j        | j        z   |_        n# t          $ r | j        |_        Y nw xY wd| _         | j
        S )Nr6   r1   T)r  r  rF  r  r   r   r  ru   r  r  r   )r   r   r   r   r  s        r   r   zJumpTracer.trace  s    9 	F
 N"u|ty'@'@"^a/DNTZDN$>$.4="@@@A-AH	$9$9H -AH	$9$9}1%)^dk%AENN  1 1 1%)[ENNN1 	zs   B% %B>=B>N)r6   F)r   r    r!   r"   r   r   r#   r   r   r  r    sC        HH9?        r   r  c                     	 |                      d           d S # t          $ r/}|                      dt          |          v            Y d }~d S d }~ww xY w)Nr>   integer)r   r  r   r   r   s     r   no_jump_to_non_integersr  -  sm    +a + + +i3q66)*********+s    
A$AAc                      	 t          j                    j        } | j        | _        t	          d          # t
          $ r}dt          |          vr Y d }~d S d }~ww xY w)Nz'Trace-function-less jump failed to failr   )rr   rt   ru   r   AssertionErrorr  r   )previous_framer   s     r   no_jump_without_trace_functionr  5  s}    
H/"0"9 FGGG     #a&&   !     s   $5 
AAAc                      e Zd Zd Zd Z	 	 ddZ	 	 ddZddZdd	Z ed
ddg          d             Z	 edd
g d          d             Z
 eddddg          d             Z edd
g d          d             Z eddddg          d             Z eddg d          d             Z ed
ddg          d             Z eddg d          d             Z eddddg          d             Z eddddgedf          d              Z edd!dd!gedf          d"             Z edd!ddged#f          d$             Z eddd
ged%f          d&             Z eddddg          d'             Z eddg d(          d)             Z eddd
dg          d*             Z eddd
dg          d+             Z edd
g d,          d-             Z edd
g d,          d.             Z edddg          d/             Z edd
g d0          d1             Z edddg          d2             Z  edd
g d3          d4             Z! eddg d5          d6             Z" eddg d5          d7             Z# eddg d8          d9             Z$ edd
g d:          d;             Z% eddg d<          d=             Z& eddg d<          d>             Z' eddg d?          d@             Z( eddg d?          dA             Z) eddg dB          dC             Z* eddg dB          dD             Z+ eddg dE          dF             Z, eddg dE          dG             Z- edHd!g dI          dJ             Z. eddg dK          dL             Z/ eddg dK          dM             Z0 eddg dN          dO             Z1 eddHg dP          dQ             Z2 ed
dddHg          dR             Z3 ed
dddHg          dS             Z4 eddd
ged%f          dT             Z5 eddUd
gedVf          dW             Z6 edddgedXf          dY             Z7 edddgedXf          dZ             Z8 edddgedXf          d[             Z9 edddgedXf          d\             Z: ed
dg ed]f          d^             Z; ed
dg ed]f          d_             Z< eddddged]f          d`             Z= eddddgedaf          db             Z> ed
dg edcf          dd             Z? ed
dg edcf          de             Z@ eddg dfedcf          dg             ZA eddg dfedcf          dh             ZB ed
dddg          di             ZC eddg dj          dk             ZD ed
ddg          dl             ZE eddg dm          dn             ZF eddg d5          do             ZG ed
ddg          dp             ZH eddg dq          dr             ZI edd
g ds          dt             ZJ ed
dg eduf          dv             ZK ed
dg eduf          dw             ZL eddg dxeduf          dy             ZM edddgeduf          dz             ZN edd
g d{          d|             ZO edd
g d{          d}             ZP eddg d~          d             ZQ eddg d~          d             ZR eddddged%f          d             ZS eddd
dged]f          d             ZT eddd
dged]f          d             ZUd ZVd ZWd ZXd ZY eddd
gdedf          d             ZZ edd
d
gdedf          d             Z[ edd
d
gd#edf          d             Z\ eddddgd          d             Z] eddd
dg          d             Z^ edd
g           d             Z_ edHdg d          d             Z` eddd
dg          d             Za edd
g           d             Zb edHdg d          d             Zc eddg edcf          d             Zd eddHg edcf          d             Ze eddg edcf          d             Zf eddd
dg          d             Zg eddg d          d             Zhd Zi eddd
dg          d             ZjdS )JumpTestCasec                     |                      t          j        t          j                               t          j        d            d S r   rk  r   s    r   r   zJumpTestCase.setUpD  4    clnn555Tr   c                     ||k    r=|                      dt          |          z   dz   dz   t          |          z              d S d S )NzOutputs don't match:
Expected: r   z
Received: )r   repr)r   expectedreceiveds      r   compare_jump_outputz JumpTestCase.compare_jump_outputH  sf    xII $&*8nn57;<#$&*8nn5 6 6 6 6 6  r   Nr6   Fc                 ,   t          |||||          }t          j        |j                   g }	| ||	           n- | j        | 5   ||	           d d d            n# 1 swxY w Y   t          j        d            |                     ||	           d S r   )r  rr   rs   r   assertRaisesRegexr  
r   r   r  r  r  r  r   r  r   r   s
             r   r   zJumpTestCase.run_testN  s    D(FE9EEV\"""=DLLLL''/  V              T  622222s   AA#&A#c                    t          |||||          }t          j        |j                   g }	|t	          j         ||	                     n? | j        | 5  t	          j         ||	                     d d d            n# 1 swxY w Y   t          j        d            t	          j        d            |                     ||	           d S r   )	r  rr   rs   r   asynciorI  r  set_event_loop_policyr  r  s
             r   run_async_testzJumpTestCase.run_async_test[  s   D(FE9EEV\"""=KV%%%%''/ * *DDLL)))* * * * * * * * * * * * * * *T%d+++  622222s   BB
Bc                 "      fd}|S )zqDecorator that creates a test that makes a jump
        from one place to another in the following code.
        c                 H     t                      fd            }|S )Nc           	      @    |                      d           d S NT)r  r   r  )r   r   r  r   r  r   r  r  s    r   testz7JumpTestCase.jump_test.<locals>.decorator.<locals>.testn  s<    dHfh$)$  H H H H Hr   r   r   r  r  r   r  r  r  s   ` r   	decoratorz)JumpTestCase.jump_test.<locals>.decoratorm  W    4[[H H H H H H H H H [H Kr   r#   r  r  r  r  r   r  s   ````` r   	jump_testzJumpTestCase.jump_testi  <    	 	 	 	 	 	 	 	 	 r   c                 "      fd}|S )z~Decorator that creates a test that makes a jump
        from one place to another in the following asynchronous code.
        c                 H     t                      fd            }|S )Nc           	      @    |                      d           d S r  )r  r  s    r   r  z=JumpTestCase.async_jump_test.<locals>.decorator.<locals>.testz  s>    ##D(FH$)$ $ H H H H Hr   r   r  s   ` r   r  z/JumpTestCase.async_jump_test.<locals>.decoratory  r  r   r#   r  s   ````` r   async_jump_testzJumpTestCase.async_jump_testu  r  r   r1   r@   c                     |                      d           |                      d           |                      d           d S Nr1   r>   r@   r   r   s    r   test_jump_simple_forwardsz&JumpTestCase.test_jump_simple_forwards  >    aaar   r>   )r1   r1   r>   c                 Z    |                      d           |                      d           d S rR   r  r  s    r   test_jump_simple_backwardsz'JumpTestCase.test_jump_simple_backwards  ,    aar   rB   c                     dD ]1}|                      d           dD ]}|                      d           2|                      d           d S )Nr  r>   r@   rI   rB   r  r   r   rx  s      r   test_jump_out_of_block_forwardsz,JumpTestCase.test_jump_out_of_block_forwards  sd     	! 	!AMM! ! !a    !ar   rX   )r1   r@   rB   r1   r@   rB   rX   rK   c                     |                      d           dD ]F}|                      d           dD ]}|                      d           |                      d           G|                      d           d S )Nr1   r   r@   )r>   rB   rX   rK   r  r  s      r    test_jump_out_of_block_backwardsz-JumpTestCase.test_jump_out_of_block_backwards  s    a 	 	AMM! ! !a    MM!ar   rI   c                    K   dD ][}t          ddg          2 3 d {V }|                     d           |                     d           26 |                     d           \d S )Nr   r1   r>   r@   rI   rB   r.   r   r   r   s     r   )test_jump_out_of_async_for_block_forwardsz6JumpTestCase.test_jump_out_of_async_for_block_forwards  s       	 	A$aV,, ! ! ! ! ! ! !aa   a     - MM!		 	s   A
)r>   rI   r>   rI   rB   rX   c                    K   dD ]o}|                      d           t          dg          2 3 d {V }|                      d           |                      d           26 |                      d           pd S )Nr   r>   r1   rI   rB   rX   r   r.   r  s     r   *test_jump_out_of_async_for_block_backwardsz7JumpTestCase.test_jump_out_of_async_for_block_backwards  s       	 	AMM!$aS>> ! ! ! ! ! ! !aa   a     * MM!	 	s   Ac                 Z    |                      d           |                      d           d S )Nr1   r@   r  r  s    r   test_jump_to_codeless_linez'JumpTestCase.test_jump_to_codeless_line  s,    aar   )r1   r>   r@   c                     |                      d           |                      d           |                      d           d S r  r  r  s    r   test_jump_to_same_linez#JumpTestCase.test_jump_to_same_line  r  r   r+  c                    	 |                      d           |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S # |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           w xY w)Nr>   rI   rX   r*  r+  r  r  s    r   test_jump_in_nested_finallyz(JumpTestCase.test_jump_in_nested_finally  s    	MM!MM!!a   a    a    MM! MM!!a   a    a    MM!s.   B	 A A/	C; C5C;C""C;rK    c                     	 |                      d           ddz   	 |                      d           |                      d           d S # |                      d           |                      d           w xY w)Nr>   r1   r   rX   rK   r  r  s    r   test_jump_in_nested_finally_2z*JumpTestCase.test_jump_in_nested_finally_2  s|    	MM!aCCMM!MM! MM!MM!s   A	 	,A5rk  c                    	 |                      d           ddz   	 |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S # |                      d           	 |                      d           |                      d           n# |                      d           w xY w|                      d           w xY w)Nr>   r1   r   rX   r*  r   rk  r  r  s    r   test_jump_in_nested_finally_3z*JumpTestCase.test_jump_in_nested_finally_3  s   
	MM!aCCMM!"a   b!!!!b!!!!MM" MM!"a   b!!!!b!!!!MM"s.   B A A5D&C;DC((Dro   c                     	 |                      d           |                      d           |                      d           d S # |                      d           |                      d            Y d S xY wNr>   rI   rB   r  r  s    r   5test_no_jump_over_return_try_finally_in_finally_blockzBJumpTestCase.test_no_jump_over_return_try_finally_in_finally_block  s{    
	MM!MM!MM!F MM!MM!FFF
 DD   A ,A2afterc                 Z    |                      d           	 |                      d           )Nr1   Tr@   r  r  s    r    test_no_jump_infinite_while_loopz-JumpTestCase.test_no_jump_infinite_while_loop  s0    a	MM!	r   c                     d}|                      d           |dk    r"|                      d           |dz  }|dk     d S d S )Nr1   r>   rI   r  r  s     r   #test_jump_forwards_into_while_blockz0JumpTestCase.test_jump_forwards_into_while_block  sP    a1ffMM!FA 1ffffffr   )r@   r@   r@   rB   c                     d}|dk    r |                      d           |dz  }|dk     |                      d           d S )Nr1   r>   r@   rB   r  r  s     r   $test_jump_backwards_into_while_blockz1JumpTestCase.test_jump_backwards_into_while_block  sP    1ffMM!FA 1ff 	ar   c                     t          | d          5  |                     d           d d d            n# 1 swxY w Y   |                     d           d S r  r
   r   r  s    r   $test_jump_forwards_out_of_with_blockz1JumpTestCase.test_jump_forwards_out_of_with_block
      &!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	a   377c                    K   t          | d          4 d {V  |                     d           d d d           d {V  n# 1 d {V swxY w Y   |                     d           d S r  r%   r   r  s    r   *test_jump_forwards_out_of_async_with_blockz7JumpTestCase.test_jump_forwards_out_of_async_with_block        $VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	a   A
AA)r1   r>   r1   r>   r@   rf   c                     |                      d           t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r  r   r
   r  s    r   %test_jump_backwards_out_of_with_blockz2JumpTestCase.test_jump_backwards_out_of_with_block      a&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A		AAc                    K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r  r   r%   r  s    r   +test_jump_backwards_out_of_async_with_blockz8JumpTestCase.test_jump_backwards_out_of_async_with_block        a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A
A!$A!c                     	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S r  r  r  s    r   +test_jump_forwards_out_of_try_finally_blockz8JumpTestCase.test_jump_forwards_out_of_try_finally_block"  ^    	MM!MM!FMM!a	   - A)r1   r1   r@   rB   c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wNr1   r@   rB   r  r  s    r   ,test_jump_backwards_out_of_try_finally_blockz9JumpTestCase.test_jump_backwards_out_of_try_finally_block*  [    a	MM!MM!FMM!   A Ac                     	 |                      d           n#  |                      d            xY w|                      d           d S Nr>   rI   rX   r  r  s    r   *test_jump_forwards_out_of_try_except_blockz7JumpTestCase.test_jump_forwards_out_of_try_except_block2  R    	MM!	MM!a    0)r1   r1   r@   c                     |                      d           	 |                      d           d S #  |                      d            xY wr  r  r  s    r   +test_jump_backwards_out_of_try_except_blockz8JumpTestCase.test_jump_backwards_out_of_try_except_block;  O    a	MM!	MM!	   . A)rI   rK   r*  c                     	 ddz   nZ# t           $ r- |                     d           |                     d           Y n$t          $ r |                     d           Y nw xY w|                     d           d S Nr1   r   rI   rB   rK   r*  r  r   FloatingPointErrorr  s    r   test_jump_between_except_blocksz,JumpTestCase.test_jump_between_except_blocksD  s    	aCCC  	 	 	MM!MM!! 	 	 	MM!	as    4AAAc                    	 ddz   n:# t           $ r- |                     d           |                     d           Y nw xY w|                     d           n# |                     d           w xY w|                     d           d S r  )r  r   r  s    r    test_jump_from_except_to_finallyz-JumpTestCase.test_jump_from_except_to_finallyO  s    	aCCC  	 	 	MM!MM!	 MM!FMM!as!    A 4?A ?A A/)rI   rX   rK   c                     	 ddz   nF#  |                      d           |                      d           |                      d           Y nxY w|                      d           d S )Nr1   r   rI   rB   rX   rK   r  r  s    r   test_jump_within_except_blockz*JumpTestCase.test_jump_within_except_blockZ  so    	aCCC	MM!MM!MM!as
    AA)r1   rB   r1   rB   c                     |                      d           	 ddz   n,# t          $ r}|                      d           Y d }~nd }~ww xY wd}d S )Nr1   r   rB   rD  r   r  )r   r   r-   s      r   test_jump_over_try_exceptz&JumpTestCase.test_jump_over_try_exceptd  sm    a	EEE  	 	 	MM!	s    
AAA)r1   rI   rB   r   c                 &   |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S Nr1   r>   r@   rI   rB   r  r  s    r   test_jump_across_withz"JumpTestCase.test_jump_across_withm     a&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	&!$$ 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	#   AAA#BB
B
c                 r  K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r'  r  r  s    r   test_jump_across_async_withz(JumpTestCase.test_jump_across_async_withu       a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	#   A
A #A =B&&
B03B0)r1   r@   rB   rX   c                    |                      d           dD ]T}t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           U|                      d           d S Nr1   r   r@   rI   rB   rX   r  r  s     r   ,test_jump_out_of_with_block_within_for_blockz9JumpTestCase.test_jump_out_of_with_block_within_for_block}  s    a 	 	Afa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as   AA	A	c                 0  K   |                      d           dD ]f}t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           g|                      d           d S r0  r  r  s     r   2test_jump_out_of_async_with_block_within_for_blockz?JumpTestCase.test_jump_out_of_async_with_block_within_for_block  s%     a 	 	A(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as   A
A$	'A$	)r1   r>   r@   rB   rf   rX   c                 N   |                      d           t          | d          5  t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           d d d            n# 1 swxY w Y   |                      d           d S Nr1   r>   r@   rI   rB   rX   r  r  s    r   -test_jump_out_of_with_block_within_with_blockz:JumpTestCase.test_jump_out_of_with_block_within_with_block  s   a&!$$ 	 	fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as4   BABA	B A	!BB	B	c                 v  K   |                      d           t          | d          5  t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           d d d            n# 1 swxY w Y   |                      d           d S r5  )r   r
   r%   r  s    r   3test_jump_out_of_async_with_block_within_with_blockz@JumpTestCase.test_jump_out_of_async_with_block_within_with_block  sz     a&!$$ 	 	(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as4   BA'B'
A1	1B4A1	5BB B)r>   rI   rX   rK   c                    	 |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           nW# t          | d          5  |                      d           d d d            n# 1 swxY w Y   |                      d           w xY w|                      d           d S Nr>   rI   rB   rX   rK   r  r  s    r   0test_jump_out_of_with_block_within_finally_blockz=JumpTestCase.test_jump_out_of_with_block_within_finally_block  sO   	MM!fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM! fa(( ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as@   A* A		AA*B>;BB>B!!B>$B!%B>c                   K   	 |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           ni# t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           w xY w|                      d           d S r:  r  r  s    r   6test_jump_out_of_async_with_block_within_finally_blockzCJumpTestCase.test_jump_out_of_async_with_block_within_finally_block  s     	MM!(33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM! )33 ! ! ! ! ! ! ! !a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !MM!as@   A> A
A!$A!>C$B=+C$=
CC$
CC$r*  )r1   r@   rB   rk  rt  c                    |                      d           dD ]}|                      d           dD ]b}|                      d           	 dD ]}|                      d           	 |                      d           I# |                      d           w xY w|                      d           |                      d	           d S )
Nr1   r   r@   r  rB   r*  r   rk  rt  r  )r   r   rx  ks       r   &test_jump_out_of_complex_nested_blocksz3JumpTestCase.test_jump_out_of_complex_nested_blocks  s    a 		 		AMM! & &a   &# ) )a(((() MM"%%%%FMM"%%%%MM"bs   	A::B)r1   r>   rB   c                     |                      d           t          | d          5 }|                      d           d d d            n# 1 swxY w Y   |                      d           d S Nr1   r>   rI   rB   r  r   r-   s     r    test_jump_out_of_with_assignmentz-JumpTestCase.test_jump_out_of_with_assignment  s    a&!$$ 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as   AAAc                    K   |                      d           t          | d          4 d {V 	 }|                      d           d d d           d {V  n# 1 d {V swxY w Y   |                      d           d S rB  r  rC  s     r   &test_jump_out_of_async_with_assignmentz3JumpTestCase.test_jump_out_of_async_with_assignment  s     a$VQ// 	 	 	 	 	 	 	 	MM!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	as   A
A!$A!)r1   rX   r*  r+  c                 D   |                      d           	 |                      d           | s	 |                      d           d S |                      d           |                      d           n# |                      d           w xY w|                      d           d S )Nr1   r@   r*  rX   r+  r  r  s    r   *test_jump_over_return_in_try_finally_blockz7JumpTestCase.test_jump_over_return_in_try_finally_block  s    a	MM!  MM! MM!MM!FMM!as   A1 A1 1B)r1   r@   r*  r   rk  r  c                    |                      d           	 |                      d           	 |                      d           | s	 |                      d           n[|                      d           |                      d           n# |                      d           w xY w|                      d           	 |                      d           d S )	Nr1   Tr@   rB   r   r*  rk  r  r  r  s    r   )test_jump_over_break_in_try_finally_blockz6JumpTestCase.test_jump_over_break_in_try_finally_block  s    a
	MM!"a     b!!!! a   b!!!!b!!!!MM"bs   B B Bc                     |                      d           | sdD ]}|                      d           n*|                      d           |                      d           |                      d           d S Nr1   r  rI   rX   rK   r*  r  r  s     r   $test_jump_over_for_block_before_elsez1JumpTestCase.test_jump_over_for_block_before_else      a 	 ! !a    ! MM!MM!ar   c                   K   |                      d           | s/t          dg          2 3 d {V }|                      d           6 n*|                      d           |                      d           |                      d           d S Nr1   r@   rI   rX   rK   r*  r  r  s     r   *test_jump_over_async_for_block_before_elsez7JumpTestCase.test_jump_over_async_for_block_before_else        a 	$aS>> ! ! ! ! ! ! !aa     *> MM!MM!a   Ac                 Z    |                      d           |                      d           d S rR   r  r  s    r   test_no_jump_too_far_forwardsz*JumpTestCase.test_no_jump_too_far_forwards	  r  r   rf   beforec                 Z    |                      d           |                      d           d S rR   r  r  s    r   test_no_jump_too_far_backwardsz+JumpTestCase.test_no_jump_too_far_backwards	  r  r   exceptc                 h    	 |                      d           d S #  |                      d            xY wNr>   rI   r  r  s    r   test_no_jump_to_except_1z%JumpTestCase.test_no_jump_to_except_1	  s=    	MM!	MM!s    1c                 z    	 |                      d           d S # t          $ r |                      d            w xY wr[  r   r  r  s    r   test_no_jump_to_except_2z%JumpTestCase.test_no_jump_to_except_2	  sO    	MM! 	 	 	MM!	s    !:c                     	 |                      d           d S # t          $ r}|                      d           |d }~ww xY wr[  r^  r  s     r   test_no_jump_to_except_3z%JumpTestCase.test_no_jump_to_except_3#	  sU    	MM! 	 	 	MM!G	s    
?:?c                     	 |                      d           d S # t          t          f$ r}|                      d           |d }~ww xY wr[  )r   r  r}   r  s     r   test_no_jump_to_except_4z%JumpTestCase.test_no_jump_to_except_4+	  sZ    	MM!L) 	 	 	MM!G	s    AAAintoc                 d    |                      d           dD ]}|                      d           d S )Nr1   r  r@   r  r  s     r   $test_no_jump_forwards_into_for_blockz1JumpTestCase.test_no_jump_forwards_into_for_block3	  sB    a 	 	AMM!	 	r   c                    K   |                      d           t          ddg          2 3 d {V }|                      d           6 d S r  r  r  s     r   *test_no_jump_forwards_into_async_for_blockz7JumpTestCase.test_no_jump_forwards_into_async_for_block9	  sk      a !Q(( 	 	 	 	 	 	 	!MM! )s   Ac                 d    dD ]}|                      d           |                      d           d S )Nr  r>   r@   r  r  s     r   %test_no_jump_backwards_into_for_blockz2JumpTestCase.test_no_jump_backwards_into_for_block@	  s>     	 	AMM!ar   z&can't jump into the body of a for loopc                    K   t          ddg          2 3 d {V }|                     d           6 |                     d           d S r  r  r  s     r   +test_no_jump_backwards_into_async_for_blockz8JumpTestCase.test_no_jump_backwards_into_async_for_blockF	  sl       !Q(( 	 	 	 	 	 	 	!MM! )as   1stackc                     |                      d           t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r  r  r  s    r   %test_no_jump_forwards_into_with_blockz2JumpTestCase.test_no_jump_forwards_into_with_blockL	  r  r  c                    K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r  r  r  s    r   +test_no_jump_forwards_into_async_with_blockz8JumpTestCase.test_no_jump_forwards_into_async_with_blockR	  r  r  )r1   r>   r   c                     t          | d          5  |                     d           d d d            n# 1 swxY w Y   |                     d           d S r  r  r  s    r   &test_no_jump_backwards_into_with_blockz3JumpTestCase.test_no_jump_backwards_into_with_blockX	  r  r  c                    K   t          | d          4 d {V  |                     d           d d d           d {V  n# 1 d {V swxY w Y   |                     d           d S r  r  r  s    r   ,test_no_jump_backwards_into_async_with_blockz9JumpTestCase.test_no_jump_backwards_into_async_with_block^	  r  r  c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr  r  r  s    r   )test_jump_forwards_into_try_finally_blockz6JumpTestCase.test_jump_forwards_into_try_finally_blockd	  r  r  )r>   rI   r>   rI   rB   c                     	 |                      d           |                      d           n# |                      d           w xY w|                      d           d S r  r  r  s    r   *test_jump_backwards_into_try_finally_blockz7JumpTestCase.test_jump_backwards_into_try_finally_blockl	  r
  r  c                     |                      d           	 |                      d           d S #  |                      d            xY wr  r  r  s    r   (test_jump_forwards_into_try_except_blockz5JumpTestCase.test_jump_forwards_into_try_except_blockt	  r  r  )r>   r>   rX   c                     	 |                      d           n#  |                      d            xY w|                      d           d S r  r  r  s    r   )test_jump_backwards_into_try_except_blockz6JumpTestCase.test_jump_backwards_into_try_except_block}	  r  r  c                     	 ddz   na# t           $ r- |                     d           |                     d           Y n+t          $ r}|                     d           Y d }~nd }~ww xY w|                     d           d S r  r  r  s     r   !test_jump_between_except_blocks_2z.JumpTestCase.test_jump_between_except_blocks_2	  s    	aCCC  	 	 	MM!MM!! 	 	 	MM!	as    4A&	A&A!!A&c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr  r  r  s    r   test_jump_into_finally_blockz)JumpTestCase.test_jump_into_finally_block	  r  r  )r>   rX   rK   c                 :   	 |                      d           |                      d           |                      d           |                      d           n/# |                      d           |                      d           w xY w|                      d           d S )Nr>   r@   rB   rX   rK   r  r  s    r   +test_jump_into_finally_block_from_try_blockz8JumpTestCase.test_jump_into_finally_block_from_try_block	  s    	MM!MM!MM!MM! MM!MM!as   *A ,B)r1   r@   r1   r@   rB   c                     |                      d           	 |                      d           |                      d           d S # |                      d           w xY wr  r  r  s    r   test_jump_out_of_finally_blockz+JumpTestCase.test_jump_out_of_finally_block	  r  r  z9can't jump into an 'except' block as there's no exceptionc                     |                      d           	 |                      d           d S #  |                      d           Y d S xY wr  r  r  s    r   #test_no_jump_into_bare_except_blockz0JumpTestCase.test_no_jump_into_bare_except_block	  sU    a	MM!	MM!s	   . Ac                     |                      d           	 |                      d           d S # t          $ r |                      d           Y d S w xY wr  r   rj   r  s    r   (test_no_jump_into_qualified_except_blockz5JumpTestCase.test_no_jump_into_qualified_except_block	  sg    a	MM! 	 	 	MM!	s   . AA)r>   rB   rX   c                     	 |                      d           |                      d           n0#  |                      d           |                      d            xY w|                      d           d S Nr>   r@   rB   rX   r*  r  r  s    r   2test_no_jump_into_bare_except_block_from_try_blockz?JumpTestCase.test_no_jump_into_bare_except_block_from_try_block	  sv    	MM!MM!	MM!MM!as	   *- -Ac                     	 |                      d           |                      d           n9# t          $ r, |                      d           |                      d            w xY w|                      d           d S r  r$  r  s    r   7test_no_jump_into_qualified_except_block_from_try_blockzDJumpTestCase.test_no_jump_into_qualified_except_block_from_try_block	  s    	MM!MM!  	 	 	MM!MM!	 	as	   *- 6A#)r1   r@   rX   r1   r@   rX   rK   c                     |                      d           	 |                      d           ddz   d S #  |                      d           |                      d           Y d S xY wNr1   r@   r   rX   rK   r  r  s    r   "test_jump_out_of_bare_except_blockz/JumpTestCase.test_jump_out_of_bare_except_block	  sn    a	MM!aCCCC	MM!MM!s	   3 ,A"c                     |                      d           	 |                      d           ddz   d S # t          $ r. |                      d           |                      d           Y d S w xY wr  r  r  s    r   'test_jump_out_of_qualified_except_blockz4JumpTestCase.test_jump_out_of_qualified_except_block	  s    a	MM!aCCCC 	 	 	MM!MM!	s   3 4A+*A+)r1   r>   rB   rf   c                 &   |                      d           t          | d          5  |                      d           d d d            n# 1 swxY w Y   t          | d          5  |                      d           d d d            d S # 1 swxY w Y   d S r'  r  r  s    r   test_jump_between_with_blocksz*JumpTestCase.test_jump_between_with_blocks	  r)  r*  c                 r  K   |                      d           t          | d          4 d {V  |                      d           d d d           d {V  n# 1 d {V swxY w Y   t          | d          4 d {V  |                      d           d d d           d {V  d S # 1 d {V swxY w Y   d S r'  r  r  s    r   #test_jump_between_async_with_blocksz0JumpTestCase.test_jump_between_async_with_blocks	  r-  r.  c                     	 |                      d           |                      d           |                      d           d S # |                      d           |                      d            Y d S xY wr  r  r  s    r   -test_no_jump_over_return_out_of_finally_blockz:JumpTestCase.test_no_jump_over_return_out_of_finally_block	  sx    	MM!MM!MM!F MM!MM!FFFFFFr  c                     |                      d           | sdD ]}|                      d           n*|                      d           |                      d           |                      d           d S rL  r  r  s     r   'test_no_jump_into_for_block_before_elsez4JumpTestCase.test_no_jump_into_for_block_before_else 
  rN  r   c                   K   |                      d           | s/t          dg          2 3 d {V }|                      d           6 n*|                      d           |                      d           |                      d           d S rP  r  r  s     r   -test_no_jump_into_async_for_block_before_elsez:JumpTestCase.test_no_jump_into_async_for_block_before_else
  rR  rS  c                 B    |                      t          dddg           d S )Nr>   SpamT)r   r  r   s    r   test_no_jump_to_non_integersz)JumpTestCase.test_no_jump_to_non_integers
  s#    -q&4&AAAAAr   c                 "    t                       d S r   )r  r   s    r   #test_no_jump_without_trace_functionz0JumpTestCase.test_no_jump_without_trace_function
  s     	'(((((r   c                 r    i }t          ddz  |           |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   r  r  s      r   test_large_functionz JumpTestCase.test_large_function
  sX      '' )*	+ 	+ 	+ cFaD1#&&&&&r   c                 (   t          ddd           G fdd          }t          |dd          }t          j        |j                   dg i}t          |           t          j        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                       e Zd Z ZdS )<JumpTestCase.test_jump_to_firstlineno.<locals>.fake_functionN)r   r    r!   r   )r  s   r   fake_functionr  6
  s        HHHr   r  rI   r1   r   )r>   r@   r>   r@   rI   )compiler  rr   rs   r   r  r  )r   r  r   r   r  s       @r   test_jump_to_firstlinenoz%JumpTestCase.test_jump_to_firstlineno,
  s      
 f 	 	 	 	 	 	 	 	 	 	M1a00V\"""rN	T9T  )H2EFFFFFr   r4   z5can't jump from the 'call' trace event of a new frame)r   r  c                 z                           d            fd} |                                   d           d S )Nr1   c                  2                          d           d S r  r  r  s   r   nestedz3JumpTestCase.test_no_jump_from_call.<locals>.nestedC
  s    MM!r   rB   r  )r   r  s   ` r   test_no_jump_from_callz#JumpTestCase.test_no_jump_from_call?
  sS     	a	 	 	 	 	ar   r8   z'can only jump from a 'line' trace eventc                 0    |                      d           d S r0   r  r  s    r   test_no_jump_from_return_eventz+JumpTestCase.test_no_jump_from_return_eventH
  s     	ar   c                 :    |                      d           ddz   d S r  r  r  s    r   !test_no_jump_from_exception_eventz.JumpTestCase.test_no_jump_from_exception_eventN
  s#     	a	Ar   )r   c                 j      fd}t           |                                            d           d S )Nc               3   >   K                         d           dV  d S )Nr>   r@   r  r  s   r   r.  z.JumpTestCase.test_jump_from_yield.<locals>.genV
  s&      MM!GGGGGr   rB   )r=  r   )r   r.  s   ` r   test_jump_from_yieldz!JumpTestCase.test_jump_from_yieldT
  sG    	 	 	 	 	 	SSUUar   c                     |                      d           d t          d          D             }|                      d           d S )Nr1   c                     g | ]}|S r#   r#   r   r   s     r   r   z@JumpTestCase.test_jump_forward_over_listcomp.<locals>.<listcomp>_
      """1Q"""r   r   r@   r   rT   rC  s     r   test_jump_forward_over_listcompz,JumpTestCase.test_jump_forward_over_listcomp\
  sE    a""b		"""ar   c                 @    d}d t          d          D             }d}d S )Nr1   c                     g | ]}|S r#   r#   r  s     r   r   zAJumpTestCase.test_jump_backward_over_listcomp.<locals>.<listcomp>g
  r  r   r   r@   rS   r   rU   r-   r  s       r    test_jump_backward_over_listcompz-JumpTestCase.test_jump_backward_over_listcompd
  s)    ""b		"""r   )r>   rK   r>   c                     d}|                      d           |rd S d t          d          D             }d}|                      d           |                      d           d S )NFr>   c                     g | ]}|S r#   r#   r  s     r   r   zDJumpTestCase.test_jump_backward_over_listcomp_v2.<locals>.<listcomp>p
  s    !!!1Q!!!r   rB   rX   rK   r*  r  r   flagr-   s      r   #test_jump_backward_over_listcomp_v2z0JumpTestCase.test_jump_backward_over_listcomp_v2j
  sn    a 	F!!a!!!aar   c                    K   |                      d           d t          t          d                    2              d {V }|                      d           d S )Nr1   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zFJumpTestCase.test_jump_forward_over_async_listcomp.<locals>.<listcomp>x
  .      33333333Q3333   r   r@   r   r.   rT   rC  s     r   %test_jump_forward_over_async_listcompz2JumpTestCase.test_jump_forward_over_async_listcompu
  sc      a33ib		22333333333ar   c                 j   K   d}d t          t          d                    2              d {V }d}d S )Nr1   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zGJumpTestCase.test_jump_backward_over_async_listcomp.<locals>.<listcomp>~
  r  r  r   r@   )r.   rT   r  s       r   &test_jump_backward_over_async_listcompz3JumpTestCase.test_jump_backward_over_async_listcomp{
  sG      33ib		22333333333r   c                    K   d}|                      d           |rd S d t          t          d                    2              d {V }d}|                      d           |                      d           d S )NFr>   c                 "   K   g | 3 d {V }|
6 S r   r#   r  s     r   r   zJJumpTestCase.test_jump_backward_over_async_listcomp_v2.<locals>.<listcomp>
  s.      22222222Q2222r  rB   rX   rK   r*  r  r  s      r   )test_jump_backward_over_async_listcomp_v2z6JumpTestCase.test_jump_backward_over_async_listcomp_v2
  s      a 	F22ia11222222222aar   )r  c                     d}t          |                     d                     |                     d           |dz   dz    |                     d           d S Nr1   r@   rB   r   r  r  rD  r   r   rU   s     r   (test_jump_with_null_on_stack_load_globalz5JumpTestCase.test_jump_with_null_on_stack_load_global
  sr    MM!	
 	
 	
 	a 
   	br   c                     d}t           } ||                     d                     |                     d           |dz   dz    |                     d           d S )Nr1   rI   rX   rk  rm     r  )r   rU   r  s      r   &test_jump_with_null_on_stack_push_nullz3JumpTestCase.test_jump_with_null_on_stack_push_null
  sy    	MM!	
 	
 	
 	a 
   	br   c                     d}t                               | d           |                     d           |dz   dz    |                     d           d S r  )listr   r  s     r   &test_jump_with_null_on_stack_load_attrz3JumpTestCase.test_jump_with_null_on_stack_load_attr
  sl    A	
 	
 	
 	a 
   	br   c                     |                      d           |                      d          pd^}}}|                      d           d S Nr1   r>   r  r@   r  r   r0  s     r   (test_jump_extended_args_unpack_ex_simplez5JumpTestCase.test_jump_extended_args_unpack_ex_simple
  sH    a==##-vAqar   )r1   rI   rI   rB   c                     |                      d           |                      d          pd^}}}|                      d           d S )Nr1   rI   r  rB   r  r  s     r   (test_jump_extended_args_unpack_ex_trickyz5JumpTestCase.test_jump_extended_args_unpack_ex_tricky
  sN    a MM!&	
1ar   c                     dddgd t          dd          D             d}i }t          d                    |          |           |d	         }|                     |d
dddg           d S )Nzdef f(output):z    output.append(1)z    for _ in spam:c              3   "   K   | ]
}d | dV  dS )z        output.append()Nr#   r  s     r   r   z@JumpTestCase.test_jump_extended_args_for_iter.<locals>.<genexpr>
  s.      GG+q+++GGGGGGr   r@   i z    output.append(100_000)r   r  r>   r1   )rT   r  r   r   )r   sourcer   r  s       r    test_jump_extended_args_for_iterz-JumpTestCase.test_jump_extended_args_for_iter
  s     " 
 HGU1g5F5FGGG	

 *
 	TYYv	***cNa!Wq'l33333r   c                     |                      d           |                      d          od}|                      d           d S r  r  r  s     r   test_jump_or_popzJumpTestCase.test_jump_or_pop
  sB    aMM!'ar   )Nr6   Frw  )kr   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,  r1  r3  r6  r8  r;  r=  r@  rD  rF  rH  rJ  rM  rQ  rU  rX  r\  r_  ra  rc  rf  rh  rj  rl  ro  rq  rs  ru  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  C  s6         6 6 6 @D).3 3 3 3 FJ).3 3 3 3
 
 
 

 
 
 
 Yq!aS  
 Yq!YYY    Yq!aV   Yq!---..  /. _QAq6""  #" _Q---..  /. Yq!aS  
 Yq!YYY    Yq!aV	 	 	 Yq!aV/455  65 Yq"q"g 12677  87 Yq"q!fz;788  98 Yq!aS:w/00  10 Yq!aV   Yq!\\\""  #" Yq!aV  
 _QAq6""  #"
 Yq!((())  *)
 _Q...//  0/
 Yq!aS   Yq!\\\""  #" Yq!aS   Yq!YYY    Yq!YYY    Yq!YYY    Yq!YYY    Yq!\\\""  #" Yq!]]]##  $# _Q===))  *) Yq!\\\""  #" _Q<<<((  )( Yq!((())  *) _Q...//  0/ Yq!\\\""  #" _Q<<<((  )( Yq"'''((  )( Yq!YYY    _Q999%%  &% Yq!\\\""	 	 #"	 Yq!***++  ,+ Yq!aV   _QAq6""  #" Yq!aS:w/00  10 Yq"qcJ122  32
 Yq!aS:x011  21 Yq!aS:x011  21 Yq!aS:x011  21 Yq!aS:x011  21 Yq!R*f-..  /.
 _Q2
F344  54 Yq!aVj&122  32
 _QAq6J0X#YZZ  [Z
 Yq!R*g.//  0/
 _Q2
G455  65
 Yq!ZZZ*g!677  87
 _Q:::
G'<==  >=
 Yq!aV   Yq!___%%  &% Yq!aS   Yq!YYY    Yq!YYY    Yq!aS   Yq!YYY    Yq!___%%  &% Yq!R*&abcc  dc Yq!R*&abcc  dc Yq!YYY-h ijj  kj Yq!aS:'bcdd  ed Yq!***++  ,+ Yq!***++  ,+ Yq!]]]##  $# _Q===))  *) Yq!aVj'233  43 Yq!aVj&122  32 _QAq6J#788  98B B B) ) )
' ' 'G G G& Yq!aSz <8 /9 : : : : : Yq!aS81: ; ; ; ; ; Yq!aSJ84: ; ; ; ; ; Yq!aV8,,,  -, Yq!aV   Yq!R  
 Yq!YYY    _QAq6""  #"
 _Q2  
 _Q999%%  &% Yq!R
G4555  65$ Yq!R
G4555  65& Yq!R
G4555  65" Yq!aV  
 Yq!\\\""  #"4 4 4 Yq!aV    r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestExtendedArgsc                     |                      t          j        t          j                               t          j        d            d S r   rk  r   s    r   r   zTestExtendedArgs.setUp
  r  r   c                     t          d          D ]} |             ddddfdt          j                    |             t          j        d            S )N   r   r4   r6   r8   c                 (    |xx         dz  cc<   S r0   r#   )r   r   r   countsr   s      r   r   z,TestExtendedArgs.count_traces.<locals>.trace
  s    5MMMQMMMLr   )rT   rr   rs   )r   r   r0  r  r   s      @@r   count_traceszTestExtendedArgs.count_traces
  s    r 	 	ADFFFFQ!44	 	 	 	 	 	 	UTr   c                     i }d}t          ||           |                     |d                   }|                     |dddd           d S )Na"  def f():
  (y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   y,
   ) = range(300)r  r1   i-  r  )r  r  r7  )r   nsr  r  s       r   test_trace_unpack_long_sequencez0TestExtendedArgs.test_trace_unpack_long_sequence   sV    AT2""2c7++!SA!F!FGGGGGr   c                 @   d                     d                    d t          d          D                                 }d t          d          D             }t          ||           |                     |d                   }|                     |dddd	           d S )
Nzeif 1:
            def f():
                return (
                    {}
                )
        z
+
c              3   "   K   | ]
}d | dV  dS )varr   Nr#   r  s     r   r   z>TestExtendedArgs.test_trace_lots_of_globals.<locals>.<genexpr>  s*      AAaAAAAAAr   i  c                     i | ]}d | |	S )r  r#   r  s     r   
<dictcomp>z?TestExtendedArgs.test_trace_lots_of_globals.<locals>.<dictcomp>  s     000qiAii000r   r  r1   i  r  )formatr   rT   r  r  r7  )r   r  r  r  s       r   test_trace_lots_of_globalsz+TestExtendedArgs.test_trace_lots_of_globals  s    
 F7<<AAU4[[AAAAABB 	 10E$KK000T2""2c7++!TQ!G!GHHHHHr   N)r   r    r!   r   r  r  r  r#   r   r   r  r  
  sX             H H H
I 
I 
I 
I 
Ir   r  c                        e Zd Zd Zd Zd ZdS )TestEdgeCasesc                     |                      t          j        t          j                               t          j        d            d S r   rk  r   s    r   r   zTestEdgeCases.setUp  r  r   c                    d }d  G fdd          }t          j         |                       t          j                    5 }t          j        |           |                     |j        j        |j                   |                     |j        j	        t                     d d d            n# 1 swxY w Y   |                     t          j                    |           d S )Nc                      d S r   r#   r   s    r   r  z*TestEdgeCases.test_reentrancy.<locals>.foo      Cr   c                      d S r   r#   r   s    r   barz*TestEdgeCases.test_reentrancy.<locals>.bar  r  r   c                        e Zd Zd Z fdZdS )(TestEdgeCases.test_reentrancy.<locals>.Ac                     d S r   r#   )r   r   s     r   __call__z1TestEdgeCases.test_reentrancy.<locals>.A.__call__"  r  r   c                 0    t          j                   d S r   r   )r   r  s    r   __del__z0TestEdgeCases.test_reentrancy.<locals>.A.__del__%  s    S!!!!!r   N)r   r    r!   r  r
  )r  s   r   r  r  !  s=          " " " " " " "r   r  )rr   rs   r   catch_unraisable_exceptionr7  
unraisableobjectr
  r  	exc_valuer}   r   )r   r  r  cmr  s       @r   test_reentrancyzTestEdgeCases.test_reentrancy  sH   	 	 		 	 		" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	QQSS/11 	IRLR]119===!!"-"9<HHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I
 	-----s   AB11B58B5c                     d }t          j        |           ~t          j        t          j                               d S )Nc                      d S r   r#   r   s    r   r  z+TestEdgeCases.test_same_object.<locals>.foo2  r  r   )rr   rs   r   )r   r  s     r   test_same_objectzTestEdgeCases.test_same_object1  sB    	 	 	 	SS\^^$$$$$r   N)r   r    r!   r   r  r  r#   r   r   r  r    sA          . . ..% % % % %r   r  __main__)6r  r   unittestunittest.mockr   rr   r   r   	functoolsr   r  test.supportr   requires_working_socketr
   r%   r.   r2   r   r;   rE   rG   rN   rV   r]   ra   r4   rk   rm   ry   r{   r~   r   r   r   r   r   r   r   TestCaser   r2  rT  rR  r`  ri  r  r  r  r  r  r  r   mainr#   r   r   <module>r     sz          # # # # # # 



  				        & & & & & &  t , , , ,
( 
( 
( 
( 
( 
( 
( 
(
( 
( 
( 
( 
( 
( 
( 
(      
 
 
' ' ' 
 
 
' ' '   ' ' ' 
 
 

( ( (   	% 	% 	% 
 
 
' ' ' 
 
 
        
$ 
$ 
$
 / / /$ $ $ ,_      , , ,    ) ) )   + + +  "  + + +      	- 	- 	- )+6;
< )-89         0h1 h1 h1 h1 h1H% h1 h1 h1V)  	/ 	/ 	/ 	/ 	/- 	/ 	/ 	/ 	0 0 0 0 0= 0 0 0g3 g3 g3 g3 g3x0 g3 g3 g3\# # # # # # # #L+ + +H H Hd d d d d8$ d d dN'I 'I 'I 'I 'Ix( 'I 'I 'IT#% #% #% #% #%H% #% #% #%L zHMOOOOO r   