Ñò
¾?TE  c           @   s*  d  Z  d d k Z d d k i i Z d d k Z d d k Z y d d k	 l	 Z	 Wn# e
 j
 o d d k l	 Z	 n Xd d k l Z d d k l Z l Z d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   s   Debugger TestsiÿÿÿÿN(   t   StringIO(   t   Debugger(   t   Eventt	   Componentt   testc           B   s   e  Z d  Z RS(   s
   test Event(   t   __name__t
   __module__t   __doc__(    (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyR      s   t   Appc           B   s   e  Z e d  „ Z RS(   c         C   s   | o t  ƒ  ‚ n d  S(   N(   t	   Exception(   t   selft   raiseException(    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyR      s    (   R   R   t   FalseR   (    (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyR      s   t   Loggerc           B   s&   e  Z d Z d Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t	   error_msg(   R
   t   msg(    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   error$   s    c         C   s   | |  _  d  S(   N(   t	   debug_msg(   R
   R   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   debug'   s    N(   R   R   t   NoneR   R   R   R   (    (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyR      s   	c          C   s  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 W| i d ƒ | i ƒ  | i } | pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } t ƒ  } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } t | ƒ } | | j } | pt
 i d | f d | | f ƒ h d	 t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d	 d 6d
 t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d
 d 6d t i	 ƒ  j p t
 i t ƒ o t
 i t ƒ n d d 6t
 i | ƒ d 6} d h | d 6}	 t t
 i |	 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  t | _ | i } | }
 |
 pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } }
 t ƒ  } |  i | ƒ | i d ƒ | i ƒ  i ƒ  } d } | | j } | p™ t
 i d | f d | | f ƒ h d	 t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d	 d 6t
 i | ƒ d 6} d h | d 6} t t
 i | ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  d  S(   Nt   filei    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}t   debuggert   py0t   py2s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}t   st   et   py3t   strt   py5s   assert %(py7)st   py7s/   assert not %(py2)s
{%(py2)s = %(py0)s._events
}t    s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   R   R    R   t   registert   flusht   seekt   truncatet   _eventst   @py_builtinst   localst
   @pytest_art   _should_repr_global_namet	   _safereprt   AssertionErrort   _format_explanationR   R   t   firet   readt   stripR   t   _call_reprcompareR   (   t   appt   stderrR   t   @py_assert1t   @py_format3R   R   t   @py_assert4t   @py_format6t   @py_format8t   @py_assert3t   @py_format4t   @py_assert2(    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt	   test_main+   s`    		 
	  T  	
   ã   

		   T  
	   o   
c         C   s+  t  |  i d ƒ ƒ } t | d ƒ } t ƒ  } t d | ƒ } | i | ƒ x | o | i ƒ  qL W| i d ƒ | i ƒ  | i	 } | pm d h d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6t i | ƒ d 6} t t i | ƒ ƒ ‚ n d  } t ƒ  } | i | ƒ | i ƒ  | i d ƒ | i ƒ  i ƒ  } t  | ƒ }	 | |	 j } | pt i d | f d | |	 f ƒ h d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6d t
 i ƒ  j p t i t  ƒ o t i t  ƒ n d d 6t i |	 ƒ d 6}
 d h |
 d 6} t t i | ƒ ƒ ‚ n d  } }	 | i d ƒ | i ƒ  t | _	 | i	 } | } | pm d h d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6t i | ƒ d 6} t t i | ƒ ƒ ‚ n d  } } t ƒ  } | i | ƒ | i d ƒ | i ƒ  i ƒ  } d } | | j } | p™ t i d | f d | | f ƒ h d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6t i | ƒ d 6} d h | d 6}
 t t i |
 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  d  S(   Ns	   debug.logs   w+R   i    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}R   R   R   s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}R   R   R   R   R   s   assert %(py7)sR   s/   assert not %(py2)s
{%(py2)s = %(py0)s._events
}R   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   R   t   ensuret   openR   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   R   R+   R,   R-   R.   R   (   t   tmpdirt   logfileR0   R/   R   R1   R2   R   R   R3   R4   R5   R6   R7   R8   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt	   test_fileM   sb    	 
	  T  	
   ã   

		   T  
	   o   
c         C   sL  d t  i j o t i d ƒ n t |  i d ƒ ƒ } t | d ƒ } t ƒ  } t d | ƒ } | i	 | ƒ x | o | i
 ƒ  qm W| i d ƒ | i ƒ  | i } | pm d h d t i ƒ  j p t i | ƒ o t i | ƒ n d d	 6t i | ƒ d
 6} t t i | ƒ ƒ ‚ n d  } t ƒ  } | i | ƒ | i
 ƒ  | i d ƒ | i ƒ  i ƒ  } t | ƒ }	 | |	 j } | pt i d | f d | |	 f ƒ h d t i ƒ  j p t i | ƒ o t i | ƒ n d d	 6d t i ƒ  j p t i | ƒ o t i | ƒ n d d 6d t i ƒ  j p t i t ƒ o t i t ƒ n d d
 6t i |	 ƒ d 6}
 d h |
 d 6} t t i | ƒ ƒ ‚ n d  } }	 | i d ƒ | i ƒ  t | _ | i } | } | pm d h d t i ƒ  j p t i | ƒ o t i | ƒ n d d	 6t i | ƒ d
 6} t t i | ƒ ƒ ‚ n d  } } t ƒ  } | i | ƒ | i d ƒ | i ƒ  i ƒ  } d } | | j } | p™ t i d | f d | | f ƒ h d t i ƒ  j p t i | ƒ o t i | ƒ n d d	 6t i | ƒ d 6} d h | d 6}
 t t i |
 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  d  S(   Nt   __pypy__s   Broken on pypys	   debug.logs   r+R   i    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}R   R   R   s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}R   R   R   R   R   s   assert %(py7)sR   s/   assert not %(py2)s
{%(py2)s = %(py0)s._events
}R   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   t   syst   modulest   pytestt   skipR   R:   R;   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   R   R+   R,   R-   R.   R   (   R<   R=   R0   R/   R   R1   R2   R   R   R3   R4   R5   R6   R7   R8   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_filenamer   sf    	 
	  T  	
   ã   

		   T  
	   o   
c          C   s"  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 W| i d ƒ | i ƒ  | i } | pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } | i } | pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } t d t ƒ } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } t | ƒ } | | j } | pt
 i d | f d | | f ƒ h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6d t i	 ƒ  j p t
 i t ƒ o t
 i t ƒ n d d 6t
 i | ƒ d 6} d h | d 6}	 t t
 i |	 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  |  i ƒ  | i d ƒ | i ƒ  i ƒ  } | i } d }
 | |
 ƒ } | p d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6t
 i |
 ƒ d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } }
 } | i d ƒ | i ƒ  t | _ t | _ | i } | }
 |
 pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } }
 | i } | }
 |
 pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } }
 t d t ƒ } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } d } | | j } | p™ t
 i d | f d | | f ƒ h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} d h | d 6} t t
 i | ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  |  i ƒ  | i d ƒ | i ƒ  i ƒ  } d } | | j } | p™ t
 i d | f d  | | f ƒ h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} d h | d 6} t t
 i | ƒ ƒ ‚ n d  } } d  S(!   NR   i    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}R   R   R   s+   assert %(py2)s
{%(py2)s = %(py0)s._errors
}R   s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}R   R   R   R   R   s   assert %(py7)sR   s   <exception[*]sL   assert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.startswith
}(%(py4)s)
}t   py4t   py6s/   assert not %(py2)s
{%(py2)s = %(py0)s._events
}s/   assert not %(py2)s
{%(py2)s = %(py0)s._errors
}R   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   s   ==(   s   %(py0)s == %(py3)s(   R   R    R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   t   _errorsR   t   TrueR+   R,   R-   R   R.   t
   startswithR   (   R/   R0   R   R1   R2   R   R   R3   R4   R5   R6   t   @py_assert5t   @py_format7R7   R8   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_exceptionsš   s¦    		 
	  T  	  T  
   ã   


	    t  
			   T  
	   T  

   o   


   o   c          C   s–  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 W| i d ƒ | i ƒ  | i } | pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } | i i d g ƒ t ƒ  } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } t | ƒ } | | j } | pt
 i d | f d | | f ƒ h d
 t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d
 d 6d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6d t i	 ƒ  j p t
 i t ƒ o t
 i t ƒ n d d 6t
 i | ƒ d 6} d h | d 6}	 t t
 i |	 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  t ƒ  } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } d }
 | |
 j } | p™ t
 i d | f d | |
 f ƒ h d
 t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d
 d 6t
 i |
 ƒ d 6} d h | d 6} t t
 i | ƒ ƒ ‚ n d  } }
 | i d ƒ | i ƒ  d  S(   NR   i    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}R   R   R   R   s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}R   R   R   R   R   s   assert %(py7)sR   R   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   R   R    R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   t   IgnoreEventst   extendR   R+   R,   R-   R   R.   R   (   R/   R0   R   R1   R2   R   R   R3   R4   R5   R8   R7   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_IgnoreEventsÎ   sV    		 
	  T  	
   ã   

	
   o   
c          C   s–  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 W| i d ƒ | i ƒ  | i } | pm d h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i | ƒ d 6} t t
 i | ƒ ƒ ‚ n d  } | i i d g ƒ t ƒ  } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } t | ƒ } | | j } | pt
 i d | f d | | f ƒ h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6d t i	 ƒ  j p t
 i t ƒ o t
 i t ƒ n d d 6t
 i | ƒ d 6} d h | d 6}	 t t
 i |	 ƒ ƒ ‚ n d  } } | i d ƒ | i ƒ  t ƒ  } |  i | ƒ |  i ƒ  | i d ƒ | i ƒ  i ƒ  } d }
 | |
 j } | p™ t
 i d | f d | |
 f ƒ h d t i	 ƒ  j p t
 i | ƒ o t
 i | ƒ n d d 6t
 i |
 ƒ d 6} d h | d 6} t t
 i | ƒ ƒ ‚ n d  } }
 | i d ƒ | i ƒ  d  S(   NR   i    s+   assert %(py2)s
{%(py2)s = %(py0)s._events
}R   R   R   t   *R   s   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}R   R   R   R   R   s   assert %(py7)sR   R   s   %(py0)s == %(py3)ss   assert %(py5)s(   RP   s   test(   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}(   s   ==(   s   %(py0)s == %(py3)s(   R   R    R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R   t   IgnoreChannelsRN   R   R+   R,   R-   R   R.   R   (   R/   R0   R   R1   R2   R   R   R3   R4   R5   R8   R7   (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_IgnoreChannelsñ   sV    		 
	  T  	
   ã   

	
   o   
c    	      C   s¾  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 Wt ƒ  } |  i | ƒ |  i ƒ  | i } t | ƒ } | | j } | pt	 i
 d | f d | | f ƒ h d t i ƒ  j p t	 i | ƒ o t	 i | ƒ n d d 6t	 i | ƒ d 6d t i ƒ  j p t	 i | ƒ o t	 i | ƒ n d d 6d t i ƒ  j p t	 i t ƒ o t	 i t ƒ n d d	 6t	 i | ƒ d
 6} d h | d 6} t t	 i | ƒ ƒ ‚ n d  } } } d  S(   Nt   loggers   ==sO   %(py2)s
{%(py2)s = %(py0)s.debug_msg
} == %(py7)s
{%(py7)s = %(py4)s(%(py5)s)
}R   R   R   R   t   reprRE   R   s   assert %(py9)st   py9(   s   ==(   sO   %(py2)s
{%(py2)s = %(py0)s.debug_msg
} == %(py7)s
{%(py7)s = %(py4)s(%(py5)s)
}(   R   R   R   R   R    R   R+   R   RT   R&   R.   R$   R%   R'   R(   R)   R*   R   (	   R/   RS   R   R   R1   t   @py_assert6R6   R5   t   @py_format10(    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_Logger_debug  s$    		 	
	    ó   c    	      C   sZ  t  ƒ  }  t ƒ  } t d | ƒ } | i |  ƒ x |  o |  i ƒ  q1 Wt d t ƒ } |  i | ƒ x |  o |  i ƒ  qf W| i } | i	 } d } | | ƒ } | p d h d t
 i ƒ  j p t i | ƒ o t i | ƒ n d d 6t i | ƒ d 6t i | ƒ d 6t i | ƒ d 6t i | ƒ d	 6} t t i | ƒ ƒ ‚ n d  } } } } d  S(
   NRS   R   s$   ERROR <handler[*.test] (App.test)> (sk   assert %(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.error_msg
}.startswith
}(%(py6)s)
}R   t   py8R   RE   RF   (   R   R   R   R   R    R   RH   R+   R   RI   R$   R%   R&   R'   R(   R)   R*   R   (	   R/   RS   R   R   R1   R6   RJ   t   @py_assert7t   @py_format9(    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   test_Logger_error"  s(    		  	 	    „  (   R   t   __builtin__R$   t   _pytest.assertion.rewritet	   assertiont   rewriteR&   R@   RB   R    t   ImportErrort   iot   circuitsR   t   circuits.coreR   R   R   R   t   objectR   R9   R>   RD   RL   RO   RR   RX   R\   (    (    (    s8   /home/prologic/work/circuits/tests/core/test_debugger.pyt   <module>   s*     	"	%	(	4	#	"	