Ë
    ojJ   ã                   ó¤  — d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZ  ej                   «        Z	 ej$                   dZ G d	„ d
«      Z G d„ de«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z eed«       G d„ de«      «       Z eed«       G d„ dee«      «       Zy# e$ r dZY Œ~w xY w)é    N)ÚskipIf)ÚHostnameAddressÚIPv4AddressÚIPv6AddressÚUNIXAddress)ÚnativeString)Úplatform)ÚSynchronousTestCaseÚTestCaseFTc                   ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)ÚAddressTestCaseMixinc                 óÄ   — | j                  | j                  «       | j                  «       k(  «       | j                  | j                  «       | j                  «       k7  «       y)a  
        Two different address instances, sharing the same properties are
        considered equal by C{==} and not considered not equal by C{!=}.

        Note: When applied via UNIXAddress class, this uses the same
        filename for both objects being compared.
        N)Ú
assertTrueÚbuildAddressÚassertFalse©Úselfs    úD/usr/lib/python3/dist-packages/twisted/internet/test/test_address.pyÚtest_addressComparisonz+AddressTestCaseMixin.test_addressComparison   sL   € ð 	�‰˜×)Ñ)Ó+¨t×/@Ñ/@Ó/BÑBÔCØ×Ñ˜×*Ñ*Ó,°×0AÑ0AÓ0CÑCÕDó    c                 óp   — | j                  «       }|di}| j                  || j                  «          «       y)z“
        C{__hash__} can be used to get a hash of an address, allowing
        addresses to be used as keys in dictionaries, for instance.
        TN©r   r   ©r   ÚaddrÚds      r   Ú	test_hashzAddressTestCaseMixin.test_hash)   ó5   € ð
 × Ñ Ó"ˆØ�4ˆLˆØ�‰˜˜$×+Ñ+Ó-Ñ.Õ/r   c                 ó„  — | j                  | j                  «       | j                  «       k(  «       | j                  | j                  «       | j                  «       k(  «       | j                  | j                  «       | j                  «       k7  «       | j                  | j                  «       | j                  «       k7  «       y)z~
        Check that comparison operators work correctly on address objects
        when a different name is passed in
        N)r   r   ÚbuildDifferentAddressr   r   s    r   Útest_differentNamesComparisonz2AddressTestCaseMixin.test_differentNamesComparison2   s”   € ð
 	×Ñ˜×*Ñ*Ó,°×0JÑ0JÓ0LÑLÔMØ×Ñ˜×3Ñ3Ó5¸×9JÑ9JÓ9LÑLÔMà�‰˜×)Ñ)Ó+¨t×/IÑ/IÓ/KÑKÔLØ�‰˜×2Ñ2Ó4¸×8IÑ8IÓ8KÑKÕLr   c                 óÆ   — | j                  |g«      }| j                  |d   d   t        «       | j                  |d   d   |«       | j                  t        |«      d«       y)z{
        Assert that the a DeprecationWarning with the given message was
        emitted against the given method.
        r   ÚcategoryÚmessageé   N)ÚflushWarningsÚassertEqualÚDeprecationWarningÚlen)r   Ú
testMethodr#   Úwarningss       r   ÚassertDeprecationsz'AddressTestCaseMixin.assertDeprecations=   s]   € ð
 ×%Ñ% z lÓ3ˆØ×Ñ˜ !™ ZÑ0Ô2DÔEØ×Ñ˜ !™ YÑ/°Ô9Ø×Ñœ˜X›¨Õ*r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r    r+   © r   r   r   r      s   „ ò	Eò0ò	Mó+r   r   c                   ó   — e Zd ZdZy)ÚIPv4AddressTestCaseMixin©)Útypeú%s)Úhostú%r©Úportz%dN)r,   r-   r.   ÚaddressArgSpecr/   r   r   r1   r1   H   s   „ ØE�Nr   r1   c                   ó    — e Zd ZdZdZd„ Zd„ Zy)ÚHostnameAddressTestsz+
    Test case for L{HostnameAddress}.
    ))Úhostnamer4   r7   c                 ó   — t        dd«      S )zw
        Create an arbitrary new L{HostnameAddress} instance.

        @return: A L{HostnameAddress} instance.
        s   example.comr   ©r   r   s    r   r   z!HostnameAddressTests.buildAddressS   ó   € ô ˜~¨qÓ1Ð1r   c                 ó   — t        dd«      S )zw
        Like L{buildAddress}, but with a different hostname.

        @return: A L{HostnameAddress} instance.
        s   example.netr   r>   r   s    r   r   z*HostnameAddressTests.buildDifferentAddress[   r?   r   N)r,   r-   r.   Ú__doc__r9   r   r   r/   r   r   r;   r;   L   s   „ ñð :€Nò2ó2r   r;   c                   ó   — e Zd Zd„ Zd„ Zy)ÚIPv4AddressTCPTestsc                 ó   — t        ddd«      S )z²
        Create an arbitrary new L{IPv4Address} instance with a C{"TCP"}
        type.  A new instance is created for each call, but always for the
        same address.
        ÚTCPú	127.0.0.1r   ©r   r   s    r   r   z IPv4AddressTCPTests.buildAddresse   ó   € ô ˜5 +¨qÓ1Ð1r   c                 ó   — t        ddd«      S )úK
        Like L{buildAddress}, but with a different fixed address.
        rE   ú	127.0.0.2r   rG   r   s    r   r   z)IPv4AddressTCPTests.buildDifferentAddressm   ó   € ô ˜5 +¨qÓ1Ð1r   N©r,   r-   r.   r   r   r/   r   r   rC   rC   d   ó   „ ò2ó2r   rC   c                   ó   — e Zd Zd„ Zd„ Zy)ÚIPv4AddressUDPTestsc                 ó   — t        ddd«      S )z²
        Create an arbitrary new L{IPv4Address} instance with a C{"UDP"}
        type.  A new instance is created for each call, but always for the
        same address.
        ÚUDPrF   r   rG   r   s    r   r   z IPv4AddressUDPTests.buildAddressu   rH   r   c                 ó   — t        ddd«      S )rJ   rR   rK   r   rG   r   s    r   r   z)IPv4AddressUDPTests.buildDifferentAddress}   rL   r   NrM   r/   r   r   rP   rP   t   rN   r   rP   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚIPv6AddressTestsr2   c                 ó   — t        ddd«      S )z²
        Create an arbitrary new L{IPv6Address} instance with a C{"TCP"}
        type.  A new instance is created for each call, but always for the
        same address.
        rE   z::1r   ©r   r   s    r   r   zIPv6AddressTests.buildAddress‡   s   € ô ˜5 %¨Ó+Ð+r   c                 ó   — t        ddd«      S )rJ   rE   z::2r   rW   r   s    r   r   z&IPv6AddressTests.buildDifferentAddress�   s   € ô ˜5 %¨Ó+Ð+r   N)r,   r-   r.   r9   r   r   r/   r   r   rU   rU   „   s   „ ØE€Nò,ó,r   rU   z&Platform doesn't support UNIX sockets.c                   ód   — e Zd ZdZd„ Zd„ Zd„ Zd„ Z ee	d«      d„ «       Z
 ee	d«      d„ «       Zy	)
ÚUNIXAddressTests©)Únamer6   c                 óX   — | j                  «       | _        | j                  «       | _        y ©N)ÚmktempÚ_socketAddressÚ_otherAddressr   s    r   ÚsetUpzUNIXAddressTests.setUpš   s   € Ø"Ÿk™k›mˆÔØ!Ÿ[™[›]ˆÕr   c                 ó,   — t        | j                  «      S )z•
        Create an arbitrary new L{UNIXAddress} instance.  A new instance is
        created for each call, but always for the same address.
        ©r   r`   r   s    r   r   zUNIXAddressTests.buildAddressž   s   € ô
 ˜4×.Ñ.Ó/Ð/r   c                 ó,   — t        | j                  «      S )rJ   )r   ra   r   s    r   r   z&UNIXAddressTests.buildDifferentAddress¥   s   € ô ˜4×-Ñ-Ó.Ð.r   c                 ó‚   — | j                  t        | j                  «       «      dt        | j                  «      z  «       y)zn
        The repr of L{UNIXAddress} returns with the filename that the
        L{UNIXAddress} is for.
        zUNIXAddress('%s')N)r&   Úreprr   r   r`   r   s    r   Ú	test_reprzUNIXAddressTests.test_repr«   s6   € ð
 	×ÑÜ�×"Ñ"Ó$Ó%Ø¤<°×0CÑ0CÓ#DÑEõ	
r   ú"Platform does not support symlinksc                 ó¶  — | j                  «       }t        | j                  d«      5 | _        t	        j
                  t        j                  j                  | j                  «      |«       | j                  t        | j                  «      t        |«      «       | j                  t        |«      t        | j                  «      «       ddd«       y# 1 sw Y   yxY w)zU
        UNIXAddress objects compare as equal if they link to the same file.
        ÚwN)
r_   Úopenr`   ÚfdÚosÚsymlinkÚpathÚabspathr&   r   ©r   ÚlinkNames     r   Útest_comparisonOfLinkedFilesz-UNIXAddressTests.test_comparisonOfLinkedFilesµ   s�   € ð
 —;‘;“=ˆÜ�$×%Ñ% sÓ+ð 	V¨t¬wÜ�J‰J”r—w‘w—‘ t×':Ñ':Ó;¸XÔFØ×Ñœ[¨×)<Ñ)<Ó=¼{È8Ó?TÔUØ×Ñœ[¨Ó2´KÀ×@SÑ@SÓ4TÔU÷	V÷ 	Vñ 	Vúó   §BCÃCc           	      ó~  — | j                  «       }t        | j                  d«      5 | _        t	        j
                  t        j                  j                  | j                  «      |«       | j                  t        t        | j                  «      «      t        t        |«      «      «       ddd«       y# 1 sw Y   yxY w)zU
        UNIXAddress Objects that compare as equal have the same hash value.
        rk   N)r_   rl   r`   rm   rn   ro   rp   rq   r&   Úhashr   rr   s     r   Útest_hashOfLinkedFilesz'UNIXAddressTests.test_hashOfLinkedFilesÀ   s†   € ð
 —;‘;“=ˆÜ�$×%Ñ% sÓ+ð 	¨t¬wÜ�J‰J”r—w‘w—‘ t×':Ñ':Ó;¸XÔFØ×ÑÜ”[ ×!4Ñ!4Ó5Ó6¼¼[ÈÓ=RÓ8Sô÷	÷ 	ñ 	ús   §BB3Â3B<N)r,   r-   r.   r9   rb   r   r   rh   r   ÚsymlinkSkiprt   rx   r/   r   r   rZ   rZ   –   sU   „ à&€Nò+ò0ò/ò
ñ ˆKÐ=Ó>ñVó ?ðVñ ˆKÐ=Ó>ñ	ó ?ñ	r   rZ   z&platform doesn't support UNIX sockets.c                   óJ   — e Zd ZdZdZd„ Zd„ Zd„ Z ee	d«      d„ «       Z
d„ Zy	)
ÚEmptyUNIXAddressTestszJ
    Tests for L{UNIXAddress} operations involving a L{None} address.
    r[   c                 ó.   — | j                  «       | _        y r^   )r_   r`   r   s    r   rb   zEmptyUNIXAddressTests.setUpÕ   s   € Ø"Ÿk™k›mˆÕr   c                 ó   — t        d«      S )zÍ
        Create an arbitrary new L{UNIXAddress} instance.  A new instance is
        created for each call, but always for the same address. This builds it
        with a fixed address of L{None}.
        N)r   r   s    r   r   z"EmptyUNIXAddressTests.buildAddressØ   s   € ô ˜4Ó Ð r   c                 ó,   — t        | j                  «      S )zN
        Like L{buildAddress}, but with a random temporary directory.
        rd   r   s    r   r   z+EmptyUNIXAddressTests.buildDifferentAddressà   s   € ô ˜4×.Ñ.Ó/Ð/r   ri   c                 ó¶  — | j                  «       }t        | j                  d«      5 | _        t	        j
                  t        j                  j                  | j                  «      |«       | j                  t        | j                  «      t        d«      «       | j                  t        d«      t        | j                  «      «       ddd«       y# 1 sw Y   yxY w)z†
        A UNIXAddress referring to a L{None} address does not
        compare equal to a UNIXAddress referring to a symlink.
        rk   N)
r_   rl   r`   rm   rn   ro   rp   rq   ÚassertNotEqualr   rr   s     r   rt   z2EmptyUNIXAddressTests.test_comparisonOfLinkedFilesæ   s�   € ð —;‘;“=ˆÜ�$×%Ñ% sÓ+ð 	U¨t¬wÜ�J‰J”r—w‘w—‘ t×':Ñ':Ó;¸XÔFØ×Ñ¤¨D×,?Ñ,?Ó @Ä+ÈdÓBSÔTØ×Ñ¤¨DÓ 1´;¸t×?RÑ?RÓ3SÔT÷	U÷ 	Uñ 	Uúru   c                 óp   — | j                  «       }|di}| j                  || j                  «          «       y)z…
        C{__hash__} can be used to get a hash of an address, even one referring
        to L{None} rather than a real path.
        TNr   r   s      r   Útest_emptyHashz$EmptyUNIXAddressTests.test_emptyHashò   r   r   N)r,   r-   r.   rA   r9   rb   r   r   r   ry   rt   r‚   r/   r   r   r{   r{   Í   s@   „ ñð '€Nò,ò!ò0ñ ˆKÐ=Ó>ñ	Uó ?ð	Uó0r   r{   )rn   ÚsocketÚunittestr   Útwisted.internet.addressr   r   r   r   Útwisted.python.compatr   Útwisted.python.runtimer	   Útwisted.trial.unittestr
   r   Ú_supportsSymlinksry   ÚAF_UNIXÚunixSkipÚAttributeErrorr   r1   r;   rC   rP   rU   rZ   r{   r/   r   r   ú<module>r�      s  ðó
 
Û Ý ÷ó õ /Ý +ß @à,�(×,Ñ,Ó.Ð.€ðØ
‡N‚Nð €H÷(+ñ (+ôVFÐ3ô Fô2˜8Ð%9ô 2ô02Ð-Ð/Gô 2ô 2Ð-Ð/Gô 2ô ,Ð*Ð,@ô ,ñ$ ˆÐ:Ó;ô3Ð*ó 3ó <ð3ñl ˆÐ:Ó;ô+0Ð/Ð1Eó +0ó <ñ+0øðo ò Ø‚Hðús   ÁC ÃCÃC