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 :  /usr/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 : /usr/lib/python3/dist-packages/twisted/logger/test/__pycache__/test_stdlib.cpython-310.pyc
o

�b�!�@s&dZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZmZddl
mZmZmZddlmZddlmZdd	lmZdd
lmZddlmZdd
lmZmZddlmZddl m!Z!deee"e#ffdd�Z$Gdd�d�Z%Gdd�dej&�Z'deeeffdd�Z(Gdd�dej)�Z*dS)z+
Test cases for L{twisted.logger._format}.
�N)�
getsourcefile)�BytesIO�
TextIOWrapper)�	Formatter�	LogRecord�
StreamHandler�	getLogger)�List�Optional�Tuple)�BrokenMethodImplementation)�verifyObject)�currentframe)�Failure)�unittest�)�ILogObserver�LogEvent)�LogLevel)�STDLibLogObserver�returncCs&td�}ttj|jd�|jdfS)z�
    Retrive the file name and line number immediately after where this function
    is called.

    @return: the file name and line number
    ��__name__)rr�sys�modules�	f_globals�f_lineno)�caller�r�A/usr/lib/python3/dist-packages/twisted/logger/test/test_stdlib.py�nextLines�r c@s2eZdZdZd
dd�Zd
dd�Zdefdd	�ZdS)�StdlibLoggingContainerzF
    Continer for a test configuration of stdlib logging objects.
    rNcCsZtd�|_|j��|_|j�tj�t�|_|j�	|j�t
�\|_|_|j�	|j�dS)N�)
r�
rootLogger�getEffectiveLevel�
originalLevel�setLevel�
py_logging�DEBUG�BufferedHandler�bufferedHandler�
addHandler�handlerAndBytesIO�
streamHandler�output��selfrrr�__init__-s
zStdlibLoggingContainer.__init__cCsB|j�|j�|j�|j�|j�|j�|j��|j��dS)z#
        Close the logger.
        N)r#r&r%�
removeHandlerr*r-�closer.r/rrrr39s

zStdlibLoggingContainer.closecCs|j���d�S)zd
        Get the output to the underlying stream as text.

        @return: the output text
        �utf-8)r.�getvalue�decoder/rrr�outputAsTextCsz#StdlibLoggingContainer.outputAsText�rN)r�
__module__�__qualname__�__doc__r1r3�strr7rrrrr!(s



r!c@s�eZdZdZddd�Zdefdd�Zdedee	e
effd	d
�Zddd�Z
dd
d�Zddd�Zddd�Zddd�Zddd�Zddd�Zddd�ZdS)�STDLibLogObserverTestsz)
    Tests for L{STDLibLogObserver}.
    rNc
CsHt�}ztt|�WdSty#}z|�|�WYd}~dSd}~ww)z=
        L{STDLibLogObserver} is an L{ILogObserver}.
        N)rr
rr�fail)r0�observer�errr�test_interfaceQs��z%STDLibLogObserverTests.test_interfacecCst�}|�|j�|S)zj
        Create a logging object we can use to test with.

        @return: a stdlib-style logger
        )r!�
addCleanupr3)r0�loggerrrr�	py_logger[sz STDLibLogObserverTests.py_logger�eventscGs:|��}ttjdd�}|D]}||�q|jj|��fS)z�
        Send one or more events to Python's logging module, and capture the
        emitted L{LogRecord}s and output stream as a string.

        @param events: events

        @return: a tuple: (records, output)
        r)�
stackDepth)rDr�defaultStackDepthr*�recordsr7)r0rE�plr?�eventrrr�logEventes	��
zSTDLibLogObserverTests.logEventcCs4|�i�\}}|�t|�d�|�|djd�dS)z
        Logger name.
        rr�twistedN)rK�assertEqual�len�name�r0rHr.rrr�	test_name{sz STDLibLogObserverTests.test_namec	Cs�dtjtjtjtjtjtjtjtjtj	tj
tji}g}|��D]\}}i}|dur-||d<t
|�|d<|�|�q|j|�\}}|�t|�t|��tt|��D]}|�||j||d�qPdS)z
        Log levels.
        N�	log_level�
py_levelno)r'�INFOr�debugr(�info�warn�WARNING�error�ERROR�critical�CRITICAL�items�int�appendrKrMrN�range�levelno)	r0�levelMappingrE�level�pyLevelrJrHr.�irrr�test_levels�s&�
�z"STDLibLogObserverTests.test_levelscCs`t�\}}|�i�\}}|�t|�d�|�|dj|�|�|dj|�|�|dj�dS)zb
        C{pathname}, C{lineno}, C{exc_info}, C{func} is set properly on
        records.
        rrN)r rKrMrN�pathname�lineno�assertIsNone�exc_info)r0�filename�logLinerHr.rrr�test_callerInfo�s
z&STDLibLogObserverTests.test_callerInfocCsVtddd�}|�|�\}}|�t|�d�|�t|dj�d�|�|djd�dS)	zL
        Basic formattable event passes the format along correctly.
        �
Hello, {who}!�dude��
log_format�whorrzHello, dude!rN)�dictrKrMrNr<�msg�args�r0rJrHr.rrr�test_basicFormat�s
z'STDLibLogObserverTests.test_basicFormatcCsDtddd�}|�|�\}}|�t|�d�|�|�d�t|��dS)z<
        Basic formattable event renders correctly.
        rnrorprz:Hello, dude!
N)rsrKrMrN�
assertTrue�endswith�reprrvrrr�test_basicFormatRendered�sz/STDLibLogObserverTests.test_basicFormatRenderedcCs8|�i�\}}|�t|�d�|�t|dj�d�dS)z'
        Event with no format.
        rrr"N)rKrMrNr<rtrPrrr�
test_noFormat�sz$STDLibLogObserverTests.test_noFormatcCs�ddd�}z|�Wntyt�}Ynwtdd|d�}|�|�\}}|�t|�d�|�d|�|�d	|�|�d
|�dS)zK
        An event with a failure logs the failure details as well.
        rNcS�dddS�Nrrrrrrr�failing_func��z9STDLibLogObserverTests.test_failure.<locals>.failing_func�Hi mom�me�rqrr�log_failurer�in failing_func�ZeroDivisionErrorr8)r�rrsrKrMrN�assertIn�r0r�failurerJrHr.rrr�test_failure�s


�z#STDLibLogObserverTests.test_failurecCs�ddd�}z|�Wntyt�}|��Ynwtdd|d�}|�|�\}}|�t|�d�|�d|�|�d	|�|�d
|�dS)z�
        A cleaned Failure object has a fake traceback object; make sure that
        logging such a failure still results in the exception details being
        logged.
        rNcSr}r~rrrrrr�r�z@STDLibLogObserverTests.test_cleanedFailure.<locals>.failing_funcr�r�r�rr�r�r8)r�r�cleanFailurersrKrMrNr�r�rrr�test_cleanedFailure�s

�z*STDLibLogObserverTests.test_cleanedFailurer8)rr9r:r;rAr!rDrrr	rr<rKrQrfrmrwr{r|r�r�rrrrr=Ls




	
#




	r=cCs<t�}tj}t|ddd�}t|�}t|�}|�|�||fS)z�
    Construct a 2-tuple of C{(StreamHandler, BytesIO)} for testing interaction
    with the 'logging' module.

    @return: handler and io object
    r4�
)�encoding�newline)rr'�BASIC_FORMATrrr�setFormatter)r.�template�stream�	formatter�handlerrrrr,s
r,c@s,eZdZdZd	dd�Zdeddfdd�ZdS)
r)zN
    A L{py_logging.Handler} that remembers all logged records in a list.
    rNcCstj�|�g|_dS)z5
        Initialize this L{BufferedHandler}.
        N)r'�Handlerr1rHr/rrrr1s
zBufferedHandler.__init__�recordcCs|j�|�dS)z&
        Remember the record.
        N)rHr_)r0r�rrr�emit szBufferedHandler.emitr8)rr9r:r;r1rr�rrrrr)s
r))+r;�loggingr'r�inspectr�iorrrrrr�typingr	r
r�zope.interface.exceptionsr�zope.interface.verifyr
�twisted.python.compatr�twisted.python.failurer�
twisted.trialr�_interfacesrr�_levelsr�_stdlibrr<r^r r!�TestCaser=r,r�r)rrrr�<module>s*$9

Anon7 - 2022
AnonSec Team