File: //lib/python3/dist-packages/twisted/test/__pycache__/test_strerror.cpython-38.pyc
U
W[? � @ sl d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ G dd� de�Z
G d d
� d
e�ZdS )z
Test strerror
� N)�TestCase)�ECONNABORTED)�_ErrorFormatter�formatError)�platformc @ s e Zd ZdZdS )�_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.pyr s r c @ st e Zd ZdZeZdZdd� Zdd� Zdd� Z d d
� Z
dd� Zd
d� Ze
�� dkrVde_dd� Ze
�� dkrpde_dS )�ErrorFormatingTestsz3
Tests for C{_ErrorFormatter.formatError}.
zcorrect message valuec C s0 t ddd�}|�| 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)r r �probeErrorCode�assertEqual�os�strerror��self� formatter�messager r r
�test_strerrorFormatting s z+ErrorFormatingTests.test_strerrorFormattingc C sF d}| � | 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)ZassertNotEqualr r r r r r )r �errorr r r r r
�test_emptyErrorTab) s
z&ErrorFormatingTests.test_emptyErrorTabc C s2 t dd| j| ji�}|�| j�}| �|| j� dS )z�
L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
and contains the requested error code.
N)r r �probeMessager r r r r r
�
test_errorTab7 s
�z!ErrorFormatingTests.test_errorTabc sR g � � �fdd�}t d|�jdi�}|��j�}��|�j� ��� �jg� dS )z~
L{_ErrorFormatter.formatError} should return the return value of
C{formatMessage} if it is supplied.
c s � � | � �jS �N)�appendr �Z errorCode�ZformatCallsr r r
�
formatMessageH s
z=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageNr �r r r r r )r r"