mς
­fIc           @   sΆ   d  k  Z  d  k Z  d  k Z d  k Z d  k Z d k l Z d k l Z l Z l	 Z	 d   Z
 d e  i i f d     YZ d e i f d     YZ d   Z e d	 j o e   n d  S(
   N(   s   test_support(   s   ENTERs   EXITs   LINEc         C   s3   |  o$ t i i t i i |    d Sn |  Sd  S(   Ni    (   t   fnt   ost   patht   splitextt   basename(   R    (    (    t.   /mit/python/lib/python2.4/test/test_hotshot.pyt   shortfilename   s    $t   UnlinkingLogReaderc           B   s#   t  Z d  Z d   Z e d  Z RS(   sM   Extend the LogReader so the log file is unlinked when we're
    done with it.c         C   s#   | |  _ t i i i |  |  d  S(   N(   t   logfnt   selft   _UnlinkingLogReader__logfnt   hotshott   logt	   LogReadert   __init__(   R	   R   (    (    R   R      s    	c         C   sN   y t  i i i |   SWn0 t j
 o$ |  i   t i |  i	    n Xd  S(   N(
   R   R   R   t   nextR	   t   StopIterationt   closeR   t   unlinkR
   (   R	   t   index(    (    R   R      s    
(   t   __name__t
   __module__t   __doc__R   t   NoneR   (    (    (    R   R      s    	t   HotShotTestCasec           B   sb   t  Z d d d  Z d   Z d   Z d   Z d  d  Z d   Z d	   Z	 d
   Z
 d   Z RS(   Ni    i   c         C   s"   t  i |  _ t i |  i | |  S(   N(   t   test_supportt   TESTFNR	   R   R   t   Profilet
   lineeventst   linetimings(   R	   R   R   (    (    R   t   new_profiler(   s    c         C   s   t  |  i  S(   N(   R   R	   R   (   R	   (    (    R   t   get_logreader,   s    c         C   s[   g  } xN |  i   D]@ } | \ } \ } } } } | i	 | t
 |  | | f f  q W| S(   N(   t   LR	   R   t   eventt   whatt   filenamet   linenot   funcnamet   tdeltat   appendR   (   R	   R"   R    R#   R$   R&   R%   R!   (    (    R   t   get_events_wotime/   s     &c         C   sJ   |  i   } | | j o- |  i d t i |  t i |  f  n d  S(   Ns6   events did not match expectation; got:
%s
expected:
%s(   R	   R(   t   eventst   expectedt   failt   pprintt   pformat(   R	   R*   R)   (    (    R   t   check_events6   s    c         C   s   | d  j o |  i   } n |  i | i i  | i |  |  i | i i  | i	   |  i | i i  |  i
 |  d  S(   N(   t   profilerR   R	   R   t
   failUnlesst   _proft   closedt   runcallt   callableR   R.   R)   (   R	   R4   R)   R/   (    (    R   t   run_test=   s    
c         C   sl   d   } |  i   } | i | |  | i   |  i   } | i } t
 |  |  i | d d g j  d  S(   Nc         C   s   |  i d d  d  S(   Ns   test-keys
   test-value(   t   pt   addinfo(   R6   (    (    R   t   fH   s    s   test-keys
   test-value(   R8   R	   R   R/   R3   R   R   R   t   _infot   infot   listR0   (   R	   R:   R   R8   R/   (    (    R   t   test_addinfoG   s    	
	
c            sΰ   d       d   }   i i } | i i } t d | d f f t d | d d f f t d | d f f t d | d d f f t d | d d f f t d | d f f t d | d f f g } |  i | | |  i d d   d  S(	   Nc          C   s   d }  d } d  S(   Ni   i   (   t   yt   x(   R=   R>   (    (    R   R8   S   s    c              s       d  S(   N(   R8   (    (   R8   (    R   t   gV   s    t   test_hotshotR?   i   R8   i   R   (   R8   R?   t	   func_codet   co_firstlinenot   f_linenot   g_linenot   ENTERt   LINEt   EXITR)   R	   R5   R   (   R	   R?   R8   RD   RC   R)   (    (   R8   R   t   test_line_numbersR   s    	c         C   s>   |  i   } | i   | i   | i   t i |  i  d  S(   N(	   R	   R   R/   t   startt   stopR   R   R   R   (   R	   R/   (    (    R   t   test_start_stopd   s
    


c         C   s‘   d  k  } d  k } | i } t i i } z? d | _ |  i t	 | t
 i  | ` |  i t	 | t
 i  Wd  | | _ | i i t
 i  o | i t
 i  n Xd  S(   Nt   abc(   t   sysR   R   t	   orig_pathR   t   _hotshott   coverageR	   t   assertRaisest   RuntimeErrorR   R   t   existst   remove(   R	   RP   RM   R   RN   (    (    R   t   test_bad_sys_pathn   s    				 	(   R   R   R   R   R(   R.   R   R5   R<   RH   RK   RU   (    (    (    R   R   '   s   			
			
c           C   s   t  i t  d  S(   N(   R   t   run_unittestR   (    (    (    R   t	   test_main   s    t   __main__(   R   t   hotshot.logR   R,   t   unittestt   testR   RE   RG   RF   R   R   R   R   t   TestCaseR   RW   R   (   R   R   R   RZ   R,   R   RG   RW   R   RE   RF   R   (    (    R   t   ?   s   						
X	