%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_yieldfrom.cpython-312.pyc

�

Ϫ�f(��V�dZddlZddlmZmZmZmZddlmZddl	m
Z
Gd�de
�Zy)z/
Tests for C{yield from} support in Deferreds.
�N)�Deferred�ensureDeferred�fail�succeed)�Clock)�TestCasec�H�eZdZdZd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
y)�YieldFromTestsz@
    Tests for using Deferreds in conjunction with PEP-380.
    Nc���d�}|�}|j|tj�t|�}|j|t�|j|�}|j
|d�y)zM
        L{ensureDeferred} will turn a coroutine into a L{Deferred}.
        c3�<K�td�}|Ed{���}|S7��w�N�foo�r��d�ress  �L/usr/lib/python3/dist-packages/twisted/internet/test/test_defer_yieldfrom.py�runz/YieldFromTests.test_ensureDeferred.<locals>.run� �������A��,�C��J������rN)�assertIsInstance�types�
GeneratorTyperr�successResultOf�assertEqual)�selfr�rrrs     r�test_ensureDeferredz"YieldFromTests.test_ensureDeferredsd��
	�
�E�����a��!4�!4�5�
�1������a��*��"�"�1�%������e�$�c����fd�}d��|�}|j|tj�tj|�}|j|t�|j|�}|j
|d�y)zU
        L{Deferred.fromCoroutine} will turn a coroutine into a L{Deferred}.
        c3�`�K�td�}|Ed{�����Ed{���}|S7�7��w)N�barr)rr�run2s  �rrz6YieldFromTests.test_DeferredfromCoroutine.<locals>.run0s/��������A��L�L�!�V�#�C��J�
��#�s�.�*�.�,�.�.c3�<K�td�}|Ed{���}|S7��wr
rrs  rr#z7YieldFromTests.test_DeferredfromCoroutine.<locals>.run26rrrN)rrrr�
fromCoroutinerr)rrrrrr#s     @r�test_DeferredfromCoroutinez)YieldFromTests.test_DeferredfromCoroutine+sp���
	�	�
�E�����a��!4�!4�5�
�"�"�1�%�����a��*��"�"�1�%������e�$rc��d�}tj|��}|j|�}|j|d�y)ze
        L{Deferred.fromCoroutine} allows a function to C{yield from} a
        L{Deferred}.
        c3�<K�td�}|Ed{���}|S7��wr
rrs  rrz&YieldFromTests.test_basic.<locals>.runMrrrN)rr%rr�rrrrs    r�
test_basiczYieldFromTests.test_basicGs;��	�

�"�"�3�5�)���"�"�1�%������e�$rc��d�}tj|��}|j|�}|jt	|j
�t�|j|j
jd�y)��
        An exception in a generator scheduled with L{Deferred.fromCoroutine}
        will cause the returned L{Deferred} to fire with a failure.
        c3�NK�td�}|Ed{���td��7��w)Nr�Oh no!)r�
ValueError)rs rrz*YieldFromTests.test_exception.<locals>.run\s&�������A��L�L��X�&�&�
�s�%�#�%)r.N)rr%�failureResultOfr�type�valuer/�argsr)s    r�test_exceptionzYieldFromTests.test_exceptionVs[��	'�

�"�"�3�5�)���"�"�1�%������c�i�i��*�5����������5rc������t��g���fd�����fd�}tj|��}�jd�|j	�ddg��jd�|j	�gd���jd�|j	�gd���jd�|j	�gd��|j|�}|j	|d	�y
)r,c3��K��jd�t�}�jd|jd�|Ed{����jd�y7��w)N����Yay!��appendr�	callLater�callback)r�reactor�sectionss ��r�runonez+YieldFromTests.test_twoDeep.<locals>.runonensK������O�O�A���
�A����a����T�2��L�L��O�O�A���
�s�>A�A�Ac3��K��jd���Ed{���}�jd�t�}�jd|jd�|Ed{����jd�|S7�Y7��w)Nr8��r;)�resultrr?rAr@s  ���rrz(YieldFromTests.test_twoDeep.<locals>.runvsi������O�O�A�� &��(�F��O�O�A���
�A����a����T�2��L�L��O�O�A���M�
)��
�s"�A=�A9�AA=�!A;�"A=�;A=g�������?r8r7皙�����?)r8r7r9rC)r8r7r9rCrDr:N)rrr%�advancerr)rrrrr?rAr@s    @@@r�test_twoDeepzYieldFromTests.test_twoDeepfs����
�'����	�	�
�"�"�3�5�)�����������A�q�6�*����������<�0����������<�0����������?�3��"�"�1�%������f�%rc����fd�}�jtj|���}�j|d�y)zT
        Yielding from an already failed Deferred will raise the exception.
        c3��K�	ttd��Ed{���y7�#t$r&}�j|jd�Yd}~yd}~wwxYw�w)N�Boom)rKr8r)rr/rr3)�ers �r�testz)YieldFromTests.test_reraise.<locals>.test�sO�����
��
�6� 2�3�3�3��	4���
�� � �����3���
�s6�A�$�"�$�A�$�	A�A�	A�A�Ar8N)rrr%r)rrMrs`  r�test_reraisezYieldFromTests.test_reraise�s7���
	��"�"�8�#9�#9�$�&�#A�B������a� rc���t���fd�}tj|��}�jd�|j	|�}|j|d�y)zi
        Yielding from a paused & chained Deferred will give the result when it
        has one.
        c3����K�t�}t��|j�fd��|jd��jd�jd�|Ed{���}|S7��w)Nc����S)N�)�ignored�d2s �r�<lambda>z;YieldFromTests.test_chained.<locals>.test.<locals>.<lambda>�s���"�rr�bye)r�addCallbackr>r=)rrrTr?s  @�rrMz)YieldFromTests.test_chained.<locals>.test�sU������
�A���B�
�M�M�,�-�
�J�J�t�����a����e�4��,�C��J��s�AA)� A'�!A)rFrVN)rrr%rGrr)rrMrrr?s    @r�test_chainedzYieldFromTests.test_chained�sQ���
�'��	�
�"�"�4�6�*��������"�"�1�%������e�$r)�returnN)�__name__�
__module__�__qualname__�__doc__rr&r*r4rHrNrXrRrrr
r
s+���%�,%�8
%�6� )&�V!� %rr
)r]r�twisted.internet.deferrrrr�twisted.internet.taskr�twisted.trial.unittestrr
rRrr�<module>ras)��
�
�J�J�'�+�f%�X�f%r

Zerion Mini Shell 1.0