HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/python/test/__pycache__/test_syslog.cpython-38.pyc
U


W[T�@s^ddlmZddlmZzddlZWnek
r<dZYnXddlmZGdd�de�ZdS)�)�TestCase)�FailureN)�syslogc@s�eZdZdZdZedkrdZdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�SyslogObserverTestszS
    Tests for L{SyslogObserver} which sends Twisted log events to the syslog.
    Nz(syslog is not supported on this platformcCs4|�tjd|j�|�tjd|j�t�d�|_dS)N�openlogrr)ZpatchrZSyslogObserverr�observer��self�r
�A/usr/lib/python3/dist-packages/twisted/python/test/test_syslog.py�setUpszSyslogObserverTests.setUpcCs|||f|_g|_dS�N)Z	logOpened�events)r	�prefix�optionsZfacilityr
r
rrszSyslogObserverTests.openlogcCs|j�||f�dSr
)r�append)r	r�messager
r
rr$szSyslogObserverTests.syslogcCs&|j�dddd��|�|jg�dS)zm
        L{SyslogObserver.emit} ignores events with an empty value for the
        C{'message'} key.
        r
F�-�r�isError�systemN)r�emit�assertEqualrrr
r
r�test_emitWithoutMessage(sz+SyslogObserverTests.test_emitWithoutMessagecCs2|j�dddtjd��|�|jtjdfg�dS)��
        L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} as the
        syslog priority, if that key is present in the event dictionary.
        �zhello, worldFr)rrr�syslogPriority�[-] hello, worldN)rr�	stdsyslogZ	LOG_DEBUGrrrr
r
r�test_emitCustomPriority1s�
�z+SyslogObserverTests.test_emitCustomPrioritycCs8|j�dddttd��d��|�|jtjdfg�dS)zd
        L{SyslogObserver.emit} uses C{LOG_ALERT} if the event represents an
        error.
        rTrZfoo)rrr�failurerN)rrr�	ExceptionrrrZ	LOG_ALERTrr
r
r�test_emitErrorPriority>s
�
�z*SyslogObserverTests.test_emitErrorPriorityc	Cs<|j�dddtjttd��d��|�|jtjdfg�dS)z�
        L{SyslogObserver.emit} uses the value of the C{'syslogPriority'} key if
        it is specified even if the event dictionary represents an error.
        rTrZbar)rrrrr rN)rrrZ
LOG_NOTICErr!rrrr
r
r�%test_emitCustomPriorityOverridesErrorKs
�
�z9SyslogObserverTests.test_emitCustomPriorityOverridesErrorcCs8|j�dddtjd��|�|jtjtjBdfg�dS)rrFr)rrrZsyslogFacilityrN)rrrZLOG_CRONrr�LOG_INFOrr
r
r�test_emitCustomFacilityYs��z+SyslogObserverTests.test_emitCustomFacilitycCs.|j�dddd��|�|jtjdfg�dS)zt
        L{SyslogObserver.emit} uses the value of the C{'system'} key to prefix
        the logged message.
        rFZnonDefaultSystemrz[nonDefaultSystem] hello, worldN�rrrrrr$rr
r
r�test_emitCustomSystemfs
�
�z)SyslogObserverTests.test_emitCustomSystemcCs.|j�dddd��|�|jtjdfg�dS)z�
        L{SyslogObserver.emit} logs the value of the C{'message'} key of the
        event dictionary it is passed to the syslog.
        rFrrrNr&rr
r
r�test_emitMessagers�
�z$SyslogObserverTests.test_emitMessagecCs6|j�dddd��|�|jtjdftjdfg�dS)zW
        Each line of a multiline message is emitted separately to the syslog.
        )zhello,
worldFrr�
[-] hello,�
[-] 	worldNr&rr
r
r�test_emitMultilineMessages���z-SyslogObserverTests.test_emitMultilineMessagecCs6|j�dddd��|�|jtjdftjdfg�dS)zw
        Trailing empty lines of a multiline message are omitted from the
        messages sent to the syslog.
        )zhello,
world

Frrr)r*Nr&rr
r
r�!test_emitStripsTrailingEmptyLines�s���z5SyslogObserverTests.test_emitStripsTrailingEmptyLines)�__name__�
__module__�__qualname__�__doc__rr�skiprrrrrr"r#r%r'r(r+r,r
r
r
rrs 	




r)	Ztwisted.trial.unittestrZtwisted.python.failurerrr�ImportErrorZtwisted.pythonrr
r
r
r�<module>s