U
    
W[                     @   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 G dd	 d	eZG d
d dejZdS )z+
Tests for L{twisted.internet.serialport}.
    )unittest)Failure)Protocol)ConnectionDone)
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	   G/usr/lib/python3/dist-packages/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   Z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   ZassertEqualr   r   r   )r
   r   r!   Z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.trialr   Ztwisted.python.failurer   Ztwisted.internet.protocolr   Ztwisted.internet.errorr   Ztwisted.internetr   ImportErrorobjectr   ZTestCaser   r	   r	   r	   r   <module>   s   
