%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_domish.cpython-312.pyc

�

Ϫ�f�K���dZddlmZddlmZddlmZddlmZGd�dej�Z
Gd�d	�ZGd
�deej�ZGd�d
eej�Z
Gd�dej�Zy)zF
Tests for L{twisted.words.xish.domish}, a DOM-like library for XMPP.
�)�verifyObject)�
requireModule)�unittest)�domishc�p�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�ElementTestsz&
    Tests for L{domish.Element}.
    c�^�ttjtjd��y)zB
        L{domish.Element} implements L{domish.IElement}.
        �N�fooN)rr�IElement�Element��selfs �@/usr/lib/python3/dist-packages/twisted/words/test/test_domish.py�test_interfacezElementTests.test_interfaces��	�V�_�_�f�n�n�]�&C�D�c��d}|jtj|�d�|jtj|d�d�y)zF
        The built-in entity references are properly encoded.
        z&<>'"z&amp;&lt;&gt;'"�z&amp;&lt;&gt;&apos;&quot;N)�assertEqualr�escapeToXml)r�ss  r�
test_escapingzElementTests.test_escapingsC��
������+�+�A�.�0B�C�����+�+�A�q�1�3N�Orc�f�tjd�}|j|jd�y)zN
        An attribute on L{domish.Namespace} yields a qualified name.
        �testns�rrN)r�	Namespacerr)r�nss  r�test_namespacezElementTests.test_namespace#s)���
�
�h�
'��������!2�3rc��tjd�}|j|jd�|j|jd�|j|j
d�|j|jd�tjd�}|j|jd�|j|jd�|j|j
d�|j|jd�tjd�}|j|jd�|j|jd�|j|j
d�|j|jd�tjdd�}|j|jd�|j|jd�|j|j
d�y)	z?
        Basic L{domish.Element} initialization tests.
        r
rN��rr!rr�test2ns)rr
r�name�uri�
defaultUri�parent�r�es  r�test_elementInitzElementTests.test_elementInit*sl��
�N�N�=�)���������'��������%�������t�,�������4�(��N�N�;�'���������'��������#�������r�*�������4�(��N�N�,�-���������'��������)�������x�0�������4�(��N�N�,�i�8���������'��������)�������y�1rc�Z�tjd�}|jd�|jd�}d|d<d|d<|jd�|jd�|jd	�|jd
�|j	|j
dd�|j	|j|�|jjd
�d|jd<|j	|j
d|j�|j	|j
d|j�|j	|dd�|d=|j	|jd�d�|j	|jd�d�|j	|dd�y)z6
        Basic L{domish.Element} child tests.
        r�somecontent)�testns2�bar2�value1�attrib1�value2)r,�attrib2�bar�abc�123����abc123�
subcontent�	somevalue�	bar2valuer�rr1N)	rr
�
addContent�
addElementr�childrenr-r2�hasAttribute)rr(�b2s   r�
test_childOpszElementTests.test_childOpsEsa��
�N�N�,�-��	���]�#�
�\�\�-�
.����)��$,��
 �!�	���U��	���U��	���U��	���U��	
������B���2�	
�������$�	�����,�'�)����{��	
������A�����/�������A�����.�	
����9��x�0�
�i�L�������	�2�A�6�������	�2�A�6�����1�2�H�=rc��tjd�}|jd�t|�}|j	d|�|j|t�y)�6
        Extract character data using L{str}.
        rr+N�rr
r;�strr�assertIsInstance�r�element�texts   r�test_characterDatazElementTests.test_characterDataf�J���.�.�!2�3�����=�)��7�|�������-����d�C�(rc��tjd�}|jd�t|�}|j	d|�|j|t�y)z<
        Extract ascii character data using L{str}.
        rr+NrCrFs   r�test_characterDataNativeStringz+ElementTests.test_characterDataNativeStringqrJrc��tjd�}|jd�t|�}|j	d|�|j|t�y)rBr�☃NrCrFs   r�test_characterDataUnicodez&ElementTests.test_characterDataUnicode|rJrc���tjd�}|jd�t|�}|j	dj�|�|j
|t�y)zA
        Extract character data as UTF-8 using L{bytes}.
        rrNN)rr
r;�bytesr�encoderErFs   r�test_characterDataBytesz$ElementTests.test_characterDataBytes�sS���.�.�!2�3�����=�)��W�~������-�-�/��6����d�E�*rc���tjd�}|jd�|jd�|jd�|j	dt|��y)zV
        Mixing addChild with cdata and element, the first cdata is returned.
        rr3r2�defN)rr
�addChildr<rrD�rrGs  r�test_characterDataMixedz$ElementTests.test_characterDataMixed�sQ���.�.�!2�3����������5�!�����������G��-rc��tjd�}|jd�|jdt	|��y)zT
        Unicode strings passed to C{addContent} become the character data.
        r�unicodeN�rr
r;rrDrWs  r�test_addContentzElementTests.test_addContent�s5���.�.�!2�3�����9�%�����C��L�1rc��tjd�}|jd�|jdt	|��y)zY
        ASCII native strings passed to C{addContent} become the character data.
        r�nativeNr[rWs  r� test_addContentNativeStringASCIIz-ElementTests.test_addContentNativeStringASCII�s5���.�.�!2�3�����8�$�����3�w�<�0rc�p�tjd�}|jt|jd�y)zV
        Byte strings passed to C{addContent} are not acceptable on Python 3.
        rsbytesN)rr
�assertRaises�	TypeErrorr;rWs  r�test_addContentBytesz!ElementTests.test_addContentBytes�s+���.�.�!2�3�����)�W�%7�%7��Brc��tjd�}|jdd��}|jdt	|��y)zW
        Content passed to addElement becomes character data on the new child.
        rr2r3)�contentN)rr
r<rrD)rrG�childs   r�test_addElementContentz#ElementTests.test_addElementContent�s<���.�.�!2�3���"�"�5�%�"�8�������E�
�+rc�x�tjd�}|jd�}|jd�}|jd�}|jd�}t|j	��}|j||�|j||�|j||�|j||�y)z�
        Calling C{elements} without arguments on a L{domish.Element} returns
        all child elements, whatever the qualified name.
        rr#�r,�baz�quux�rr#N)rr
r<�list�elements�assertIn�rr(�c1�c2�c3�c4�eltss       r�
test_elementszElementTests.test_elements�s���

�N�N�,�-��
�\�\�&�
!��
�\�\�,�
-��
�\�\�&�
!��
�\�\�,�
-���A�J�J�L�!���
�
�b�$���
�
�b�$���
�
�b�$���
�
�b�$�rc�|�tjd�}|jd�}|jd�}|jd�}|jd�}t|j	dd��}|j||�|j
||�|j
||�|j||�y)z�
        Calling C{elements} with a namespace and local name on a
        L{domish.Element} returns all child elements with that qualified name.
        rr#rirkrlrN)rr
r<rmrnro�assertNotInrps       r�test_elementsWithQNz ElementTests.test_elementsWithQN�s���

�N�N�,�-��
�\�\�&�
!��
�\�\�,�
-��
�\�\�&�
!��
�\�\�,�
-���A�J�J�x��0�1���
�
�b�$������T�"�����T�"��
�
�b�$�rN)�__name__�
__module__�__qualname__�__doc__rrrr)r@rIrLrOrSrXr\r_rcrgrvry�rrrrs[���E�P�4�2�6>�B	)�	)�	)�	+�.�2�1�C�,� �$ rrc�d�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zy)�DomishStreamTestsMixinz�
    Mixin defining tests for different stream implementations.

    @ivar streamClass: A no-argument callable which will be used to create an
        XML parser which can produce a stream of elements from incremental
        input.
    c��d|_d|_d|_g|_|j	�|_|j|j
_|jj|j
_	|j|j
_y)NF)�doc_started�	doc_ended�rootrn�streamClass�stream�_docStarted�DocumentStartEvent�append�ElementEvent�	_docEnded�DocumentEndEventrs r�setUpzDomishStreamTestsMixin.setUp�sg�� ��������	���
��&�&�(���)-�)9�)9����&�#'�=�=�#7�#7���� �'+�~�~����$rc� �||_d|_y�NT)r�r�)rr�s  rr�z"DomishStreamTestsMixin._docStarted�s����	���rc��d|_yr�)r�rs rr�z DomishStreamTestsMixin._docEnded�s	����rc�:�|jj|�y)N)r��parse�r�xmls  r�doTestzDomishStreamTestsMixin.doTest�s�������#�rc��d}|jj|�|j|jd�|j|jj
d�|j|jdj
d�|j|jdj
d�|j|jd�y)Ns<root><child/><child2/></root>Tr�rrfr�child2)r�r�rr�r�r#rnr�r�s  r�testHarnessz"DomishStreamTestsMixin.testHarness�s���/�������#������)�)�4�0����������0�������q�)�.�.��8�������q�)�.�.��9��������.rc��d}|jj|�|j|jjd�|j|jj
d�|j|jdjd�|j|jdj
d�|j|jddd�|j|jdjj
d	�|jt|jdj�d
�y)Ns�<stream:stream xmlns:stream='etherx' xmlns='jabber'>
  <message to='bar'>    <x xmlns='xdelay'>some&amp;data&gt;</x>  </message></stream:stream>r��etherxr�message�jabber�tor2�xdelayz
some&data>)	r�r�rr�r#r$rn�xrDr�s  r�	testBasicz DomishStreamTestsMixin.testBasics���
"�	�	
�����#�����������2����������1�������q�)�.�.�	�:�������q�)�-�-�x�8�������q�)�$�/��7�������q�)�+�+�/�/��:�����T�]�]�1�-�/�/�0�,�?rc���d}|jj|�|j|jjd�|j|j
djd�y)Ns(<stream><error xmlns='etherx'/></stream>r!rr��r�r�rr�r$rnr�s  r�testNoRootNSz#DomishStreamTestsMixin.testNoRootNSsP��9�������#�����������+�������q�)�-�-�x�8rc�z�d}|jj|�|j|jjd�|j|jj
d�|j|jdjd�|j|jdj
d�y)Ns=<stream:stream xmlns:stream='etherx'><error/></stream:stream>r�r!r)r�r�rr�r$r%rnr�s  r�testNoDefaultNSz&DomishStreamTestsMixin.testNoDefaultNSs���N�������#�����������1�������-�-�r�2�������q�)�-�-�r�2�������q�)�4�4�b�9rc���d}|jj|�|j|jjd�|j|j
djd�y)Ns$<root xmlns='testns'><child/></root>rrr�r�s  r�testChildDefaultNSz)DomishStreamTestsMixin.testChildDefaultNS(sP��5�������#�����������1�������q�)�-�-�x�8rc��d}|jj|�|j|jdjj
d�y)Nsg<root xmlns='testns'>
                    <child1><child2 xmlns=''/></child1>
                  </root>rr!)r�r�rrnr�r$r�s  r�testEmptyChildNSz'DomishStreamTestsMixin.testEmptyChildNS/sB����	
�����#��������q�)�0�0�4�4�b�9rc��d}|jj|�|j|jdjd�y)z�
        Attributes with namespace are parsed without Exception.
        (https://twistedmatrix.com/trac/ticket/9730 regression test)
        s~<root xmlns:test='http://example.org' xml:lang='en'>
                    <test:test>test</test:test>
                  </root>rzhttp://example.orgN)r�r�rrnr$r�s  r�test_attributesWithNamespacesz4DomishStreamTestsMixin.test_attributesWithNamespaces7s=����	
�����#��������q�)�-�-�/C�Drc���d}|jj|�|j|jjdd�|j|j
djd�y)Ns<<root xmlns='testns' xmlns:foo='testns2'><foo:child/></root>rr,r)r�r�rr��
localPrefixesrnr$r�s  r�testChildPrefixz&DomishStreamTestsMixin.testChildPrefixGsW��M�������#��������0�0��7��C�������q�)�-�-�y�9rc�n�|jtj|jjd�y)Ns<root><error></root>)rar�ParserErrorr�r�rs r�testUnclosedElementz*DomishStreamTestsMixin.testUnclosedElementNs(����������� 1� 1�3J�	
rc���d}|jj|�|jd|jdj�|jd|jdj
�|jd|jdj�|jddi|jdj�|jd|jdj�|jd|jdj
�|jd|jdj�|ji|jdj�y	)
at
        Test that reuse of namespaces does affect an element's serialization.

        When one element uses a prefix for a certain namespace, this is
        stored in the C{localPrefixes} attribute of the element. We want
        to make sure that elements created after such use, won't have this
        prefix end up in their C{localPrefixes} attribute, too.
        s�<root>
                    <foo:child1 xmlns:foo='testns'/>
                    <child2 xmlns='testns'/>
                  </root>�child1rrr!rr�rN)r�r�rrnr#r$r%r�r�s  r�test_namespaceReusez*DomishStreamTestsMixin.test_namespaceReuseSs����
	
�����#������4�=�=��#3�#8�#8�9�����4�=�=��#3�#7�#7�8�����T�]�]�1�-�8�8�9����%��*�D�M�M�!�,<�,J�,J�K�����4�=�=��#3�#8�#8�9�����4�=�=��#3�#7�#7�8�����4�=�=��#3�#>�#>�?�����T�]�]�1�-�;�;�<rN)rzr{r|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r~rrr�r��sO���6� ���/�@�$9�:�9�:�E� :�
�
=rr�c�B�eZdZdZej
Zedd���dZyy)�DomishExpatStreamTestszd
    Tests for L{domish.ExpatElementStream}, the expat-based element stream
    implementation.
    �pyexpatN)�defaultz1pyexpat is required for ExpatElementStream tests.)	rzr{r|r}r�ExpatElementStreamr�r�skipr~rrr�r�ms+���
�+�+�K��Y��-�5�B��6rr�c�(�eZdZdZej
Zy)�DomishSuxStreamTestszo
    Tests for L{domish.SuxElementStream}, the L{twisted.web.sux}-based element
    stream implementation.
    N)rzr{r|r}r�SuxElementStreamr�r~rrr�r�ys���
�)�)�Krr�c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�SerializerTestsc��tjd�}|j|j�d�|j|jd��d�y)Nr
z<foo/>r)�closeElementz<foo>�rr
r�toXmlr's  r�testNoNamespacezSerializerTests.testNoNamespace�sA���N�N�=�)���������H�-�������a��0�'�:rc�n�tjd�}|j|j�d�y)Nrz<foo xmlns='testns'/>r�r's  r�testDefaultNamespacez$SerializerTests.testDefaultNamespace�s(���N�N�,�-���������$;�<rc�v�tjdd�}|j|jddi�d�y)Nrr,rr2z-<bar:foo xmlns:bar='testns' xmlns='testns2'/>r�r's  r�testOtherNamespacez"SerializerTests.testOtherNamespace�s5���N�N�,�i�8�����
�G�G�X�u�%�&�(W�	
rc��tjd�}|jd�|j|j	�d�y)Nrr2� <foo xmlns='testns'><bar/></foo>�rr
r<rr�r's  r�testChildDefaultNamespacez)SerializerTests.testChildDefaultNamespace�s4���N�N�,�-��	���U���������$F�Grc��tjd�}|jd�|j|j	�d�y)Nr�rr2r�r�r's  r�testChildSameNamespacez&SerializerTests.testChildSameNamespace�s5���N�N�,�-��	���&�'��������$F�Grc��tjd�}|jdd�|j|j	�d�y)Nrr2rr�r�r's  r�testChildSameDefaultNamespacez-SerializerTests.testChildSameDefaultNamespace�s6���N�N�,�-��	���U�H�%��������$F�Grc��tjd�}|jdd�|j|j	�d�y)Nr�r,r2r,z0<foo xmlns='testns'><bar xmlns='testns2'/></foo>r�r's  r�testChildOtherDefaultNamespacez.SerializerTests.testChildOtherDefaultNamespace�s7���N�N�,�-��	���'��3��������$V�Wrc��tjd�}|jdd�|j|j	�d�y)Nr
)�ns2r2r�z<foo><bar xmlns='ns2'/></foo>r�r's  r�testOnlyChildDefaultNamespacez-SerializerTests.testOnlyChildDefaultNamespace�s5���N�N�=�)��	���^�U�+��������$C�Drc��tjd�}|jd�|j|j	�d�y)Nr
r2z<foo><bar/></foo>r�r's  r�testOnlyChildDefaultNamespace2z.SerializerTests.testOnlyChildDefaultNamespace2�s3���N�N�=�)��	���U���������$7�8rc��tjdd�}|jd�|j|j	�d�y)Nrr,r�z<<xn0:foo xmlns:xn0='testns' xmlns='testns2'><bar/></xn0:foo>r�r's  r�testChildInDefaultNamespacez+SerializerTests.testChildInDefaultNamespace�s:���N�N�,�i�8��	���'�(����
�G�G�I�U�	
rc�v�tjdddi��}|j|j�d�y)Nr
r�rj��attribsz(<foo xmlns:xn0='testns2' xn0:bar='baz'/>r�r's  r�testQualifiedAttributez&SerializerTests.testQualifiedAttribute�s/���N�N�=�3E�u�2M�N���������$N�Orc�v�tjdddi��}|j|j�d�y)Nrr�rjr�z6<foo xmlns='testns' xmlns:xn0='testns' xn0:bar='baz'/>r�r's  r�testQualifiedAttributeDefaultNSz/SerializerTests.testQualifiedAttributeDefaultNS�s3���N�N�,�7H�%�6P�Q�����
�G�G�I�O�	
rc��tjd�}|jdd�}|jd�|jdd�}|jd�|j|j	�d�y)	Nr r�r,)r,rk)�testns3rj�testns4)rrkz�<foo><xn0:bar xmlns:xn0='testns' xmlns='testns2'><quux/></xn0:bar><xn1:baz xmlns:xn1='testns3' xmlns='testns4'><xn0:quux xmlns:xn0='testns'/></xn1:baz></foo>r�)rr(r�r�s    r�
testTwoChildszSerializerTests.testTwoChilds�sm���N�N�;�'�����/��;�����-�.����0�)�<�����,�-����
�G�G�I�
l�	
rc�v�tjdddi��}|j|j�d�y)Nr
)z$http://www.w3.org/XML/1998/namespace�lang�en_USr�z<foo xml:lang='en_US'/>r�r's  r�testXMLNamespacez SerializerTests.testXMLNamespace�s4���N�N��E�w�O�
��	
�������$=�>rc�|�tjdddi��}|j|jddi�d�y)Nr
r�rjr�r,�quxz(<foo xmlns:qux='testns2' qux:bar='baz'/>r�r's  r�)testQualifiedAttributeGivenListOfPrefixesz9SerializerTests.testQualifiedAttributeGivenListOfPrefixes�s:���N�N�=�3E�u�2M�N�����
�G�G�Y��&�'�)S�	
rc��tjdddi��}|jd�}d|d<|j|j	�d�y)Nr
r�rjr��r,r�rkzF<foo xmlns:xn0='testns2' xn0:bar='baz'><xn0:qux xn0:bar='quux'/></foo>r��rr(�cs   r�testNSPrefixzSerializerTests.testNSPrefix�sL���N�N�=�3E�u�2M�N��
�L�L�+�,�� &��
�����
�G�G�I�T�	
rc���tjdddi��}|jd�}d|d<|jd�|j|j	�d�y)	Nr
r�rjr�r�rkrzY<foo xmlns:xn0='testns2' xn0:bar='baz'><xn0:qux xn0:bar='quux'><xn0:foo/></xn0:qux></foo>r�r�s   r�testDefaultNSPrefixz#SerializerTests.testDefaultNSPrefix�sX���N�N�=�3E�u�2M�N��
�L�L�+�,�� &��
��	���U�����
�G�G�I�g�	
rc�z�tjd�}|j|jddidg��d�y)Nrrr2)�prefixes�prefixesInScopez
<bar:foo/>r�r's  r�testPrefixScopezSerializerTests.testPrefixScope�s8���N�N�,�-�����
�G�G�h��.���G�H�,�	
rc�v�tjdddi��}|j|j�d�y)Nrr2r�r�z<bar:foo xmlns:bar='testns'/>r�r's  r�testLocalPrefixesz!SerializerTests.testLocalPrefixes�s/���N�N�,�U�H�<M�N���������$C�Drc���tjdddi��}|jd�|j|jj
d�|j
|j�d�y)Nrr2rr�rjz,<bar:foo xmlns:bar='testns'><baz/></bar:foo>)rr
r<�assertIdenticalrjr%rr�r's  r�testLocalPrefixesWithChildz*SerializerTests.testLocalPrefixesWithChild�sU���N�N�,�U�H�<M�N��	���U�����Q�U�U�-�-�t�4��������$R�Src�T�ddi}tj|��}|j||j�tjdddi��}|jd|j
|���tjd�}|jd	|j
|���y
)aQ
        Test that prefixes passed to serialization are not modified.

        This test makes sure that passing a dictionary of prefixes repeatedly
        to C{toXml} of elements does not cause serialization errors. A
        previous implementation changed the passed in dictionary internally,
        causing havoc later on.
        rr)r�)r,rrkr,r�z <quux:foo xmlns:quux='testns2'/>z<foo xmlns='testns2'/>N)r�SerializerClass�assertNotIdenticalr�r
rr�)rr�rr(s    r�test_prefixesReusez"SerializerTests.test_prefixesReuse�s����e�$��
�"�"�H�5������!�*�*�5�
�N�N�-�f�i�=P�Q�����;�Q�W�W�h�W�=W�X��N�N�-�.�����1�1�7�7�H�7�3M�Nrc��tjd�}|jd�|j|j	�d�y)Nr
z<abc123>z<foo><abc123></foo>�rr
�	addRawXmlrr�r's  r�testRawXMLSerializationz'SerializerTests.testRawXMLSerializations5���N�N�=�)��	���J��	
�������$9�:rc��tjd�}|jd�|j|j	�d�y)Nr
u<degree>°</degree>u<foo><degree>°</degree></foo>rr's  r�"testRawXMLWithUnicodeSerializationz2SerializerTests.testRawXMLWithUnicodeSerializations4���N�N�=�)��	���-�.��������$H�Irc��tjd�}d|d<|jd�|j|j	�d�y)Nr
umy valueȡe�testuA degree symbol...°u2<foo test='my valueȡe'>A degree symbol...°</foo>)rr
r;rr�r's  r�testUnicodeSerializationz(SerializerTests.testUnicodeSerialization!s@���N�N�=�)��%��&�	�	���/�0����
�G�G�I�V�	
rN)rzr{r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
r~rrr�r��s���;�
=�
�H�
H�
H�
X�
E�
9�

�P�
�	
�?�
�
�	
�
�E�T�O�*;�J�

rr�N)r}�zope.interface.verifyr�twisted.python.reflectr�
twisted.trialr�twisted.words.xishr�TestCaserr�r�r�r�r~rr�<module>rsz���
/�0�"�%�M �8�$�$�M �`J=�J=�Z	C�3�X�5F�5F�	C�*�1�8�3D�3D�*�e
�h�'�'�e
r

Zerion Mini Shell 1.0