%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_win32serialport.cpython-312.pyc

�

Ϫ�f���J�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
dejvZ	ddlZdd	lmZe�*Gd
�dej(�ZGd�d
ej,�ZGd�de�ZGd�de
j2�Zy#e$r
er�dZdZY�[wxYw)z+
Tests for L{twisted.internet.serialport}.
�N)�Protocol)�	DoNothing)�Failure)�platform)�unittest�TWISTED_FORCE_SERIAL_TESTS)�
serialportc�*��eZdZ�fd�Zd�Zd�Z�xZS)�RegularFileSerialc�@��t�|�|i|��||_||_y�N)�super�__init__�
captured_args�captured_kwargs)�self�args�kwargs�	__class__s   ��L/usr/lib/python3/dist-packages/twisted/internet/test/test_win32serialport.pyrzRegularFileSerial.__init__$s%����G��d�-�f�-�!%�D��#)�D� �c��yr
��rs r�_reconfigurePortz"RegularFileSerial._reconfigurePort)���rc��yr
rrs r�_reconfigure_portz#RegularFileSerial._reconfigure_port,rr)�__name__�
__module__�__qualname__rrr�
__classcell__�rs@rrr#s���	*�
	�	rrc�(��eZdZeZ�fd�Zd�Z�xZS)�RegularFileSerialPortc���|jd�}d|vr|d=tjj|_||j_t
�|�|i|��y)N�cbInQue)�get�serial�win32�COMSTAT�comstatr'rr)rrrr'rs    �rrzRegularFileSerialPort.__init__2sP����j�j��+�G��F�"��9�%�!�<�<�/�/�D�L�#*�D�L�L� ��G��d�-�f�-rc��d|jfS)NT)r,rs r�_clearCommErrorz%RegularFileSerialPort._clearCommError=s������%�%r)rr r!r�_serialFactoryrr.r"r#s@rr%r%/s���*��		.�	&rr%c��eZdZd�Zd�Zy)�CollectReceivedProtocolc��g|_yr
)�
received_datars rrz CollectReceivedProtocol.__init__Bs
����rc�:�|jj|�yr
)r3�append)r�datas  r�dataReceivedz$CollectReceivedProtocol.dataReceivedEs�����!�!�$�'rN)rr r!rr7rrrr1r1As�� �(rr1c��eZdZdZesej�sdZnesdZd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zy)�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�L�t�|_t�|_t	j
�|_tjj|jd�|_d}t|jd�5}|j|�ddd�y#1swYyxYw)N�fake_serials1234�wb)r�protocolr�reactor�tempfile�mkdtemp�	directory�os�path�join�open�write)rr6�fs   r�setUpzWin32SerialPortTests.setUpUss�� �
��
� �{���!�)�)�+����G�G�L�L�����?��	���
�$�)�)�T�
"�	�a�
�G�G�D�M�	�	�	�s�?B�B#c�B�tj|j�yr
)�shutil�rmtreerArs r�tearDownzWin32SerialPortTests.tearDownas���
�
�d�n�n�%rc��t|j|j|j�}|j	|jf|j
j�|j
j}|j	d|d�|j	tj|d�|j	tj|d�|j	tj|d�|j	d|d�|j	d|d�|j	d	|d
�|jttd���y	)zx
        Test correct positional and keyword arguments have been
        passed to the C{serial.Serial} object.
        i�%�baudrate�bytesize�parity�stopbitsr�xonxoff�rtsctsN�timeout�Cleanup)r%r=rCr>�assertEqual�_serialrrr)�	EIGHTBITS�PARITY_NONE�STOPBITS_ONE�connectionLostr�	Exception)r�portrs   r�test_serialPortDefaultArgsz/Win32SerialPortTests.test_serialPortDefaultArgsds
��
%�T�]�]�D�I�I�t�|�|�L�����$�)�)��t�|�|�'A�'A�B����-�-������v�j�1�2�����)�)�6�*�+=�>�����+�+�V�H�-=�>�����,�,�f�Z�.@�A�����F�9�-�.�����F�8�,�-�����v�i�0�1����G�I�i�$8�9�:rc��|jd|jj�t|j|j|j
�}|jd|j�|jd|jj�|j||jj�|jttd���y)z�
        Test the port is connected at initialization time, and
        C{Protocol.makeConnection} has been called on the desired protocol.
        r�rUN)
rVr=�	connectedr%rCr>�	transportr[rr\)rr]s  r�!test_serialPortInitiallyConnectedz6Win32SerialPortTests.test_serialPortInitiallyConnectedws���
	
����D�M�M�3�3�4�$�T�]�]�D�I�I�t�|�|�L������D�N�N�+�����D�M�M�3�3�4�����t�}�}�6�6�7����G�I�i�$8�9�:rc�j�t|j|j|j|��}|j	�|jd�|jd�|jd�|j
�|j
�|jttd���y)N�r=�deviceNameOrPortNumberr>r'rsabcdsABCDrU)
r%r=rCr>�serialReadEventrF�serialWriteEventr[rr\)rr'r]s   r�common_exerciseHandleAccessz0Win32SerialPortTests.common_exerciseHandleAccess�s���$��]�]�#'�9�9��L�L��	
��	
�����
�
�3���
�
�7���
�
�7�������������G�I�i�$8�9�:rc�(�|jd��y�NF�r'�rirs r�test_exerciseHandleAccess_1z0Win32SerialPortTests.test_exerciseHandleAccess_1�s���(�(��(�7rc�(�|jd��y�NTrlrmrs r�test_exerciseHandleAccess_2z0Win32SerialPortTests.test_exerciseHandleAccess_2�s���(�(��(�6rc��t�}t||j|j|��}|j	�|jt
d�|jD���|jttd���y)Nrec3�<K�|]}t|t����y�wr
)�
isinstance�bytes)�.0�ds  r�	<genexpr>zEWin32SerialPortTests.common_serialPortReturnsBytes.<locals>.<genexpr>�s����Q�Q�J�q�%�0�Q�s�rU)r1r%rCr>rg�
assertTrue�allr3r[rr\)rr'r=r]s    r�common_serialPortReturnsBytesz2Win32SerialPortTests.common_serialPortReturnsBytes�sk��*�,��$��#'�9�9��L�L��	
��	
��������Q�(�:P�:P�Q�Q�R����G�I�i�$8�9�:rc�(�|jd��yrk�r{rs r�test_serialPortReturnsBytes_1z2Win32SerialPortTests.test_serialPortReturnsBytes_1�s���*�*�5�*�9rc�(�|jd��yrpr}rs r�test_serialPortReturnsBytes_2z2Win32SerialPortTests.test_serialPortReturnsBytes_2�s���*�*�4�*�8rN)rr r!�__doc__�
testingForcedr�	isWindows�skipr	rHrLr^rcrirnrqr{r~r�rrrr9r9IsY����!�x�!�!�#�3�D��B�D�
�&�;�&;�
;�$8�7�;�:�9rr9)r�rBrJr?�twisted.internet.protocolr�%twisted.internet.test.test_serialportr�twisted.python.failurer�twisted.python.runtimer�
twisted.trialr�environr�r)�twisted.internetr	�ImportError�Serialr�
SerialPortr%r1�TestCaser9rrr�<module>r�s����
�
��.�;�*�+�"�,��
�
�:�
�	��+���
�F�M�M�
�&�
� 5� 5�&�$(�h�(�d9�8�,�,�d9��a���
��J�
�F��s�
B�B"�!B"

Zerion Mini Shell 1.0