+
    Dfj-                     l    ^ RI Ht ^ RIHt  ^ RIt]t^ RIHt  ! R R]4      t	R#   ] d    Rt Li ; i)    )Failure)TestCaseN)syslogc                   |   a  ] tR t^t o RtRt]f   RtR tR t	R t
R tR tR	 tR
 tR tR tR tR tR tRtV tR# )SyslogObserverTestszK
Tests for L{SyslogObserver} which sends Twisted log events to the syslog.
Nz(syslog is not supported on this platformc                    V P                  \        P                  R V P                  4       V P                  \        P                  RV P                  4       \        P                  ! R4      V n        R# )openlogr   r   N)patchr   SyslogObserverr	   observerselfs   &A/usr/lib/python3/dist-packages/twisted/python/test/test_syslog.pysetUpSyslogObserverTests.setUp   sI    

6(()T\\B

6(((DKK@--.CD    c                &    WV3V n         . V n        R # N)	logOpenedevents)r   prefixoptionsfacilitys   &&&&r   r	   SyslogObserverTests.openlog   s     84r   c                >    V P                   P                  W34       R # r   )r   append)r   r   messages   &&&r   r   SyslogObserverTests.syslog#   s    G-.r   c                    V P                   P                  RRRRRR/4       V P                  V P                  . 4       R# )zU
L{SyslogObserver.emit} ignores events with an empty value for the
C{'message'} key.
r   isErrorFsystem-N )r   emitassertEqualr   r   s   &r   test_emitWithoutMessage+SyslogObserverTests.test_emitWithoutMessage&   s7    
 	Ir9eXsKLb)r   c           
         V P                   P                  RR	RRRRR\        P                  /4       V P	                  V P
                  \        P                  R3.4       R# )

L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the
syslog priority, if that key is present in the event dictionary.
r   r    Fr!   r"   syslogPriority[-] hello, worldNzhello, world)r   r$   	stdsyslog	LOG_DEBUGr%   r   r   s   &r   test_emitCustomPriority+SyslogObserverTests.test_emitCustomPriority.   s[    
 	,5# )"5"5		
 		(;(;=O'P&QRr   c                    V P                   P                  RR
RRRRR\        \        R4      4      /4       V P	                  V P
                  \        P                  R3.4       R	# )zL
L{SyslogObserver.emit} uses C{LOG_ALERT} if the event represents an
error.
r   r    Tr!   r"   failurefoor+   Nr,   )r   r$   r   	Exceptionr%   r   r-   	LOG_ALERTr   s   &r   test_emitErrorPriority*SyslogObserverTests.test_emitErrorPriority=   s_    
 	,4#79U#34		
 		(;(;=O'P&QRr   c                    V P                   P                  RRRRRRR\        P                  R\	        \        R4      4      /4       V P                  V P                  \        P                  R	3.4       R
# )z
L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} key if
it is specified even if the event dictionary represents an error.
r   r    Tr!   r"   r*   r2   barr+   Nr,   )r   r$   r-   
LOG_NOTICEr   r4   r%   r   r   s   &r   %test_emitCustomPriorityOverridesError9SyslogObserverTests.test_emitCustomPriorityOverridesErrorL   sj    
 	,4# )"6"679U#34	
 		(<(<>P'Q&RSr   c           
         V P                   P                  RR	RRRRR\        P                  /4       V P	                  V P
                  \        P                  \        P                  ,          R3.4       R# )
r)   r   r    Fr!   r"   syslogFacilityr+   Nr,   )r   r$   r-   LOG_CRONr%   r   LOG_INFOr   s   &r   test_emitCustomFacility+SyslogObserverTests.test_emitCustomFacility\   si    
 	,5# )"4"4		
 	KK9--	0B0BBDVWX	
r   c                    V P                   P                  RRRRRR/4       V P                  V P                  \        P
                  R3.4       R# )	z\
L{SyslogObserver.emit} uses the value of the C{'system'} key to prefix
the logged message.
r   r    Fr!   nonDefaultSystemz[nonDefaultSystem] hello, worldNr,   r   r$   r%   r   r-   r@   r   s   &r   test_emitCustomSystem)SyslogObserverTests.test_emitCustomSystemm   sT    
 	,5,	
 	KK9--/PQR	
r   c                    V P                   P                  RRRRRR/4       V P                  V P                  \        P
                  R3.4       R# )	zs
L{SyslogObserver.emit} logs the value of the C{'message'} key of the
event dictionary it is passed to the syslog.
r   r    Fr!   r"   r+   Nr,   rE   r   s   &r   test_emitMessage$SyslogObserverTests.test_emitMessage}   sL    
 	)9eXsK	
 		(:(:<N'O&PQr   c                    V P                   P                  RR	RRRR/4       V P                  V P                  \        P
                  R3\        P
                  R3.4       R# )
zG
Each line of a multiline message is emitted separately to the syslog.
r   r    Fr!   r"   
[-] hello,
[-] 	worldN)zhello,
worldrE   r   s   &r   test_emitMultilineMessage-SyslogObserverTests.test_emitMultilineMessage   s\     	*IuhL	
 	KK  ,/)2D2Dm1TU	
r   c                    V P                   P                  RR	RRRR/4       V P                  V P                  \        P
                  R3\        P
                  R3.4       R# )
z_
Trailing empty lines of a multiline message are omitted from the
messages sent to the syslog.
r   r    Fr!   r"   rL   rM   N)zhello,
world

rE   r   s   &r   !test_emitStripsTrailingEmptyLines5SyslogObserverTests.test_emitStripsTrailingEmptyLines   s\    
 	.	5(CP	
 	KK  ,/)2D2Dm1TU	
r   )r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r-   skipr   r	   r   r&   r/   r6   r;   rA   rF   rI   rN   rQ   __static_attributes____classdictcell__)__classdict__s   @r   r   r      sb      F9E
/*SST 
"
 R


 
r   r   )
twisted.python.failurer   twisted.trial.unittestr   r   
_stdsyslogr-   twisted.pythonImportErrorr   r#   r   r   <module>ra      sC    + +& I%N
( N
  Is   ' 	33