U
    n5{iÅ  ã                   @   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k
r\   dZ
Y nX 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   s   d S ©N© )ÚselfÚargsÚkwargsr	   r	   úI/tmp/pip-unpacked-wheel-mnhg7r0q/twisted/internet/test/test_serialport.pyÚ__init__   s    zDoNothing.__init__c                 C   s   dd„ S )Nc                  _   s   d S r   r	   )r   r   r	   r	   r   Ú<lambda>   ó    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k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   s   d S r   r	   ©r
   r	   r	   r   Ú_finishPortSetup5   s    zQSerialPortTests.test_connectionMadeLost.<locals>.DummySerialPort._finishPortSetupN)r   r   r   r   Z_serialFactoryr   r	   r	   r	   r   ÚDummySerialPort2   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   ÚSerialProtocol:   s   r"   Ú )Zreactorr   r    N)r   Z
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   Ztwisted.internet.errorr   Ztwisted.internet.protocolr   Ztwisted.python.failurer   Ztwisted.trialr   Ztwisted.internetr   Z_serialportÚImportErrorr   ZTestCaser   r	   r	   r	   r   Ú<module>   s   
