
    daf                         d dl mZmZ  ej                  d      Zd dlmZ d dlZd dlZd dl	Z	d dl
Z
d dlmZ  G d de
j                        Zedk(  r e
j                           yy)	    )import_helperthreading_helpersyslog)supportN)dedentc                   |    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
 ej                         d	        Zd
 Zd Zd Zy)Testc                 ,    t         j                          y N)r   closelogselfs    +/root/Python-3.12.4/Lib/test/test_syslog.pytearDownzTest.tearDown   s        c                 x    t         j                  d       | j                  t        t         j                  d       y )Npythonu   )r   openlogassertRaisesUnicodeEncodeErrorr   s    r   test_openlogzTest.test_openlog   s%    x ,fnnhGr   c                     t         j                  d       t         j                  d       t         j                  t         j                  d       y )Nr   $test message from python test_syslog"test error from python test_syslog)r   r   LOG_ERRr   s    r   test_syslogzTest.test_syslog   s.    x <=fnn&JKr   c                     t         j                          t         j                  d       t         j                  t         j                  d       y )Nr   r   )r   r   r   r   s    r   test_syslog_implicit_openzTest.test_syslog_implicit_open   s,    <=fnn&JKr   c                 ~    t         j                  d       t         j                          t         j                          y )Nr   )r   r   r   r   s    r   test_closelogzTest.test_closelog"   s"    x r   c                    t         j                  t         j                        }t         j                  |      }| j	                  t         j                  d      |       | j	                  t         j                  |      |       y )Nr   )r   LOG_UPTOLOG_WARNING
setlogmaskassertEqual)r   maskoldmasks      r   test_setlogmaskzTest.test_setlogmask'   s\    v112##D)**1-t4**73T:r   c                    t         j                  t         j                        }| j                  |t         j	                  t         j                        z         | j                  |t         j	                  t         j
                        z         | j                  |t         j	                  t         j                        z         y r   )r   r"   r#   
assertTrueLOG_MASKr   assertFalseLOG_INFO)r   r&   s     r   test_log_maskzTest.test_log_mask-   st    v112vv/A/ABBCvv~~>>? @@Ar   c                 V    t         j                          t         j                  d       y )Nr   )r   r   r   s    r   test_openlog_noargszTest.test_openlog_noargs3   s    <=r   c                 8   t        j                         dfd}fd}t        j                         }t	        j
                  d       	 t        j                  |      g}|t        d      D cg c]  }t        j                  |       c}z  }t        j                  |      5  j                          t        j                  d       dd d d        t        j
                  |       y c c}w # 1 sw Y   $xY w# t        j
                  |       w xY w)	NFc                  r    j                  d       d} s!t        j                  d|         | dz  } s y y )N
      zpython-test-)waitr   r   )istartstops    r   openerz)Test.test_syslog_threaded.<locals>.opener;   s7    JJrNAaS12Q r   c                  ^     j                  d       st        j                  d       sy y )Nr3   r   )r5   r   )r7   r8   s   r   loggerz)Test.test_syslog_threaded.<locals>.loggerA   s#    JJrNDE r   g&.>)targetr3   g?T)	threadingEventsysgetswitchintervalr   setswitchintervalThreadranger   start_threadssettimesleep)r   r9   r;   orig_sithreadskr7   r8   s         @@r   test_syslog_threadedzTest.test_syslog_threaded7   s    !		F
 '')!!$'	+ ''v67GrKA	((7KKG!//8 		

3
 !!'* L 
 !!'*s6   %D 4C1D +(C6D 1D 6C?;D Dc                    | j                  d      5  t        d      }t        j                  |      }| j	                  |d       d d d        t
        j                          	 | j                  d      5  t        d      }t        j                  |      }| j	                  |d       d d d        t
        j                          y # 1 sw Y   xY w# 1 sw Y   *xY w# t
        j                          w xY w)Nzbefore openlog()a   
                import syslog
                caught_error = False
                try:
                    syslog.syslog('foo')
                except RuntimeError:
                    caught_error = True
                assert(caught_error)
            r   zafter openlog()z\
                    import syslog
                    syslog.syslog('foo')
                )subTestr   r   run_in_subinterpr%   r   r   r   r   coderess      r   test_subinterpreter_syslogzTest.test_subinterpreter_syslogR   s     \\,- 	%  D **40CS!$	% 			/0 )   ..t4  a() OO/	% 	%) ) OOs/   3C"C 33C&C CCC C1c                     	 t        d      }t        j                  |      }| j                  |d       t        j                          y # t        j                          w xY w)Nz
                import syslog
                caught_error = False
                try:
                    syslog.openlog()
                except RuntimeError:
                    caught_error = True

                assert(caught_error)
            r   )r   r   rN   r%   r   r   rO   s      r   test_subinterpreter_openlogz Test.test_subinterpreter_openlogn   sM    	 	 	D **40CS!$OOFOOs   2A	 	Ac                     t         j                  d       	 t        d      }t        j                  |      }| j                  |d       t         j                          y # t         j                          w xY w)Nr   z
                import syslog
                caught_error = False
                try:
                    syslog.closelog()
                except RuntimeError:
                    caught_error = True

                assert(caught_error)
            r   )r   r   r   r   rN   r%   r   rO   s      r   test_subinterpreter_closelogz!Test.test_subinterpreter_closelog   sY    x 	 	 	D **40CS!$OOFOOs   2A A4N)__name__
__module____qualname__r   r   r   r   r    r(   r.   r0   r   requires_working_threadingrK   rR   rT   rV    r   r   r	   r	      s]    H
L
L

;B> 1002+ 3+48"r   r	   __main__)test.supportr   r   import_moduler   testr   r?   r=   rF   unittesttextwrapr   TestCaser	   rW   mainr[   r   r   <module>rd      s[    8	$	$	$X	.  
    A8 AH zHMMO r   