HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/words/test/__pycache__/test_xmlstream.cpython-38.pyc
U


W[��@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
Gdd�de	j�ZGd	d
�d
ejej�ZGdd�de	j�ZGd
d�de�ZGdd�de�ZdS)z,
Tests for L{twisted.words.xish.xmlstream}.
�)�absolute_import�division)�protocol)�failure)�unittest)�domish�utility�	xmlstreamc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�XmlStreamTestscCs0d|_g|_t��|_||j_|jj|jj_dS)Nz	no reason)�connectionLostMsg�outlistr	Z	XmlStreamZ	transport�append�write��self�r�C/usr/lib/python3/dist-packages/twisted/words/test/test_xmlstream.py�setUps

zXmlStreamTests.setUpcCs|j�t�t|j���dS)zA
        Stub loseConnection because we are a transport.
        N)r	ZconnectionLostr�Failure�	Exceptionrrrrr�loseConnections
�zXmlStreamTests.loseConnectioncCs,|j��|j�d�|�|jdd�dS)zq
        Calling L{xmlstream.XmlStream.send} results in the data being written
        to the transport.
        s<root>rN)r	�connectionMade�send�assertEqualrrrrr�	test_send s
zXmlStreamTests.test_sendcsJg��fdd�}|j�tj|�|j��|j�d�|�dt���dS)zU
        Receiving the starttag of the root element results in stream start.
        cs��d�dS�N�r
)Zrootelem�Z
streamStartedrr�streamStartEvent0sz9XmlStreamTests.test_receiveRoot.<locals>.streamStartEvent�<root>�N)r	�addObserverZSTREAM_START_EVENTr�dataReceivedr�len)rrrrr�test_receiveRoot*s
�
zXmlStreamTests.test_receiveRootcs�g�g��fdd�}�fdd�}|j�tj|�|j�tj|�|j��|j�d�|�dt���|�dt���|j�d�|�dt���|��d�	t
j��|�dt���d	S)
zN
        Receiving malformed XML results in an L{STREAM_ERROR_EVENT}.
        cs��|�dSrr��reason)�streamErrorrr�streamErrorEventAsz;XmlStreamTests.test_receiveBadXML.<locals>.streamErrorEventcs��d�dSrr)�_��	streamEndrr�streamEndEventDsz9XmlStreamTests.test_receiveBadXML.<locals>.streamEndEventrrz<child><unclosed></child>r N)r	r!ZSTREAM_ERROR_EVENT�STREAM_END_EVENTrr"rr#Z
assertTrueZcheckrZParserError)rr(r,r)r+r'r�test_receiveBadXML:s$
�
�
z!XmlStreamTests.test_receiveBadXMLcsng��fdd�}|j�tj|�|j��|��|�dt���|��dtj	�|��d�
�|j�dS)z@
        Ending the stream fires a L{STREAM_END_EVENT}.
        cs��|�dSrrr%r*rrr,]sz5XmlStreamTests.test_streamEnd.<locals>.streamEndEventr rN)r	r!r-rrrr#ZassertIsInstancerrZgetErrorMessager)rr,rr*r�test_streamEndWs
�
�zXmlStreamTests.test_streamEndN)	�__name__�
__module__�__qualname__rrrr$r.r/rrrrr
s
r
c@seZdZdZdd�ZdS)�
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.
    cOs"||_||_g|_tj�|�dSr)�args�kwargsZ	observersr�EventDispatcher�__init__)rr4r5rrrr7sszDummyProtocol.__init__N)r0r1r2�__doc__r7rrrrr3ksr3c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BootstrapMixinTestszq
    Tests for L{xmlstream.BootstrapMixin}.

    @ivar factory: Instance of the factory or mixin under test.
    cCst��|_dSr)r	ZBootstrapMixin�factoryrrrrr�szBootstrapMixinTests.setUpcsPg��fdd�}t�}|j�d|�|j�|�|�dd�|�dt���dS)zL
        Dispatching an event fires registered bootstrap observers.
        cs��|�dSrr��data�Zcalledrr�cb�sz6BootstrapMixinTests.test_installBootstraps.<locals>.cb�//event/myeventNr )r3r:�addBootstrap�installBootstraps�dispatchrr#�rr>�
dispatcherrr=r�test_installBootstraps�sz*BootstrapMixinTests.test_installBootstrapscsXg��fdd�}|j�d|�|j�d|�t�}|j�|�|�dd�|���dS)zI
        Test addition and removal of a bootstrap event handler.
        cs��|�dSrrr;r=rrr>�sz:BootstrapMixinTests.test_addAndRemoveBootstrap.<locals>.cbr?N)r:r@ZremoveBootstrapr3rArBZassertFalserCrr=r�test_addAndRemoveBootstrap�sz.BootstrapMixinTests.test_addAndRemoveBootstrapN)r0r1r2r8rrErFrrrrr9|sr9c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�!GenericXmlStreamFactoryTestsMixinz3
    Generic tests for L{XmlStream} factories.
    cCst��|_dSr)r	ZXmlStreamFactoryr:rrrrr�sz'GenericXmlStreamFactoryTestsMixin.setUpcsJg��fdd�}|j�d|�|j�d�}|�dd�|�dt���dS)zY
        The protocol factory installs bootstrap event handlers on the protocol.
        cs��|�dSrrr;r=rrr>�szRGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps.<locals>.cbr?Nr )r:r@�
buildProtocolrBrr#)rr>�xsrr=r�$test_buildProtocolInstallsBootstraps�szFGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstrapscCs |j�d�}|�|j|j�dS)z@
        The protocol factory is saved in the protocol.
        N)r:rHZassertIdentical�rrIrrr�test_buildProtocolStoresFactory�szAGenericXmlStreamFactoryTestsMixin.test_buildProtocolStoresFactoryN)r0r1r2r8rrJrLrrrrrG�srGc@s eZdZdZdd�Zdd�ZdS)�XmlStreamFactoryMixinTestsz7
    Tests for L{xmlstream.XmlStreamFactoryMixin}.
    cCstjddd�|_t|j_dS)N)�test)r	ZXmlStreamFactoryMixinr:r3rrrrrr�sz XmlStreamFactoryMixinTests.setUpcCs0|j�d�}|�d|j�|�ddi|j�dS)zb
        Arguments passed to the factory are passed to protocol on
        instantiation.
        NrrN)r:rHrr4r5rKrrr�"test_buildProtocolFactoryArguments�sz=XmlStreamFactoryMixinTests.test_buildProtocolFactoryArgumentsN)r0r1r2r8rrOrrrrrM�srMN)r8Z
__future__rrZtwisted.internetrZtwisted.pythonrZ
twisted.trialrZtwisted.words.xishrrr	ZTestCaser
ZProtocolr6r3r9rGrMrrrr�<module>s\1#