Ë
    ojmJ  ã                   óÀ  — d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ  G d„ dej                  «      Z G d	„ d
«      Zd„ Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zd„ Z G d„ de«      Z G d„ de«      Z G d„ dej2                  ej4                  «      Z G d„ dej2                  ej4                  «      Z G d„ d e«      Zy)!z/
Test cases for L{jelly} object serialization.
é    N)ÚStringTransport)ÚbananaÚjellyÚpb)Úunittest)ÚTestCasec                   ó   — e Zd ZdZdZdd„Zy)ÚTestNodezD
    An object to test jellyfying of new style class instances.
    é   Nc                 ó’   — |r0|j                   dz   | _         |j                  j                  | «       nd| _         || _        g | _        y )Né   )ÚidÚchildrenÚappendÚparent)Úselfr   s     ú@/usr/lib/python3/dist-packages/twisted/spread/test/test_jelly.pyÚ__init__zTestNode.__init__   s;   € ÙØ—i‘i !‘mˆDŒGØ�O‰O×"Ñ" 4Õ(àˆDŒGØˆŒØˆ�ó    ©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	classAttrr   © r   r   r
   r
      s   „ ñð €Iôr   r
   c                   ó   — e Zd ZdZd„ Zy)ÚAú
    Dummy class.
    c                  ó   — y©z;
        Method to be used in serialization tests.
        Nr   ©r   s    r   Úamethodz	A.amethod(   ó   � r   N)r   r   r   r   r#   r   r   r   r   r   #   ó   „ ñór   r   c                  ó   — y)z:
    A dummy function to test function serialization.
    Nr   r"   s    r   Úafuncr'   .   r$   r   c                   ó   — e Zd ZdZd„ Zy)ÚBr   c                  ó   — yr!   r   r"   s    r   Úbmethodz	B.bmethod9   r$   r   N)r   r   r   r   r+   r   r   r   r)   r)   4   r%   r   r)   c                   ó   — e Zd ZdZd„ Zy)ÚCr   c                  ó   — yr!   r   r"   s    r   Úcmethodz	C.cmethodD   r$   r   N)r   r   r   r   r/   r   r   r   r-   r-   ?   r%   r   r-   c                   ó   — e Zd ZdZy)ÚDz 
    Dummy new-style class.
    N)r   r   r   r   r   r   r   r1   r1   J   s   „ òr   r1   c                   ó(   — e Zd ZdZdZdd„Zd„ Zd„ Zy)ÚEz+
    Dummy new-style class with slots.
    ©ÚxÚyNc                 ó    — || _         || _        y r   r4   ©r   r5   r6   s      r   r   z
E.__init__W   ó   € ØˆŒØˆ�r   c                 ó4   — | j                   | j                  dœS )Nr4   r4   r"   s    r   Ú__getstate__zE.__getstate__[   s   € Ø—V‘V $§&¡&Ñ)Ð)r   c                 ó,   — |d   | _         |d   | _        y )Nr5   r6   r4   ©r   Ústates     r   Ú__setstate__zE.__setstate__^   s   € Ø�s‘ˆŒØ�s‘ˆ�r   )NN)r   r   r   r   Ú	__slots__r   r;   r?   r   r   r   r3   r3   P   s   „ ñð €Ióò*ór   r3   c                   ó   — e Zd Zd„ Zd„ Zy)ÚSimpleJellyTestc                 ó    — || _         || _        y r   r4   r8   s      r   r   zSimpleJellyTest.__init__d   r9   r   c                 ó4   — | j                   |j                   k(  S r   )Ú__dict__©r   Úothers     r   ÚisTheSameAszSimpleJellyTest.isTheSameAsh   s   € Ø�}‰} §¡Ñ.Ð.r   N)r   r   r   r   rH   r   r   r   rB   rB   c   s   „ òó/r   rB   c                 óÐ   — t        j                   |«      }t        j                  |«      }t        j                  |«      }t        j                  |«      }| j                  ||«       y)zt
    Verify that the given object round-trips through jelly & banana and comes
    out equivalent to the input.
    N)r   r   ÚencodeÚdecodeÚunjellyÚassertEqual)ÚtestCaseÚtoSerializeÚjelliedÚencodedÚdecodedÚ	unjellieds         r   ÚjellyRoundTriprT   l   sL   € ô
 �k‰k˜+Ó&€GÜ�m‰m˜GÓ$€GÜ�m‰m˜GÓ$€GÜ—‘˜gÓ&€IØ×Ñ˜ iÕ0r   c                   óâ   — e Zd ZdZdg d¢g d¢g d¢g d¢gZd„ Zd„ Zd	„ Zd
„ Zd„ Z	d„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd „ Zd!„ Zd"„ Z d#„ Z!d$„ Z"y%)&Ú
JellyTestsz¦
    Testcases for L{jelly} module serialization.

    @cvar decimalData: serialized version of decimal data, to be used in tests.
    @type decimalData: L{list}
    s   list)ó   decimaliã  éþÿÿÿ)rW   r   r   )rW   é@â r   )rW   iËËþÿéýÿÿÿc                 ó8  — t        j                   |«      }t        j                  «       }|j                  «        t        j                  ||«       |j                  j                  |«       | j                  t         j                  t         j                  ||«       y)zñ
        Helper test method to test security options for a type.

        @param inputList: a sample input for the type.
        @type inputList: L{list}

        @param atom: atom identifier for the type.
        @type atom: L{str}
        N)r   ÚSecurityOptionsÚallowBasicTypesrL   ÚallowedTypesÚpopÚassertRaisesÚInsecureJelly)r   Ú	inputListÚatomÚcÚtasters        r   Ú_testSecurityzJellyTests._testSecurityˆ   sl   € ô �K‰K˜	Ó"ˆÜ×&Ñ&Ó(ˆØ×ÑÔ ä�‰�a˜Ô Ø×Ñ×Ñ Ô%à×Ñœ%×-Ñ-¬u¯}©}¸aÀÕHr   c                 óD  — t        «       }t        «       }t        «       }|j                  |_        ||_        t        j                  }t        `	 | j                  t        t        j                  t        j                  |«      «       |t        _        y# |t        _        w xY w)z 
        If a class change after an instance has been created, L{jelly.unjelly}
        shoud raise a C{TypeError} when trying to unjelly the instance.
        N)
r   r)   r-   r/   r+   Úar`   Ú	TypeErrorr   rL   )r   rh   Úbrd   Úsavecmethods        r   Útest_methodsNotSelfIdentityz&JellyTests.test_methodsNotSelfIdentity›   sk   € ô
 ‹CˆÜ‹CˆÜ‹CˆØ—I‘IˆŒ	ØˆŒÜ—i‘iˆÜˆIð	$Ø×Ñœi¬¯©¼¿¹ÀA»ÔGà#ŒA�Iø˜ŒA�Iús   Á8B ÂBc                 óZ  — t        «       }d|_        t        «       }||_        ||_        t	        j                  |«      }t	        j
                  |«      }| j                  |t         «       | j                  |j                  |j                  «       | j                  |j                  d«       y)zƒ
        Test that a new style class can be jellied and unjellied with its
        objects and attribute values preserved.
        r   N)	r1   r5   Ún2Ún3r   rL   ÚassertIsInstanceÚassertIsrM   )r   Únrn   rd   Úms        r   Útest_newStylezJellyTests.test_newStyle¬   s|   € ô
 ‹CˆØˆŒÜ‹SˆØˆŒØˆŒÜ�K‰K˜‹NˆÜ�M‰M˜!ÓˆØ×Ñ˜a¤Ô#Ø�‰�a—d‘d˜AŸD™DÔ!Ø×Ñ˜Ÿ™˜aÕ r   c                 óÞ   — t        «       }d|_        t        j                  |«      }t        j                  |«      }| j	                  |t         «       | j                  |j                  d«       y)z‚
        A class defined with I{slots} can be jellied and unjellied with the
        values for its attributes preserved.
        r   N)r3   r5   r   rL   rp   rM   )r   rr   rd   rs   s       r   Útest_newStyleWithSlotsz!JellyTests.test_newStyleWithSlots¼   sQ   € ô
 ‹CˆØˆŒÜ�K‰K˜‹NˆÜ�M‰M˜!ÓˆØ×Ñ˜a¤Ô#Ø×Ñ˜Ÿ™˜aÕ r   c                 ó†   — t         g}t        j                  t        j                  |«      «      }| j                  ||«       y)zm
        Test that a new style class type can be jellied and unjellied
        to the original type.
        N)r1   r   rL   rM   ©r   ÚtÚrs      r   Útest_typeNewStylezJellyTests.test_typeNewStyleÈ   s1   € ô
 ˆCˆÜ�M‰Mœ%Ÿ+™+ a›.Ó)ˆØ×Ñ˜˜AÕr   c                 ó†   — t         g}t        j                  t        j                  |«      «      }| j                  ||«       y)ze
        Test that a builtin type can be jellied and unjellied to the original
        type.
        N)Ústrr   rL   rM   rx   s      r   Útest_typeBuiltinzJellyTests.test_typeBuiltinÑ   s1   € ô
 ˆEˆÜ�M‰Mœ%Ÿ+™+ a›.Ó)ˆØ×Ñ˜˜AÕr   c                 ó&  — t         j                   j                  «       }t         j                   j                  «       |z
  }||g}t        j                  |«      }t        j                  |«      }| j	                  ||«       | j                  ||«       y)z³
        Jellying L{datetime.timedelta} instances and then unjellying the result
        should produce objects which represent the values of the original
        inputs.
        N)ÚdatetimeÚnowr   rL   rM   ÚassertIsNot)r   ÚdtnÚdtdrb   rd   Úoutputs         r   Útest_dateTimezJellyTests.test_dateTimeÚ   sv   € ô ×Ñ×#Ñ#Ó%ˆÜ×Ñ×#Ñ#Ó%¨Ñ+ˆØ˜#�Jˆ	Ü�K‰K˜	Ó"ˆÜ—‘˜qÓ!ˆØ×Ñ˜ FÔ+Ø×Ñ˜ FÕ+r   c                 ó6  — t        j                  ddd«      }t        j                  dddd«      }t         j                   j                  ||«      }|t        j                   ddd«      z
  }t	        | |«       t	        | |«       t	        | |«       t	        | |«       y	)
zÝ
        Jellying L{datetime.time}, L{datetime.timedelta}, L{datetime.datetime},
        and L{datetime.date} objects should result in jellied objects which can
        be serialized and unserialized with banana.
        iä  é   é   r   é   é   iX  é   N)r€   ÚdateÚtimeÚcombinerT   )r   Ú
sampleDateÚ
sampleTimeÚsampleDateTimeÚsampleTimeDeltas        r   Útest_bananaTimeTypeszJellyTests.test_bananaTimeTypesè   sƒ   € ô —]‘] 4¨¨BÓ/ˆ
Ü—]‘] 1 b¨!¨SÓ1ˆ
Ü!×*Ñ*×2Ñ2°:¸zÓJˆØ(¬8×+<Ñ+<¸TÀ1ÀaÓ+HÑHˆÜ�t˜ZÔ(Ü�t˜ZÔ(Ü�t˜^Ô,Ü�t˜_Õ-r   c                 óD  — t        j                  d«      t        j                  d«      t        j                  d«      t        j                  d«      g}t        j                  |«      }t        j                  |«      }| j	                  ||«       | j                  ||«       y)z°
        Jellying L{decimal.Decimal} instances and then unjellying the result
        should produce objects which represent the values of the original
        inputs.
        ú9.95r   rY   ú-78.901N)ÚdecimalÚDecimalr   rL   rM   r‚   )r   rb   rd   r…   s       r   Útest_decimalzJellyTests.test_decimal÷   sy   € ô �O‰O˜FÓ#Ü�O‰O˜AÓÜ�O‰O˜FÓ#Ü�O‰O˜IÓ&ð	
ˆ	ô �K‰K˜	Ó"ˆÜ—‘˜qÓ!ˆØ×Ñ˜ FÔ+Ø×Ñ˜ FÕ+r   c                 ó
  — t        j                  d«      t        j                  d«      t        j                  d«      t        j                  d«      g}t        j                  | j                  «      }| j                  ||«       y)a  
        Unjellying the s-expressions produced by jelly for L{decimal.Decimal}
        instances should result in L{decimal.Decimal} instances with the values
        represented by the s-expressions.

        This test also verifies that L{decimalData} contains valid jellied
        data.  This is important since L{test_decimalMissing} re-uses
        L{decimalData} and is expected to be unable to produce
        L{decimal.Decimal} instances even though the s-expression correctly
        represents a list of them.
        r–   r   rY   r—   N)r˜   r™   r   rL   ÚdecimalDatarM   )r   Úexpectedr…   s      r   Útest_decimalUnjellyzJellyTests.test_decimalUnjelly  sa   € ô �O‰O˜FÓ#Ü�O‰O˜AÓÜ�O‰O˜FÓ#Ü�O‰O˜IÓ&ð	
ˆô —‘˜t×/Ñ/Ó0ˆØ×Ñ˜ Õ*r   c                 óT   — t        j                  d«      g}| j                  |d«       y)zÏ
        By default, C{decimal} objects should be allowed by
        L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise
        L{jelly.InsecureJelly} when trying to unjelly it.
        r–   rW   N)r˜   r™   rf   ©r   rb   s     r   Útest_decimalSecurityzJellyTests.test_decimalSecurity  s%   € ô —_‘_ VÓ,Ð-ˆ	Ø×Ñ˜9 jÕ1r   c                 ó¦   — h d£g}t        j                  t        j                   |«      «      }| j                  ||«       | j                  ||«       y)z¤
        Jellying C{set} instances and then unjellying the result
        should produce objects which represent the values of the original
        inputs.
        ¾   r   é   rŒ   N)r   rL   rM   r‚   ©r   rb   r…   s      r   Útest_setzJellyTests.test_set&  sB   € ò �Kˆ	Ü—‘œuŸ{™{¨9Ó5Ó6ˆØ×Ñ˜ FÔ+Ø×Ñ˜ FÕ+r   c                 ó¸   — t        g d¢«      g}t        j                  t        j                  |«      «      }| j                  ||«       | j	                  ||«       y)zª
        Jellying L{frozenset} instances and then unjellying the result
        should produce objects which represent the values of the original
        inputs.
        ©r   r¤   rŒ   N)Ú	frozensetr   rL   rM   r‚   r¥   s      r   Útest_frozensetzJellyTests.test_frozenset1  sH   € ô šyÓ)Ð*ˆ	Ü—‘œuŸ{™{¨9Ó5Ó6ˆØ×Ñ˜ FÔ+Ø×Ñ˜ FÕ+r   c                 ó2   — h d£g}| j                  |d«       y)zË
        By default, C{set} objects should be allowed by
        L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise
        L{jelly.InsecureJelly} when trying to unjelly it.
        r£   s   setN)rf   r    s     r   Útest_setSecurityzJellyTests.test_setSecurity<  s   € ò �Kˆ	Ø×Ñ˜9 fÕ-r   c                 óD   — t        g d¢«      g}| j                  |d«       y)zÑ
        By default, L{frozenset} objects should be allowed by
        L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise
        L{jelly.InsecureJelly} when trying to unjelly it.
        r¨   s	   frozensetN)r©   rf   r    s     r   Útest_frozensetSecurityz!JellyTests.test_frozensetSecurityE  s!   € ô šyÓ)Ð*ˆ	Ø×Ñ˜9 lÕ3r   c                 ó  — | j                  t        dd«      j                  t        dd«      «      «       t        dd«      }t        j                  |«      }t        j                  |«      }| j                  |j                  |«      «       y)z%
        Simplest test case.
        rh   rj   r   r¤   N)Ú
assertTruerB   rH   r   rL   )r   rh   Úcerealrj   s       r   Útest_simplezJellyTests.test_simpleN  sj   € ð 	�‰Ü˜C Ó%×1Ñ1´/À#ÀsÓ2KÓLô	
ô ˜A˜qÓ!ˆÜ—‘˜Q“ˆÜ�M‰M˜&Ó!ˆØ�‰˜Ÿ™ aÓ(Õ)r   c                 ód  — g }|}|j                  |«       |j                  |«       | j                  |d   |d   «       | j                  |d   d   |«       t        j                  |«      }t        j                  |«      }| j                  |d   |d   «       | j                  |d   d   |«       y)zJ
        Test to make sure that objects retain identity properly.
        r   r   N)r   rq   r   rL   )r   r5   r6   ÚsÚzs        r   Útest_identityzJellyTests.test_identityZ  s—   € ð ˆØˆØ	�‰�ŒØ	�‰�ŒØ�‰�a˜‘d˜A˜a™DÔ!Ø�‰�a˜‘d˜1‘g˜qÔ!Ü�K‰K˜‹NˆÜ�M‰M˜!ÓˆØ�‰�a˜‘d˜A˜a™DÔ!Ø�‰�a˜‘d˜1‘g˜qÕ!r   c                 óÄ   — d}t        j                  t        j                   |«      «      }| j                  ||«       | j                  t        |«      t        |«      «       y )NÚblah)r   rL   rM   Útyper8   s      r   Útest_strzJellyTests.test_stri  sE   € ØˆÜ�M‰Mœ%Ÿ+™+ a›.Ó)ˆØ×Ñ˜˜AÔØ×Ñœ˜a›¤$ q£'Õ*r   c                 óö   — g }d|i|f}|j                  |«       t        j                  |«      }t        j                  |«      }| j                  |d   d   |d   «       | j                  |d   d   d   |«       y )NÚlistr   r   ©r   r   rL   rq   )r   ÚrerefÚtoplevelTupler´   rµ   s        r   Útest_stressReferencesz JellyTests.test_stressReferenceso  sq   € ØˆØ  %˜¨%Ð0ˆØ�‰�]Ô#Ü�K‰K˜Ó&ˆÜ�M‰M˜!ÓˆØ�‰�a˜‘d˜6‘l A a¡DÔ)Ø�‰�a˜‘d˜6‘l 1‘o qÕ)r   c                 ó¼   — g }|f}|j                  |f«       t        j                  |«      }t        j                  |«      }| j                  |d   d   d   |«       y ©Nr   r½   )r   rh   ry   r´   rµ   s        r   Útest_moreReferenceszJellyTests.test_moreReferencesx  sP   € ØˆØˆDˆØ	�‰�!�ŒÜ�K‰K˜‹NˆÜ�M‰M˜!ÓˆØ�‰�a˜‘d˜1‘g˜a‘j !Õ$r   c                 ó¶   — t        j                  «       }t        j                   i «      }| j                  t         j                  t         j                  ||«       y)z@
        Test for type-level security of serialization.
        N)r   r\   r`   ra   rL   )r   re   Údcts      r   Útest_typeSecurityzJellyTests.test_typeSecurity€  s=   € ô ×&Ñ&Ó(ˆÜ�k‰k˜"‹oˆØ×Ñœ%×-Ñ-¬u¯}©}¸cÀ6ÕJr   c                 ób   — t        j                  t        «      }| j                  t        |«       y r   )r   rL   r1   rq   )r   Úujs     r   Útest_newStyleClasseszJellyTests.test_newStyleClassesˆ  s   € Ü�]‰]œ1ÓˆØ�‰”a˜Õr   c                 óÈ  — t        «       }t        j                  t        j                  |«      «       t        j                  t        j                  |j                  «      «       t        g d¢t        d«       t        d«      ddddt         t        ddit         j                  g}|D ]:  }| j                  |t        j                  t        j                  |«      «      «       Œ< y)zA
        Test for all types currently supported in jelly
        r¨   r   ÚtestgÍÌÌÌÌL4@Nrh   )r   r   rL   r#   r'   Úboolr   rM   )r   rh   ÚitemsÚis       r   Útest_lotsaTypeszJellyTests.test_lotsaTypesŒ  s§   € ô ‹CˆÜ�‰”e—k‘k !“nÔ%Ü�‰”e—k‘k !§)¡)Ó,Ô-äÚÜ�Q“ˆKÜ�‹GØØØØÜÜØ�!ˆHÜ�I‰Ið
ˆð ò 	?ˆAØ×Ñ˜Q¤§¡¬e¯k©k¸!«nÓ =Õ>ñ	?r   c                 ó\  —  G d„ d«      a t        «       }t        |«      }t        |«      }t        ||f«      }||||||d|i}t        j                  t        j                  |«      «      d   }| j	                  |j
                  d   j
                  |j
                  d   j
                  «       y )Nc                   ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)Ú
TupleStatec                 ó   — || _         y r   ©rG   rF   s     r   r   zTupleState.__init__¨  s	   € Ø"�•
r   c                 ó   — | j                   fS r   rÔ   r"   s    r   r;   zTupleState.__getstate__«  s   € ØŸ
™
�}Ð$r   c                 ó   — |d   | _         y rÂ   rÔ   r=   s     r   r?   zTupleState.__setstate__®  s   € Ø" 1™X�•
r   c                 ó,   — t        | j                  «      S r   )ÚhashrG   r"   s    r   Ú__hash__zTupleState.__hash__±  s   € Ü˜DŸJ™JÓ'Ð'r   N)r   r   r   r   r;   r?   rÙ   r   r   r   rÒ   rÒ   §  s   „ ò#ò%ò&ó(r   rÒ   Út3r   r   )rÒ   r   r   rL   rq   rG   )r   rh   Út1Út2rÚ   ÚdÚt3primes          r   Útest_setStatezJellyTests.test_setState¤  s’   € ÷	(ñ 	(ô ‹CˆÜ˜‹]ˆÜ˜‹]ˆÜ˜˜R˜Ó!ˆØ��R˜˜R  T¨2Ð.ˆÜ—-‘-¤§¡¨A£Ó/°Ñ5ˆØ�‰�g—m‘m AÑ&×,Ñ,¨g¯m©m¸AÑ.>×.DÑ.DÕEr   c                 óì  — t        j                  «       }|j                  t        t        «       t        «       }t	        «       }t        «       }||_        ||_        ||_        ||_        t        j                   ||«      }t        j                  ||«      }| j                  |j                  t         j                  «       t        j                   |«      }| j                  t         j                  t         j                  ||«       | j                  |j                  |j                  d«       t        j                   t        |«      }t        j                  ||«      }| j                  |t        d|z  «       y)zA
        Test for class-level security of serialization.
        zIdentity mismatchzA came back: %sN)r   r\   ÚallowInstancesOfr   r)   r-   rj   rd   r5   rL   rp   ÚUnpersistabler`   ra   rq   )r   re   rh   rj   rd   Úfriendlyr5   Úmeans           r   Útest_classSecurityzJellyTests.test_classSecurity¼  s  € ô ×&Ñ&Ó(ˆØ×Ñ¤¤1Ô%Ü‹CˆÜ‹CˆÜ‹CˆàˆŒØˆŒàˆŒØˆŒä—;‘;˜q &Ó)ˆÜ�M‰M˜( FÓ+ˆØ×Ñ˜aŸc™c¤5×#6Ñ#6Ô7ä�{‰{˜1‹~ˆØ×Ñœ%×-Ñ-¬u¯}©}¸dÀFÔKØ�‰�a—c‘c˜1Ÿ3™3Ð 3Ô4ä—;‘;œq &Ó)ˆÜ�M‰M˜( FÓ+ˆØ�‰�aœÐ-°Ñ1Õ2r   c                 ób  —  G d„ dt         j                  «      }t        j                  |t         j                  «        |«       }d|_        t        j
                  t        j                   |«      «      }| j                  |j                  d«       | j                  |t         j                  «       y)zr
        Test that if Unjellyable is used to deserialize a jellied object,
        state comes out right.
        c                   ó   — e Zd Zy)ú7JellyTests.test_unjellyable.<locals>.JellyableTestClassN©r   r   r   r   r   r   ÚJellyableTestClassrè   Þ  ó   „ Ør   rê   ÚvalueN)r   Ú	JellyableÚsetUnjellyableForClassÚUnjellyableÚ	attributerL   rM   rp   )r   rê   Úinputr…   s       r   Útest_unjellyablezJellyTests.test_unjellyableØ  s}   € ô	¤§¡ô 	ô 	×$Ñ$Ð%7¼×9JÑ9JÔKÙ"Ó$ˆØ!ˆŒÜ—‘œuŸ{™{¨5Ó1Ó2ˆØ×Ñ˜×)Ñ)¨7Ô3Ø×Ñ˜f¤e×&7Ñ&7Õ8r   c                 óÆ  — i dg}|fd„}|fd„}t        dd«      }t        dd«      }t        dd«      }||_        ||_        ||_        t        j                  ||¬	«      }t        j                  ||¬
«      }| j                  |j                  |j                  j                  «       | j                  |d   d«       | j                  |j                  |j                  d«       y )Nr   c                 óJ   — |d   dz   |d<   | |d   |d   <   t        |d   «      S )Nr   r   )r}   )ÚobjÚjelÚpersts      r   ÚpersistentStorez:JellyTests.test_persistentStorage.<locals>.persistentStoreë  s3   € Ø˜Q‘x !‘|ˆE�!‰HØ!$ˆE�!‰H�U˜1‘XÑÜ�u˜Q‘x“=Ð r   c                 ó(   — t        | «      }|d   |   S rÂ   )Úint)ÚpidstrÚunjr÷   Úpids       r   ÚpersistentLoadz9JellyTests.test_persistentStorage.<locals>.persistentLoadð  s   € Ü�f“+ˆCØ˜‘8˜C‘=Ð r   r¤   rŒ   r   r‹   é   )rø   )rþ   r   zpersistentStore was not called.z$Persistent storage identity failure.)rB   rj   rd   r   rL   rq   r°   )	r   r÷   rø   rþ   rh   rj   rd   rö   r5   s	            r   Útest_persistentStoragez!JellyTests.test_persistentStorageè  s¾   € Ø�Q�ˆà,1ó 	!ð
 /4ó 	!ô ˜A˜qÓ!ˆÜ˜A˜qÓ!ˆÜ˜A˜qÓ!ˆàˆŒØˆŒØˆŒä�k‰k˜!¨_Ô=ˆÜ�M‰M˜#¨nÔ=ˆà�‰�a—c‘c˜1Ÿ3™3Ÿ5™5Ô!Ø�‰˜˜a™Ð"CÔDØ�‰�a—c‘c˜1Ÿ3™3Ð FÕGr   c                 óÒ   — t        «       }t        |«      }t        |«       t        |«       t        j                  |«      }t        j                  |«      }| j                  ||«       y r   )r
   r   rL   Ú_check_newstyle)r   rr   Ún1rö   rs   s        r   Útest_newStyleClassesAttributesz)JellyTests.test_newStyleClassesAttributes  sK   € Ü‹JˆÜ�a‹[ˆÜ�ŒÜ�Œä�k‰k˜!‹nˆÜ�M‰M˜#Óˆà×Ñ˜Q Õ"r   c                 ó¤  — | j                  |j                  |j                  «       | j                  |j                  d«       | j                  |j                  d«       | j                  t        |j                  «      t        |j                  «      «       t        |j                  |j                  «      D ]  \  }}| j                  ||«       Œ y )Nr   )rM   r   r   Úlenr   Úzipr  )r   rh   rj   r5   r6   s        r   r  zJellyTests._check_newstyle  s”   € Ø×Ñ˜Ÿ™˜qŸt™tÔ$Ø×Ñ˜Ÿ™ aÔ(Ø×Ñ˜Ÿ™ aÔ(Ø×Ñœ˜QŸZ™Z›¬#¨a¯j©j«/Ô:Ü˜Ÿ
™
 A§J¡JÓ/ò 	'‰DˆAˆqØ× Ñ   AÕ&ñ	'r   c                 óˆ  — t        j                  «       }t        j                  «       }|j                  t	        «       «       t        j
                  ||¬«      }t        j                  «       }|j                  t	        «       «       t        j                  ||¬«      }| j                  |j                  |j                  «       y)a  
        A L{pb.Referenceable} instance jellies to a structure which unjellies to
        a L{pb.RemoteReference}.  The C{RemoteReference} has a I{luid} that
        matches up with the local object key in the L{pb.Broker} which sent the
        L{Referenceable}.
        ©ÚinvokerN)
r   ÚReferenceableÚBrokerÚmakeConnectionr   r   rL   ÚassertInÚluidÚlocalObjects)r   ÚrefÚjellyBrokerÚjÚunjellyBrokerrÈ   s         r   Útest_referenceablezJellyTests.test_referenceable  s‚   € ô ×ÑÓ ˆÜ—i‘i“kˆØ×"Ñ"¤?Ó#4Ô5Ü�K‰K˜ [Ô1ˆäŸ	™	›ˆØ×$Ñ$¤_Ó%6Ô7ä�]‰]˜1 mÔ4ˆØ�‰�b—g‘g˜{×7Ñ7Õ8r   N)#r   r   r   r   rœ   rf   rl   rt   rv   r{   r~   r†   r”   rš   rž   r¡   r¦   rª   r¬   r®   r²   r¶   rº   rÀ   rÃ   rÆ   rÉ   rÏ   rß   rå   rò   r   r  r  r  r   r   r   rV   rV   x   s¹   „ ñð 	ÚÚÚÚ ð€KòIò&$ò"!ò 
!òòò,ò.ò,ò"+ò*2ò	,ò	,ò.ò4ò
*ò"ò+ò*ò%òKòò?ò0Fò03ò89ò Hò6	#ò'ó9r   rV   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚJellyDeprecationTestsz+
    Tests for deprecated Jelly things
    c                 óú   — t         j                   | j                  | j                  g«      }| j	                  t        |«      d«       | j	                  |d   d   d«       | j	                  |d   d   t        «       y)zD
        L{jelly.instance_atom} is deprecated since 15.0.0.
        r   r   Úmessagezltwisted.spread.jelly.instance_atom was deprecated in Twisted 15.0.0: instance_atom is unused within Twisted.ÚcategoryN)r   Úinstance_atomÚflushWarningsÚtest_deprecatedInstanceAtomrM   r  ÚDeprecationWarning©r   Úwarningss     r   r  z1JellyDeprecationTests.test_deprecatedInstanceAtom.  su   € ô 	×ÒØ×%Ñ% t×'GÑ'GÐ&HÓIˆØ×Ñœ˜X›¨Ô*Ø×ÑØ�Q‰K˜	Ñ"ð>ô	
ð
 	×Ñ˜ !™ ZÑ0Ô2DÕEr   c                 óø   — t        j                  dddgdgg«       | j                  «       }| j                  t	        |«      d«       | j                  |d   d   d«       | j                  |d   d	   t
        «       y
)zI
        Unjellying the instance atom is deprecated with 15.0.0.
        ÚinstanceÚclassz twisted.spread.test.test_jelly.AÚ
dictionaryr   r   r  ztUnjelly support for the instance atom is deprecated since Twisted 15.0.0.  Upgrade peer for modern instance support.r  N)r   rL   r  rM   r  r  r  s     r   Ú%test_deprecatedUnjellyingInstanceAtomz;JellyDeprecationTests.test_deprecatedUnjellyingInstanceAtom<  s‚   € ô 	�‰Ø˜'Ð#EÐFÈÈÐWô	
ð ×%Ñ%Ó'ˆØ×Ñœ˜X›¨Ô*Ø×ÑØ�Q‰K˜	Ñ"ðIô	
ð
 	×Ñ˜ !™ ZÑ0Ô2DÕEr   N)r   r   r   r   r  r%  r   r   r   r  r  )  s   „ ñòFóFr   r  c                   ó   — e Zd Zd„ Zy)ÚClassAc                 ó$   — t        | «      | _        y r   )ÚClassBr  r"   s    r   r   zClassA.__init__N  s   € Ü˜$“<ˆ�r   N©r   r   r   r   r   r   r   r'  r'  M  s   „ ó r   r'  c                   ó   — e Zd Zd„ Zy)r)  c                 ó   — || _         y r   )r  )r   r  s     r   r   zClassB.__init__S  s	   € Øˆ�r   Nr*  r   r   r   r)  r)  R  s   „ ór   r)  c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚCircularReferenceTestszN
    Tests for circular references handling in the jelly/unjelly process.
    c                 ó*  — t        j                  t        t        «       t        j                  t        t        «       t        j                  t        j                   t        «       «      «      }| j                  |j                  j                  |d«       y )Nú,Identity not preserved in circular reference)r   rî   r'  r)  rL   rq   r  )r   rh   s     r   Útest_simpleCirclez(CircularReferenceTests.test_simpleCircle\  sT   € Ü×$Ñ$¤V¬VÔ4Ü×$Ñ$¤V¬VÔ4Ü�M‰Mœ%Ÿ+™+¤f£hÓ/Ó0ˆØ�‰�a—e‘e—i‘i Ð$RÕSr   c                 óf  —  G d„ d«      } |«       }d |_         t        «       }t        j                  t        t        «       t        j                  t        t        «       t        j                  ||¬«      }t        j
                  |«      }| j                  |j                  j                  |d«       y )Nc                   ó   — e Zd Zy)úHCircularReferenceTests.test_circleWithInvoker.<locals>.DummyInvokerClassNré   r   r   r   ÚDummyInvokerClassr4  c  rë   r   r5  r	  r0  )ÚserializingPerspectiver'  r   rî   r)  rL   ÚfailUnlessIdenticalr  )r   r5  ÚdummyInvokerÚa0r  Úa1s         r   Útest_circleWithInvokerz-CircularReferenceTests.test_circleWithInvokerb  s�   € ÷	ñ 	ñ )Ó*ˆØ.2ˆÔ+Ü‹XˆÜ×$Ñ$¤V¬VÔ4Ü×$Ñ$¤V¬VÔ4Ü�K‰K˜ LÔ1ˆÜ�]‰]˜1ÓˆØ× Ñ Ø�F‰F�J‰J˜ÐJõ	
r   c                 ó.  — t        «       }t        |d«      }|j                  |«       t        j                  t        j                  |«      «      }| j                  |j                  t         «       | j                  t        |j                  «      |g«       y)z�
        Check that a C{set} can contain a circular reference and be serialized
        and unserialized without losing the reference.
        N)	ÚsetrB   Úaddr   rL   rp   r5   rM   r¼   )r   r´   rh   Úress       r   r¦   zCircularReferenceTests.test_setq  sf   € ô
 ‹EˆÜ˜A˜tÓ$ˆØ	�‰ˆaŒÜ�m‰mœEŸK™K¨›NÓ+ˆØ×Ñ˜cŸe™e¤SÔ)Ø×Ñœ˜cŸe™e› s eÕ,r   c                 ó  — t        dd«      }t        |g«      }||_        t        j                  t        j                  |«      «      }| j                  |j                  t        «       | j                  t        |j                  «      |g«       y)z•
        Check that a L{frozenset} can contain a circular reference and be
        serialized and unserialized without losing the reference.
        N)rB   r©   r5   r   rL   rp   rM   r¼   )r   rh   r´   r?  s       r   rª   z%CircularReferenceTests.test_frozenset}  sf   € ô
 ˜D $Ó'ˆÜ�q�c‹NˆØˆŒÜ�m‰mœEŸK™K¨›NÓ+ˆØ×Ñ˜cŸe™e¤YÔ/Ø×Ñœ˜cŸe™e› s eÕ,r   N)r   r   r   r   r1  r;  r¦   rª   r   r   r   r.  r.  W  s   „ ñòTò
ò
-ó
-r   r.  )r   r€   r˜   Útwisted.internet.testingr   Útwisted.spreadr   r   r   Útwisted.trialr   Útwisted.trial.unittestr   rí   r
   r   r'   r)   r-   r1   r3   rB   rT   rV   r  ÚCopyableÚ
RemoteCopyr'  r)  r.  r   r   r   ú<module>rG     sÍ   ðñó
 Û å 4ß ,Ñ ,Ý "Ý +ôˆu�‰ô ÷"ñ ò÷ñ ÷ñ ÷ñ ÷ñ ÷&/ñ /ò	1ôn9�ô n9ôb!F˜Hô !FôH ˆR�[‰[˜"Ÿ-™-ô  ô
ˆR�[‰[˜"Ÿ-™-ô ô
0-˜Xõ 0-r   