%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/python/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/python/test/__pycache__/test_components.cpython-312.pyc

�

Ϫ�f�d���dZddlmZddlmZmZmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZddlmZGd	�d
e
j(�ZGd�de�ZGd
�de�Zee�Gd�de
j0��Zee�Gd�de
j0��ZGd�de
j(�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�d e�Z!eee e!�Gd!�d"e
j0��Z"ee�Gd#�d$��Z#Gd%�d&�Z$Gd'�d(ejJe$�Z&Gd)�d*ejJ�Z'Gd+�d,e�Z(ee(�Gd-�d.e
j0��Z)ee(�Gd/�d0e
j0��Z*Gd1�d2�Z+Gd3�d4e
j(�Z,ee(�Gd5�d6e
j0��Z-Gd7�d8e�Z.Gd9�d:e�Z/ee.�Gd;�d<��Z0e
Gd=�d>��Z1Gd?�d@e$ejJ�Z2GdA�dBe$ejJ�Z3GdC�dDe�Z4GdE�dFe4�Z5ee4�GdG�dH��Z6ee5�GdI�dJ��Z7GdK�dLe�Z8GdM�dN�Z9GdO�dPejJ�Z:yQ)Rz0
Test cases for Twisted component architecture.
�)�wraps)�	Attribute�	Interface�implementer)�AdapterRegistry)�
components)�cmp�
comparable)�_addHook�_removeHook�proxyForInterface)�unittestc��eZdZdZd�Zy)�Comporc�B�|jdz|_|jS�N���num��selfs �E/usr/lib/python3/dist-packages/twisted/python/test/test_components.py�incz	Compo.incs���8�8�a�<����x�x��N)�__name__�
__module__�__qualname__rr�rrrrs��
�C�rrc��eZdZd�Zy)�IAdeptc��t���N)�NotImplementedErrorrrr�adaptorFunczIAdept.adaptorFuncs��!�#�#rN)rrrr$rrrr r s��$rr c��eZdZd�Zy)�IElapsedc��y)z
        1!
        Nrrrr�elapsedFunczIElapsed.elapsedFunc#��rN�rrrr(rrrr&r&"s��rr&c��eZdZd�Zd�Zy)�Adeptc� �||_d|_y�Nr��originalr�r�origs  r�__init__zAdept.__init__+s����
���rc�v�|jdz|_|j|jj�fSr)rr0rrs rr$zAdept.adaptorFunc/s-���8�8�a�<����x�x����*�*�,�,�,rN)rrrr3r$rrrr,r,)s���-rr,c��eZdZd�Zy)�Elapsedc��yrrrs rr(zElapsed.elapsedFunc6s��rNr*rrrr6r64s��rr6c��eZdZy)�ACompN�rrrrrrr9r9:���rr9c��eZdZy)�BCompNr:rrrr=r=>r;rr=c��eZdZy)�CCompNr:rrrr?r?Br;rr?c��eZdZy)�ITestNr:rrrrArAFr;rrAc��eZdZy)�ITest2Nr:rrrrCrCJr;rrCc��eZdZy)�ITest3Nr:rrrrErENr;rrEc��eZdZy)�ITest4Nr:rrrrGrGRr;rrGc��eZdZd�Zy)�Testc��yr"rr1s  rr3z
Test.__init__X���rN�rrrr3rrrrIrIVs��
rrIc��eZdZdZd�Zy)�Test2rc��yr"rr1s  rr3zTest2.__init__`rKrN)rrr�temporaryAdapterr3rrrrNrN\s
����
rrNc��eZdZdZd�Zy)�RegistryUsingMixinzH
    Mixin for test cases which modify the global registry somehow.
    c��t�}|jtd|�t|�}|j	t
|�y)z�
        Configure L{twisted.python.components.registerAdapter} to mutate an
        alternate registry to improve test isolation.
        �globalRegistryN)r�patchrr�
addCleanupr)r�scratchRegistry�hooks   r�setUpzRegistryUsingMixin.setUpis7��*�+���
�
�:�/��A���(������T�*rN)rrr�__doc__rYrrrrRrRds���
+rrRc�L�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�ComponentizedTestsz8
    Simple test case for caching in Componentized.
    c��tj|�tjtt
t�tjtt
t�tjtt
t�yr")
rRrYr�registerAdapterrIr9rArErNrCrs rrYzComponentizedTests.setUp~sF��� � ��&��"�"�4���6��"�"�4���7��"�"�5�%��8rc��tjttt�tjt
tt�t�}|jt�j�dk(sJ�|jt�j�dk(sJ�t
t	|��j�dk(sJ�y)N)rr)�r`r)
rr^r,rr r6r&�getComponentr$r(�r�cs  r�testComponentizedz$ComponentizedTests.testComponentized�s����"�"�5�%��8��"�"�7�E�8�<��G���~�~�f�%�1�1�3�v�=�=�=��~�~�f�%�1�1�3�v�=�=�=���q�	�"�.�.�0�A�5�5�5rc�f�t�}|jt�}|jt�}|jt�}|jt�}||usJ�||usJ�|j	|�|jt�}|jt�}||usJ�||usJ�yr")r?rarArC�removeComponent)rrc�co1�co2�co3�co4�co5�co6s        r�testInheritanceAdaptationz,ComponentizedTests.testInheritanceAdaptation�s����G���n�n�U�#���n�n�U�#���n�n�V�$���n�n�V�$���c�z��z��#�~��~�	���#���n�n�U�#���n�n�U�#���c�z��z��#�~��~rc���t�}|jt�}|jt�}|jt�}|j|�|j
||�yr")r?rarArErG�assertIsNone�assertIs)rrcrgrirjs     r�testMultiAdapterz#ComponentizedTests.testMultiAdapter�sO���G���n�n�U�#���n�n�V�$���n�n�V�$�����#���
�
�c�3�rc�$�tj�}t�}|j|j	t
|�|�|j|j	t
|��|�|j|j	t
�d�y)z�
        Test that a default value specified to Componentized.getComponent if
        there is no component for the requested interface.
        )�defaultN)r�
Componentized�objectrprarA)r�
componentizedrss   r�test_getComponentDefaultsz,ComponentizedTests.test_getComponentDefaults�sk��
#�0�0�2�
��(���
�
�m�0�0���@�'�J��
�
�m�0�0���0�H�'�R��
�
�m�0�0��7��>rc���tj�}|jtt�|jt�}|j
|j|�|j|t�y)z�
        C{Componentized.setAdapter} sets a component for an interface by
        wrapping the instance with the given adapter class.
        N)	rrt�
setAdapterr r,ra�assertEqualr0�assertIsInstance�rrv�	components   r�test_setAdapterz"ComponentizedTests.test_setAdapter�sX��
#�0�0�2�
�� � ���/�!�.�.�v�6�	�����+�+�]�;����i��/rc���tj�}|jtd��|j	t
�}|j
|j|�|j|t�y)z�
        C{Componentized.setAdapter} adapts the instance by wrapping it with
        given adapter class, then stores it using C{addComponent}.
        T)�ignoreClassN)	rrt�
addAdapterr,rar rzr0r{r|s   r�test_addAdapterz"ComponentizedTests.test_addAdapter�s[��
#�0�0�2�
�� � ��D� �9�!�.�.�v�6�	�����+�+�]�;����i��/rc��tj�}t�}|jt|�|j|j
t�|�y)zx
        C{Componentized.setComponent} stores the given component using the
        given interface as the key.
        N)rrtru�setComponentrArpra�rrv�objs   r�test_setComponentz$ComponentizedTests.test_setComponent�sB��
#�0�0�2�
��h���"�"�5�#�.��
�
�m�0�0��7��=rc���tj�}t�}|jt|�|jt�|j
|jt��y)zm
        C{Componentized.setComponent} removes the cached component for the
        given interface.
        N)rrtrur�rA�unsetComponentrorar�s   r�test_unsetComponentz&ComponentizedTests.test_unsetComponent�sP��
#�0�0�2�
��h���"�"�5�#�.��$�$�U�+����-�4�4�U�;�<rc��tj�}|jtd�t	|�}|jd|�|jd|�y)zR
        C{ReprableComponentized} has a C{__repr__} that lists its cache.
        �hellorAN)r�ReprableComponentizedr�rA�repr�assertIn)r�rc�results   r�test_reprableComponentizedz-ComponentizedTests.test_reprableComponentized�sE���
-�
-�
/��
����w�'��b����
�
�g�v�&��
�
�g�v�&rN)rrrrZrYrdrmrqrwr~r�r�r�r�rrrr\r\ys9���9�6�� �	?�	0�	0�>�	=�'rr\c��eZdZdZd�Zy)�AdapterTestszTest adapters.c��t�}t|�}|jtjt
|�|j
t|d��yr")rur,�assertRaisesr�CannotAdaptrAro)r�o�as   r�testAdapterGetComponentz$AdapterTests.testAdapterGetComponent�s>���H���!�H�����*�0�0�%��;����%��4�.�)rN)rrrrZr�rrrr�r��s
���*rr�c��eZdZy)�IMetaNr:rrrr�r��r;rr�c��eZdZd�Zy)�	MetaAdderc�4�|jj|zSr"r/�rrs  r�addz
MetaAdder.add�����}�}� � �3�&�&rN�rrrr�rrrr�r�����'rr�c��eZdZd�Zy)�BackwardsAdderc�4�|jj|z
Sr"r/r�s  rr�zBackwardsAdder.add�r�rNr�rrrr�r��r�rr�c��eZdZdZd�Zy)�
MetaNumberz9
    Integer wrapper for Interface adaptation tests.
    c��||_yr"rr�s  rr3zMetaNumber.__init__s	����rN)rrrrZr3rrrr�r��s���rr�c��eZdZd�Zy)�ComponentNumberc�P�d|_tjj|�yr.)rrrtr3rs rr3zComponentNumber.__init__	s������ � �)�)�$�/rNrLrrrr�r�s��0rr�c��eZdZdZd�Zd�Zy)�ComponentAdderz0
    Adder for componentized adapter tests.
    c�z�tjj||�|jj|_yr")r�Adapterr3r0r�rr0s  rr3zComponentAdder.__init__s)�����#�#�D�(�3��=�=�$�$��rc�D�|xj|z
c_|jSr"rr�s  rr�zComponentAdder.adds�����C����x�x�rN)rrrrZr3r�rrrr�r�s���%�rr�c��eZdZdZd�Zy)�IAttrXz=
    Base interface for test of adapter with C{__cmp__}.
    c��y)z!
        Return a value.
        Nrrrr�xzIAttrX.x"r)rN�rrrrZr�rrrr�r�����rr�c��eZdZdZd�Zy)�IAttrXXz@
    Adapted interface for test of adapter with C{__cmp__}.
    c��y)z+
        Return a tuple of values.
        Nrrrr�xxz
IAttrXX.xx-r)rN)rrrrZr�rrrr�r�(r�rr�c��eZdZdZd�Zy)�XcellentzG
    L{IAttrX} implementation for test of adapter with C{__cmp__}.
    c��y)z;
        Return a value.

        @return: a value
        �x!rrs rr�z
Xcellent.x9s��rNr�rrrr�r�3s���rr�c�&�eZdZdZdZd�Zd�Zd�Zy)�DoubleXAdapterz
    Adapter with __cmp__.
    �*c��||_yr")r0r�s  rr3zDoubleXAdapter.__init__Js	�� ��
rc�j�|jj�|jj�fSr")r0r�rs rr�zDoubleXAdapter.xxMs#���
�
���!�4�=�=�?�?�#4�5�5rc�B�t|j|j�Sr")r	r)r�others  r�__cmp__zDoubleXAdapter.__cmp__Ps���4�8�8�U�Y�Y�'�'rN)rrrrZrr3r�r�rrrr�r�Bs���
�C�!�6�(rr�c��eZdZd�Zd�Zd�Zy)�MetaInterfaceTestsc��tjttt�td�}|jt	|�j
d�d�y)zS
        Registered adapters can be used to adapt classes to an interface.
        rr`N)rr^r�r�r�rzr�)r�ns  r�
test_basiczMetaInterfaceTests.test_basicUs;��	�"�"�9�j�%�@��q�M������q����a��!�,rc��tjttt�t�}t	|�jd�t	|�jd�|j
t	|�jd�d�y)Nr�)rr^r�r�r�r�rzrbs  r�testComponentizedInteractionz/MetaInterfaceTests.testComponentizedInteraction]sV���"�"�>�?�E�J����
�a����Q��
�a����Q������q����a��!�,rc��tjttt�t	t��}|j
d|j��y)N)r�r�)rr^r�r�r�r�rzr�)rr�s  r�testAdapterWithCmpz%MetaInterfaceTests.testAdapterWithCmpds6���"�"�>�6�7�C�
�X�Z�
 ������r�u�u�w�/rN)rrrr�r�r�rrrr�r�Ts��-�-�0rr�c�j�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�RegistrationTestsz)
    Tests for adapter registration.
    c��d�}tj||t�|jtj|td�|�y)z�
        Register an adapter with L{components.registerAdapter} for the given
        class or interface and verify that the adapter can be looked up with
        L{components.getAdapterFactory}.
        c��yr"r�r�s r�<lambda>zGRegistrationTests._registerAdapterForClassOrInterface.<locals>.<lambda>vr)rN�rr^rArp�getAdapterFactory�rr0�adapters   r�#_registerAdapterForClassOrInterfacez5RegistrationTests._registerAdapterForClassOrInterfaceps8��!���"�"�7�H�e�<��
�
�j�2�2�8�U�D�I�7�Src�8�Gd�d�}|j|�S)za
        Test that an adapter from a class can be registered and then looked
        up.
        c��eZdZy)�CRegistrationTests.test_registerAdapterForClass.<locals>.TheOriginalNr:rrr�TheOriginalr�����rr�)r��rr�s  r�test_registerAdapterForClassz.RegistrationTests.test_registerAdapterForClasszs��	�	��7�7��D�Drc�,�|jt�S)zf
        Test that an adapter from an interface can be registered and then
        looked up.
        )r�rCrs r� test_registerAdapterForInterfacez2RegistrationTests.test_registerAdapterForInterface�s��
�7�7��?�?rc���d�}d�}tj||t�|jttj||t�|jtj|td�|�y)z�
        Verify that L{components.registerAdapter} raises L{ValueError} if the
        from-type/interface and to-interface pair is not unique.
        c��y�NFrr�s rr�zHRegistrationTests._duplicateAdapterForClassOrInterface.<locals>.<lambda>�r)rc��y�NTrr�s rr�zHRegistrationTests._duplicateAdapterForClassOrInterface.<locals>.<lambda>�r)rN)rr^rAr��
ValueErrorrpr�)rr0�firstAdapter�
secondAdapters    r�$_duplicateAdapterForClassOrInterfacez6RegistrationTests._duplicateAdapterForClassOrInterface�s^��
'��&�
��"�"�<��5�A�����
�2�2�M�8�U�	
�	
�
�
�j�2�2�8�U�D�I�<�Xrc�8�Gd�d�}|j|�S)zz
        Test that attempting to register a second adapter from a class
        raises the appropriate exception.
        c��eZdZy)�DRegistrationTests.test_duplicateAdapterForClass.<locals>.TheOriginalNr:rrrr�r��r�rr�)r�r�s  r�test_duplicateAdapterForClassz/RegistrationTests.test_duplicateAdapterForClass�s��	�	��8�8��E�Erc�,�|jt�S)z
        Test that attempting to register a second adapter from an interface
        raises the appropriate exception.
        )r�rCrs r�!test_duplicateAdapterForInterfacez3RegistrationTests.test_duplicateAdapterForInterface�s��
�8�8��@�@rc���d�}d�}Gd�dt�}tj|||�dt_	tj|||�|j	tj
||d�|�dt_|j
ttj|||�|j	tj
||d�|�y#dt_wxYw)z�
        Verify that when C{components.ALLOW_DUPLICATES} is set to C{True}, new
        adapter registrations for a particular from-type/interface and
        to-interface pair replace older registrations.
        c��yr�rr�s rr�zORegistrationTests._duplicateAdapterForClassOrInterfaceAllowed.<locals>.<lambda>�r)rc��yr�rr�s rr�zORegistrationTests._duplicateAdapterForClassOrInterfaceAllowed.<locals>.<lambda>�r)rc��eZdZy)�SRegistrationTests._duplicateAdapterForClassOrInterfaceAllowed.<locals>.TheInterfaceNr:rrr�TheInterfacer��r�rr�TNF)rrr^�ALLOW_DUPLICATESrpr�r�r�)rr0r�r�r�s     r�+_duplicateAdapterForClassOrInterfaceAllowedz=RegistrationTests._duplicateAdapterForClassOrInterfaceAllowed�s���'��&�
�	�9�	�	�"�"�<��<�H�&*�
�#�	0��&�&�}�h��M��M�M��,�,�X�|�T�J��
�
+0�J�'�	
����
�2�2�L�(�L�	
�	
�
�
��(�(��<��F�
�	
��+0�J�'�s�>C�
Cc�8�Gd�d�}|j|�S)z�
        Test that when L{components.ALLOW_DUPLICATES} is set to a true
        value, duplicate registrations from classes are allowed to override
        the original registration.
        c��eZdZy)�KRegistrationTests.test_duplicateAdapterForClassAllowed.<locals>.TheOriginalNr:rrrr�r�r�rr�)r�r�s  r�$test_duplicateAdapterForClassAllowedz6RegistrationTests.test_duplicateAdapterForClassAllowed�s��	�	��?�?��L�Lrc�B�Gd�dt�}|j|�S)z�
        Test that when L{components.ALLOW_DUPLICATES} is set to a true
        value, duplicate registrations from interfaces are allowed to
        override the original registration.
        c��eZdZy)�ORegistrationTests.test_duplicateAdapterForInterfaceAllowed.<locals>.TheOriginalNr:rrrr�r�r�rr�)rr�r�s  r�(test_duplicateAdapterForInterfaceAllowedz:RegistrationTests.test_duplicateAdapterForInterfaceAllowed�s!��	�)�	��?�?��L�Lrc��d�}tj||tt�|j	tj
|td�|�|j	tj
|td�|�y)zh
        Verify that an adapter can be registered for multiple to-interfaces at a
        time.
        c��yr"rr�s rr�zJRegistrationTests._multipleInterfacesForClassOrInterface.<locals>.<lambda>�r)rN)rr^rArCrpr�r�s   r�&_multipleInterfacesForClassOrInterfacez8RegistrationTests._multipleInterfacesForClassOrInterface�sW��
!���"�"�7�H�e�V�D��
�
�j�2�2�8�U�D�I�7�S��
�
�j�2�2�8�V�T�J�G�Trc�8�Gd�d�}|j|�S)zi
        Test the registration of an adapter from a class to several
        interfaces at once.
        c��eZdZy)�FRegistrationTests.test_multipleInterfacesForClass.<locals>.TheOriginalNr:rrrr�r�r�rr�)r	r�s  r�test_multipleInterfacesForClassz1RegistrationTests.test_multipleInterfacesForClass�s��	�	��:�:�;�G�Grc�,�|jt�S)zn
        Test the registration of an adapter from an interface to several
        interfaces at once.
        )r	rErs r�#test_multipleInterfacesForInterfacez5RegistrationTests.test_multipleInterfacesForInterface�s��
�:�:�6�B�Brc�>�d�}d�}Gd�d|�}tj||t�tj||t�|jtj|td�|�|jtj|td�|�y)a 
        Verify that a new adapter can be registered for a particular
        to-interface from a subclass of a type or interface which already has an
        adapter registered to that interface and that the subclass adapter takes
        precedence over the base class adapter.
        c��yr�rr�s rr�zSRegistrationTests._subclassAdapterRegistrationForClassOrInterface.<locals>.<lambda>r)rc��yr�rr�s rr�zSRegistrationTests._subclassAdapterRegistrationForClassOrInterface.<locals>.<lambda>r)rc��eZdZy)�VRegistrationTests._subclassAdapterRegistrationForClassOrInterface.<locals>.TheSubclassNr:rrr�TheSubclassr
r�rrNr�)rr0r�r�rs     r�/_subclassAdapterRegistrationForClassOrInterfacezARegistrationTests._subclassAdapterRegistrationForClassOrInterfaces}��&��'�
�	�(�	�	�"�"�<��5�A��"�"�=�+�u�E��
�
�j�2�2�8�U�D�I�<�X��
�
��(�(��e�T�B�M�	
rc�8�Gd�d�}|j|�S)z~
        Test that an adapter to a particular interface can be registered
        from both a class and its subclass.
        c��eZdZy)�ORegistrationTests.test_subclassAdapterRegistrationForClass.<locals>.TheOriginalNr:rrrr�rr�rr�)rr�s  r�(test_subclassAdapterRegistrationForClassz:RegistrationTests.test_subclassAdapterRegistrationForClasss��	�	��C�C�K�P�Prc�,�|jt�S)z�
        Test that an adapter to a particular interface can be registered
        from both an interface and its subclass.
        )rrCrs r�,test_subclassAdapterRegistrationForInterfacez>RegistrationTests.test_subclassAdapterRegistrationForInterfaces��
�C�C�F�K�KrN)rrrrZr�r�r�r�r�r�r�rrr	r
rrrrrrrr�r�ks`���T�	E�@�Y�	F�A�
�@
M�
M�U�	H�C�
�(	Q�Lrr�c�&�eZdZdZed�Zd�Zy)�IProxiedInterfacez=
    An interface class for use by L{proxyForInterface}.
    z@
        An example declared attribute, which should be proxied.c��y)z:
        A sample method which should be proxied.
        Nr)r��kws  r�yayzIProxiedInterface.yay1r)rN)rrrrZr�ifaceAttributer!rrrrr's����	C��N�
rrc��eZdZdZd�Zy)�IProxiedSubInterfacezS
    An interface that derives from another for use with L{proxyForInterface}.
    c��y)zD
        A different sample method which should be proxied.
        Nrrrr�boozIProxiedSubInterface.boo<r)rN�rrrrZr&rrrr$r$7r�rr$c��eZdZdZd�Zd�Zy)�Yayablez�
    A provider of L{IProxiedInterface} which increments a counter for
    every call to C{yay}.

    @ivar yays: The number of times C{yay} has been called.
    c� �d|_g|_yr.)�yays�yayArgsrs rr3zYayable.__init__Ms����	���rc�~�|xjdz
c_|jj||f�|jS)z)
        Increment C{self.yays}.
        r)r+r,�append�rr�r s   rr!zYayable.yayQs1��	
�	�	�Q��	������Q��G�$��y�y�rN)rrrrZr3r!rrrr)r)Bs����rr)c�$�eZdZdZdZdZd�Zd�Zy)�Booablez3
    An implementation of IProxiedSubInterface
    Fc��d|_y)z;
        Mark the fact that 'yay' has been called.
        TN)�yayedr/s   rr!zBooable.yaye�����
rc��d|_y)z<
        Mark the fact that 'boo' has been called.1
        TN)�booedrs rr&zBooable.bookr4rN)rrrrZr3r6r!r&rrrr1r1Zs���
�E��E��rr1c��eZdZdZd�Zd�Zy)�IMultipleMethodsz-
    An interface with multiple methods.
    c��y)z4
        The first method. Should return 1.
        Nrrrr�	methodOnezIMultipleMethods.methodOnewr)rc��y)z5
        The second method. Should return 2.
        Nrrrr�	methodTwozIMultipleMethods.methodTwo|r)rN�rrrrZr:r<rrrr8r8rs����
rr8c��eZdZdZd�Zd�Zy)�MultipleMethodImplementorz:
    A precise implementation of L{IMultipleMethods}.
    c��y)z
        @return: 1
        rrrs rr:z#MultipleMethodImplementor.methodOne����rc��y)z
        @return: 2
        r`rrs rr<z#MultipleMethodImplementor.methodTwo�rArNr=rrrr?r?�s����rr?c�d�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zy)�ProxyForInterfaceTestsz)
    Tests for L{proxyForInterface}.
    c�z�t�}tt�|�}|j|j|�y)z�
        Proxy objects should have an C{original} attribute which refers to the
        original object passed to the constructor.
        N)rur
rrpr0)rr0�proxys   r�
test_originalz$ProxyForInterfaceTests.test_original�s0��
�8��4�!�"3�4�X�>���
�
�e�n�n�h�/rc���tt�}t�}||�}|j�|j	|j�d�|j	|j
d�y)z�
        The class created from L{proxyForInterface} passes methods on an
        interface to the object which is passed to its constructor.
        r`N�r
rr)r!rzr+)r�klass�yayablerFs    r�test_proxyMethodz'ProxyForInterfaceTests.test_proxyMethod�sR��
"�"3�4���)���g���
�	�	���������a�(�������q�)rc���tt��G�fd�d��}t�}||�}|j�|j	d|j
�y)z�
        Methods of the class created from L{proxyForInterface} can be used with
        the decorator-helper L{functools.wraps}.
        c�D��eZdZeW�j��fd��Zy)�?ProxyForInterfaceTests.test_decoratedProxyMethod.<locals>.klassc�d��|jxjdz
c_�j|�Sr)r0r+r!)r�bases �rr!zCProxyForInterfaceTests.test_decoratedProxyMethod.<locals>.klass.yay�s&����
�
�"�"�a�'�"��x�x��~�%rN)rrrrr!)rQs�rrJrO�s���
�4�8�8�_�
&��
&rrJr`NrI)rrJr0rKrQs    @r�test_decoratedProxyMethodz0ProxyForInterfaceTests.test_decoratedProxyMethod�sK���
!�!2�3��	&�D�	&��9����/�����
�����H�M�M�*rc����t�}t�|_tt�|��|j�j|j�|j
t�fd��y)zc
        Proxy objects should proxy declared attributes, but not other
        attributes.
        c����jSr")r+)rFs�rr�z<ProxyForInterfaceTests.test_proxyAttribute.<locals>.<lambda>�s���%�*�*�rN)r)rur"r
rrpr��AttributeError�rrKrFs  @r�test_proxyAttributez*ProxyForInterfaceTests.test_proxyAttribute�sT���
�)��!'����4�!�"3�4�W�=���
�
�e�*�*�G�,B�,B�C����.�*<�=rc��t�}tt�|�}t�}||_|j|j|�y)zv
        The attributes that proxy objects proxy should be assignable and affect
        the original object.
        N)r)r
rrur"rp�rrKrF�thingys    r�test_proxySetAttributez-ProxyForInterfaceTests.test_proxySetAttribute�sA��
�)��4�!�"3�4�W�=�����%����
�
�g�,�,�f�5rc��t�}d|_tt�|�}|`|j	t|d��y)zu
        The attributes that proxy objects proxy should be deletable and affect
        the original object.
        Nr")r)r"r
r�assertFalse�hasattrrVs   r�test_proxyDeleteAttributez0ProxyForInterfaceTests.test_proxyDeleteAttribute�sB��
�)��!%���4�!�"3�4�W�=��� ������*:�;�<rc���t�}tt�|�}|j|j	�d�|j|j�d�y)z�
        [Regression test] The proxy should send its method calls to the correct
        method, not the incorrect one.
        rr`N)r?r
r8rzr:r<)r�multirFs   r�test_multipleMethodsz+ProxyForInterfaceTests.test_multipleMethods�sM��
*�+��3�!�"2�3�E�:��������*�A�.�������*�A�.rc���Gd�dtt��}t�}||�}|j|jd�|j�|j|jd�y)zP
        It is possible to subclass the result of L{proxyForInterface}.
        c��eZdZdZd�Zy)�AProxyForInterfaceTests.test_subclassing.<locals>.SpecializedProxyzU
            A specialized proxy which can decrement the number of yays.
            c�B�|jxjdzc_y)z?
                Decrement the number of yays.
                rN)r0r+rs rr&zEProxyForInterfaceTests.test_subclassing.<locals>.SpecializedProxy.boo�s���
�
�"�"�a�'�"rNr'rrr�SpecializedProxyre�s��
�
(rrgr���N)r
rr)rzr+r&)rrgrK�specials    r�test_subclassingz'ProxyForInterfaceTests.test_subclassing�sY��
		(�0�1B�C�		(��)��"�7�+��������q�)����
�������r�*rc�Z�tt�}|j|jd�y)zQ
        The name of a proxy class indicates which interface it proxies.
        zA(Proxy for twisted.python.test.test_components.IProxiedInterface)N)r
rrzr�rrFs  r�test_proxyNamez%ProxyForInterfaceTests.test_proxyNames'��"�"3�4������N�N�R�	
rc�j�tt�}|jtj|��y)zO
        The resulting proxy implements the interface that it proxies.
        N)r
r�
assertTrue�
implementedByrls  r�test_implementsz&ProxyForInterfaceTests.test_implementss'��"�"3�4�����)�7�7��>�?rc�,�Gd�d�}|�}|�}||_tjdd�}|j|j	|�|j
�|j	d�}||�|j
|j�y)a\
        _ProxyDescriptor's __get__ method should return the appropriate
        attribute of its argument's 'original' attribute if it is invoked with
        an object.  If it is invoked with None, it should return a false
        class-method emulator instead.

        For some reason, Python's documentation recommends to define
        descriptors' __get__ methods with the 'type' parameter as optional,
        despite the fact that Python itself never actually calls the descriptor
        that way.  This is probably do to support 'foo.__get__(bar)' as an
        idiom.  Let's make sure that the behavior is correct.  Since we don't
        actually use the 'type' argument at all, this test calls it the
        idiomatic way to ensure that signature works; test_proxyInheritance
        verifies the how-Python-actually-calls-it signature.
        c��eZdZdZd�Zy)�>ProxyForInterfaceTests.test_proxyDescriptorGet.<locals>.SampleFc��d|_yr�)�calledrs rr�zDProxyForInterfaceTests.test_proxyDescriptorGet.<locals>.Sample.hello&s	��"��rN)rrrrvr�rrr�Samplert#s���F�
#rrwr�r0N)r0r�_ProxyDescriptorrz�__get__r�rorv)rrw�	fakeProxy�
testObject�pd�fakeClassMethods      r�test_proxyDescriptorGetz.ProxyForInterfaceTests.test_proxyDescriptorGets}��"	#�	#��H�	��X�
�'�	��
�
(�
(��*�
=��������I�.�
�0@�0@�A��*�*�T�*���	�"����
�)�)�*rc���Gd�dtt���G�fd�d��}t�}||�}|j|j	dddd�	�d
�|j|j
dt
dd�	�fg�y)
z�
        Subclasses of the class returned from L{proxyForInterface} should be
        able to upcall methods by reference to their superclass, as any normal
        Python class can.
        c��eZdZdZy)�DProxyForInterfaceTests.test_proxyInheritance.<locals>.YayableWrapperzI
            This class does not override any functionality.
            N)rrrrZrrr�YayableWrapperr�9s��
rr�c� ��eZdZdZdZ�fd�Zy)�EProxyForInterfaceTests.test_proxyInheritance.<locals>.EnhancedWrapperz@
            This class overrides the 'yay' method.
            rc�`��|xjdz
c_�j|g|��i|��dzS)Nr�)�wrappedYaysr!)rr��kr�s   �rr!zIProxyForInterfaceTests.test_proxyInheritance.<locals>.EnhancedWrapper.yayEs6���� � �A�%� �)�~�)�)�$�8��8�a�8�1�<�<rN)rrrrZr�r!)r�s�r�EnhancedWrapperr�>s���
��K�
=rr�r����)r��y�)r�r�N)r
rr)rzr!r,�dict)rr�rK�wrapperr�s    @r�test_proxyInheritancez,ProxyForInterfaceTests.test_proxyInheritance2sx���	�.�/@�A�	�
		=�n�		=��)��!�'�*��������Q��Q�!��4�a�8�������F�D�1��N�+C�*D�Erc���tt�}t�}||�}|j�|j	�|j|j�|j|j�y)z�
        Proxies of subinterfaces generated with proxyForInterface should allow
        access to attributes of both the child and the base interfaces.
        N)r
r$r1r!r&ror3r6)r�
proxyClass�booablerFs    r�test_interfaceInheritancez0ProxyForInterfaceTests.test_interfaceInheritanceNsR��
'�';�<�
��)���7�#��
�	�	��
�	�	������
�
�&�����
�
�&rc��t�}t�|_ttd��|�}|j|j|�|j|j�d�|j|j|j�t�}||_|j|j|�|`|jt|d��y)a
        The original attribute name can be customized via the
        C{originalAttribute} argument of L{proxyForInterface}: the attribute
        should change, but the methods of the original object should still be
        callable, and the attributes still accessible.
        �foo)�originalAttributerr"N)r)rur"r
rrpr�rzr!r]r^rYs    r�test_attributeCustomizationz2ProxyForInterfaceTests.test_attributeCustomization[s����)��!'����M�!�"3�u�M�g�V���
�
�e�i�i��)�	
�������a�(��
�
�e�*�*�G�,B�,B�C����%����
�
�g�,�,�f�5�� ������*:�;�<rN)rrrrZrGrLrRrWr[r_rbrjrmrqr~r�r�r�rrrrDrD�sP���0�
*�+�$	>�	6�	=�/�+�,
�@�+�@F�8'�=rrDN);rZ�	functoolsr�zope.interfacerrr�zope.interface.adapterr�twisted.pythonr�twisted.python.compatr	r
�twisted.python.componentsrrr
�
twisted.trialrrtrr r&r�r,r6r9r=r?rArCrErGrIrNrR�SynchronousTestCaser\r�r�r�r�r�r�r�r�r�r�r�r�r�rr$r)r1r8r?rDrrr�<module>r�s��
�
�<�<�2�%�1�N�N�"��J�$�$��$�Y�$�
�y��
�V��-�J���-��-�
�X���j� � ����
	�J�$�$�	�	�E�	�	�E�	�	�I�	�	�Y�	�	�Y�	�	�Y�	�
�U�F�F�#�
�:���
�$�
�

�V��
�
��
�+�+�*i'��5�5�7I�i'�X*�8�/�/�*�	�I�	�
�U��'�
�"�"�'��'�

�U��'�Z�'�'�'��'�
��0�j�.�.�0�
�U���Z�'�'�����Y���i��
�V�������(�(��(�"0�+�X�-I�-I�0�.yL�*�H�,H�,H�yL�x
�	�
� �,��
�
���� ��.
�
!�"���#��.
�y�
� ��$Z=�X�9�9�Z=r

Zerion Mini Shell 1.0