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/trial/test/__pycache__/test_log.cpython-38.pyc
U


W[!�@s�dZddlmZmZddlZddlmZmZddlm	Z	m
Z
ddlmZm
Z
mZdd�ZGd	d
�d
e�ZGdd�dej�ZGd
d�de�ZGdd�deej�ZGdd�deej�ZdS)zG
Test the interaction between trial and errors logged during test run.
�)�division�absolute_importN)�reactor�task)�failure�log)�unittest�reporter�	_synctestcCs.zddWntk
r(t��}YnX|S)z*
    Return a new, realistic failure.
    �r)�ZeroDivisionErrorr�Failure)�f�r�=/usr/lib/python3/dist-packages/twisted/trial/test/test_log.py�makeFailures
rc@sHeZdZdZGdd�de�ZGdd�deej�ZGdd�deej	�Z
dS)	�Maskz?
    Hide C{MockTest}s from Trial's automatic test finder.
    c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
zMask.FailureLoggingMixincCsdS)z/
            Don't log any errors.
            Nr��selfrrr�test_silent!sz$Mask.FailureLoggingMixin.test_silentcCst�t��dS)z-
            Log a single error.
            N�r�errrrrrr�test_single&sz$Mask.FailureLoggingMixin.test_singlecCst�t��t�t��dS)z)
            Log two errors.
            Nrrrrr�test_double,sz$Mask.FailureLoggingMixin.test_doublecCst�t��dddS)z8
            Log a single error, then fail.
            rNrrrrr�test_singleThenFail4sz,Mask.FailureLoggingMixin.test_singleThenFailN)�__name__�
__module__�__qualname__rrrrrrrr�FailureLoggingMixin src@seZdZdS)zMask.SynchronousFailureLoggingN)rrrrrrr�SynchronousFailureLogging<src@seZdZdd�ZdS)zMask.AsynchronousFailureLoggingcCst�tddd��S)zC
            Log an error in an asynchronous callback.
            rcSst�t��S�Nrrrrr�<lambda>E�zAMask.AsynchronousFailureLogging.test_inCallback.<locals>.<lambda>)rZ
deferLaterrrrrr�test_inCallbackAsz/Mask.AsynchronousFailureLogging.test_inCallbackN)rrrr#rrrr�AsynchronousFailureLogging@sr$N)rrr�__doc__�objectrr�SynchronousTestCaser�TestCaser$rrrrrsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�
ObserverTestsz
    Tests for L{_synctest._LogObserver}, a helper for the implementation of
    L{SynchronousTestCase.flushLoggedErrors}.
    cCst��|_t��|_dSr )r	�
TestResult�resultr
�_LogObserver�observerrrrr�setUpNs
zObserverTests.setUpcCs0|j�dt��ddd��|�|j��g�dS)zW
        Test that a standard log message doesn't go anywhere near the result.
        )zsome messager�-)�message�time�isError�systemN)r-�gotEventr1�assertEqual�	getErrorsrrrr�test_msgSs�zObserverTests.test_msgc	Cs<t�}|j�dt��dd|dd��|�|j��|g�dS)zF
        Test that an observed error gets added to the result
        rrr/N�r0r1r2r3rZwhy)rr-r4r1r5r6�rrrrr�
test_error]s�zObserverTests.test_errorcCsL|��|j��}|�|j��g�|�t|�d�|�|d�t��dS)zS
        Check that flushing the observer with no args removes all errors.
        rrN)	r:r-�flushErrorsr5r6�len�
assertTrue�checkr)r�flushedrrr�
test_flushis

zObserverTests.test_flushcCst�td��S)Nz
test error)rr
�RuntimeErrorrrrr�_makeRuntimeFailuretsz!ObserverTests._makeRuntimeFailurec
Csx|��|��}|j�tdt��dd|dd��|j�t�}|�|j�	�|g�|�t
|�d�|�|d�t��dS)zY
        Check that flushing the observer remove all failures of the given type.
        rrr/Nr8r)
r:rBr-r4�dictr1r;rr5r6r<r=r>)rrr?rrr�test_flushByTypexs�zObserverTests.test_flushByTypec	CsF|j�t�t�}|j�dt��dd|dd��|�|j��g�dS)zS
        Check that C{_ignoreErrors} actually causes errors to be ignored.
        rrr/Nr8)r-�
_ignoreErrorsrrr4r1r5r6r9rrr�test_ignoreErrors�s�zObserverTests.test_ignoreErrorsc	CsR|j�t�|j��t�}|j�dt��dd|dd��|�|j��|g�dS)zj
        Check that C{_clearIgnores} ensures that previously ignored errors
        get captured.
        rrr/Nr8)	r-rErZ
_clearIgnoresrr4r1r5r6r9rrr�test_clearIgnores�s
�zObserverTests.test_clearIgnoresN)rrrr%r.r7r:r@rBrDrFrGrrrrr)Is

r)c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�LogErrorsMixinzb
    High-level tests demonstrating the expected behaviour of logged errors
    during tests.
    cCst��|_dSr )r	r*r+rrrrr.�szLogErrorsMixin.setUpcCs|�t�dSr )ZflushLoggedErrorsrrrrr�tearDown�szLogErrorsMixin.tearDowncCsf|�d�}||j�|�t|jj�d�|�|jjdd�t�|jjdd�|�d|jj�dS)zI
        Test that a logged error gets reported as a test error.
        rrrN)	�MockTestr+r5r<�errorsr=r>r�	successes�r�testrrr�test_singleError�s

�zLogErrorsMixin.test_singleErrorcCs<|�d�}||j�|�t|jj�d�|�d|jj�dS)zf
        Test that when two errors get logged, they both get reported as test
        errors.
        r�rN�rJr+r5r<rKrLrMrrr�test_twoErrors�s

zLogErrorsMixin.test_twoErrorscCsh|�d�}|�d�}||j�||j�|�t|jj�d�|�|jjdd|�|�d|jj�dS)zT
        Check that an error logged in one test doesn't fail the next test.
        rrrrNrQ�r�t1�t2rrr�test_errorsIsolated�s



z"LogErrorsMixin.test_errorsIsolatedcCs�|�d�}|�d�}||j�||j�|�t|jj�d�|�|jjdd|�|jjdd�t�|�|jjdd|�|jjdd�t�|�d|jj�dS)zN
        An error logged in a failed test doesn't fail the next test.
        rrrPrrN)	rJr+r5r<rKZtrap�	TypeErrorrrLrSrrr� test_errorsIsolatedWhenTestFails�s



z/LogErrorsMixin.test_errorsIsolatedWhenTestFailscCsLt��}|�td|�tjjdd�}|��}||j�|�|tjj�dS)zE
        There are no extra log observers after a test runs.
        Z_logObserverN)	r
r,ZpatchrZtheLogPublisher�	observersrJr+r5)rr-rYrNrrr�test_boundedObservers�s
z$LogErrorsMixin.test_boundedObserversN)rrrr%r.rIrOrRrVrXrZrrrrrH�s
rHc@seZdZejZdS)�SynchronousLogErrorsTestsN)rrrrrrJrrrrr[�sr[c@seZdZejZdd�ZdS)�AsynchronousLogErrorsTestscCsV|�d�}||j�|�t|jj�d�|�|jjdd�t�|jjdd�dS)zS
        Test that errors logged in callbacks get reported as test errors.
        r#rrN)rJr+r5r<rKr=r>rrMrrrr#�s

�z*AsynchronousLogErrorsTests.test_inCallbackN)rrrrr$rJr#rrrrr\�sr\)r%Z
__future__rrr1Ztwisted.internetrrZtwisted.pythonrrZ
twisted.trialrr	r
rr&rr'r)rHr[r(r\rrrr�<module>s-ZR