mò
­fIc           @   sî   d  k  Z  d  k Z d  k Z d k l Z d f  d „  ƒ  YZ d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d	 „  ƒ  YZ	 d
 e f d „  ƒ  YZ
 d „  Z d „  Z e e ƒ Z d  d „ Z d „  Z d „  Z e d j o e ƒ  n d  S(   N(   s   test_supportt   HookWatcherc           B   s/   t  Z d „  Z d „  Z d  d „ Z d „  Z RS(   Nc         C   s   g  |  _ g  |  _ d  S(   N(   t   selft   framest   events(   R   (    (    t3   /mit/python/lib/python2.4/test/test_profilehooks.pyt   __init__	   s    	c         C   s?   | d j p | d j p | d j o |  i | | ƒ n d  S(   Nt   callt   returnt	   exception(   t   eventR   t	   add_eventt   frame(   R   R   R	   t   arg(    (    R   t   callback   s    'c         C   sŽ   | d j o t i d ƒ } n y |  i i | ƒ } Wn2 t j
 o& t	 |  i ƒ } |  i i
 | ƒ n X|  i i
 | | t | ƒ f ƒ d S(   s   Add an event to the log.i   N(   R   t   Nonet   syst	   _getframeR   R   t   indext   framenot
   ValueErrort   lent   appendR   R	   t   ident(   R   R	   R   R   (    (    R   R
      s     c         C   s^   t  |  i i ƒ t  t  ƒ g } d |  _ g  } |  i D]" } | d | j o | | q5 q5 ~ S(   s   Remove calls to add_event().i   N(
   R   R   R
   t   im_funct
   disallowedR   R   t   _[1]R   t   item(   R   R   R   R   (    (    R   t
   get_events    s     	(   t   __name__t
   __module__R   R   R   R
   R   (    (    (    R   R       s   		t   ProfileSimulatorc           B   sz   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z h  d e <d e <d	 e <d
 e <d e <d e <Z RS(   Nc         C   s#   | |  _  g  |  _ t i |  ƒ d  S(   N(   t   testcaseR   t   stackR    R   (   R   R   (    (    R   R   )   s    		c         C   s   |  i | |  | ƒ d  S(   N(   R   t   dispatchR	   R   (   R   R   R	   R   (    (    R   R   .   s    c         C   s$   |  i d | ƒ |  i i | ƒ d  S(   NR   (   R   R
   R   R    R   (   R   R   (    (    R   t
   trace_call2   s    c         C   s!   |  i d | ƒ |  i i ƒ  d  S(   NR   (   R   R
   R   R    t   pop(   R   R   (    (    R   t   trace_return6   s    c         C   s   |  i i d ƒ d  S(   Ns2   the profiler should never receive exception events(   R   R   t   fail(   R   R   (    (    R   t   trace_exception:   s    c         C   s   d  S(   N(    (   R   R   (    (    R   t
   trace_pass>   s    R   R   R   t   c_callt   c_returnt   c_exception(	   R   R   R   R   R"   R$   R&   R'   R!   (    (    (    R   R   (   s   						t   TestCaseBasec           B   s   t  Z d „  Z RS(   Nc         C   sS   t  | |  i ƒ  ƒ } | | j o- |  i d t i | ƒ t i | ƒ f ƒ n d  S(   Ns'   Expected events:
%s
Received events:
%s(	   t   capture_eventst   callableR   t   new_watcherR   t   expectedR%   t   pprintt   pformat(   R   R-   R/   R   (    (    R   t   check_eventsL   s    (   R   R   R2   (    (    (    R   R+   K   s   t   ProfileHookTestCasec           B   s†   t  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 RS(   Nc         C   s   t  ƒ  S(   N(   R    (   R   (    (    R   R.   T   s    c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   d  S(   N(    (   t   p(    (    R   t   fX   s    i   R   R   (   R5   R   t   f_identR   R2   (   R   R6   R5   (    (    R   t   test_simpleW   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   d d d  S(   Ni   i    (    (   R4   (    (    R   R5   `   s    i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_exception_   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   y d d Wn n Xd  S(   Ni   i    (    (   R4   (    (    R   R5   h   s      i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_caught_exceptiong   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   y d d Wn n Xd  S(   Ni   i    (    (   R4   (    (    R   R5   q   s      i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_caught_nested_exceptionp   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   d d d  S(   Ni   i    (    (   R4   (    (    R   R5   z   s    i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_nested_exceptiony   s    	c            s‰   d „  ‰  ‡  d †  } t ˆ  ƒ } t | ƒ } |  i | d d | f d d | f d d | f d d | f d d | f d d | f g ƒ d  S(   Nc         C   s   d d d  S(   Ni   i    (    (   R4   (    (    R   R5   …   s    c            s4   y ˆ  |  ƒ Wn y ˆ  |  ƒ Wq0 q0 Xn Xd  S(   N(   R5   R4   (   R4   (   R5   (    R   t   g‡   s      i   R   i   R   i   (   R5   R<   R   R6   t   g_identR   R2   (   R   R<   R=   R5   R6   (    (   R5   R   t   test_exception_in_except_clause„   s
    	c      
      s}   d „  ‰  ‡  d †  } t ˆ  ƒ } t | ƒ } |  i | d d | f d d | f d d | f d d | f d d | f g ƒ d  S(   Nc         C   s   d d d  S(   Ni   i    (    (   R4   (    (    R   R5   ˜   s    c            s#   z ˆ  |  ƒ Wd  |  i d ƒ Xd  S(   Ns   falling through(   R5   R4   R
   (   R4   (   R5   (    R   R<   š   s     i   R   i   R   s   falling through(   R5   R<   R   R6   R=   R   R2   (   R   R<   R=   R5   R6   (    (   R5   R   t   test_exception_propogation—   s
    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s"   y d d Wn d d n Xd  S(   Ni   i    (    (   R4   (    (    R   R5   §   s      i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_raise_twice¦   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   y d d Wn
 ‚  n Xd  S(   Ni   i    (    (   R4   (    (    R   R5   °   s      i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_raise_reraise¯   s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   t  ƒ  ‚ d  S(   N(   t	   Exception(   R4   (    (    R   R5   ¹   s    i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t
   test_raise¸   s    	c            s  d „  ‰ ‡ d †  ‰  ‡  d †  ‰ ‡ d †  ‰ ‡ d †  } t ˆ ƒ }	 t ˆ  ƒ } t ˆ ƒ } t ˆ ƒ } t | ƒ }
 |  i | d d |
 f d d | f d	 d | f d
 d | f d d |	 f d d |	 f d
 d | f d	 d | f d d | f d d |
 f g
 ƒ d  S(   Nc           C   s   d d d  S(   Ni   i    (    (    (    (    R   R5   Á   s    c              s   ˆ  ƒ  d  S(   N(   R5   (    (   R5   (    R   R<   Ã   s    c              s   ˆ  ƒ  d  S(   N(   R<   (    (   R<   (    R   t   hÅ   s    c              s   ˆ  ƒ  d  S(   N(   RD   (    (   RD   (    R   t   iÇ   s    c            s   ˆ  ƒ  d  S(   N(   RE   (   R4   (   RE   (    R   t   jÉ   s    i   R   i   i   i   i   R   (   R5   R<   RD   RE   RF   R   R6   R=   t   h_identt   i_identt   j_identR   R2   (   R   R=   RG   R<   R5   RE   RD   RF   RH   R6   RI   (    (   R<   R5   RE   RD   R   t   test_distant_exceptionÀ   s    	c            s¡   d „  ‰  ‡  d †  } t ˆ  ƒ } t | ƒ } |  i | d d | f d d | f d d | f d d | f d d | f d d | f d d | f d d | f g ƒ d  S(   Nc          c   s   x t  d ƒ D]
 }  |  Vq Wd  S(   Ni   (   t   rangeRE   (   RE   (    (    R   R5   Ý   s     c            s   x ˆ  ƒ  D] } q
 Wd  S(   N(   R5   RE   (   R4   RE   (   R5   (    R   R<   à   s    
 i   R   i   R   (   R5   R<   R   R6   R=   R   R2   (   R   R<   R=   R5   R6   (    (   R5   R   t   test_generatorÜ   s
    	c            s¡   d „  ‰  ‡  d †  } t ˆ  ƒ } t | ƒ } |  i | d d | f d d | f d d | f d d | f d d | f d d | f d d | f d d | f g ƒ d  S(   Nc          c   s%   x t  d ƒ D]
 }  |  Vq Wt ‚ d  S(   Ni   (   RK   RE   t   StopIteration(   RE   (    (    R   R5   ó   s     c            s   x ˆ  ƒ  D] } q
 Wd  S(   N(   R5   RE   (   R4   RE   (   R5   (    R   R<   ÷   s    
 i   R   i   R   (   R5   R<   R   R6   R=   R   R2   (   R   R<   R=   R5   R6   (    (   R5   R   t   test_stop_iterationò   s
    	(   R   R   R.   R7   R8   R9   R:   R;   R>   R?   R@   RA   RC   RJ   RL   RN   (    (    (    R   R3   S   s   																	t   ProfileSimulatorTestCasec           B   s5   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s
   t  |  ƒ S(   N(   R   R   (   R   (    (    R   R.   
  s    c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   d  S(   N(    (   R4   (    (    R   R5     s    i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   R7     s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   d d d  S(   Ni   i    (    (   R4   (    (    R   R5     s    i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   t   test_basic_exception  s    	c         C   sA   d „  } t | ƒ } |  i | d d | f d d | f g ƒ d  S(   Nc         C   s   y d d Wn n Xd  S(   Ni   i    (    (   R4   (    (    R   R5     s      i   R   R   (   R5   R   R6   R   R2   (   R   R6   R5   (    (    R   R9     s    	c            s  d „  ‰ ‡ d †  ‰  ‡  d †  ‰ ‡ d †  ‰ ‡ d †  } t ˆ ƒ }	 t ˆ  ƒ } t ˆ ƒ } t ˆ ƒ } t | ƒ }
 |  i | d d |
 f d d | f d	 d | f d
 d | f d d |	 f d d |	 f d
 d | f d	 d | f d d | f d d |
 f g
 ƒ d  S(   Nc           C   s   d d d  S(   Ni   i    (    (    (    (    R   R5   '  s    c              s   ˆ  ƒ  d  S(   N(   R5   (    (   R5   (    R   R<   )  s    c              s   ˆ  ƒ  d  S(   N(   R<   (    (   R<   (    R   RD   +  s    c              s   ˆ  ƒ  d  S(   N(   RD   (    (   RD   (    R   RE   -  s    c            s   ˆ  ƒ  d  S(   N(   RE   (   R4   (   RE   (    R   RF   /  s    i   R   i   i   i   i   R   (   R5   R<   RD   RE   RF   R   R6   R=   RG   RH   RI   R   R2   (   R   R=   RG   R<   R5   RE   RD   RF   RH   R6   RI   (    (   R<   R5   RE   RD   R   RJ   &  s    	(   R   R   R.   R7   RP   R9   RJ   (    (    (    R   RO   	  s
   					c         C   s6   t  |  d ƒ o |  i } n
 |  i } | i | i f S(   Nt   f_code(   t   hasattrt   functionRQ   t   codet	   func_codet   co_firstlinenot   co_name(   RS   RT   (    (    R   R   C  s    	c         C   s   y |  | ƒ Wn n Xd  S(   N(   R5   R4   (   R5   R4   (    (    R   t   protectK  s      c         C   sˆ   y t  i ƒ  Wn t j
 o n Xt i d ƒ ‚ | d  j o t ƒ  } n t  i | i ƒ t	 |  | ƒ t  i d  ƒ | i ƒ  d d !S(   Ns(   sys.setprofile() did not raise TypeErrori   iÿÿÿÿ(   R   t
   setprofilet	   TypeErrort   test_supportt
   TestFailedR4   R   R    R   RX   R-   R   (   R-   R4   (    (    R   R,   R  s    c         C   s    d  k  } | i  t |  ƒ ƒ d  S(   N(   R0   R,   R-   (   R-   R0   (    (    R   t   show_eventsc  s    	c           C   s   t  i t t ƒ d  S(   N(   R[   t   run_unittestR3   RO   (    (    (    R   t	   test_mainh  s    	t   __main__(   R0   R   t   unittestt   testR[   R    R   t   TestCaseR+   R3   RO   R   RX   t   protect_identR   R,   R]   R_   R   (   R[   R    RX   R+   R]   R3   R,   Ra   R0   R   R   R_   RO   Rd   R   (    (    R   t   ?   s    			 #¶:				