Ë
    ojê  ã                   ó¾   — d Z ddlZddlZddlmZmZ ddlmZ  G d„ d«      Z G d„ d«      Z	dd	„Z
d
„ Z G d„ dej                  «      Z G d„ dej                  «      Zy)z(
Tests for L{twisted.persisted.styles}.
é    N)Ú_UniversalPicklingErrorÚunpickleMethod)Úunittestc                   ó   — e Zd ZdZdd„Zd„ Zy)ÚFooú
    Helper class.
    Nc                 ó   — d| _         y )Nú
test-value©Úinstance_member©Úselfs    úD/usr/lib/python3/dist-packages/twisted/persisted/test/test_styles.pyÚ__init__zFoo.__init__   s
   € Ø+ˆÕó    c                 ó   — | j                   S )z 
        Helper method.
        r   r   s    r   Úmethodz
Foo.method   s   € ð ×#Ñ#Ð#r   ©ÚreturnN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      s   „ ñó,ó$r   r   c                   ó   — e Zd ZdZy)ÚBarr   N)r   r   r   r   r   r   r   r   r      s   „ òr   r   c                   ó   — y)z)
    A sample function for pickling.
    Nr   r   r   r   ÚsampleFunctionr   $   s   � r   c                 ó   — | S )Nr   )Úxs    r   ú<lambda>r!   *   s   € ˜!€ r   c                   ó   — e Zd ZdZd„ Zdd„Zy)ÚUniversalPicklingErrorTestsz9
    Tests the L{_UniversalPicklingError} exception.
    c                 ó   — t         ‚)z2
        Raise L{UniversalPicklingError}.
        )r   r   s    r   Úraise_UniversalPicklingErrorz8UniversalPicklingErrorTests.raise_UniversalPicklingError2   s
   € ô &Ð%r   Nc                 óX   — | j                  t        j                  | j                  «       y)z^
        Handling L{pickle.PicklingError} handles
        L{_UniversalPicklingError}.
        N)ÚassertRaisesÚpickleÚPicklingErrorr%   r   s    r   Útest_handledByPickleModulez6UniversalPicklingErrorTests.test_handledByPickleModule8   s    € ð
 	×Ñœ&×.Ñ.°×0QÑ0QÕRr   r   )r   r   r   r   r%   r*   r   r   r   r#   r#   -   s   „ ñò&ôSr   r#   c                   ó@   — e Zd ZdZd	d„Zd	d„Zd	d„Zd	d„Zd	d„Zd	d„Z	y)
ÚUnpickleMethodTestsz0
    Tests for the unpickleMethod function.
    Nc                 óª   — t        «       }t        d|t         «      }| j                  ||j                  «       | j	                  ||j                  «       y)zj
        L{unpickleMethod} returns an instance method bound to the
        instance passed to it.
        r   N)r   r   ÚassertEqualr   ÚassertIsNot©r   ÚfooÚms      r   Ú test_instanceBuildingNamePresentz4UnpickleMethodTests.test_instanceBuildingNamePresentE   sA   € ô
 ‹eˆÜ˜8 S¬#Ó.ˆØ×Ñ˜˜CŸJ™JÔ'Ø×Ñ˜˜CŸJ™JÕ'r   c                 ó0  — t        «       }t        j                  |j                  «      }| j                  ||j                  «       | j	                  ||j                  «       | j                  d |«       «       d|_        | j                  d |«       «       y)za
        Copying an instance method returns a new method with the same
        behavior.
        r
   z	new-valueN)r   Úcopyr   r.   r/   r   r0   s      r   Útest_instanceCopyMethodz+UnpickleMethodTests.test_instanceCopyMethodO   sq   € ô
 ‹eˆÜ�I‰I�c—j‘jÓ!ˆØ×Ñ˜˜CŸJ™JÔ'Ø×Ñ˜˜CŸJ™JÔ'Ø×Ñ˜¡q£sÔ+Ø)ˆÔØ×Ñ˜¡a£cÕ*r   c                 óª   — t        «       }t        d|t        «      }| j                  ||j                  «       | j                  ||j                  «       y)z·
        If the named method is not present in the class,
        L{unpickleMethod} finds a method on the class of the instance
        and returns a bound method from there.
        r   N)r   r   r   r.   r   r/   r0   s      r   Ú#test_instanceBuildingNameNotPresentz7UnpickleMethodTests.test_instanceBuildingNameNotPresent\   sA   € ô ‹eˆÜ˜8 S¬#Ó.ˆØ×Ñ˜˜CŸJ™JÔ'Ø×Ñ˜˜CŸJ™JÕ'r   c                 ób   — t        j                   t        «      }| j                  |t        «       y)zi
        Copying a function returns the same reference, without creating
        an actual copy.
        N)r5   r   r.   )r   Úfs     r   Útest_copyFunctionz%UnpickleMethodTests.test_copyFunctiong   s"   € ô
 �I‰I”nÓ%ˆØ×Ñ˜œNÕ+r   c                 ól   — d„ }| j                  t        j                  t        d¬«       |d«      «       y)zd
        We do not contaminate normal function pickling with concerns from
        Twisted.
        c                 óz   — dj                  dt        z   t        j                  d| z   dg«      j                  d«      S )Nú
ÚcÚpú.Úascii)Újoinr   r   Úencode)Úns    r   Úexpectedz9UnpickleMethodTests.test_primeDirective.<locals>.expectedu   s6   € Ø—9‘9Ø”x‘¤×!8Ñ!8¸#À¹'À3ÐGóç‰f�W‹oðr   r   )ÚprotocolÚ0N)r.   r(   Údumpsr   )r   rF   s     r   Útest_primeDirectivez'UnpickleMethodTests.test_primeDirectiveo   s(   € ò	ð
 	×ÑœŸ™¤n¸qÔAÁ8ÈCÃ=ÕQr   c                 ój   — | j                  t        j                  t        j                  t        «       y)zY
        Pickling a C{lambda} function ought to raise a L{pickle.PicklingError}.
        N)r'   r(   r)   rI   ÚlambdaExampler   s    r   Útest_lambdaRaisesPicklingErrorz2UnpickleMethodTests.test_lambdaRaisesPicklingError|   s    € ð 	×Ñœ&×.Ñ.´·±¼mÕLr   r   )
r   r   r   r   r3   r6   r8   r;   rJ   rM   r   r   r   r,   r,   @   s'   „ ñó(ó+ó	(ó,óRôMr   r,   r   )r   r5   r(   Útwisted.persisted.stylesr   r   Útwisted.trialr   r   r   r   rL   ÚTestCaser#   r,   r   r   r   ú<module>rQ      sb   ðñó Û ç LÝ "÷$ñ $÷ñ óñ €ôS (×"3Ñ"3ô Sô&@M˜(×+Ñ+õ @Mr   