o
    ¯bÄ  ã                   @   s„   d Z ddlmZ ddlmZ ddlmZ ddlmZ zddl	m
Z W n ey-   dZ
Y nw eZ
G dd	„ d	ƒZG d
d„ dejƒZdS )z+
Tests for L{twisted.internet.serialport}.
é    )ÚConnectionDone)ÚProtocol)ÚFailure)Úunittest)Ú
serialportNc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú	DoNothingz.
    Object with methods that do nothing.
    c                 O   ó   d S ©N© )ÚselfÚargsÚkwargsr
   r
   úG/usr/lib/python3/dist-packages/twisted/internet/test/test_serialport.pyÚ__init__   ó   zDoNothing.__init__c                 C   s   dd„ S )Nc                  _   r   r	   r
   )r   r   r
   r
   r   Ú<lambda>   s    z'DoNothing.__getattr__.<locals>.<lambda>r
   )r   Úattrr
   r
   r   Ú__getattr__   s   zDoNothing.__getattr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r
   r
   r   r      s    r   c                   @   s$   e Zd ZdZedu rdZdd„ ZdS )ÚSerialPortTestszt
    Minimal testing for Twisted's serial port support.

    See ticket #2462 for the eventual full test suite.
    Nz%Serial port support is not available.c                    sv   G dd„ dt jƒ}g ‰ G ‡ fdd„dtƒ}||ƒ dtƒ d�}|  ˆ dg¡ ttƒ ƒ}| |¡ |  ˆ dd|fg¡ d	S )
zr
        C{connectionMade} and C{connectionLost} are called on the protocol by
        the C{SerialPort}.
        c                   @   s   e Zd ZeZdd„ ZdS )z@SerialPortTests.test_connectionMadeLost.<locals>.DummySerialPortc                 S   r   r	   r
   ©r   r
   r
   r   Ú_finishPortSetup4   r   zQSerialPortTests.test_connectionMadeLost.<locals>.DummySerialPort._finishPortSetupN)r   r   r   r   Ú_serialFactoryr   r
   r
   r
   r   ÚDummySerialPort1   s    r   c                       s$   e Zd Z‡ fdd„Z‡ fdd„ZdS )z?SerialPortTests.test_connectionMadeLost.<locals>.SerialProtocolc                    s   ˆ   d¡ d S )NÚconnectionMade©Úappendr   ©Úeventsr
   r   r   :   s   zNSerialPortTests.test_connectionMadeLost.<locals>.SerialProtocol.connectionMadec                    s   ˆ   d|f¡ d S )NÚconnectionLostr   )r   Úreasonr    r
   r   r"   =   s   zNSerialPortTests.test_connectionMadeLost.<locals>.SerialProtocol.connectionLostN)r   r   r   r   r"   r
   r    r
   r   ÚSerialProtocol9   s    r$   Ú )Úreactorr   r"   N)r   Ú
SerialPortr   r   ÚassertEqualr   r   r"   )r   r   r$   ÚportÚfr
   r    r   Útest_connectionMadeLost+   s   

z'SerialPortTests.test_connectionMadeLost)r   r   r   r   r   Úskipr+   r
   r
   r
   r   r   !   s
    r   )r   Útwisted.internet.errorr   Útwisted.internet.protocolr   Útwisted.python.failurer   Útwisted.trialr   Útwisted.internetr   Ú_serialportÚImportErrorr   ÚTestCaser   r
   r
   r
   r   Ú<module>   s   ÿ