%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/test/__pycache__/ignore_test_failure.cpython-312.pyc

�

Ϫ�f�����dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlmZddl
mZddlmZmZdd	lmZdd
lmZddlmZmZddlmZd
d�d&d�ZGd�de�ZGd�de�ZGd�de�Z Gd�dee ��Z!Gd�de�Z"Gd�de�Z#d'd�Z$Gd�de�Z%Gd �d!e�Z&Gd"�d#e�Z'Gd$�d%e�Z(y)(z6
Test cases for the L{twisted.python.failure} module.
�)�annotationsN)�distb)�StringIO��FrameSummary)�
TracebackType)�Any�	Generator)�skipIf)�raiser)�failure�reflect)�SynchronousTestCaseF��captureVarsc�^�	ddzS#t$rtj|��}Y|SwxYw)z6
    Make a C{Failure} of a divide-by-zero error.
    �rr)�
BaseExceptionr
�Failure)r�fs  �B/usr/lib/python3/dist-packages/twisted/test/ignore_test_failure.py�getDivisionFailurers9��5�	�A��
�H���5��O�O��4���H�5�s�	�,�,c�"�eZdZdZd#d�Zd#d�Zd#d�Zd#d�Zd$d�Zd%d�Z	d&d�Z
	d'					d(d	�Zd)d*d
�Zd)d*d�Z
d#d�Zd#d
�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd+d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Zd#d�Z d#d�Z!d#d �Z"d#d!�Z#y"),�FailureTestsz'
    Tests for L{failure.Failure}.
    c��	td��#t$rtj�}YnwxYw|j	t
t�}|j|t�|j|jt�y)z(
        Trapping a L{Failure}.
        �testN)	�NotImplementedErrorrr
r�trap�
SystemExit�RuntimeError�assertEqual�type)�selfr�errors   r�test_failAndTrapzFailureTests.test_failAndTrap+sb��	"�%�f�-�-���	"����!�A�	"�����z�<�0�������-�������!4�5s�
�-�-c���t�}	|�#t$rtj�}YnwxYw|j	t|j
t�}|j||�y)z�
        If the wrapped C{Exception} is not a subclass of one of the
        expected types, L{failure.Failure.trap} raises the wrapped
        C{Exception}.
        N)�
ValueErrorrr
r�assertRaisesr�
OverflowError�assertIs)r#�	exceptionr�	untrappeds    r�test_trapRaisesWrappedExceptionz,FailureTests.test_trapRaisesWrappedException7sX���L�	�	"��O���	"����!�A�	"���%�%�j�!�&�&�-�H�	��
�
�i��+s��.�.c��t�}tj|�}tj|�}|j|j|�y)z�
        A L{failure.Failure} constructed from another
        L{failure.Failure} instance, has its C{value} property set to
        the value of that L{failure.Failure} instance.
        N)r'r
rr*�value�r#r+�f1�f2s    r�test_failureValueFromFailurez)FailureTests.test_failureValueFromFailureFs9���L�	�
�_�_�Y�
'��
�_�_�R�
 ���
�
�b�h�h�	�*�c���t�}tj|�}	|jt�|j
j|�y#t
$rtj�}Y�<wxYw)z�
        A L{failure.Failure} constructed without a C{exc_value}
        argument, will search for an "original" C{Failure}, and if
        found, its value will be used as the value for the new
        C{Failure}.
        N)r'r
rrr)rr*r/r0s    r�!test_failureValueFromFoundFailurez.FailureTests.test_failureValueFromFoundFailureQs[���L�	�
�_�_�Y�
'��	#��G�G�M�"�	
�
�
�b�h�h�	�*���	#����"�B�	#�s�A�A3�2A3c�P�|j|j|�|�d|���y)z�
        Assert that C{s} starts with a particular C{prefix}.

        @param s: The input string.
        @type s: C{str}
        @param prefix: The string that C{s} should start with.
        @type prefix: C{str}
        z is not the start of N)�
assertTrue�
startswith)r#�s�prefixs   r�assertStartsWithzFailureTests.assertStartsWithas(��	
������V�,��
�:O�PQ�u�.U�Vr4c�P�|j|j|�|�d|���y)z�
        Assert that C{s} end with a particular C{suffix}.

        @param s: The input string.
        @type s: C{str}
        @param suffix: The string that C{s} should end with.
        @type suffix: C{str}
        z is not the end of N)r8�endswith)r#r:�suffixs   r�assertEndsWithzFailureTests.assertEndsWithls'��	
����
�
�6�*�v�j�8K�A�5�,Q�Rr4c�L�|j||�|j||�y)ac
        Assert that the C{tb} traceback contains a particular C{prefix} and
        C{suffix}.

        @param tb: The traceback string.
        @type tb: C{str}
        @param prefix: The string that C{tb} should start with.
        @type prefix: C{str}
        @param suffix: The string that C{tb} should end with.
        @type suffix: C{str}
        N)r<r@)r#�tbr;r?s    r�assertTracebackFormatz"FailureTests.assertTracebackFormatws$��	
���b�&�)����B��'r4c���|rd}|t|��}t�}|r|j�|j|�|j	�}d|j
|jxrdxsdfz}djtj|j�tj|j�|j
�}|j|||�|j�D�	cgc]}	|	jd�s�|	��}
}	|r,|j!g|
�|rd}	nd	}	|j#|	|
�y|j%g|
�|j#d
|�ycc}	w)a�
        Assert that L{printDetailedTraceback} produces and prints a detailed
        traceback.

        The detailed traceback consists of a header::

          *--- Failure #20 ---

        The body contains the stacktrace::

          /twisted/trial/_synctest.py:1180: _run(...)
          /twisted/python/util.py:1076: runWithWarningsSuppressed(...)
          --- <exception caught here> ---
          /twisted/test/test_failure.py:39: getDivisionFailure(...)

        If C{captureVars} is enabled the body also includes a list of
        globals and locals::

           [ Locals ]
             exampleLocalVar : 'xyz'
             ...
           ( Globals )
             ...

        Or when C{captureVars} is disabled::

           [Capture of Locals and Globals disabled (use captureVars=True)]

        When C{cleanFailure} is enabled references to other objects are removed
        and replaced with strings.

        And finally the footer with the L{Failure}'s value::

          exceptions.ZeroDivisionError: float division
          *--- End of Failure #20 ---

        @param captureVars: Enables L{Failure.captureVars}.
        @type captureVars: C{bool}
        @param cleanFailure: Enables L{Failure.cleanFailure}.
        @type cleanFailure: C{bool}
        �xyzrz*--- Failure #%d%s---
z (pickled) � z#{}: {}
*--- End of Failure #{} ---
z  z  exampleLocalVar : "'xyz'"z  exampleLocalVar : 'xyz'zA [Capture of Locals and Globals disabled (use captureVars=True)]
N)rr�cleanFailure�printDetailedTraceback�getvalue�count�pickled�formatr�qualr"�safe_strr/rC�
splitlinesr9�assertNotEqual�assertInr!)r#rrG�exampleLocalVarr�outrB�start�end�line�
linesWithVarss           r�assertDetailedTracebackz$FailureTests.assertDetailedTraceback�s;��X�#�O�
��;�7���j���
�N�N��	� � ��%�
�\�\�^��)�
�G�G�
�Y�Y�
(�=�0�S�-
�
��6�<�<��L�L���� ����Q�W�W�%�
�G�G�
��
	
�"�"�2�u�c�2�+-�-�-�/�S�$�T�_�_�T�=R��S�
�S������M�2��6��2���M�M�$�
�.����R��/��M�M�W��
��Ts�/E�Ec��|rd}|t�}t�}|j|�|j�}d}|jD]\}}}	}
}||�d|	�d|�d�z
}�tt�}|j|d|�d�tj�d|���|r&|jtjd|��yy)	a`
        Assert that L{printBriefTraceback} produces and prints a brief
        traceback.

        The brief traceback consists of a header::

          Traceback: <type 'exceptions.ZeroDivisionError'>: float division

        The body with the stacktrace::

          /twisted/trial/_synctest.py:1180:_run
          /twisted/python/util.py:1076:runWithWarningsSuppressed

        And the footer::

          --- <exception caught here> ---
          /twisted/test/test_failure.py:39:getDivisionFailure

        @param captureVars: Enables L{Failure.captureVars}.
        @type captureVars: C{bool}
        �abcde��:�
zTraceback: �: zexampleLocalVar.*abcdeN)
rr�printBriefTracebackrI�frames�repr�ZeroDivisionErrorrCr
�EXCEPTION_CAUGHT_HERE�assertIsNone�re�search)
r#rrRrrSrB�stack�method�filename�lineno�	localVars�
globalVars�zdes
             r�assertBriefTracebackz!FailureTests.assertBriefTraceback�s���,�%�O�
�� ���j��	���c�"�
�\�\�^����?@�x�x�	7�;�F�H�f�i����z��6�(�!�F�8�2�6�6�E�	7��$�%���"�"���#��b�!��,�,�-�R��w�7�	
�����b�i�i�(@�"�E�F�r4c�@�|rd}|t|��}t�}|j|�|j�}d}|jD]B\}}}	}
}|d|�d|	�d|�d�z
}|dtj||	�j��d�z
}�D|j|d	tj�d|�tj|j��d
tj|j��d��|r&|j!t#j$d|��yy)
a�
        Assert that L{printTraceback} produces and prints a default traceback.

        The default traceback consists of a header::

          Traceback (most recent call last):

        The body with traceback::

          File "/twisted/trial/_synctest.py", line 1180, in _run
             runWithWarningsSuppressed(suppress, method)

        And the footer::

          --- <exception caught here> ---
            File "twisted/test/test_failure.py", line 39, in getDivisionFailure
              1 / 0
            exceptions.ZeroDivisionError: float division

        @param captureVars: Enables L{Failure.captureVars}.
        @type captureVars: C{bool}
        �xyzzyrr[z  File "z", line z, in r]z    z"Traceback (most recent call last):r^zexampleLocalVar.*xyzzyN)rr�printTracebackrIr`�	linecache�getline�striprCr
rcrrMr"rNr/rdrerf)r#rrRrrSrBrgrhrirjrkrls            r�assertDefaultTracebackz#FailureTests.assertDefaultTraceback	s��.�%�O�
��;�7���j��	�����
�\�\�^����?@�x�x�	L�;�F�H�f�i���x��z��&���v�h�b�I�I�E��t�I�-�-�h��?�E�E�G�H��K�K�E�	L�	
�"�"��0��-�-�����Q�V�V�$�� � ����)�
�
	
�����b�i�i�(@�"�E�F�r4c�$�|j�y)zr
        L{printDetailedTraceback} returns a detailed traceback including the
        L{Failure}'s count.
        N�rX�r#s r�test_printDetailedTracebackz(FailureTests.test_printDetailedTraceback>s��
	
�$�$�&r4c�$�|j�y)zC
        L{printBriefTraceback} returns a brief traceback.
        N�rnrxs r�test_printBriefTracebackz%FailureTests.test_printBriefTracebackEs��	
�!�!�#r4c�$�|j�y)z8
        L{printTraceback} returns a traceback.
        N�rurxs r�test_printTracebackz FailureTests.test_printTracebackKs��	
�#�#�%r4c�(�|jd��y)z�
        L{printDetailedTraceback} captures the locals and globals for its
        stack frames and adds them to the traceback, when called on a
        L{Failure} constructed with C{captureVars=True}.
        TrNrwrxs r�'test_printDetailedTracebackCapturedVarsz4FailureTests.test_printDetailedTracebackCapturedVarsQs��	
�$�$��$�6r4c�(�|jd��y)z�
        L{printBriefTraceback} returns a brief traceback when called on a
        L{Failure} constructed with C{captureVars=True}.

        Local variables on the stack can not be seen in the resulting
        traceback.
        TrNr{rxs r�$test_printBriefTracebackCapturedVarsz1FailureTests.test_printBriefTracebackCapturedVarsYs��	
�!�!�d�!�3r4c�(�|jd��y)z�
        L{printTraceback} returns a traceback when called on a L{Failure}
        constructed with C{captureVars=True}.

        Local variables on the stack can not be seen in the resulting
        traceback.
        TrNr~rxs r�test_printTracebackCapturedVarsz,FailureTests.test_printTracebackCapturedVarscs��	
�#�#��#�5r4c�*�|jdd��y)z�
        C{printDetailedTraceback} includes information about local variables on
        the stack after C{cleanFailure} has been called.
        T)rrGNrwrxs r�.test_printDetailedTracebackCapturedVarsCleanedz;FailureTests.test_printDetailedTracebackCapturedVarsCleanedms��
	
�$�$��D�$�Ir4c�T�|jttjddd��y)zu
        L{failure.format_frames} raises a L{ValueError} if the supplied
        C{detail} level is unknown.
        N�noisia��detail)r(r'r
�
format_framesrxs r�test_invalidFormatFramesDetailz+FailureTests.test_invalidFormatFramesDetailts(��
	
�����-�-�t�T�(�	�	
r4c��t�}tj|�}|jt�|j	|j
|�y�N)r r
rrr!r/)r#�ers   r�test_ExplictPasszFailureTests.test_ExplictPass}s7���N���O�O�A���	���|��������!�$r4c���	|j�td��#t$r<tjtj�d�}|djcYSwxYw)Nz3f.raiseException() didn't raise ZeroDivisionError!?����)�raiseException�	Exceptionrb�	traceback�
extract_tb�sys�exc_inforV)r#rrBs   r�_getInnermostFrameLinez#FailureTests._getInnermostFrameLine�s\��	S�
����
�Q�R�R��	!�	��%�%�c�l�l�n�Q�&7�8�B��b�6�;�;��	�s��AA"�!A"c�^�t�}|j|�}|j|d�y)N�1 / 0)rr�r!)r#r�	innerlines   r�test_RaiseExceptionWithTBz&FailureTests.test_RaiseExceptionWithTB�s*��� ���/�/��2�	�����G�,r4c��|jttjd�}|j	dt|��y)z�
        Constructing a C{Failure} with a string as its exception value raises
        a C{TypeError}, as this is no longer supported as of Python 2.6.
        zono!z$Strings are not supported by FailureN)r(�	TypeErrorr
rrQ�str)r#�excs  r� test_stringExceptionConstructionz-FailureTests.test_stringExceptionConstruction�s/��
���	�7�?�?�F�C���
�
�<�c�#�h�Gr4c�`�|jtjtj�y)z�
        Creating a Failure with no arguments causes it to try to discover the
        current interpreter exception state.  If no such state exists, creating
        the Failure should raise a synchronous exception.
        N)r(r
�NoCurrentExceptionErrorrrxs r�test_ConstructionFailsz#FailureTests.test_ConstructionFails�s��	
���'�9�9�7�?�?�Kr4c�l�t�}|j|j�|j�y)z�
        If the C{Failure} has not been cleaned, then C{getTracebackObject}
        returns the traceback object that captured in its constructor.
        N)rr!�getTracebackObjectrB�r#rs  r�test_getTracebackObjectz$FailureTests.test_getTracebackObject�s)��

� ������-�-�/����6r4c���	ddz|jj	�j
�y#t$r-tj�}tjd��}Y�`wxYw)zc
        C{captureVars=True} has no effect on the result of
        C{getTracebackObject}.
        rrTrN)rbr
rr!r�rB)r#�
noVarsFailure�varsFailures   r�&test_getTracebackObjectFromCaptureVarsz3FailureTests.test_getTracebackObjectFromCaptureVars�sX��
	<�
��E�	
����9�9�;�[�^�^�L��!�	<�#�O�O�-�M�!�/�/�d�;�K�	<�s�2�3A(�'A(c�
�t�}tj|j��}|j	�tj|j��}|j|�|j
||�y)z�
        If the Failure has been cleaned, then C{getTracebackObject} returns an
        object that looks the same to L{traceback.extract_tb}.
        N)rr�r�r�rG�assertIsNotNoner!�r#r�expected�observeds    r� test_getTracebackObjectFromCleanz-FailureTests.test_getTracebackObjectFromClean�sf��

� ���'�'��(<�(<�(>�?��	�����'�'��(<�(<�(>�?�����X�&�����8�,r4c���td��}tj|j��}|j	�tj|j��}|j||�y)z�
        If the Failure was created with captureVars, then C{getTracebackObject}
        returns an object that looks the same to L{traceback.extract_tb}.
        TrN)rr�r�r�rGr!r�s    r�.test_getTracebackObjectFromCaptureVarsAndCleanz;FailureTests.test_getTracebackObjectFromCaptureVarsAndClean�sZ��

�4�0���'�'��(<�(<�(>�?��	�����'�'��(<�(<�(>�?������8�,r4c�~�tjtd��}|j|j	��y)a
        L{failure.Failure}s need not be constructed with traceback objects. If
        a C{Failure} has no traceback information at all, C{getTracebackObject}
        just returns None.

        None is a good value, because traceback.extract_tb(None) -> [].
        z
some errorN)r
rr�rdr�r�s  r�'test_getTracebackObjectWithoutTracebackz4FailureTests.test_getTracebackObjectWithoutTraceback�s.��
�O�O�I�l�3�4�����!�.�.�0�1r4c��	ddztj�}|j|j�y#t$rtj�\}}}Y�UwxYw)z�
        If a L{failure.Failure} is constructed with an exception but no
        traceback in Python 3, the traceback will be extracted from the
        exception's C{__traceback__} attribute.
        rrN)rr�r�r
rr*rB)r#�klassr+rBrs     r�$test_tracebackFromExceptionInPython3z1FailureTests.test_tracebackFromExceptionInPython3�sS��	2�
��E�
�O�O�I�&���
�
�a�d�d�B����	2�#&�<�<�>� �E�9�b�	2�s�9�!A�Ac��t�}|j|j�|j|jj
|j�|j
�|j|jj
�y)z�
        L{failure.Failure.cleanFailure} sets the C{__traceback__} attribute of
        the exception to L{None} in Python 3.
        N)rr�rBr*r/�
__traceback__rGrdr�s  r�*test_cleanFailureRemovesTracebackInPython3z7FailureTests.test_cleanFailureRemovesTracebackInPython3�s\��

� �����Q�T�T�"��
�
�a�g�g�+�+�Q�T�T�2�	�������!�'�'�/�/�0r4c��t�}t�}t|j�|��|j	d|j��y)z�
        The traceback captured by a L{Failure} is compatible with the stdlib
        L{dis.distb} function as used in post-mortem debuggers. Specifically,
        it doesn't cause that function to raise an exception.
        )�filez --> N)rrrr�rQrI)r#r�bufs   r�
test_distbzFailureTests.test_distb�s<��
� ���j��
�a�"�"�$�3�/�	
�
�
�g�s�|�|�~�.r4c��t�}tjt�}|j	t|�d|�d��y)z�
        The C{repr} of a L{failure.Failure} shows the type and string
        representation of the underlying exception.
        z <twisted.python.failure.Failure z: division by zero>N)rr�fullyQualifiedNamerbr!ra)r#r�typeNames   r�	test_reprzFailureTests.test_repr�s8��

� ���-�-�.?�@�������G�JR�T�	
r4N��return�None)r:r�r;r�r�r�)r:r�r?r�r�r�)rBr�r;r�r?r�r�r�)FF)r�boolrGr�r�r�)F)rr�r�r�)r�failure.Failurer�z
str | None)$�__name__�
__module__�__qualname__�__doc__r%r-r3r6r<r@rCrXrnruryr|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��r4rrr&s����
6�
,�	+�+� 	W�	S�
(� ?D�S��S�7;�S�	
�S�j,G�\3G�j'�$�&�7�4�6�J�
�%�S�-�
H�L�7�
M�
-�	-�	2� �	1�/�

r4rc��eZdZdZdd�Zy)�	BrokenStrzb
    An exception class the instances of which cannot be presented as strings
    via L{str}.
    c��|�r�r�rxs r�__str__zBrokenStr.__str__s���
r4N�r�r��r�r�r�r�r�r�r4rr�r�	s���
r4r�c��eZdZdZdd�Zy)�BrokenExceptionMetaclassza
    A metaclass for an exception type which cannot be presented as a string via
    L{str}.
    c��td��)Nz#You cannot make a string out of me.)r'rxs rr�z BrokenExceptionMetaclass.__str__s���>�?�?r4Nr�r�r�r4rr�r�s
���
@r4r�c��eZdZdZy)�BrokenExceptionTypeza
    The aforementioned exception type which cannot be presented as a string via
    L{str}.
    N)r�r�r�r�r�r4rr�r�s��r4r�)�	metaclassc�P�eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zy
)
�GetTracebackTestsz,
    Tests for L{Failure.getTraceback}.
    c��t�}tj|�}|j|��}|j	|t
�y)z�
        Construct a L{Failure} with an exception that raises an exception from
        its C{__str__} method and then call C{getTraceback} with the specified
        detail and verify that it returns a string.
        r�N)r�r
r�getTraceback�assertIsInstancer�)r#r��xrr�s     r�_brokenValueTestz"GetTracebackTests._brokenValueTest+s9��
�K���O�O�A����N�N�&�N�1�	����i��-r4c�&�|jd�y)z�
        A L{Failure} might wrap an exception with a C{__str__} method which
        raises an exception.  In this case, calling C{getTraceback} on the
        failure with the C{"brief"} detail does not raise an exception.
        �briefN�r�rxs r�test_brokenValueBriefDetailz-GetTracebackTests.test_brokenValueBriefDetail6s��	
���g�&r4c�&�|jd�y)�Y
        Like test_brokenValueBriefDetail, but for the C{"default"} detail case.
        �defaultNr�rxs r�test_brokenValueDefaultDetailz/GetTracebackTests.test_brokenValueDefaultDetail>���	
���i�(r4c�&�|jd�y)r��verboseNr�rxs r�test_brokenValueVerboseDetailz/GetTracebackTests.test_brokenValueVerboseDetailDr�r4c��tjt��}|j|��}|j	|t
�y)z�
        Construct a L{Failure} with an exception type that raises an exception
        from its C{__str__} method and then call C{getTraceback} with the
        specified detail and verify that it returns a string.
        r�N)r
rr�r�r�r�)r#r�rr�s    r�_brokenTypeTestz!GetTracebackTests._brokenTypeTestJs6��
�O�O�/�1�2���N�N�&�N�1�	����i��-r4c�&�|jd�y)aQ
                A L{Failure} might wrap an
                newPublisher(evt)
        xception the type object of which has a
                C{__str__} method which raises an exception.  In this case, calling
                C{getTraceback} on the failure with the C{"brief"} detail does not raise
                an exception.
        r�N�r�rxs r�test_brokenTypeBriefDetailz,GetTracebackTests.test_brokenTypeBriefDetailTs��	
���W�%r4c�&�|jd�y)zX
        Like test_brokenTypeBriefDetail, but for the C{"default"} detail case.
        r�Nr�rxs r�test_brokenTypeDefaultDetailz.GetTracebackTests.test_brokenTypeDefaultDetail_���	
���Y�'r4c�&�|jd�y)zX
        Like test_brokenTypeBriefDetail, but for the C{"verbose"} detail case.
        r�Nr�rxs r�test_brokenTypeVerboseDetailz.GetTracebackTests.test_brokenTypeVerboseDetailer�r4N)r�r�r�r�r�)r�r�r�r�r�r�r�r�r�r�r�r�r�r4rr�r�&s/���	.�'�)�)�.�	&�(�(r4r�c�T�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zee	dud�d	d��Z
y)
�FindFailureTestszE
    Tests for functionality related to L{Failure._findFailure}.
    c��	ddz|jd�y#t$r0|jtjj��YywxYw)z�
        Within an exception handler, _findFailure should return
        L{None} in case no Failure is associated with the current
        exception.
        rrzNo exception raised from 1/0!?N)�failrrdr
r�_findFailurerxs r�$test_findNoFailureInExceptionHandlerz5FindFailureTests.test_findNoFailureInExceptionHandlerqsI��	8�
��E�
�I�I�6�7���	>����g�o�o�:�:�<�=�	>�s��6A�Ac��|jtj�d�|jtjj��y)zS
        Outside of an exception handler, _findFailure should return None.
        r�N)rdr�r�r
rr�rxs r�test_findNoFailurez#FindFailureTests.test_findNoFailure~s8��	
���#�,�,�.��,�-����'�/�/�6�6�8�9r4c��t�}|j�	|j�|jd�y#t$r1|jtjj�|�YywxYw)z�
        Within an exception handler, it should be possible to find the
        original Failure that caused the current exception (if it was
        caused by raiseException).
        �)No exception raised from raiseException!?N)	rrGr�r�rr!r
rr�r�s  r�test_findFailurez!FindFailureTests.test_findFailure�sg��
� ��	����	C�
����
�I�I�A�B���	@����W�_�_�9�9�;�Q�?�	@�s�>�7A8�7A8c��t�}|j�	|j�|jd�y#t$r}tj�}|j�j�}|j�j�}|j||�|j|dd|dd�YywxYw)ax
        When a Failure is constructed in the context of an exception
        handler that is handling an exception raised by
        raiseException, the new Failure should be chained to that
        original Failure.
        Means the new failure should still show the same origin frame,
        but with different complete stack trace (as not thrown at same place).
        r���N)rrGr�r�rr
rr�rOrPr!)r#r�newFrB�new_tbs     r�,test_failureConstructionFindsOriginalFailurez=FindFailureTests.test_failureConstructionFindsOriginalFailure�s���
� ��	����		C�
����
�I�I�A�B���	3��?�?�$�D����!�,�,�.�B��&�&�(�3�3�5�F�����F�+����R���W�f�R�S�k�2�	3�s�>�BC�CNzraiser extension not availablec��	tj�|jd�y#tj$rEt	j
�}|j
|jtj��YywxYw)z�
        Pyrex and Cython are known to insert fake stack frames so as to give
        more Python-like tracebacks. These stack frames with empty code objects
        should not break extraction of the exception.
        z$No exception raised from extension?!N)rr�r��RaiserExceptionr
rr8�checkr�s  r�/test_failureConstructionWithMungedStackSucceedsz@FindFailureTests.test_failureConstructionWithMungedStackSucceeds�s`��	>��!�!�#�

�I�I�<�=��	�%�%�	=����!�A��O�O�A�G�G�F�$:�$:�;�<�	=�s�(�AB�?Br�)r�r�r�r�rrrr
rrrr�r4rr�r�ls=���8�:�
C�C�,�F�d�N�<�=�>�>�>r4r�c��t|||�Sr�r)�fnrj�name�texts    r�_tbr�s����F�D�)�)r4c� �eZdZdZdd�Zdd�Zy)�FormattableTracebackTestsa
    Whitebox tests that show that L{failure._Traceback} constructs objects that
    can be used by L{traceback.extract_tb}.

    If the objects can be used by L{traceback.extract_tb}, then they can be
    formatted using L{traceback.format_tb} and friends.
    c	��tjgdddiigg�}|jtj|�tdddd�g�y)z�
        A C{_Traceback} object constructed with a single frame should be able
        to be passed to L{traceback.extract_tb}, and we should get a singleton
        list containing a (filename, lineno, methodname, line) tuple.
        rh�filename.py�{N)r
�
_Tracebackr!r�r�r�r#rBs  r�test_singleFramez*FormattableTracebackTests.test_singleFrame�sR���
�
��h�
�s�B��%K�$L�
M��	
���� � ��$�s�=�#�x��'N�&O�	
r4c��tjdddiigdddiiggdddiigddd	iigg�}|jtj|�tdddd
�tdd	dd
�g�|jtj|j�tdddd
�tdddd
�tdddd
�g�y
)z�
        A C{_Traceback} object constructed with multiple frames should be able
        to be passed to L{traceback.extract_tb}, and we should get a list
        containing a tuple for each frame.
        �caller1r��caller2��method1r�method2��N)r
rr!r�r�r�
extract_stack�tb_framers  r�test_manyFramesz)FormattableTracebackTests.test_manyFrames�s����
�
��M�1�b�"�5��M�1�b�"�5�
�
�M�3��B�7��M�3��B�7�
�	
��	
���� � ��$��M�3�	�4�8��M�3�	�4�8�
�	
�	
����#�#�B�K�K�0��M�1�i��6��M�1�i��6��M�3�	�4�8�
�	
r4Nr�)r�r�r�r�rr&r�r4rrr�s���
� 
r4rc�(�eZdZdZdd�Zdd�Zdd�Zy)�FakeAttributesTestsaR
    _Frame, _Code and _TracebackFrame objects should possess some basic
    attributes that qualify them as fake python objects, allowing the return of
    _Traceback to be used as a fake traceback. The attributes that have zero or
    empty values are there so that things expecting them find them (e.g. post
    mortem debuggers).
    c�t�tjdd�}ddi}ddi}tjddd||f|�}|j|j|�|j|j|�|j|jtj�|j|j|�|j|jt�|j|jt�|j|jd�|j|jtd��y)	z�
        L{_Frame} instances have the C{f_globals} and C{f_locals} attributes
        bound to C{dict} instance.  They also have the C{f_code} attribute
        bound to something like a code object.
        )�dummyparent�dummyparentfile�oNNN�	local_var�*�
global_var�d�	dummyname�
dummyfilename)r
�_Framer!�	f_globals�f_localsr��f_code�_Code�f_back�
f_builtins�dict�f_lasti�int�f_lineno�f_tracer")r#�
back_frame�fake_locals�fake_globals�frames     r�test_fakeFrameAttributesz,FakeAttributesTests.test_fakeFrameAttributess���^�^�
�
�	
�
�#�B�'��$�c�*����������
�
�	
��	
������,�7��������5����e�l�l�G�M�M�:�������z�2����e�.�.��5����e�m�m�S�1��������,����e�m�m�T�$�Z�8r4c�h�tjdd�}|j|jd�|j|jd�|j|jt�|j|jt�|j|jt�|j|jt�|j|jt�|j|jt�|j|jt�|j|j t�|j|j"t�|j|j$t�|j|j&t�|j|j(t�|j|j*t�|j|j,t.�|j|j1�t�y)�N
        See L{FakeAttributesTests} for more details about this test.
        r1r2N)r
r7r!�co_name�co_filenamer��co_argcountr<�co_code�bytes�co_cellvars�tuple�	co_consts�co_firstlineno�co_flags�	co_lnotab�co_freevars�co_posonlyargcount�co_kwonlyargcount�co_names�
co_nlocals�co_stacksize�co_varnames�list�co_positions)r#�codes  r�test_fakeCodeAttributesz+FakeAttributesTests.test_fakeCodeAttributes*s���}�}�[�/�:��������{�3�����)�)�?�;����d�.�.��4����d�l�l�E�2����d�.�.��6����d�n�n�e�4����d�1�1�3�7����d�m�m�S�1����d�n�n�e�4����d�.�.��6����d�5�5�s�;����d�4�4�c�:����d�m�m�U�3����d�o�o�s�3����d�/�/��5����d�.�.��5����d�/�/�1�5�9r4c�J�tjdddiifd�}tj|�}|j|j|�|j|j
d�|j
|jt�|jt|d��y)rEr1r2r.N�tb_next)r
r3�_TracebackFramer!r%�	tb_linenor��tb_lastir<r8�hasattr)r#rB�traceback_frames   r�test_fakeTracebackFramez+FakeAttributesTests.test_fakeTracebackFrameAs������
�/�2�r�2�6��
��"�1�1�%�8������1�1�5�9�����2�2�B�7����o�6�6��<�������;�<r4Nr�)r�r�r�r�rCr[rcr�r4rr(r(�s���#9�J:�.=r4r(c�(�eZdZdZdd�Zdd�Zdd�Zy)�DebugModeTestszF
    Failure's debug mode should allow jumping into the debugger.
    c������tj�tjj�d��fd�}�j|�g�_dd�fd�
}|t_tj�y)zK
        Override pdb.post_mortem so we can make sure it's called.
        c�F���t_�tj_yr�)�pdb�post_mortemr
r�__init__)�origInitris��r�restorez%DebugModeTests.setUp.<locals>.restore]s���)�C�O�'/�G�O�O�$r4Nc�<���jj|�yr�)�result�append)�tr#s �r�logging_post_mortemz1DebugModeTests.setUp.<locals>.logging_post_mortemes����K�K���q�!r4r�r�)rpzTracebackType | Noner�r�)rhrir
rrj�
addCleanuprn�startDebugMode)r#rlrqrkris`  @@r�setUpzDebugModeTests.setUpUsQ���
�o�o���?�?�+�+��	0�	
���� �24���	"�.������ r4c��	ddz|j|jg�|jj�y#t$r/tj�\}}}tj�}Y�pwxYw)z~
        If startDebugMode() is called, calling Failure() will first call
        pdb.post_mortem with the traceback.
        rrN)	rr�r�r
rr!rn�assertFalser�r#�typr�rBrs     r�test_regularFailurez"DebugModeTests.test_regularFailureksf��
	"�
��E�	
������r�d�+�������'��	�	"��<�<�>�L�C��b����!�A�	"�s�A�5A8�7A8c��	ddz|j|jg�|jj�y#t$r1tj�\}}}tjd��}Y�rwxYw)zk
        If startDebugMode() is called, passing captureVars to Failure() will
        not blow up.
        rrTrN)	rr�r�r
rr!rnr8rrws     r�test_captureVarszDebugModeTests.test_captureVarsxsf��
	2�
��E�	
������r�d�+�����
�
�&��	�	2��<�<�>�L�C��b����D�1�A�	2�s�A�7A:�9A:Nr�)r�r�r�r�rtryr{r�r4rrerePs���!�,(�'r4rec�L�eZdZdZ						d	d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	y)�ExtendedGeneratorTestszU
    Tests C{failure.Failure} support for generator features added in Python 2.5
    c�h�	|j|�|jd�y#t$rYywxYw)Nz<throwExceptionIntoGenerator should have raised StopIteration)�throwExceptionIntoGeneratorr��
StopIteration)r#r�gs   r�_throwIntoGeneratorz*ExtendedGeneratorTests._throwIntoGenerator�s9��	Y�
�)�)�!�,�
�I�I�W�X���	��	�s�%�	1�1c�H���g�d��fd�}|�}t�}t|��j||��j�ddt��j�ddt��jt
j�dd�ddd�y)	zr
        It should be possible to throw the exception that a Failure
        represents into a generator.
        c3��K�	d���jd�y#t$r&�jtj��YywxYw�w)Nz$Yield should have yielded exception.)r�rror�r�)r#�stuffs��r�	generatorzJExtendedGeneratorTests.test_throwExceptionIntoGenerator.<locals>.generator�sA�����
B���	�	�@�A��!�
-����S�\�\�^�,�
-��%�A
��A
�,A
�A
�	A
�
A
rrr�r�r�N�r�zGenerator[None, None, None])r�nextr�r!rbr�r�r�)r#r�r�rr�s`   @r� test_throwExceptionIntoGeneratorz7ExtendedGeneratorTests.test_throwExceptionIntoGenerator�s����
��	B�
�K��� ���Q��� � ��A�&�����q��!��&7�8����e�A�h�q�k�+<�=�����-�-�e�A�h�q�k�:�2�>�r�B�G�Lr4c����t�}|j�g�d��fd�}|�}t|��j||��j	�|g�y)z�
        Within an exception handler, it should be possible to find the
        original Failure that caused the current exception (if it was
        caused by throwExceptionIntoGenerator).
        c3��K�	d���jd�y#t$r0�jtjj��YywxYw�w�NzNo exception sent to generator)r�rror
rr�)�
foundFailuresr#s��rr�zEExtendedGeneratorTests.test_findFailureInGenerator.<locals>.generator�sK�����
<���	�	�:�;��!�
E��$�$�W�_�_�%A�%A�%C�D�
E�s%�A��A�6A�A�A�ANr�)rrGr�r�r!)r#rr�r�r�s`   @r�test_findFailureInGeneratorz2ExtendedGeneratorTests.test_findFailureInGenerator�sS���
� ��	�����
�	<�
�K���Q��� � ��A�&�������,r4c����t�}|j�|j�}g�d��fd�}|�}t|��j	||��jt
��d��j||j���j�dj�|j���jd�dj���jd|j��y)z�
        When a Failure is constructed in the context of an exception
        handler that is handling an exception raised by
        throwExceptionIntoGenerator, the new Failure should be chained to that
        original Failure.
        c3��K�	d���jd�y#t$r&�jtj��YywxYw�wr�)r�rror
r)�newFailuresr#s��rr�zVExtendedGeneratorTests.test_failureConstructionFindsOriginalFailure.<locals>.generator�sC�����
<���	�	�:�;��!�
6��"�"�7�?�?�#4�5�
6�r�rrr�Nr�)
rrGr�r�r�r!�lenrPrQ�assertNotIn)r#r�original_failure_strr�r�r�s`    @rr
zCExtendedGeneratorTests.test_failureConstructionFindsOriginalFailure�s����
� ��	���� �~�~�/����	<�
�K���Q��� � ��A�&�����[�)�1�-�	
���-�q�~�~�/?�@�	
���K��N�7�7�9�1�>�>�;K�L��
�
�k�;�q�>�#>�#>�#@�A�����a�n�n�&6�7r4c�n��d�fd�}|�}t|�t�}�j||�y)z�
        When a generator reraises a different exception,
        L{Failure._findFailure} inside the generator should find the reraised
        exception rather than original one.
        c3���K�		d��y#t$rgdYywxYw#t$r5�jtj�jt
�YywxYw�w�Nr)rr�r
rr/�
IndexErrorrxs�rr�zJExtendedGeneratorTests.test_ambiguousFailureInGenerator.<locals>.generator�sW�����
K����$���q�E��� �
K��%�%�g�o�o�&7�&=�&=�z�J�
K�s:�A ��A ���A ���;A�A �A�A Nr�)r�rr��r#r�r�rs`   r� test_ambiguousFailureInGeneratorz7ExtendedGeneratorTests.test_ambiguousFailureInGenerator�s1���	K�
�K���Q��� ��� � ��A�&r4c���dd�}|�}t|�t�}	|j||�y#t$r5|j	tj�jt�YywxYw)z�
        When a generator reraises a different exception,
        L{Failure._findFailure} above the generator should find the reraised
        exception rather than original one.
        c3�>K�	d��y#t$rgdYywxYw�wr�)rr�r4rr�zLExtendedGeneratorTests.test_ambiguousFailureFromGenerator.<locals>.generators#����
��� �
��1��
�s��	�����Nr�)	r�rr�rr�r
rr/r�r�s    r�"test_ambiguousFailureFromGeneratorz9ExtendedGeneratorTests.test_ambiguousFailureFromGenerator�sc��	�
�K���Q��� ��	G��$�$�Q��*���	G��!�!�'�/�/�"3�"9�"9�:�F�	G�s�5�;A3�2A3N)rr�r�zGenerator[Any, Any, Any]r�r�r�)
r�r�r�r�r�r�r�r
r�r�r�r4rr}r}�sD���Y� �Y�%=�Y�	
�Y�M�2-�0"8�H'�*Gr4r})rr�r�r�)
rr�rjr<rr�rr�r�r))r��
__future__rrrrhrer�r��disr�iorr�typesr�typingr	r
�unittestr�cython_test_exception_raiserr�twisted.pythonr
r�twisted.trial.unittestrrrr�r�r"r�r�r�r�rrr(rer}r�r4r�<module>r�s����#��
�	�
����"��!��/�+�6�/4�
�`
�&�`
�F�	��@�t�@��)�/G��C(�+�C(�LK>�*�K>�d*�7
� 3�7
�tQ=�-�Q=�h3'�(�3'�lLG�0�LGr4

Zerion Mini Shell 1.0