%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�fl$���dZddlmZddlmZddlmZddlmZddl	m
Z
Gd�d�ZGd	�d
�ZGd�dej�ZGd
�dej�Zy)z+
Test cases for twisted.words.xish.utility
�)�OrderedDict)�unittest)�utility)�Element)�EventDispatcherc��eZdZdZd�Zd�Zy)�CallbackTrackerz�
    Test helper for tracking callbacks.

    Increases a counter on each call to L{call} and stores the object
    passed in the call.
    c� �d|_d|_y)Nr��called�obj��selfs �B/usr/lib/python3/dist-packages/twisted/words/test/test_xishutil.py�__init__zCallbackTracker.__init__s��������c�:�|jdz|_||_y)N�r)rr
s  r�callzCallbackTracker.calls���k�k�A�o�����rN)�__name__�
__module__�__qualname__�__doc__rr�rrr	r	s����rr	c�(�eZdZdZd�Zd�Zd�Zd�Zy)�OrderedCallbackTrackerz=
    Test helper for tracking callbacks and their order.
    c��g|_y�N)�callListrs rrzOrderedCallbackTracker.__init__'s	����
rc�N�|jj|j�yr)r�append�call1�r�objects  rr"zOrderedCallbackTracker.call1*����
�
���T�Z�Z�(rc�N�|jj|j�yr)rr!�call2r#s  rr'zOrderedCallbackTracker.call2-r%rc�N�|jj|j�yr)rr!�call3r#s  rr)zOrderedCallbackTracker.call30r%rN)rrrrrr"r'r)rrrrr"s����)�)�)rrc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�EventDispatcherTestsz'
    Tests for L{EventDispatcher}.
    c��t�}t�}t�}t�}|jd|j�|jd|j�|jd|j�|jd|j�t	d�}|jd�t	d�}|jd�|j
|�|j|jd	�|j|j|�|j|jd
�|j
|�|j|jd	�|j|jd�|j|j|�|j|jd
�|j
|d�|j|jd�|j|j|�|jd|j�|j
|�|j|jd�y)N�
/message/body�/message�	/presence�//event/testevent��ns�message�body�r2�presencer6�rr)rr	�addObserverrr�
addElement�dispatch�assertEqualrr
�removeObserver)r�d�cb1�cb2�cb3�msg�press       r�	testStuffzEventDispatcherTests.testStuff9s���������������	�
�
�o�s�x�x�0�	�
�
�j�#�(�(�+�	�
�
�k�3�8�8�,�	�
�
�)�3�8�8�4��'�(�����v���)�*�����
�#�	�
�
�3��������Q�'�������#�&�������Q�'�	�
�
�4��������Q�'�������Q�'�������$�'�������Q�'�	�
�
�1�)�*�������Q�'�������!�$�	����c�h�h�/�	�
�
�4��������Q�'rc��t�}t�}t�}|jd|j�|jd|j�|j	|d�|j|jd�|j|j|�|j|jd�|j|j|�y)z�
        Test adding two observers for the same query.

        When the event is dispatched both of the observers need to be called.
        r0rN)rr	r8rr:r;rr
)rr=r>r?s    r�test_addObserverTwicez*EventDispatcherTests.test_addObserverTwice]s���
���������	�
�
�)�3�8�8�4�	�
�
�)�3�8�8�4�	�
�
�1�)�*�������Q�'�������!�$�������Q�'�������!�$rc����t��td�}t����fd�}�jd|��j	|�|j�jd��j	|�|j�jd��j	|�|j�jd�y)zG
        Test for registration of an observer during dispatch.
        r1c�>���jd�j�y�Nr.)r8r)�_�cbr=s ��r�	onMessagezBEventDispatcherTests.test_addObserverInDispatch.<locals>.onMessagexs���
�M�M�*�b�g�g�.rr.rrr7N�rrr	�addOnetimeObserverr:r;r�rrArKrJr=s   @@r�test_addObserverInDispatchz/EventDispatcherTests.test_addObserverInDispatchps����
����'�(��
�
��	/�	
���Z��3�	�
�
�3��������A�&�	�
�
�3��������A�&�	�
�
�3��������A�&rc����t��td�}t����fd�}�jd|��j	|�|j�jd��j	|�|j�jd��j	|�|j�jd�y)zN
        Test for registration of a onetime observer during dispatch.
        r1c�>���jd�j�yrH)rMr)rArJr=s ��rrKzIEventDispatcherTests.test_addOnetimeObserverInDispatch.<locals>.onMessage�s���
� � ��R�W�W�5rr.rrNrLrNs   @@r�!test_addOnetimeObserverInDispatchz6EventDispatcherTests.test_addOnetimeObserverInDispatch�s����
����'�(��
�
��	6�	
���Z��3�	�
�
�3��������A�&�	�
�
�3��������A�&�	�
�
�3��������A�&rc�.�t�}td�}t�}|jd|j�|j|�|j
|jd�|j|�|j
|jd�y)Nr1r.r)rrr	rMrr:r;r)rr=rArJs    r�testOnetimeDispatchz(EventDispatcherTests.testOnetimeDispatch�so������'�(��
�
��	���Z����1�	�
�
�3��������A�&�	�
�
�3��������A�&rc��t�}td�}td�}t�}|jd|j�|j|�}|j
d|�|j|�}|j
d|�y)Nr1r5r/FT)rrr	r8rr:r;)rr=rArBrJ�results      r�testDispatcherResultz)EventDispatcherTests.testDispatcherResult�su������'�(���)�*��
�
��	�
�
�k�2�7�7�+����C��������'����D�!������v�&rc��t�}t�}|jd|j�|jd|jd�|jd|j
d�t
d�}|jd�|j|�|j|j|j
|j|jgdt|jD�cgc]}|j��c}�z�ycc}w)Nr-r.���rr1r4zCalls out of order: %s)
rrr8r'r)r"rr9r:r;r�reprr)rr=rJrA�cs     r�testOrderedXPathDispatchz-EventDispatcherTests.testOrderedXPathDispatch�s������
#�
%��	�
�
�o�r�x�x�0�	�
�
�j�"�(�(�B�/�	�
�
�o�r�x�x��3��'�(�����v��	�
�
�3������K�K�
�X�X�r�x�x����*�$�t����,M�A�Q�Z�Z�,M�'N�N�	
��-Ns�$Dc�`�t�}t�}|jd|j�|j	dd�|jd|j�|jd|j�|jdt|jjd���y)zO
        Test observer clean-up after removeObserver for named events.
        �//event/testNrr)rr	r8rr:r;rr<�len�_eventObservers�pop�rr=rJs   r�test_cleanUpRemoveEventObserverz4EventDispatcherTests.test_cleanUpRemoveEventObserver�s���

���
�
��	�
�
�n�b�g�g�.�	�
�
�4��(�����B�I�I�&�	�������1�����C�� 1� 1� 5� 5�a� 8�9�:rc�t�t�}t�}td�}|jd|j�|j|�|j
d|j�|jd|j�|j
dt|jjd���y)zO
        Test observer clean-up after removeObserver for XPath events.
        �Nr3r.rrN)rr	rr8rr:r;rr<r_�_xpathObserversra�rr=rJrAs    r�test_cleanUpRemoveXPathObserverz4EventDispatcherTests.test_cleanUpRemoveXPathObserver�s���

���
�
���'�(��	�
�
�j�"�'�'�*�	�
�
�3������B�I�I�&�	����R�W�W�-�����C�� 1� 1� 5� 5�a� 8�9�:rc�(�t�}t�}|jd|j�|j	dd�|jd|j�|jdt|jjd���y)zD
        Test observer clean-up after onetime named events.
        r^Nrr)
rr	rMrr:r;rr_r`rarbs   r� test_cleanUpOnetimeEventObserverz5EventDispatcherTests.test_cleanUpOnetimeEventObserver�sp��

���
�
��	���^�R�W�W�5�	�
�
�4��(�����B�I�I�&�����C�� 1� 1� 5� 5�a� 8�9�:rc�<�t�}t�}td�}|jd|j�|j|�|j
d|j�|j
dt|jjd���y)zD
        Test observer clean-up after onetime XPath events.
        rer.rrN)rr	rrMrr:r;rr_rfrargs    r� test_cleanUpOnetimeXPathObserverz5EventDispatcherTests.test_cleanUpOnetimeXPathObserver�sx��

���
�
���'�(��	���Z����1�	�
�
�3������B�I�I�&�����C�� 1� 1� 5� 5�a� 8�9�:rc�<��Gd�dtj�}Gd�dt���fd�}t�}t	�}tj}	|t_|jd|�|jd|j�	|jdd�|jd	t|j����|jd	|j�|t_y#�$r|jd�Y�jwxYw#|t_wxYw)
z�
        Test that exceptions in observers do not bubble up to dispatch.

        The exceptions raised in observers should be logged and other
        observers should be called as if nothing happened.
        c��eZdZd�Zy)�OEventDispatcherTests.test_observerRaisingException.<locals>.OrderedCallbackListc�"�t�|_yr)r�	callbacksrs rrzXEventDispatcherTests.test_observerRaisingException.<locals>.OrderedCallbackList.__init__s��!,���rN)rrrrrrr�OrderedCallbackListro
s��
/rrrc��eZdZy)�EEventDispatcherTests.test_observerRaisingException.<locals>.TestErrorN)rrrrrr�	TestErrorrts��rruc������rr)rIrus �r�
raiseErrorzFEventDispatcherTests.test_observerRaisingException.<locals>.raiseErrors����+�rr^Nz2TestError raised. Should have been logged instead.r)
r�CallbackList�	Exceptionrr	r8rr:�failr;r_�flushLoggedErrorsr)rrrrwr=rJ�originalCallbackListrus      @r�test_observerRaisingExceptionz2EventDispatcherTests.test_observerRaisingExceptions����	/�'�"6�"6�	/�	�	�	�	�
���
�
��&�3�3��
	8�#6�G� �
�M�M�.�*�5�
�M�M�.�"�'�'�2�
P��
�
�4��0�
���Q��D�$:�$:�9�$E� F�G����Q��	�	�*�#7�G� ��
�
P��	�	�N�O�
P��$8�G� �s1�9D�C2� AD�2D�D�
D�D�
DN)rrrrrCrErOrRrTrWr\rcrhrjrlr}rrrr+r+4sD���"(�H%�&'�,'�,	'�'�
�,;�
;�;�;�$8rr+c�"�eZdZdZd�Zd�Zd�Zy)�XmlPipeTestsz:
    Tests for L{twisted.words.xish.utility.XmlPipe}.
    c�6�tj�|_yr)r�XmlPipe�pipers r�setUpzXmlPipeTests.setUp.s���O�O�%��	rc�����fd�}g�|jjjd|�td�}|jjj|�|j
|g��y)zO
        Send an element from the source and observe it from the sink.
        c�(���j|�yr�r!�r
rs �rrJz,XmlPipeTests.test_sendFromSource.<locals>.cb6�����M�M�#�r�/test[@xmlns="testns"]��testns�testN)r��sinkr8r�source�sendr;�rrJ�elementrs   @r�test_sendFromSourcez XmlPipeTests.test_sendFromSource1s]���
	����	�	���"�"�#;�R�@��,�-���	�	�����g�&����'��F�+rc�����fd�}g�|jjjd|�td�}|jjj|�|j
|g��y)zO
        Send an element from the sink and observe it from the source.
        c�(���j|�yrr�r�s �rrJz*XmlPipeTests.test_sendFromSink.<locals>.cbDr�rr�r�N)r�r�r8rr�r�r;r�s   @r�test_sendFromSinkzXmlPipeTests.test_sendFromSink?s]���
	����	�	���$�$�%=�r�B��,�-���	�	�����G�$����'��F�+rN)rrrrr�r�r�rrrrr)s���&�,�,rrN)r�collectionsr�
twisted.trialr�twisted.words.xishr�twisted.words.xish.domishr�twisted.words.xish.utilityrr	r�TestCaser+rrrr�<module>r�sV���
$�"�&�-�6���")�)�$r8�8�,�,�r8�j",�8�$�$�",r

Zerion Mini Shell 1.0