%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlZddlmZddlmZmZmZmZm	Z	ddl
mZddlm
Z
ddlmZGd�d	e�ZGd
�de�Zy)z*
Tests for C{await} support in Deferreds.
�N)�NoReturn)�Deferred�ensureDeferred�fail�
maybeDeferred�succeed)�Clock)�Failure)�TestCasec��eZdZdZy)�SampleExceptionz2
    A specific sample exception for testing.
    N)�__name__�
__module__�__qualname__�__doc__���H/usr/lib/python3/dist-packages/twisted/internet/test/test_defer_await.pyr
r
s��rr
c�`�eZdZdZd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
d
d
�Zd
d�Zd
d�Z
y)�
AwaitTestsz@
    Tests for using Deferreds in conjunction with PEP-492.
    Nc�n�t�}|j�}|j|t|��y)z<
        C{Deferred.__await__} returns an iterable.
        N)r�	__await__�assertEqual�iter)�self�d�awaitedDeferreds   r�test_awaitReturnsIterablez$AwaitTests.test_awaitReturnsIterable$s+��%�J���+�+�-������$��*?�@rc���dtf�fd�}dtfd��|�}|j|tj�t	j
|�}|j|t�|j
|�}|j|d�y)zU
        L{Deferred.fromCoroutine} will turn a coroutine into a L{Deferred}.
        �returnc��`�K�td�}|�d{������d{���}|S7�7��w)N�bar�r)r�res�run2s  �r�runz2AwaitTests.test_deferredFromCoroutine.<locals>.run1s.��������A��G�G���,�C��J�
���s�.�*�.�,�.�.c��<K�td�}|�d{���}|S7��w�N�foor#�rr$s  rr%z3AwaitTests.test_deferredFromCoroutine.<locals>.run27� �������A��'�C��J������r)N)�str�assertIsInstance�types�
CoroutineTyper�
fromCoroutine�successResultOfr)rr&�rrr$r%s     @r�test_deferredFromCoroutinez%AwaitTests.test_deferredFromCoroutine,s~���
	�3�	�	�C�	�
�E�����a��!4�!4�5�
�"�"�1�%�����a��*��"�"�1�%������e�$rc��dtfd�}tj|��}|j|�}|j	|d�y)zc
        L{Deferred.fromCoroutine} allows a function to C{await} on a
        L{Deferred}.
        r c��<K�td�}|�d{���}|S7��wr(r#r*s  rr&z"AwaitTests.test_basic.<locals>.runNr+r,r)N)r-rr1r2r�rr&rr$s    r�
test_basiczAwaitTests.test_basicHsB��	�3�	�

�"�"�3�5�)���"�"�1�%������e�$rc�~�dtfd�}t|��}|j|�}|j|d�y)zS
        L{ensureDeferred} allows a function to C{await} on a L{Deferred}.
        r c��<K�td�}|�d{���}|S7��wr(r#r*s  rr&z0AwaitTests.test_basicEnsureDeferred.<locals>.run\r+r,r)N)r-rr2rr7s    r�test_basicEnsureDeferredz#AwaitTests.test_basicEnsureDeferredWs<��
	�3�	�

�3�5�!���"�"�1�%������e�$rc��dtfd�}tj|��}|j|�}|j	t|j�t�|j	|jjd�y)z�
        An exception in a coroutine scheduled with L{Deferred.fromCoroutine}
        will cause the returned L{Deferred} to fire with a failure.
        r c��NK�td�}|�d{���td��7��w)Nr)�Oh no!)r�
ValueError)rs rr&z&AwaitTests.test_exception.<locals>.runks&�������A��G�G��X�&�&�
�s�%�#�%)r>N)	rrr1�failureResultOfr�type�valuer?�argsr7s    r�test_exceptionzAwaitTests.test_exceptionesb��	'�8�	'�

�"�"�3�5�)���"�"�1�%������c�i�i��*�5����������5rc���dd�}t|��d�fd�}|jtj|���}|j	d|j��|j	d|j��y)z�
        When a Deferred is awaited upon that has already failed with a Failure
        that has a traceback, both the place that the synchronous traceback
        comes from and the awaiting line are shown in the traceback.
        Nc��t���N)r
rrr�raiseszCAwaitTests.test_synchronousDeferredFailureTraceback.<locals>.raises|s��!�#�#rc��$�K���d{���S7��wrGr��its�r�doomedzCAwaitTests.test_synchronousDeferredFailureTraceback.<locals>.doomed��������8�O�8������, in doomed
z, in raises
�r N)rr@rr1�assertIn�getTraceback)rrHrL�failurerKs    @r�(test_synchronousDeferredFailureTracebackz3AwaitTests.test_synchronousDeferredFailureTracebackusf���	$��6�
"��	��&�&�x�'=�'=�f�h�'G�H���
�
�o�w�';�';�'=�>��
�
�o�w�';�';�'=�>rc�^��dtfd�}t��d�fd�}tj|��}|j|��j	|��|j|�}|j
d|j��|j
d|j��y)z�
        When a Deferred is awaited upon that later fails with a Failure that
        has a traceback, both the place that the synchronous traceback comes
        from and the awaiting line are shown in the traceback.
        r c�J�	t��#t$r
t�cYSwxYwrG)r
r
rrr�returnsFailurezEAwaitTests.test_asyncDeferredFailureTraceback.<locals>.returnsFailure�s'��
!�%�'�'��"�
!��y� �
!�s�
�"�"Nc��$�K���d{���S7��wrGrrJs�rrLz=AwaitTests.test_asyncDeferredFailureTraceback.<locals>.doomed�rMrNrOz, in returnsFailure
rP)r
rr1�assertNoResult�errbackr@rQrR)rrWrL�startedrSrKs     @r�"test_asyncDeferredFailureTracebackz-AwaitTests.test_asyncDeferredFailureTraceback�s����	!��	!�&�Z��	��(�(���2�����G�$�
�
�
�>�#�$��&�&�w�/���
�
�o�w�';�';�'=�>��
�
�-�w�/C�/C�/E�Frc�����t��g�dtf��fd��dtf���fd�}tj|��}�j	d�|j�ddg��j	d�|j�gd���j	d�|j�gd���j	d�|j�gd	��|j
|�}|j|d
�y)z�
        A coroutine scheduled with L{Deferred.fromCoroutine} that awaits a
        L{Deferred} suspends its execution until the inner L{Deferred} fires.
        r c���K��jd�t�}�jd|jd�|�d{����jd�y7��w)N����Yay!��appendr�	callLater�callback)r�reactor�sectionss ��r�runonez'AwaitTests.test_twoDeep.<locals>.runone�sK������O�O�A��'�z�A����a����Q�/��G�G��O�O�A���
�s�>A�A�Ac���K��jd����d{���}�jd�t�}�jd|jd�|�d{����jd�|S7�Y7��w)Nr`��rc)�resultrrgrirhs  ���rr&z$AwaitTests.test_twoDeep.<locals>.run�sh������O�O�A��!�8�^�F��O�O�A��'�z�A����a����Q�/��G�G��O�O�A���M�
$��
�s"�A=�A9�AA=�!A;�"A=�;A=g�������?r`r_皙�����?)r`r_rark)r`r_rarkrlrbN)r	r-rr1�advancerr2)rr&rr$rgrirhs    @@@r�test_twoDeepzAwaitTests.test_twoDeep�s����
�'����	�c�	�	�3�	�
�"�"�3�5�)�����������A�q�6�*����������<�0����������<�0����������?�3��"�"�1�%������f�%rc���dtf�fd�}�jtj|���}�j	|d�y)zO
        Awaiting an already failed Deferred will raise the exception.
        r c���K�	ttd���d{���y7�#t$r&}�j|jd�Yd}~yd}~wwxYw�w)N�Boom)rsr`r)rr?rrC)�ers �r�testz%AwaitTests.test_reraise.<locals>.test�sO�����
��:�f�-�.�.�.��	/���
�� � �����3���
�s6�A�$�"�$�A�$�	A�A�	A�A�Ar`N)�intr2rr1r)rrur$s`  r�test_reraisezAwaitTests.test_reraise�s>���
	�C�	��"�"�8�#9�#9�$�&�#A�B������a� rc����t��d�fd�}tj|��}�jd�|j	|�}|j|d�y)zd
        Awaiting a paused & chained Deferred will give the result when it has
        one.
        Nc�����K�t�}t��|j�fd��|jd��jd�jd�|�d{���S7��w)Nc����SrGr)�ignored�d2s �r�<lambda>z7AwaitTests.test_chained.<locals>.test.<locals>.<lambda>�s���"�rr�bye)r�addCallbackrfre)rr|rgs @�rruz%AwaitTests.test_chained.<locals>.test�sM����� (�
�A�!)��B�
�M�M�,�-�
�J�J�t�����a����e�4��7�N�7�s�AA'� A%�!A'rnr~rP)r	rr1ror2r)rrurr$rgs    @r�test_chainedzAwaitTests.test_chained�sQ���
�'��	�
�"�"�4�6�*��������"�"�1�%������e�$rrP)rrrrrr4r8r;rDrTr\rprwr�rrrrrs<���A�%�8
%�%�6� ?�(G�2)&�V!� %rr)rr/�typingr�twisted.internet.deferrrrrr�twisted.internet.taskr	�twisted.python.failurer
�twisted.trial.unittestr�	Exceptionr
rrrr�<module>r�sA��
�
����(�*�+��i��R%��R%r

Zerion Mini Shell 1.0