
    kcS                     |   d dl Z d dlZd dlZd dlZd dlZd dlZd dl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 d dlmZ  G d d	ej                        Z G d
 d      Z G d deej                        Z G d deej                        Zej(                  j+                  d      reZneZ G d de      Z G d de      Z G d dej                        Z G d dej                        Z G d dej8                        Z G d deej                        Z G d d      Zd Z e!d k(  r ejD                  d!"       yy)#    N)PY2)	as_string)StringIO)unicode)mock)DummyStreamc                       e Zd Zd Zy)
LevelTestsc                     ddl m} |j                  j                         D ]"  }| j	                  |j                  d             $ y )Nr   loggers_)
supervisorr   LOG_LEVELS_BY_NUMvaluesassertFalse
startswith)selfr   
level_names      ?/usr/lib/python3/dist-packages/supervisor/tests/test_loggers.py.test_LOG_LEVELS_BY_NUM_doesnt_include_builtinsz9LevelTests.test_LOG_LEVELS_BY_NUM_doesnt_include_builtins   s<    &!33::< 	9JZ22378	9    N)__name__
__module____qualname__r    r   r   r
   r
      s    9r   r
   c                   $    e Zd Zd Zd Zd Zd Zy)HandlerTestsc                     t        j                         | _        t        j                  j                  | j                  d      | _        y )Nthelog)tempfilemkdtempbasedirospathjoinfilenamer   s    r   setUpzHandlerTests.setUp   s,    '')T\\8<r   c                 b    	 t        j                  | j                         y # t        $ r Y y w xY wN)shutilrmtreer#   OSErrorr(   s    r   tearDownzHandlerTests.tearDown   s)    	MM$,,' 		s   " 	..c                 2    | j                         } ||i |S r+   _getTargetClass)r   argkwklasss       r   _makeOnezHandlerTests._makeOne#   s     $$&c R  r   c                 b    ddl m} |j                  |j                  j                  |d       }|S )Nr   r   )levelmsgexc_info)r   r   	LogRecordLevelsByNameINFO)r   r9   r   records       r   _makeLogRecordzHandlerTests._makeLogRecord'   s6    &""&&++ # 
 r   N)r   r   r   r)   r/   r6   r?   r   r   r   r   r      s    =!r   r   c                   N    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y)BareHandlerTestsc                     ddl m} |S )Nr   )Handler)supervisor.loggersrC   )r   rC   s     r   r2   z BareHandlerTests._getTargetClass1   
    .r   c                     t        t        t        j                              }| j	                  |      }| j                  |j                         d        y Nerrorstream)r   IOErrorerrnoEPIPEr6   assertEqualflushr   rK   insts      r   ,test_flush_stream_flush_raises_IOError_EPIPEz=BareHandlerTests.test_flush_stream_flush_raises_IOError_EPIPE5   s;    75;;#78}}F}+t,r   c                     t        t        t        j                              }| j	                  |      }| j                  t        |j                         y rG   )r   rL   rM   EALREADYr6   assertRaisesrP   rQ   s      r   0test_flush_stream_flush_raises_IOError_not_EPIPEzABareHandlerTests.test_flush_stream_flush_raises_IOError_not_EPIPE:   s9    75>>#:;}}F}+'4::.r   c                     t               }| j                  |      }d|_        | j                  |j	                         d        y )NrJ   T)r   r6   closedrO   closerQ   s      r   test_close_already_closedz*BareHandlerTests.test_close_already_closed?   s6    }}F}+t,r   c                     t        d      }| j                  |      }| j                  |j                         d        | j	                  |j
                         | j	                  |j                  j
                         y )N2   filenorJ   )r   r6   rO   rZ   
assertTruerY   rK   rQ   s      r    test_close_stream_fileno_above_3z1BareHandlerTests.test_close_stream_fileno_above_3E   sX    B'}}F}+t,$**+r   c                     t        d      }| j                  |      }| j                  |j                         d        | j	                  |j
                         | j	                  |j                  j
                         y )Nr   r^   rJ   )r   r6   rO   rZ   r   rY   rK   rQ   s      r    test_close_stream_fileno_below_3z1BareHandlerTests.test_close_stream_fileno_below_3L   s\    A&}}F}+t,%++,r   c                     t               }| j                  |      }|j                          | j                  |j                         y )NrJ   )r   r6   rZ   r`   rY   rQ   s      r   6test_close_stream_handles_fileno_unsupported_operationzGBareHandlerTests.test_close_stream_handles_fileno_unsupported_operationS   s4     }}F}+

$r   c                     t               }d }||_        | j                  |      }|j                          | j	                  |j
                         y )Nc                      t               r+   )rL   r   r   r   raise_ioerrorzPBareHandlerTests.test_close_stream_handles_fileno_ioerror.<locals>.raise_ioerror]   s	    )Or   rJ   )r   r_   r6   rZ   r`   rY   )r   rK   rh   rR   s       r   (test_close_stream_handles_fileno_ioerrorz9BareHandlerTests.test_close_stream_handles_fileno_ioerror[   s>    	%}}F}+

$r   c                     t               }| j                  |      }| j                  d      }|j                  |       | j	                  |j
                  d       | j	                  |j                  d       y )NrJ      fooT)r   r6   r?   emitrO   flushedwrittenr   rK   rR   r>   s       r   test_emit_gardenpathz%BareHandlerTests.test_emit_gardenpathd   s]    }}F}+$$V,		&.0r   c                     t        t              }| j                  |      }| j                  d      }|j	                  |       | j                  |j                  d       | j                  |j                  d       y )NrH   rJ   rk   T)r   UnicodeErrorr6   r?   rl   rO   rm   rn   ro   s       r   test_emit_unicode_errorz(BareHandlerTests.test_emit_unicode_errorl   s`    <0}}F}+$$V,		&.0r   c                    t        t              }| j                  |      }g fd|_        | j	                  d      }|j                  |       | j                  |j                  d       | j                  |j                  d       y )NrH   rJ   c                  &     j                  d      S NTappendhandleds   r   <lambda>z8BareHandlerTests.test_emit_other_error.<locals>.<lambda>x   s    7>>$#7 r   rk   Fr   )	r   
ValueErrorr6   handleErrorr?   rl   rO   rm   rn   )r   rK   rR   r>   rz   s       @r   test_emit_other_errorz&BareHandlerTests.test_emit_other_errort   sn    :.}}F}+7$$V,		&/-r   N)r   r   r   r2   rS   rW   r[   ra   rc   re   ri   rp   rs   r~   r   r   r   rA   rA   0   s9    -
/
-,-%%11.r   rA   c                   T    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 Zy)FileHandlerTestsc                     ddl m} |S )Nr   )FileHandler)rD   r   )r   r   s     r   r2   z FileHandlerTests._getTargetClass   s    2r   c                    | j                  | j                        }| j                  t        j                  j                  | j                        | j                         | j                  |j                  d       | j                  |j                  | j                         | j                  |j                  j                  | j                         |j                          y )Nab)r6   r'   r`   r$   r%   existsrO   modebaseFilenamerK   namerZ   r   handlers     r   	test_ctorzFileHandlerTests.test_ctor   s    --.t}}5t}}Et,--t}}=,,dmm<r   c                     | j                  | j                        }|j                  j                          t	               |_        |j                          | j                  |j                  j                  d       y rv   )r6   r'   rK   rZ   r   rO   rY   r   s     r   
test_closezFileHandlerTests.test_close   sP    --.$..5r   c                 "   | j                  | j                        }|j                  j                          t	        t
              |_        | j                  t
        |j                         | j                  |j                  j                  d       y NF)	r6   r'   rK   rZ   r   r.   rV   rO   rY   r   s     r   test_close_raisesz"FileHandlerTests.test_close_raises   s^    --.$W-'7==1..6r   c                 h   | j                  | j                        }|j                  j                          t	               }||_        |j                          | j                  |j                  d       | j                  |j                  j                  | j                         |j                          y rv   )	r6   r'   rK   rZ   r   reopenrO   rY   r   r   r   rK   s      r   test_reopenzFileHandlerTests.test_reopen   sw    --.-,,dmm<r   c                 h   | j                  | j                        }|j                  j                          t	               }||_        t
        j                  j                  | j                  dd      |_	        | j                  t        |j                         | j                  |j                  d       y )Nnotthereza.logT)r6   r'   rK   rZ   r   r$   r%   r&   r#   r   rV   rL   r   rO   rY   r   s      r   test_reopen_raisesz#FileHandlerTests.test_reopen_raises   sw    --.!ww||DLL*gN'7>>2-r   c                 f   | j                  | j                        }| j                  t        j                  j                  | j                        | j                         |j                          | j                  t        j                  j                  | j                        | j                         y r+   )r6   r'   r`   r$   r%   r   remover   r   s     r   test_remove_existsz#FileHandlerTests.test_remove_exists   sf    --.t}}5t}}E6Fr   c                    | j                  | j                        }t        j                  | j                         | j	                  t        j
                  j                  | j                        | j                         |j                          | j	                  t        j
                  j                  | j                        | j                         y r+   )r6   r'   r$   r   r   r%   r   r   s     r   test_remove_doesntexistz(FileHandlerTests.test_remove_doesntexist   sx    --.
		$-- 6F6Fr   c                 |   | j                  | j                        }t        j                  | j                         t        j                  | j                         | j                  t        j                  j                  | j                        | j                         | j                  t        |j                         y r+   )
r6   r'   r$   r   mkdirr`   r%   r   rV   r.   r   s     r   test_remove_raisesz#FileHandlerTests.test_remove_raises   sk    --.
		$-- 
t}}5t}}E'7>>2r   c                 4   | j                  | j                        }| j                  d      }|j                  |       |j	                          t        | j                  d      5 }| j                  |j                         d       d d d        y # 1 sw Y   y xY w)N   hello!rbr6   r'   r?   rl   rZ   openrO   readr   r   r>   fs       r   test_emit_ascii_noerrorz(FileHandlerTests.test_emit_ascii_noerror   st    --.$$Y/V$--& 	2!QVVXy1	2 	2 	2   $!BBc                 4   | j                  | j                        }| j                  d      }|j                  |       |j	                          t        | j                  d      5 }| j                  |j                         d       d d d        y # 1 sw Y   y xY w)Ns   fiír   r   r   s       r   test_emit_unicode_noerrorz*FileHandlerTests.test_emit_unicode_noerror   st    --.$$]3V$--& 	6!QVVX}5	6 	6 	6r   c                    | j                  | j                        }|j                  j                          t	        t
              |_        | j                  d      }	 t        j                  }t	               }|t        _        |j                  |       |t        _        | j                  |j                  j                  d      |j                         y # t        _        w xY w)NrH   r   s   OSError
)r6   r'   rK   rZ   r   r.   r?   sysstderrrl   r`   rn   endswith)r   r   r>   
old_stderrdummy_stderrs        r   test_emit_errorz FileHandlerTests.test_emit_error   s    --.$73$$Y/	$J&=L%CJLL #CJ,,55lC$,,	. $CJs   6C C!N)r   r   r   r2   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ~   s@    67.GG326.r   r   /dev/stdoutc                       e Zd Zd Zy)StdoutTestsc                    | j                  d      }| j                  |j                  dv |j                         | j                  |j                  d       | j                  |j
                  j                  d       |j                          y )Nr   )wbr   )r6   r`   r   rO   r   rK   r   rZ   r   s     r   test_ctor_with_dev_stdoutz%StdoutTests.test_ctor_with_dev_stdout   sf    --. 	4gllC--}=,,m<r   N)r   r   r   r   r   r   r   r   r      s    r   r   c                   N    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y)RotatingFileHandlerTestsc                     ddl m} |S )Nr   )RotatingFileHandler)rD   r   )r   r   s     r   r2   z(RotatingFileHandlerTests._getTargetClass   s    :""r   c                    | j                  | j                        }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       |j                          y )Nr   i    
   )r6   r'   rO   r   maxBytesbackupCountrZ   r   s     r   r   z"RotatingFileHandlerTests.test_ctor   s]    --.t,))=9,,b1r   c                 	   | j                  | j                  dd      }| j                  d      }|j                  |       | j	                  t
        j                  j                  | j                  dz                | j	                  t
        j                  j                  | j                  dz                |j                  |       | j	                  t
        j                  j                  | j                  dz                | j	                  t
        j                  j                  | j                  dz                |j                  |       | j                  t
        j                  j                  | j                  dz                | j	                  t
        j                  j                  | j                  dz                |j                  |       | j                  t
        j                  j                  | j                  dz                | j	                  t
        j                  j                  | j                  dz                |j                  |       | j                  t
        j                  j                  | j                  dz                | j	                  t
        j                  j                  | j                  dz                |j                  |       | j                  t
        j                  j                  | j                  dz                | j                  t
        j                  j                  | j                  dz                |j                  |       |j                          | j                  t
        j                  j                  | j                  dz                | j                  t
        j                  j                  | j                  dz                t        | j                  d      5 }| j                  |j                         d       d d d        t        | j                  dz   d      5 }| j                  |j                         d       d d d        t        | j                  dz   d      5 }| j                  |j                         d       d d d        y # 1 sw Y   xY w# 1 sw Y   XxY w# 1 sw Y   y xY w)	Nr      r   r      aaaa.1z.2r   s   aaaaaaaaaaaa)r6   r'   r?   rl   r   r$   r%   r   r`   rZ   r   rO   r   r   s       r   test_emit_does_rolloverz0RotatingFileHandlerTests.test_emit_does_rollover   s5   ---J$$X.V(<=>(<=>V(<=>(<=>Vt}}t';<=(<=>Vt}}t';<=(<=>Vt}}t';<=(<=>Vt}}t';<=t}}t';<=Vt}}t';<=t}}t';<=$--& 	1!QVVXx0	1 $--$d+ 	2qQVVXy1	2 $--$d+ 	2qQVVXy1	2 	2	1 	1	2 	2	2 	2s$   !R5	!S!S5R>S
Sc                 @   | j                  | j                  dd      }| j                  d      }|j                  |       | j	                  t
        j                  j                  | j                               | j                  t
        j                  j                  | j                  dz                t        j                  | j                         | j                  t
        j                  j                  | j                               |j                  |       |j                          | j	                  t
        j                  j                  | j                               | j                  t
        j                  j                  | j                  dz                y )N      r   r   r   )r6   r'   r?   rl   r`   r$   r%   r   r   unlinkrZ   r   r   r>   s      r   test_current_logfile_removedz5RotatingFileHandlerTests.test_current_logfile_removed'  s    --q-I$$X.Vt}}56(<=> 			$-- 67Vt}}56(<=>r   c                    | j                  | j                        }g g fd|_        d |_        fd|_        |j                  dd       | j                  dg       | j                  g        |j                          y )Nc                 &    j                  |       S r+   rw   vremovess    r   r{   zZRotatingFileHandlerTests.test_removeAndRename_destination_does_not_exist.<locals>.<lambda><      !2 r   c                      yr   r   r   s    r   r{   zZRotatingFileHandlerTests.test_removeAndRename_destination_does_not_exist.<locals>.<lambda>=      r   c                 *    j                  | |f      S r+   rw   strenamess     r   r{   zZRotatingFileHandlerTests.test_removeAndRename_destination_does_not_exist.<locals>.<lambda>>      GNNAq6$: r   foobarr   r   r6   r'   _remove_exists_renameremoveAndRenamerO   rZ   r   rR   r   r   s     @@r   /test_removeAndRename_destination_does_not_existzHRotatingFileHandlerTests.test_removeAndRename_destination_does_not_exist8  sp    }}T]]+2&:UE*>"23"%

r   c                    | j                  | j                        }g g fd|_        d |_        fd|_        |j                  dd       | j                  dg       | j                  dg       |j                          y )Nc                 &    j                  |       S r+   rw   r   s    r   r{   zRRotatingFileHandlerTests.test_removeAndRename_destination_exists.<locals>.<lambda>H  r   r   c                      yrv   r   r   s    r   r{   zRRotatingFileHandlerTests.test_removeAndRename_destination_exists.<locals>.<lambda>I  r   r   c                 *    j                  | |f      S r+   rw   r   s     r   r{   zRRotatingFileHandlerTests.test_removeAndRename_destination_exists.<locals>.<lambda>J  r   r   r   r   r   r   r   s     @@r   'test_removeAndRename_destination_existsz@RotatingFileHandlerTests.test_removeAndRename_destination_existsD  sr    }}T]]+2%:UE*>"235'*

r   c                     d }| j                  | j                        }g ||_        d |_        fd|_        |j                  dd       | j                  dg       |j                          y )Nc                 4    t        t        j                        r+   r.   rM   ENOENTfns    r   r   zRRotatingFileHandlerTests.test_removeAndRename_remove_raises_ENOENT.<locals>.removeQ      %,,''r   c                      yrv   r   r   s    r   r{   zTRotatingFileHandlerTests.test_removeAndRename_remove_raises_ENOENT.<locals>.<lambda>V  r   r   c                 *    j                  | |f      S r+   rw   r   s     r   r{   zTRotatingFileHandlerTests.test_removeAndRename_remove_raises_ENOENT.<locals>.<lambda>W  r   r   r   r   r   r   )r   r   rR   r   s      @r   )test_removeAndRename_remove_raises_ENOENTzBRotatingFileHandlerTests.test_removeAndRename_remove_raises_ENOENTP  s`    	(}}T]]+%:UE*>"23

r   c                     d }| j                  | j                        }||_        d |_        | j	                  t
        |j                  dd       |j                          y )Nc                 4    t        t        j                        r+   r.   rM   EAGAINr   s    r   r   z]RotatingFileHandlerTests.test_removeAndRename_remove_raises_other_than_ENOENT.<locals>.remove]  r   r   c                      yrv   r   r   s    r   r{   z_RotatingFileHandlerTests.test_removeAndRename_remove_raises_other_than_ENOENT.<locals>.<lambda>a  r   r   r   r   )r6   r'   r   r   rV   r.   r   rZ   )r   r   rR   s      r   4test_removeAndRename_remove_raises_other_than_ENOENTzMRotatingFileHandlerTests.test_removeAndRename_remove_raises_other_than_ENOENT\  sJ    	(}}T]]+%'4#7#7F

r   c                     d }| j                  | j                        }||_        d |_        | j	                  |j                  dd      d        |j                          y )Nc                 4    t        t        j                        r+   r   r   ds     r   renamezRRotatingFileHandlerTests.test_removeAndRename_rename_raises_ENOENT.<locals>.renamef  r   r   c                      yr   r   r   s    r   r{   zTRotatingFileHandlerTests.test_removeAndRename_rename_raises_ENOENT.<locals>.<lambda>j  r   r   r   r   )r6   r'   r   r   rO   r   rZ   r   r   rR   s      r   )test_removeAndRename_rename_raises_ENOENTzBRotatingFileHandlerTests.test_removeAndRename_rename_raises_ENOENTe  sM    	(}}T]]+&--eU;TB

r   c                     d }| j                  | j                        }||_        d |_        | j	                  t
        |j                  dd       |j                          y )Nc                 4    t        t        j                        r+   r   r   s     r   r   z]RotatingFileHandlerTests.test_removeAndRename_rename_raises_other_than_ENOENT.<locals>.renameo  r   r   c                      yr   r   r   s    r   r{   z_RotatingFileHandlerTests.test_removeAndRename_rename_raises_other_than_ENOENT.<locals>.<lambda>s  r   r   r   r   )r6   r'   r   r   rV   r.   r   rZ   r  s      r   4test_removeAndRename_rename_raises_other_than_ENOENTzMRotatingFileHandlerTests.test_removeAndRename_rename_raises_other_than_ENOENTn  sJ    	(}}T]]+&'4#7#7F

r   c                     | j                  | j                        }d|_        | j                  |j	                         d        |j                          y )Nr   )r6   r'   r   rO   
doRolloverrZ   )r   rR   s     r   !test_doRollover_maxbytes_lte_zeroz:RotatingFileHandlerTests.test_doRollover_maxbytes_lte_zerow  s;    }}T]]+*D1

r   N)r   r   r   r2   r   r   r   r   r   r   r   r  r  r	  r   r   r   r   r      s:    #(2T?"


r   r   c                   2    e Zd Zd ZddZd Zd Zd Zd Zy)	BoundIOTestsc                     ddl m} |S )Nr   )BoundIO)rD   r  )r   r  s     r   r2   zBoundIOTests._getTargetClass  rE   r   c                 4    | j                         } |||      S r+   r1   )r   maxbytesbufr5   s       r   r6   zBoundIOTests._makeOne  s    $$&Xs##r   c                     | j                  dd      }|j                  d       | j                  |j                  d       y )Nr      a   b)r6   writerO   r  r   ios     r   test_write_overflowz BoundIOTests.test_write_overflow  s1    ]]1d#
&r   c                 h    | j                  dd      }| j                  |j                         d       y )Nr   r  )r6   rO   getvaluer  s     r   test_getvaluezBoundIOTests.test_getvalue  s(    ]]1d#-r   c                     | j                  dd      }|j                          | j                  |j                  d       y Nr   r  r   )r6   clearrO   r  r  s     r   
test_clearzBoundIOTests.test_clear  /    ]]1d#

%r   c                     | j                  dd      }|j                          | j                  |j                  d       y r  )r6   rZ   rO   r  r  s     r   r   zBoundIOTests.test_close  r  r   N) )	r   r   r   r2   r6   r  r  r  r   r   r   r   r  r  ~  s     $'
.&
&r   r  c                   P    e Zd Zd ZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zy)LoggerTestsc                     ddl m} |S )Nr   )Logger)rD   r%  )r   r%  s     r   r2   zLoggerTests._getTargetClass  s
    -r   Nc                 4    | j                         } |||      S r+   r1   )r   r8   handlersr5   s       r   r6   zLoggerTests._makeOne  s    $$&UH%%r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y Nr   r<   hellor   )rD   r<   DummyHandlerBLATr6   blatherrO   lenrecordsTRACr8   r   r<   r   loggers       r   test_blatherzLoggerTests.test_blather  s    3|001|007*=wW__-q1#((wW__-q1r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y r)  )rD   r<   r,  r1  r6   tracerO   r/  r0  DEBGr8   r2  s       r   
test_tracezLoggerTests.test_trace      3|001|007*=WW__-q1#((WW__-q1r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y r)  )rD   r<   r,  r7  r6   debugrO   r/  r0  r=   r8   r2  s       r   
test_debugzLoggerTests.test_debug  r9  r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y r)  )rD   r<   r,  r=   r6   inforO   r/  r0  WARNr8   r2  s       r   	test_infozLoggerTests.test_info      3|001|007*=GW__-q1#((GW__-q1r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y r)  )rD   r<   r,  r?  r6   warnrO   r/  r0  ERROr8   r2  s       r   	test_warnzLoggerTests.test_warn  rA  r   c                 n   ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       |j                  |_
        |j                  d       | j                  t        |j                        d       y r)  )rD   r<   r,  rD  r6   rI   rO   r/  r0  CRITr8   r2  s       r   
test_errorzLoggerTests.test_error  r9  r   c                     ddl m} t        |j                        }| j	                  |j                  |f      }|j                  d       | j                  t        |j                        d       y r)  )	rD   r<   r,  rG  r6   criticalrO   r/  r0  r2  s       r   test_criticalzLoggerTests.test_critical  sR    3|001|007*= W__-q1r   c                     ddl m} t        |j                        }| j	                  |j                  |f      }|j                          | j                  |j                  d       y )Nr   r*  T)rD   r<   r,  rG  r6   rZ   rO   rY   r2  s       r   r   zLoggerTests.test_close  sJ    3|001|007*=.r   c                     ddl m} t        |j                        }| j	                  |j                  |f      }| j                  t        |j                         y )Nr   r*  )rD   r<   r,  rG  r6   rV   NotImplementedErrorr  r2  s       r   r  zLoggerTests.test_getvalue  sB    3|001|007*=-v?r   )NN)r   r   r   r2   r6   r4  r8  r<  r@  rE  rH  rK  r   r  r   r   r   r#  r#    s:    &2222222/@r   r#  c                        e Zd Z fdZ xZS )
MockSysLogc                     |d   }t         j                  dk  r t        |t              r|j	                          t        t        |   |i | y )N)   r   )r   version_info
isinstancer   encodesuperrP  __call__)r   argskwargsmessage	__class__s       r   rX  zMockSysLog.__call__  sC    r(f$GW)E NNj$($9&9r   )r   r   r   rX  __classcell__)r\  s   @r   rP  rP    s    : :r   rP  c                   h   e Zd Zd Zd Zd Zd Zd Z ej                  d e
             d        Z ej                  d e
             d        Z ej                  d e
             d	        Zer" ej                  d e
             d
        Zd Zy ej                  d e
             d        Zd Zy)SyslogHandlerTestsc                      y r+   r   r(   s    r   r)   zSyslogHandlerTests.setUp      r   c                      y r+   r   r(   s    r   r/   zSyslogHandlerTests.tearDown  ra  r   c                 @    t        d      j                  j                  S )Nzsupervisor.loggers)
__import__r   SyslogHandlerr(   s    r   r2   z"SyslogHandlerTests._getTargetClass  s    ./77EEEr   c                 ,     | j                                S r+   r1   r(   s    r   r6   zSyslogHandlerTests._makeOne  s    %t##%''r   c                      G d dt               } |       }| j                         }g fd|_        |j                  |       | j	                  dg       y )Nc                       e Zd Zd Zy)ASyslogHandlerTests.test_emit_record_asdict_raises.<locals>.Recordc                     t         r+   )	TypeErrorr(   s    r   asdictzHSyslogHandlerTests.test_emit_record_asdict_raises.<locals>.Record.asdict  s    r   N)r   r   r   rl  r   r   r   Recordri    s     r   rm  c                  &     j                  d      S rv   rw   ry   s   r   r{   zCSyslogHandlerTests.test_emit_record_asdict_raises.<locals>.<lambda>  s    gnnT&: r   T)objectr6   r}   rl   rO   )r   rm  r>   r   rz   s       @r   test_emit_record_asdict_raisesz1SyslogHandlerTests.test_emit_record_asdict_raises  sN    	 V 	  --/:V4&)r   zsyslog.syslogc                 (   | j                         }| j                  d      }|j                  |       t        j                  j	                  d       | j                  d      }|j                  |       t        j                  j	                  d       y )Nr   zhello!zhi!r6   r?   rl   syslogassert_called_withr   s      r   r   z*SyslogHandlerTests.test_emit_ascii_noerror  si    --/$$Y/V((2$$U+V((/r   c                 D    | j                         }|j                          y r+   )r6   rZ   r   s     r   r   zSyslogHandlerTests.test_close!  s    --/r   c                 D    | j                         }|j                          y r+   )r6   r   r   s     r   r   zSyslogHandlerTests.test_reopen&  s    --/r   c                     | j                         }t        d      }| j                  |      }|j                  |       t        j                  j                  d       y )N   fií   fiÃ­)r6   r   r?   rl   rs  rt  )r   r   inpr>   s       r   r   z,SyslogHandlerTests.test_emit_unicode_noerror,  sE    mmoGF#C((-FLL MM,,\:r   c                     | j                         }g fd}||_        | j                  t        d            }|j	                  |       | j                  t        d      g       y )Nc                 8    sj                  |        t        y r+   rx   rr   r9   calleds    r   fake_syslogzCSyslogHandlerTests.test_emit_unicode_witherror.<locals>.fake_syslog6      MM#&&& r   rx  ry  )r6   _syslogr?   r   rl   rO   r   r   r  r>   r  s       @r   test_emit_unicode_witherrorz.SyslogHandlerTests.test_emit_unicode_witherror3  sZ    mmoGF' *GO((6):;FLL Vi&=%>?r   c                     | j                         }| j                  d      }|j                  |       t        j                  j	                  d       y )Nrx  rr  r   s      r   r   z,SyslogHandlerTests.test_emit_unicode_noerror?  s;    mmoG((0FLL MM,,V4r   c                     | j                         }g fd}||_        | j                  d      }|j                  |       | j	                  dg       y )Nc                 8    sj                  |        t        y r+   r}  r~  s    r   r  zCSyslogHandlerTests.test_emit_unicode_witherror.<locals>.fake_syslogH  r  r   rx  )r6   r  r?   rl   rO   r  s       @r   r  z.SyslogHandlerTests.test_emit_unicode_witherrorE  sO    mmoGF' *GO((0FLL VfX.r   N)r   r   r   r)   r/   r2   r6   rp  r   patchrP  r   r   r   r   r   r  r   r   r   r_  r_    s    F(	* TZZ.0 /0 TZZ. / TZZ. / 	OZ\	2	; 
3	;
	@ 
OZ\	2	5 
3	5

	/r   r_  c                   "    e Zd ZdZd Zd Zd Zy)r,  Fc                      || _         g | _        y r+   )r8   r0  )r   r8   s     r   __init__zDummyHandler.__init__S  s    
r   c                 :    | j                   j                  |       y r+   )r0  rx   )r   r>   s     r   rl   zDummyHandler.emitV  s    F#r   c                     d| _         y rv   )rY   r(   s    r   rZ   zDummyHandler.closeX  s	    r   N)r   r   r   rZ   r  rl   r   r   r   r,  r,  Q  s    E$r   r,  c                  V    t        j                  t        j                  t                 S r+   )unittestfindTestCasesr   modulesr   r   r   r   
test_suiter  [  s    !!#++h"788r   __main__r  )defaultTest)#rM   r   r  r!   r,   r$   rs  supervisor.compatr   r   r   r   supervisor.tests.baser   r   TestCaser
   r   rA   r   r%   r   StdoutTestsBasero  r   r   r  r#  MockrP  r_  r,  r  r   mainr   r   r   <module>r     s,    
    	  ! ' & % & -9"" 9 0L.|X%6%6 L.\`.|X%6%6 `.D 77>>- &O O/ K/ K\&8$$ &8W@(## W@t: :Q/x'8'8 Q/f 9 zHMMl+ r   