HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/test/__pycache__/test_strerror.cpython-38.pyc
U


W[?�@sldZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZGdd�de�Z
Gd	d
�d
e�ZdS)z
Test strerror
�N)�TestCase)�ECONNABORTED)�_ErrorFormatter�formatError)�platformc@seZdZdZdS)�_MyWindowsExceptionzT
    An exception type like L{ctypes.WinError}, but available on all platforms.
    N)�__name__�
__module__�__qualname__�__doc__�rr�</usr/lib/python3/dist-packages/twisted/test/test_strerror.pyrsrc@steZdZdZeZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Ze
��dkrVde_dd�Ze
��dkrpde_dS)�ErrorFormatingTestsz3
    Tests for C{_ErrorFormatter.formatError}.
    zcorrect message valuecCs0tddd�}|�|j�}|�|t�|j��dS)z�
        L{_ErrorFormatter.formatError} should use L{os.strerror} to format
        error messages if it is constructed without any better mechanism.
        N)rr�probeErrorCode�assertEqual�os�strerror��self�	formatter�messagerrr
�test_strerrorFormattingsz+ErrorFormatingTests.test_strerrorFormattingcCsFd}|�|j|�tdd|di�}|�|j�}|�|t�|j��dS)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)ZassertNotEqualrrrrrr)r�errorrrrrr
�test_emptyErrorTab)s
z&ErrorFormatingTests.test_emptyErrorTabcCs2tdd|j|ji�}|�|j�}|�||j�dS)z�
        L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
        and contains the requested error code.
        N)rr�probeMessagerrrrrr
�
test_errorTab7s
�z!ErrorFormatingTests.test_errorTabcsRg���fdd�}td|�jdi�}|��j�}��|�j�����jg�dS)z~
        L{_ErrorFormatter.formatError} should return the return value of
        C{formatMessage} if it is supplied.
        cs��|��jS�N)�appendr�Z	errorCode�ZformatCallsrrr
�
formatMessageHs
z=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageNr�rrrrr)rr"rrrr!r
�test_formatMessageBs�z&ErrorFormatingTests.test_formatMessagecsFg���fdd�}t|dd��jdi�}|��j�}��|�j�dS)z�
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        cs��|�t|�j�Sr)rrrr �rZwinCallsrr
�winErrorXs
z3ErrorFormatingTests.test_winError.<locals>.winErrorcSsdS)NzformatMessage: wrong messager)rrrr
�<lambda>]�z3ErrorFormatingTests.test_winError.<locals>.<lambda>zerrorTab: wrong messageNr#)rr&rrrr%r
�
test_winErrorRs�z!ErrorFormatingTests.test_winErrorcCs�t��}|jdk	r@ddlm}|�|�|j�||j�j�d|_|j	dk	rvddl
m}|�|�|j�||j��d|_	|jdk	r�ddl
m}|�|�|j�||j�dS)z�
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        Nr��WinError��
FormatMessage)�errorTab)rZfromEnvironmentr&�ctypesr+rrrrr"�win32apir-r.�socket)rrr+r-r.rrr
�test_fromEnvironmentcs*


�

�

�z(ErrorFormatingTests.test_fromEnvironmentZwin32zTest will run only on Windows.cCs�tjtg}z ddlm}|�|t�j�Wntk
r@YnXzddlm	}|�|t��Wntk
rtYnX|�
tt�|�dS)z�
        Given a known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        rr*r,N)r1r.rr/r+rr�ImportErrorr0r-ZassertInr)rZ
acceptabler+r-rrr
�test_correctLookups�sz'ErrorFormatingTests.test_correctLookupsN)rr	r
rrrrrrrr$r)r2rZgetType�skipr4rrrr
rs
r)rr1rZtwisted.trial.unittestrZtwisted.internet.tcprZtwisted.python.win32rrZtwisted.python.runtimer�OSErrorrrrrrr
�<module>s