File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_strerror.cpython-310.pyc
o
�b � @ sx d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
mZ ddlm
Z
G dd � d e�ZG d
d� de
�ZdS )z
Test strerror
� N)�skipIf)�ECONNABORTED)�platform)�_ErrorFormatter�formatError)�TestCasec @ 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� Zee
�� d
kd�dd� �Zee
�� d
kd�dd� �ZdS )�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)�assertNotEqualr 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_errorTab6 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 �� errorCode��formatCallsr r
r �
formatMessageH s
z=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageNr �r r r r r )r r&