%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_inlinecb.cpython-312.pyc |
� Ϫ�f�, � �� � d Z ddlmZmZmZmZ ddlmZmZ G d� de� Z G d� de� Z G d� d e� Z G d � de� Z G d� d e� Z G d� de� Z G d� de� Zy)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 � � e Zd ZdZd� Zy)�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}. c � � dt i}t d|� t � } |d |� }|j d� | j | j |� d� y)z� If the C{return} statement has a value it is propagated back to the L{Deferred} that the C{inlineCallbacks} function returned. r z> @inlineCallbacks def f(d): yield d return 14 �fN� )r �execr �callback�assertEqual�successResultOf)�self�environ�d1�d2s �E/usr/lib/python3/dist-packages/twisted/internet/test/test_inlinecb.py�test_returnWithValuez-StopIterationReturnTests.test_returnWithValue s` � � %�o�6��� � � � �Z�� �W�S�\�"� �� ���D������-�-�b�1�2�6� N)�__name__� __module__�__qualname__�__doc__r � r r r r s � ��7r r c �( � e Zd ZdZd� Zd� Zd� Zd� Zy)�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. c � � t d� y)z� This method mistakenly invokes L{returnValue}, despite the fact that it is not decorated with L{inlineCallbacks}. � N)r �r s r �mistakenMethodz NonLocalExitTests.mistakenMethod? s � � �A�r c � � | j |dg� | j | j g�� }| j t |� d� | j |d d t � | j |d d d� y)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�warningss r �assertMistakenMethodWarningz-NonLocalExitTests.assertMistakenMethodWarningF s � � ����a�S�)��%�%�$�:M�:M�9N�%�O������X���*�����!��Z�0�2D�E�����Q�K� �"� � r c � � � t � fd�� } |� }g }|j |j � � j |� y)z� L{returnValue} will emit a non-local exit warning in the simplest case, where the offending function is invoked immediately. c 3 �L �K � � j � t d� d�� y �w)N� r �r# r r"