HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_win32serialport.cpython-38.pyc
U


W[��@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
zddlmZddlZWnek
r�dZdZYnXedk	r�Gd	d
�d
ej�ZGdd�dej�ZGd
d�de�ZGdd�dej�ZdS)z+
Tests for L{twisted.internet.serialport}.
�N)�unittest)�Protocol)�Failure)�platform)�	DoNothing)�
serialportcs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�RegularFileSerialcs"tt|�j||�||_||_dS�N)�superr�__init__�
captured_args�captured_kwargs)�self�args�kwargs��	__class__��L/usr/lib/python3/dist-packages/twisted/internet/test/test_win32serialport.pyrszRegularFileSerial.__init__cCsdSr	r�rrrr�_reconfigurePort!sz"RegularFileSerial._reconfigurePortcCsdSr	rrrrr�_reconfigure_port$sz#RegularFileSerial._reconfigure_port)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcs(eZdZeZ�fdd�Zdd�Z�ZS)�RegularFileSerialPortcs@|�d�}d|kr|d=tjj|_||j_tt|�j||�dS)N�cbInQue)	�get�serialZwin32ZCOMSTAT�comstatrr
rr)rrrrrrrr+s

zRegularFileSerialPort.__init__cCs
d|jfS)NT)r rrrr�_clearCommError6sz%RegularFileSerialPort._clearCommError)rrrrZ_serialFactoryrr!rrrrrr(src@seZdZdd�Zdd�ZdS)�CollectReceivedProtocolcCs
g|_dSr	)�
received_datarrrrr;sz CollectReceivedProtocol.__init__cCs|j�|�dSr	)r#�append)r�datarrr�dataReceived>sz$CollectReceivedProtocol.dataReceivedN)rrrrr&rrrrr":sr"c@sveZdZdZe��sdZnes"dZdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�Win32SerialPortTestszB
    Minimal testing for Twisted's Win32 serial port support.
    zThis test must run on Windows.z-Windows serial port support is not available.c	CsVt�|_t�|_t��|_tj�	|jd�|_d}t
|jd��}|�|�W5QRXdS)NZfake_serials1234�wb)r�protocolr�reactor�tempfileZmkdtemp�	directory�os�path�join�open�write)rr%�frrr�setUpMs
zWin32SerialPortTests.setUpcCst�|j�dSr	)�shutilZrmtreer,rrrr�tearDownYszWin32SerialPortTests.tearDowncCs�t|j|j|j�}|�|jf|jj�|jj}|�d|d�|�tj	|d�|�tj
|d�|�tj|d�|�d|d�|�d|d�|�d	|d
�|�t
td���d	S)zx
        Test correct positional and keyword arguments have been
        passed to the C{serial.Serial} object.
        i�%ZbaudrateZbytesizeZparityZstopbitsrZxonxoffZrtsctsNZtimeout�Cleanup)rr)r.r*�assertEqualZ_serialrr
rZ	EIGHTBITSZPARITY_NONEZSTOPBITS_ONE�connectionLostr�	Exception)r�portrrrr�test_serialPortDefaultArgs\sz/Win32SerialPortTests.test_serialPortDefaultArgscCsf|�d|jj�t|j|j|j�}|�d|j�|�d|jj�|�||jj�|�tt	d���dS)z�
        Test the port is connected at initialization time, and
        C{Protocol.makeConnection} has been called on the desired protocol.
        r�r6N)
r7r)Z	connectedrr.r*Z	transportr8rr9)rr:rrr�!test_serialPortInitiallyConnectedosz6Win32SerialPortTests.test_serialPortInitiallyConnectedcCsbt|j|j|j|d�}|��|�d�|�d�|�d�|��|��|�tt	d���dS)N�r)ZdeviceNameOrPortNumberr*r�sabcdsABCDr6)
rr)r.r*�serialReadEventr1ZserialWriteEventr8rr9)rrr:rrr�common_exerciseHandleAccess|s�


z0Win32SerialPortTests.common_exerciseHandleAccesscCs|jdd�dS�NF�r�rArrrr�test_exerciseHandleAccess_1�sz0Win32SerialPortTests.test_exerciseHandleAccess_1cCs|jdd�dS�NTrCrDrrrr�test_exerciseHandleAccess_2�sz0Win32SerialPortTests.test_exerciseHandleAccess_2cCsRt�}t||j|j|d�}|��|�tdd�|jD���|�t	t
d���dS)Nr>css|]}t|t�VqdSr	)�
isinstance�bytes)�.0�drrr�	<genexpr>�szEWin32SerialPortTests.common_serialPortReturnsBytes.<locals>.<genexpr>r6)r"rr.r*r@Z
assertTrue�allr#r8rr9)rrr)r:rrr�common_serialPortReturnsBytes�s��
z2Win32SerialPortTests.common_serialPortReturnsBytescCs|jdd�dSrB�rNrrrr�test_serialPortReturnsBytes_1�sz2Win32SerialPortTests.test_serialPortReturnsBytes_1cCs|jdd�dSrFrOrrrr�test_serialPortReturnsBytes_2�sz2Win32SerialPortTests.test_serialPortReturnsBytes_2N)rrr�__doc__rZ	isWindows�skiprr3r5r;r=rArErGrNrPrQrrrrr'Bs
r')rRr-r4r+Z
twisted.trialrZtwisted.internet.protocolrZtwisted.python.failurerZtwisted.python.runtimerZ%twisted.internet.test.test_serialportrZtwisted.internetrr�ImportErrorZSerialrZ
SerialPortrr"ZTestCaser'rrrr�<module>s&