%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�fg���dZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
Gd�d	e�ZGd
�de
�Zy)z
Test strerror
�N)�skipIf)�ECONNABORTED)�platform)�_ErrorFormatter�formatError)�TestCasec��eZdZdZy)�_MyWindowsExceptionzT
    An exception type like L{ctypes.WinError}, but available on all platforms.
    N)�__name__�
__module__�__qualname__�__doc__���</usr/lib/python3/dist-packages/twisted/test/test_strerror.pyr
r
s��rr
c��eZdZdZeZdZd�Zd�Zd�Z	d�Z
d�Zee
j�dk7d	�d
��Zee
j�dk7d	�d��Zy)
�ErrorFormatingTestsz3
    Tests for C{_ErrorFormatter.formatError}.
    zcorrect message valuec��tddd�}|j|j�}|j|t	j
|j��y)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�messages   r�test_strerrorFormattingz+ErrorFormatingTests.test_strerrorFormatting sG��
$�D�$��5�	��'�'��(;�(;�<������"�+�+�d�.A�.A�"B�Crc���d}|j|j|�tdd|di�}|j|j�}|j	|tj|j��y)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)�assertNotEqualrrrrrr)r�errorrrs    r�test_emptyErrorTabz&ErrorFormatingTests.test_emptyErrorTab)sg�������D�/�/��7�#�D�$���0H�I�	��'�'��(;�(;�<������"�+�+�d�.A�.A�"B�Crc��tdd|j|ji�}|j|j�}|j	||j�y)z�
        L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
        and contains the requested error code.
        N)rr�probeMessagerrrs   r�
test_errorTabz!ErrorFormatingTests.test_errorTab6sT��
$��$��,�,�d�.?�.?�@�
�	��'�'��(;�(;�<������$�"3�"3�4rc�����g���fd�}td|�jdi�}|j�j�}�j|�j��j��jg�y)z~
        L{_ErrorFormatter.formatError} should return the return value of
        C{formatMessage} if it is supplied.
        c�>���j|��jS�N)�appendr%)�	errorCode�formatCallsrs ��r�
formatMessagez=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageHs������y�)��$�$�$rNr �rrrrr%)rr-rrr,s`   @r�test_formatMessagez&ErrorFormatingTests.test_formatMessageAst���
��	%�$��-�$�"5�"5��!G�
�	��'�'��(;�(;�<������$�"3�"3�4�����t�':�':�&;�<rc����g���fd�}t|d��jdi�}|j�j�}�j|�j�y)z�
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        c�R���j|�t|�j�Sr))r*r
r%)r+r�winCallss ��r�winErrorz3ErrorFormatingTests.test_winError.<locals>.winErrorZs"����O�O�I�&�&�y�$�2C�2C�D�Drc��y)NzformatMessage: wrong messager)r"s r�<lambda>z3ErrorFormatingTests.test_winError.<locals>.<lambda>`s�rzerrorTab: wrong messageNr.)rr3rrr2s`   @r�
test_winErrorz!ErrorFormatingTests.test_winErrorSs_���
��	E�$��8�
�
 �
 �";�<�
�	�
�'�'��(;�(;�<������$�"3�"3�4r�win32zTest will run only on Windows.c�&�tj�}|j�Rddlm}|j|j
|j�||j�j�d|_|j�Hddl
m}|j|j
|j�||j��d|_	|j�?ddl
m}|j|j
|j�||j�yy)z�
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        Nr��WinError��
FormatMessage)�errorTab)r�fromEnvironmentr3�ctypesr:rrrrr-�win32apir<r=�socket)rrr:r<r=s     r�test_fromEnvironmentz(ErrorFormatingTests.test_fromEnvironmentfs���$�3�3�5�	����)�'�����%�%�d�&9�&9�:���,�,�-�6�6�
�"&�I���"�"�.�.�����%�%�d�&9�&9�:��d�1�1�2�
�'+�I�#����)�'�����%�%�d�&9�&9�:���,�,�-�
�*rc�J�tjtg}	ddlm}|j|t�j�	ddlm	}|j|t��|jtt�|�y#t$rY�MwxYw#t$rY�:wxYw)z�
        Given a known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        rr9r;N)rAr=rr?r:r*r�ImportErrorr@r<�assertInr)r�
acceptabler:r<s    r�test_correctLookupsz'ErrorFormatingTests.test_correctLookups�s����o�o�l�3�4�
�	�'����h�|�4�=�=�>�	�.����m�L�9�:�	
�
�
�k�,�/��<���	��	���	��	�s#�+B�!B�	B�B�	B"�!B"N)rrr
rrrr%rr#r&r/r6rr�getTyperBrGrrrrrs����"�N�*�L�D�D�	5�=�$5�&��H����'�)�+K�L��M��B��H����'�)�+K�L�=�M�=rr)rrrA�unittestr�twisted.internet.tcpr�twisted.python.runtimer�twisted.python.win32rr�twisted.trial.unittestr�OSErrorr
rrrr�<module>rOs;���
�
��-�+�=�+��'��E=�(�E=r

Zerion Mini Shell 1.0