%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlmZddlmZddlmZddlmZm	Z	m
Z
Gd�dej�ZGd�d	eje	j�ZGd
�dej�ZGd�d
e�ZGd�de�Zy)z,
Tests for L{twisted.words.xish.xmlstream}.
�)�protocol)�failure)�unittest)�domish�utility�	xmlstreamc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�XmlStreamTestsc���d|_g|_tj�|_||j_|jj
|jj_y)Nz	no reason)�connectionLostMsg�outlistr�	XmlStream�	transport�append�write��selfs �C/usr/lib/python3/dist-packages/twisted/words/test/test_xmlstream.py�setUpzXmlStreamTests.setUpsI��!,������"�,�,�.���#'���� �)-���)<�)<���� � �&�c��|jjtjt	|j
���y)zA
        Stub loseConnection because we are a transport.
        N)r�connectionLostr�Failure�	Exceptionrrs r�loseConnectionzXmlStreamTests.loseConnections-��	
���%�%��O�O�I�d�&<�&<�=�>�	
rc��|jj�|jjd�|j|jdd�y)zq
        Calling L{xmlstream.XmlStream.send} results in the data being written
        to the transport.
        s<root>rN)r�connectionMade�send�assertEqualr
rs r�	test_sendzXmlStreamTests.test_sends>��
	
���%�%�'������I�&�������a��)�4rc���g��fd�}|jjtj|�|jj�|jj	d�|jdt
���y)zU
        Receiving the starttag of the root element results in stream start.
        c�(���jd�y�N�r)�rootelem�
streamStarteds �r�streamStartEventz9XmlStreamTests.test_receiveRoot.<locals>.streamStartEvent.s���� � ��&r�<root>�N)r�addObserver�STREAM_START_EVENTr�dataReceivedr�len)rr'r&s  @r�test_receiveRootzXmlStreamTests.test_receiveRoot(sc����
�	'�	
���"�"�9�#?�#?�AQ�R����%�%�'����#�#�H�-�����C�
�.�/rc����g�g��fd�}�fd�}|jjtj|�|jjtj|�|jj	�|jjd�|j
dt���|j
dt���|jjd�|j
dt���|j�djtj��|j
dt���y)zN
        Receiving malformed XML results in an L{STREAM_ERROR_EVENT}.
        c�(���j|�yr#r$)�reason�streamErrors �r�streamErrorEventz;XmlStreamTests.test_receiveBadXML.<locals>.streamErrorEvent=s������v�&rc�(���jd�yr#r$)�_�	streamEnds �r�streamEndEventz9XmlStreamTests.test_receiveBadXML.<locals>.streamEndEvent@s������T�"rr(rz<child><unclosed></child>r)N)rr*�STREAM_ERROR_EVENT�STREAM_END_EVENTrr,rr-�
assertTrue�checkr�ParserError)rr3r7r6r2s   @@r�test_receiveBadXMLz!XmlStreamTests.test_receiveBadXML6s�������	�	'�	#�	
���"�"�9�#?�#?�AQ�R����"�"�9�#=�#=�~�N����%�%�'����#�#�H�-�����C��,�-�����C�	�N�+����#�#�$?�@�����C��,�-�����A��,�,�V�-?�-?�@�A�����C�	�N�+rc���g��fd�}|jjtj|�|jj�|j	�|jdt
���|j�dtj�|j�dj�|j�y)z@
        Ending the stream fires a L{STREAM_END_EVENT}.
        c�(���j|�yr#r$)r1r6s �rr7z5XmlStreamTests.test_streamEnd.<locals>.streamEndEventVs������V�$rr)rN)rr*r9rrrr-�assertIsInstancerr�getErrorMessager)rr7r6s  @r�test_streamEndzXmlStreamTests.test_streamEndPs�����	�	%�	
���"�"�9�#=�#=�~�N����%�%�'���������C�	�N�+����i��l�G�O�O�<�����1��5�5�7��9O�9O�PrN)	�__name__�
__module__�__qualname__rrr r.r=rB�rrr
r
s!��=�
�5�0�,�4Qrr
c��eZdZdZd�Zy)�
DummyProtocolz�
    I am a protocol with an event dispatcher without further processing.

    This protocol is only used for testing XmlStreamFactoryMixin to make
    sure the bootstrap observers are added to the protocol instance.
    c�l�||_||_g|_tjj|�yr#)�args�kwargs�	observersr�EventDispatcher�__init__)rrJrKs   rrNzDummyProtocol.__init__is+����	����������(�(��.rN)rCrDrE�__doc__rNrFrrrHrHas���/rrHc�"�eZdZdZd�Zd�Zd�Zy)�BootstrapMixinTestszq
    Tests for L{xmlstream.BootstrapMixin}.

    @ivar factory: Instance of the factory or mixin under test.
    c�6�tj�|_yr#)r�BootstrapMixin�factoryrs rrzBootstrapMixinTests.setUpxs�� �/�/�1��rc����g��fd�}t�}|jjd|�|jj|�|j	dd�|jdt
���y)zL
        Dispatching an event fires registered bootstrap observers.
        c�(���j|�yr#r$��data�calleds �r�cbz6BootstrapMixinTests.test_installBootstraps.<locals>.cb������M�M�$�r�//event/myeventNr))rHrT�addBootstrap�installBootstraps�dispatchrr-�rrZ�
dispatcherrYs   @r�test_installBootstrapsz*BootstrapMixinTests.test_installBootstraps{sd�����	 �#�_�
����!�!�"3�R�8����&�&�z�2����D�"3�4�����C��K�(rc���g��fd�}|jjd|�|jjd|�t�}|jj	|�|jdd�|j
��y)zI
        Test addition and removal of a bootstrap event handler.
        c�(���j|�yr#r$rWs �rrZz:BootstrapMixinTests.test_addAndRemoveBootstrap.<locals>.cb�r[rr\N)rTr]�removeBootstraprHr^r_�assertFalser`s   @r�test_addAndRemoveBootstrapz.BootstrapMixinTests.test_addAndRemoveBootstrap�ss���
��	 �	
���!�!�"3�R�8����$�$�%6��;�"�_�
����&�&�z�2����D�"3�4����� rN)rCrDrErOrrbrgrFrrrQrQqs���2�)� !rrQc�"�eZdZdZd�Zd�Zd�Zy)�!GenericXmlStreamFactoryTestsMixinz3
    Generic tests for L{XmlStream} factories.
    c�6�tj�|_yr#)r�XmlStreamFactoryrTrs rrz'GenericXmlStreamFactoryTestsMixin.setUp�s�� �1�1�3��rc����g��fd�}|jjd|�|jjd�}|jdd�|j	dt���y)zY
        The protocol factory installs bootstrap event handlers on the protocol.
        c�(���j|�yr#r$rWs �rrZzRGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps.<locals>.cb�r[rr\Nr))rTr]�
buildProtocolr_rr-)rrZ�xsrYs   @r�$test_buildProtocolInstallsBootstrapszFGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps�s]�����	 �	
���!�!�"3�R�8�
�\�\�
'�
'��
-��
���D�+�,�����C��K�(rc��|jjd�}|j|j|j�y)z@
        The protocol factory is saved in the protocol.
        N)rTrn�assertIdentical�rros  r�test_buildProtocolStoresFactoryzAGenericXmlStreamFactoryTestsMixin.test_buildProtocolStoresFactory�s0���\�\�
'�
'��
-�����T�\�\�2�:�:�6rN)rCrDrErOrrprtrFrrriri�s���4�)� 7rric��eZdZdZd�Zd�Zy)�XmlStreamFactoryMixinTestsz7
    Tests for L{xmlstream.XmlStreamFactoryMixin}.
    c�f�tjdd��|_t|j_y)N)�test)r�XmlStreamFactoryMixinrTrHrrs rrz XmlStreamFactoryMixinTests.setUp�s"�� �6�6�t�$�G��� -����rc��|jjd�}|jd|j�|jddi|j�y)zb
        Arguments passed to the factory are passed to protocol on
        instantiation.
        Nr#rx)rTrnrrJrKrss  r�"test_buildProtocolFactoryArgumentsz=XmlStreamFactoryMixinTests.test_buildProtocolFactoryArguments�sD��
�\�\�
'�
'��
-������"�'�'�*����&�$�����3rN)rCrDrErOrr{rFrrrvrv�s���.�4rrvN)rO�twisted.internetr�twisted.pythonr�
twisted.trialr�twisted.words.xishrrr�TestCaser
�ProtocolrMrHrQrirvrFrr�<module>r�sz���
&�"�"�9�9�OQ�X�&�&�OQ�d
/�H�%�%�w�'>�'>�
/� +!�(�+�+�+!�\7�(;�7�@4�!B�4r

Zerion Mini Shell 1.0