σ
ϋR_c           @@  sε   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z m Z m Z m Z e   Z e d  Z e d  Z e d	  Z d
 e f d     YZ d e f d     YZ d e f d     YZ d S(   i    (   t   absolute_import(   t	   getLogger(   t   TestCase(   t   ShouldAssert(   t   patch(   t   log_capturet   comparet
   Comparisont
   LogCapturet   onet   twos	   one.childt   TestLog_Capturec           B@  sζ   e  Z e d  d  e d  e   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 e   e d  d     Z e d  e   d     Z RS(   R
   s	   one.childR	   c         C@  s   t  j d  t j d  t j d  t j d  | j d d d d  | j d d  | j d d  t | j t d
  t d
  g  d  S(   Nt   1t   2t   3t   4t   roott   INFOR	   R
   s	   one.childs   logging.LogRecord(   R   R   R   (   R	   R   R   (   R
   R   R   (   s	   one.childR   R   (   R	   R   R   (   s	   one.childR   R   (   R
   R   R   (   s	   one.childR   R   (	   R   t   infoR	   R
   t   childt   checkR   t   recordst   C(   t   selft   l1t   l2t   l3(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_logging   s$    		c         @  sς   t    } t  d  } | j } | j } z§ | j } | j d  | j } | j d  t d  t     f d     } |     j | j d    j | j d    j | j |    j | j |  Wd  | j |  | j |  Xd  S(   NR   i1   iE   c         @  sv   t    } | j d    j | j d  t  d  }   j | j d  | j d  |  j d d  | j d	  d  S(
   NR   i   R   R   R   R   (   R   R   R   (   R   R   R   (   R   R   R   (   R   R   t   assertEqualt   levelR   (   R   R   R   R   (   R   (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_method?   s    	(   R   t   handlersR   t   setLevelR   R   (   R   R   R   t   before_roott   before_childt   old_root_levelt   old_child_levelR   (    (   R   s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_uninstall_properly4   s$    	

			c         C@  s   |  j  t | t   d  S(   N(   t
   failUnlesst
   isinstanceR   (   R   t   l(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt!   test_decorator_returns_logcapture\   s    c         @  si   t        j } zF t   g   _ } t     f d    } |   t   j |  Wd  |   _ Xd  S(   Nc         @  s     j  d  |  j d  d  S(   Nt   duringR   R   (   R   R   R*   (   R   R   (   R(   (   t   logger(    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyR   j   s    (   R   R   t   objectR   R   (   R   t   originalt   startR   (    (   R+   s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_remove_existing_handlersb   s    		c         C@  sS   d d l  m } m } t   } | j   |  j | | k  |  j | | k  d  S(   Ni    (   t	   _handlerst   _handlerList(   t   loggingR0   R1   R   t	   uninstallt   assertFalse(   R   R0   R1   t   capture(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_clear_global_statev   s
    	
c         @  st   t  d    t   j t  t d d t   f d    } t    } |   Wd  QX| j   t   j t  d  S(   NR   t	   propagatec         @  s     j  d  |  j d  d  S(   Ns   a log messageR   R   (   R   R   s   a log message(   R   R   (   R(   (   R+   (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyR      s    (   R   R   R7   t   TrueR   t   FalseR   R   (   R   R   t
   global_log(    (   R+   s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_no_propogate}   s    !
c         C@  s9   t  d d   } t   j d  Wd  QX| j d  d  S(	   Nt
   attributest   funcNamet   processNames   oh hait   test_different_attributest   MainProcess(   R=   R>   (   R?   R@   (   R   R   R   R   (   R   t   log(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyR?      s    c         C@  s<   t  d d   } t   j d d  Wd  QX| j d  d  S(   NR<   t   msgt   lolwuts   oh %st   hai(   RB   RC   (   s   oh %sN(   R   R   R   R   t   None(   R   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_missing_attribute   s    c      
   C@  sZ   t  d d g  & } t   j t d d d d   Wd  QX| j t d d d d   d  S(   NR<   RB   t   foot   bart   bazt   bob(   R   R   R   t   dictR   (   R   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_single_attribute   s    %c      
   C@  sZ   d   } t  d |  & } t   j t d d d d   Wd  QX| j t d d   d  S(   Nc         S@  s   d   |  j  j   D S(   Nc         S@  s+   i  |  ]! \ } } | d  k r | |  q S(   RI   (    (   t   .0t   kt   v(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pys
   <dictcomp>₯   s   	 	(   RB   t   items(   t   record(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   extract_msg€   s    R<   RG   RH   RI   RJ   (   R   R   R   RK   R   (   R   RR   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt"   test_callable_instead_of_attribute£   s
    	%c      
   C@  sH   t  d d  & } t   j d  d t d d  Wd  QX| j d  d  S(   NR<   RB   RG   t   extraRH   (   RB   RG   (   NRH   (   R   R   R   RE   RK   R   (   R   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_msg_is_none­   s    %c      	   C@  sF   t     } t   j d  Wd  QXt d   | j d  Wd  QXd  S(   Ns   oh haist   sequence not as expected:

same:
()

expected:
(('root', 'INFO', 'oh noez'),)

actual:
(('root', 'INFO', 'oh hai'),)R   R   s   oh noez(   R   R   s   oh noez(   R   R   R   R   R   (   R   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_normal_check΄   s
    
c      	   C@  sL   t  d t   } t   j d  Wd  QXt d   | j d  Wd  QXd  S(   Nt   recursive_checks   oh hais,  sequence not as expected:

same:
()

expected:
(('root', 'INFO', 'oh noez'),)

actual:
(('root', 'INFO', 'oh hai'),)

While comparing [0]: sequence not as expected:

same:
('root', 'INFO')

expected:
('oh noez',)

actual:
('oh hai',)

While comparing [0][2]: 'oh noez' (expected) != 'oh hai' (actual)R   R   s   oh noez(   R   R   s   oh noez(   R   R8   R   R   R   R   (   R   RA   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_recursive_checkΓ   s
    
s'   testfixtures.tests.sample1.SampleClassAc         C@  sB   g  | | f D] } t  |  j ^ q } t | d d d g d  S(   Nt   expectedt	   MagicMockt   LogCaptureForDecorator(   t   typet   __name__R   (   R   t   a1t   a2t   ct   actual(    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_patch_then_logΧ   s    (c         C@  sB   g  | | f D] } t  |  j ^ q } t | d d d g d  S(   NRY   R[   RZ   (   R\   R]   R   (   R   R^   R_   R`   Ra   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_log_then_patchέ   s    ((   R]   t
   __module__R   R   R%   R)   R/   R6   R;   R?   RF   RL   RS   RU   RV   RX   R   Rb   Rc   (    (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyR      s&   		(							
				t   BaseCaptureTestc           B@  s    e  Z d  Z e   d    Z RS(   i!   c         C@  sZ   t    } |  j d k  r4 | j d j |  j   n  | j d d d j |  j  f  d  S(   Ni,   s   {} is smaller than 44R   R   (   R   t   aR   t   formatR   (   R   t   logsR+   (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   test_logs_if_a_smaller_than_44η   s
    	(   R]   Rd   Rf   R   Ri   (    (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyRe   δ   s   t   SubclassCaptureTestc           B@  s   e  Z d  Z RS(   i   (   R]   Rd   Rf   (    (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyRj   ς   s   N(   t
   __future__R    R2   R   t   unittestR   t   testfixtures.shouldraiseR   t   testfixtures.mockR   t   testfixturesR   R   R   R   R   R   R	   R
   R   R   Re   Rj   (    (    (    s\   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_log_capture.pyt   <module>   s   "	Ρ