+
    Dfj                        R t ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
  ! R R]P                  4      t ! R R]P                  ]	P                  4      t ! R	 R
]P                  4      t ! R R]4      t ! R R]4      tR# )z,
Tests for L{twisted.words.xish.xmlstream}.
)protocol)failure)unittest)domishutility	xmlstreamc                   D   a  ] tR t^t o R tR tR tR tR tR t	Rt
V tR# )	XmlStreamTestsc                    R V n         . V n        \        P                  ! 4       V n        W P                  n        V P                  P
                  V P                  P                  n        R# )z	no reasonN)connectionLostMsgoutlistr   	XmlStream	transportappendwriteselfs   &C/usr/lib/python3/dist-packages/twisted/words/test/test_xmlstream.pysetUpXmlStreamTests.setUp   sG    !,",,.#' )-)<)<  &    c                    V P                   P                  \        P                  ! \	        V P
                  4      4      4       R# )z1
Stub loseConnection because we are a transport.
N)r   connectionLostr   Failure	Exceptionr   r   s   &r   loseConnectionXmlStreamTests.loseConnection   s-     	%%OOId&<&<=>	
r   c                    V P                   P                  4        V P                   P                  R4       V P                  V P                  ^ ,          R4       R# )zY
Calling L{xmlstream.XmlStream.send} results in the data being written
to the transport.
s   <root>N)r   connectionMadesendassertEqualr   r   s   &r   	test_sendXmlStreamTests.test_send   s>    
 	%%'I&a)4r   c                  a . oV3R lpV P                   P                  \         P                  V4       V P                   P                  4        V P                   P	                  R4       V P                  ^\        S4      4       R# )zE
Receiving the starttag of the root element results in stream start.
c                 *   < SP                  R 4       R # Nr   )rootelemstreamStarteds   &r   streamStartEvent9XmlStreamTests.test_receiveRoot.<locals>.streamStartEvent.   s      &r   <root>N)r   addObserverSTREAM_START_EVENTr   dataReceivedr    len)r   r)   r(   s   & @r   test_receiveRootXmlStreamTests.test_receiveRoot(   sc     	' 	""9#?#?AQR%%'##H-C./r   c                  aa . o. oV3R lpV3R lpV P                   P                  \         P                  V4       V P                   P                  \         P                  V4       V P                   P	                  4        V P                   P                  R4       V P                  ^ \        S4      4       V P                  ^ \        S4      4       V P                   P                  R4       V P                  ^\        S4      4       V P                  S^ ,          P                  \        P                  4      4       V P                  ^\        S4      4       R# )z>
Receiving malformed XML results in an L{STREAM_ERROR_EVENT}.
c                 *   < SP                  V 4       R # r%   r&   )reasonstreamErrors   &r   streamErrorEvent;XmlStreamTests.test_receiveBadXML.<locals>.streamErrorEvent=   s    v&r   c                 *   < SP                  R 4       R # r%   r&   )_	streamEnds   &r   streamEndEvent9XmlStreamTests.test_receiveBadXML.<locals>.streamEndEvent@   s    T"r   r+   z<child><unclosed></child>N)r   r,   STREAM_ERROR_EVENTSTREAM_END_EVENTr   r.   r    r/   
assertTruecheckr   ParserError)r   r6   r;   r:   r5   s   &  @@r   test_receiveBadXML!XmlStreamTests.test_receiveBadXML6   s     		'	# 	""9#?#?AQR""9#=#=~N%%'##H-C,-C	N+##$?@C,-A,,V-?-?@AC	N+r   c                  a . oV3R lpV P                   P                  \         P                  V4       V P                   P                  4        V P	                  4        V P                  ^\        S4      4       V P                  S^ ,          \        P                  4       V P                  S^ ,          P                  4       V P                  4       R# )z0
Ending the stream fires a L{STREAM_END_EVENT}.
c                 *   < SP                  V 4       R # r%   r&   )r4   r:   s   &r   r;   5XmlStreamTests.test_streamEnd.<locals>.streamEndEventV   s    V$r   N)r   r,   r>   r   r   r    r/   assertIsInstancer   r   getErrorMessager   )r   r;   r:   s   & @r   test_streamEndXmlStreamTests.test_streamEndP   s     		% 	""9#=#=~N%%'C	N+ilGOO<15579O9OPr   )r   r   r   N)__name__
__module____qualname____firstlineno__r   r   r!   r0   rB   rI   __static_attributes____classdictcell____classdict__s   @r   r	   r	      s*     =
50,4Q Qr   r	   c                   *   a  ] tR t^at o RtR tRtV tR# )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                j    Wn         W n        . V n        \        P                  P                  V 4       R # r%   )argskwargs	observersr   EventDispatcher__init__)r   rV   rW   s   &*,r   rZ   DummyProtocol.__init__i   s'    	((.r   )rV   rW   rX   N)rK   rL   rM   rN   __doc__rZ   rO   rP   rQ   s   @r   rT   rT   a   s     / /r   rT   c                   6   a  ] tR t^qt o RtR tR tR tRtV t	R# )BootstrapMixinTestsze
Tests for L{xmlstream.BootstrapMixin}.

@ivar factory: Instance of the factory or mixin under test.
c                :    \         P                  ! 4       V n        R # r%   )r   BootstrapMixinfactoryr   s   &r   r   BootstrapMixinTests.setUpx   s     //1r   c                   a . oV3R lp\        4       pV P                  P                  RV4       V P                  P                  V4       VP	                  RR4       V P                  ^\        S4      4       R# )z<
Dispatching an event fires registered bootstrap observers.
c                 *   < SP                  V 4       R # r%   r&   datacalleds   &r   cb6BootstrapMixinTests.test_installBootstraps.<locals>.cb       MM$r   //event/myeventN)rT   ra   addBootstrapinstallBootstrapsdispatchr    r/   r   rh   
dispatcherrg   s   &  @r   test_installBootstraps*BootstrapMixinTests.test_installBootstraps{   sd     	  #_
!!"3R8&&z2D"34CK(r   c                  a . oV3R lpV P                   P                  RV4       V P                   P                  RV4       \        4       pV P                   P	                  V4       VP                  RR4       V P                  S4       R# )z9
Test addition and removal of a bootstrap event handler.
c                 *   < SP                  V 4       R # r%   r&   re   s   &r   rh   :BootstrapMixinTests.test_addAndRemoveBootstrap.<locals>.cb   rj   r   rk   N)ra   rl   removeBootstraprT   rm   rn   assertFalsero   s   &  @r   test_addAndRemoveBootstrap.BootstrapMixinTests.test_addAndRemoveBootstrap   ss    
 	  	!!"3R8$$%6;"_
&&z2D"34 r   ra   N)
rK   rL   rM   rN   r\   r   rq   rx   rO   rP   rQ   s   @r   r^   r^   q   s     2) ! !r   r^   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )!GenericXmlStreamFactoryTestsMixinz+
Generic tests for L{XmlStream} factories.
c                :    \         P                  ! 4       V n        R # r%   )r   XmlStreamFactoryra   r   s   &r   r   'GenericXmlStreamFactoryTestsMixin.setUp   s     113r   c                   a . oV3R lpV P                   P                  RV4       V P                   P                  R4      pVP                  RR4       V P	                  ^\        S4      4       R# )zI
The protocol factory installs bootstrap event handlers on the protocol.
c                 *   < SP                  V 4       R # r%   r&   re   s   &r   rh   RGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps.<locals>.cb   rj   r   rk   N)ra   rl   buildProtocolrn   r    r/   )r   rh   xsrg   s   &  @r   $test_buildProtocolInstallsBootstrapsFGenericXmlStreamFactoryTestsMixin.test_buildProtocolInstallsBootstraps   s]     	  	!!"3R8\\''-
D+,CK(r   c                    V P                   P                  R4      pV P                  V P                   VP                   4       R# )z0
The protocol factory is saved in the protocol.
N)ra   r   assertIdenticalr   r   s   & r   test_buildProtocolStoresFactoryAGenericXmlStreamFactoryTestsMixin.test_buildProtocolStoresFactory   s0     \\''-T\\2::6r   rz   N)
rK   rL   rM   rN   r\   r   r   r   rO   rP   rQ   s   @r   r|   r|      s     4) 7 7r   r|   c                   0   a  ] tR t^t o RtR tR tRtV tR# )XmlStreamFactoryMixinTestsz/
Tests for L{xmlstream.XmlStreamFactoryMixin}.
c                j    \         P                  ! R R R7      V n        \        V P                  n        R # )N)test)r   XmlStreamFactoryMixinra   rT   r   r   s   &r   r    XmlStreamFactoryMixinTests.setUp   s"     66t$G -r   c                    V P                   P                  R4      pV P                  RVP                  4       V P                  RR/VP                  4       R# )zJ
Arguments passed to the factory are passed to protocol on
instantiation.
Nr   r%   )ra   r   r    rV   rW   r   s   & r   "test_buildProtocolFactoryArguments=XmlStreamFactoryMixinTests.test_buildProtocolFactoryArguments   sD    
 \\''-"''*&$3r   rz   N)	rK   rL   rM   rN   r\   r   r   rO   rP   rQ   s   @r   r   r      s     .4 4r   r   N)r\   twisted.internetr   twisted.pythonr   twisted.trialr   twisted.words.xishr   r   r   TestCaser	   ProtocolrY   rT   r^   r|   r    r   r   <module>r      sz   
 & " " 9 9OQX&& OQd/H%%w'>'> / +!(++ +!\7(; 7@4!B 4r   