§
    Ètºfg  ã                   ó’   — d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZ ddlmZ  G d„ d	e¦  «        Z G d
„ de¦  «        ZdS )z
Test strerror
é    N)ÚskipIf)ÚECONNABORTED)Úplatform)Ú_ErrorFormatterÚformatError)ÚTestCasec                   ó   — e Zd ZdZdS )Ú_MyWindowsExceptionzT
    An exception type like L{ctypes.WinError}, but available on all platforms.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úY/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/test/test_strerror.pyr
   r
      s   € € € € € ðð ð ð r   r
   c                   óÐ   — e Zd ZdZeZdZd„ Zd„ Zd„ Z	d„ Z
d„ Z e ej        ¦   «         dk    d	¦  «        d
„ ¦   «         Z e ej        ¦   «         dk    d	¦  «        d„ ¦   «         ZdS )ÚErrorFormatingTestsz3
    Tests for C{_ErrorFormatter.formatError}.
    zcorrect message valuec                 ó¶   — t          ddd¦  «        }|                     | j        ¦  «        }|                      |t	          j        | j        ¦  «        ¦  «         dS )zž
        L{_ErrorFormatter.formatError} should use L{os.strerror} to format
        error messages if it is constructed without any better mechanism.
        N)r   r   ÚprobeErrorCodeÚassertEqualÚosÚstrerror©ÚselfÚ	formatterÚmessages      r   Útest_strerrorFormattingz+ErrorFormatingTests.test_strerrorFormatting    sT   € õ
 $ D¨$°Ñ5Ô5ˆ	Ø×'Ò'¨Ô(;Ñ<Ô<ˆØ×Ò˜¥"¤+¨dÔ.AÑ"BÔ"BÑCÔCÐCÐCÐCr   c                 óô   — d}|                       | j        |¦  «         t          dd|di¦  «        }|                     | j        ¦  «        }|                      |t          j        | j        ¦  «        ¦  «         dS )zØ
        L{_ErrorFormatter.formatError} should use L{os.strerror} to format
        error messages if it is constructed with only an error tab which does
        not contain the error code it is called with.
        é   Núwrong message)ÚassertNotEqualr   r   r   r   r   r   )r   Úerrorr   r   s       r   Útest_emptyErrorTabz&ErrorFormatingTests.test_emptyErrorTab)   sw   € ð ˆà×Ò˜DÔ/°Ñ7Ô7Ð7Ý# D¨$°¸Ð0HÑIÔIˆ	Ø×'Ò'¨Ô(;Ñ<Ô<ˆØ×Ò˜¥"¤+¨dÔ.AÑ"BÔ"BÑCÔCÐCÐCÐCr   c                 óª   — t          dd| j        | j        i¦  «        }|                     | j        ¦  «        }|                      || j        ¦  «         dS )zˆ
        L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
        and contains the requested error code.
        N)r   r   ÚprobeMessager   r   r   s      r   Útest_errorTabz!ErrorFormatingTests.test_errorTab6   s\   € õ
 $Ø�$˜Ô,¨dÔ.?Ð@ñ
ô 
ˆ	ð ×'Ò'¨Ô(;Ñ<Ô<ˆØ×Ò˜ $Ô"3Ñ4Ô4Ð4Ð4Ð4r   c                 óì   ‡ ‡— g Šˆˆ fd„}t          d|‰ j        di¦  «        }|                     ‰ j        ¦  «        }‰                      |‰ j        ¦  «         ‰                      ‰‰ j        g¦  «         dS )z~
        L{_ErrorFormatter.formatError} should return the return value of
        C{formatMessage} if it is supplied.
        c                 ó<   •— ‰                      | ¦  «         ‰j        S ©N)Úappendr%   )Ú	errorCodeÚformatCallsr   s    €€r   ÚformatMessagez=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageH   s    ø€ Ø×Ò˜yÑ)Ô)Ð)ØÔ$Ð$r   Nr    ©r   r   r   r   r%   )r   r-   r   r   r,   s   `   @r   Útest_formatMessagez&ErrorFormatingTests.test_formatMessageA   sœ   øø€ ð
 ˆð	%ð 	%ð 	%ð 	%ð 	%ð 	%õ $Ø�- $Ô"5°Ð!Gñ
ô 
ˆ	ð ×'Ò'¨Ô(;Ñ<Ô<ˆØ×Ò˜ $Ô"3Ñ4Ô4Ð4Ø×Ò˜ tÔ':Ð&;Ñ<Ô<Ð<Ð<Ð<r   c                 ó¶   ‡ ‡— g Šˆ ˆfd„}t          |d„ ‰ j        di¦  «        }|                     ‰ j        ¦  «        }‰                      |‰ j        ¦  «         dS )zŸ
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        c                 óX   •— ‰                      | ¦  «         t          | ‰j        ¦  «        S r)   )r*   r
   r%   )r+   r   ÚwinCallss    €€r   ÚwinErrorz3ErrorFormatingTests.test_winError.<locals>.winErrorZ   s(   ø€ Ø�OŠO˜IÑ&Ô&Ð&Ý& y°$Ô2CÑDÔDÐDr   c                 ó   — dS )NzformatMessage: wrong messager   )r"   s    r   ú<lambda>z3ErrorFormatingTests.test_winError.<locals>.<lambda>`   s   € Ð8€ r   zerrorTab: wrong messageNr.   )r   r3   r   r   r2   s   `   @r   Útest_winErrorz!ErrorFormatingTests.test_winErrorS   sŒ   øø€ ð
 ˆð	Eð 	Eð 	Eð 	Eð 	Eð 	Eõ $ØØ8Ð8ØÔ Ð";Ð<ñ
ô 
ˆ	ð
 ×'Ò'¨Ô(;Ñ<Ô<ˆØ×Ò˜ $Ô"3Ñ4Ô4Ð4Ð4Ð4r   Úwin32zTest will run only on Windows.c                 ó  — t          j        ¦   «         }|j        �Nddlm} |                      |                     | j        ¦  «         || j        ¦  «        j        ¦  «         d|_        |j	        �Iddl
m} |                      |                     | j        ¦  «         || j        ¦  «        ¦  «         d|_	        |j        �Addlm} |                      |                     | j        ¦  «        || j                 ¦  «         dS dS )z›
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        Nr   ©ÚWinError©ÚFormatMessage)ÚerrorTab)r   ÚfromEnvironmentr3   Úctypesr:   r   r   r   r   r-   Úwin32apir<   r=   Úsocket)r   r   r:   r<   r=   s        r   Útest_fromEnvironmentz(ErrorFormatingTests.test_fromEnvironmentf   s;  € õ $Ô3Ñ5Ô5ˆ	àÔÐ)Ø'Ð'Ð'Ð'Ð'Ð'à×ÒØ×%Ò% dÔ&9Ñ:Ô:Ø�˜Ô,Ñ-Ô-Ô6ñô ð ð "&ˆIÔàÔ"Ð.Ø.Ð.Ð.Ð.Ð.Ð.à×ÒØ×%Ò% dÔ&9Ñ:Ô:Ø�˜dÔ1Ñ2Ô2ñô ð ð '+ˆIÔ#àÔÐ)Ø'Ð'Ð'Ð'Ð'Ð'à×ÒØ×%Ò% dÔ&9Ñ:Ô:Ø˜Ô,Ô-ñô ð ð ð ð *Ð)r   c                 ó|  — t           j        t                   g}	 ddlm} |                      |t          ¦  «        j        ¦  «         n# t          $ r Y nw xY w	 ddlm	} |                      |t          ¦  «        ¦  «         n# t          $ r Y nw xY w|  
                    t          t          ¦  «        |¦  «         dS )z¼
        Given a known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        r   r9   r;   N)rA   r=   r   r?   r:   r*   r   ÚImportErrorr@   r<   ÚassertInr   )r   Ú
acceptabler:   r<   s       r   Útest_correctLookupsz'ErrorFormatingTests.test_correctLookupsˆ   sê   € õ ”o¥lÔ3Ð4ˆ
ð	Ø'Ð'Ð'Ð'Ð'Ð'à×Ò˜h˜h¥|Ñ4Ô4Ô=Ñ>Ô>Ð>Ð>øÝð 	ð 	ð 	ØˆDð	øøøð	Ø.Ð.Ð.Ð.Ð.Ð.à×Ò˜m˜m­LÑ9Ô9Ñ:Ô:Ð:Ð:øÝð 	ð 	ð 	ØˆDð	øøøð 	�Š•k¥,Ñ/Ô/°Ñ<Ô<Ð<Ð<Ð<s#   š.A	 Á	
AÁAÁ)B Â
BÂBN)r   r   r   r   r   r   r%   r   r#   r&   r/   r6   r   r   ÚgetTyperB   rG   r   r   r   r   r      sò   € € € € € ðð ð "€NØ*€LðDð Dð DðDð Dð Dð	5ð 	5ð 	5ð=ð =ð =ð$5ð 5ð 5ð& €VÐˆHÔÑÔ 'Ò)Ð+KÑLÔLðð ñ MÔLððB €VÐˆHÔÑÔ 'Ò)Ð+KÑLÔLð=ð =ñ MÔLð=ð =ð =r   r   )r   r   rA   Úunittestr   Útwisted.internet.tcpr   Útwisted.python.runtimer   Útwisted.python.win32r   r   Útwisted.trial.unittestr   ÚOSErrorr
   r   r   r   r   ú<module>rO      së   ððð ð 
€	€	€	Ø €€€Ø Ð Ð Ð Ð Ð à -Ð -Ð -Ð -Ð -Ð -Ø +Ð +Ð +Ð +Ð +Ð +Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø +Ð +Ð +Ð +Ð +Ð +ðð ð ð ð ˜'ñ ô ð ðE=ð E=ð E=ð E=ð E=˜(ñ E=ô E=ð E=ð E=ð E=r   