§
    Ètºfº  ã                   ó>  — d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dej        v Z	 ddlZdd	lmZ n# e$ r
 er‚ dZdZY nw xY we�& G d
„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ de¦  «        Z G d„ dej        ¦  «        ZdS )z+
Tests for L{twisted.internet.serialport}.
é    N)ÚProtocol)Ú	DoNothing)ÚFailure)Úplatform)ÚunittestÚTWISTED_FORCE_SERIAL_TESTS)Ú
serialportc                   ó*   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zˆ xZS )ÚRegularFileSerialc                 óV   •—  t          ¦   «         j        |i |¤Ž || _        || _        d S ©N)ÚsuperÚ__init__Úcaptured_argsÚcaptured_kwargs)ÚselfÚargsÚkwargsÚ	__class__s      €úi/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/test/test_win32serialport.pyr   zRegularFileSerial.__init__$   s5   ø€ Ø�E‰GŒGÔ˜dÐ- fÐ-Ð-Ð-Ø!%ˆDÔØ#)ˆDÔ Ð Ð ó    c                 ó   — d S r   © ©r   s    r   Ú_reconfigurePortz"RegularFileSerial._reconfigurePort)   ó   € ØˆDr   c                 ó   — d S r   r   r   s    r   Ú_reconfigure_portz#RegularFileSerial._reconfigure_port,   r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   Ú__classcell__©r   s   @r   r   r   #   sV   ø€ € € € € ð	*ð 	*ð 	*ð 	*ð 	*ð
	ð 	ð 	ð	ð 	ð 	ð 	ð 	ð 	ð 	r   r   c                   ó(   ‡ — e Zd ZeZˆ fd„Zd„ Zˆ xZS )ÚRegularFileSerialPortc                 ó¶   •— |                      d¦  «        }d|v r|d= t          j        j        | _        || j        _         t          ¦   «         j        |i |¤Ž d S )NÚcbInQue)ÚgetÚserialÚwin32ÚCOMSTATÚcomstatr'   r   r   )r   r   r   r'   r   s       €r   r   zRegularFileSerialPort.__init__2   s_   ø€ Ø—j’j Ñ+Ô+ˆGà˜FÐ"Ð"Ø˜9Ð%å!œ<Ô/ˆDŒLØ#*ˆDŒLÔ à�E‰GŒGÔ˜dÐ- fÐ-Ð-Ð-Ð-Ð-r   c                 ó   — d| j         fS )NT)r,   r   s    r   Ú_clearCommErrorz%RegularFileSerialPort._clearCommError=   s   € Ø˜œÐ%Ð%r   )r   r    r!   r   Ú_serialFactoryr   r.   r"   r#   s   @r   r%   r%   /   sL   ø€ € € € € Ø*ˆð		.ð 		.ð 		.ð 		.ð 		.ð	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&r   r%   c                   ó   — e Zd Zd„ Zd„ ZdS )ÚCollectReceivedProtocolc                 ó   — g | _         d S r   )Úreceived_datar   s    r   r   z CollectReceivedProtocol.__init__B   s   € ØˆÔÐÐr   c                 ó:   — | j                              |¦  «         d S r   )r3   Úappend)r   Údatas     r   ÚdataReceivedz$CollectReceivedProtocol.dataReceivedE   s   € ØÔ×!Ò! $Ñ'Ô'Ð'Ð'Ð'r   N)r   r    r!   r   r7   r   r   r   r1   r1   A   s2   € € € € € ð ð  ð  ð(ð (ð (ð (ð (r   r1   c                   ó~   — e Zd ZdZes ej        ¦   «         sdZnesdZd„ Z	d„ Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ ZdS )ÚWin32SerialPortTestszB
    Minimal testing for Twisted's Win32 serial port support.
    zThis test must run on Windows.z-Windows serial port support is not available.c                 ó`  — t          ¦   «         | _        t          ¦   «         | _        t	          j        ¦   «         | _        t          j         	                    | j        d¦  «        | _        d}t          | j        d¦  «        5 }|                     |¦  «         d d d ¦  «         d S # 1 swxY w Y   d S )NÚfake_serials   1234Úwb)r   Úprotocolr   ÚreactorÚtempfileÚmkdtempÚ	directoryÚosÚpathÚjoinÚopenÚwrite)r   r6   Úfs      r   ÚsetUpzWin32SerialPortTests.setUpU   sÈ   € å ™
œ
ˆŒÝ ‘{”{ˆŒå!Ô)Ñ+Ô+ˆŒÝ”G—L’L ¤°Ñ?Ô?ˆŒ	àˆÝ�$”)˜TÑ"Ô"ð 	 aØ�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   Â B#Â#B'Â*B'c                 ó8   — t          j        | j        ¦  «         d S r   )ÚshutilÚrmtreerA   r   s    r   ÚtearDownzWin32SerialPortTests.tearDowna   s   € ÝŒ�d”nÑ%Ô%Ð%Ð%Ð%r   c                 óÌ  — t          | j        | j        | j        ¦  «        }|                      | j        f|j        j        ¦  «         |j        j        }|                      d|d         ¦  «         |                      t          j	        |d         ¦  «         |                      t          j
        |d         ¦  «         |                      t          j        |d         ¦  «         |                      d|d         ¦  «         |                      d|d         ¦  «         |                      d	|d
         ¦  «         |                     t          t          d¦  «        ¦  «        ¦  «         d	S )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=   rC   r>   ÚassertEqualÚ_serialr   r   r)   Ú	EIGHTBITSÚPARITY_NONEÚSTOPBITS_ONEÚconnectionLostr   Ú	Exception)r   Úportr   s      r   Útest_serialPortDefaultArgsz/Win32SerialPortTests.test_serialPortDefaultArgsd   s4  € õ
 % T¤]°D´I¸t¼|ÑLÔLˆà×Ò˜$œ)˜ t¤|Ô'AÑBÔBÐBà”Ô-ˆØ×Ò˜˜v jÔ1Ñ2Ô2Ð2Ø×Ò�Ô)¨6°*Ô+=Ñ>Ô>Ð>Ø×Ò�Ô+¨V°HÔ-=Ñ>Ô>Ð>Ø×Ò�Ô,¨f°ZÔ.@ÑAÔAÐAØ×Ò˜˜F 9Ô-Ñ.Ô.Ð.Ø×Ò˜˜F 8Ô,Ñ-Ô-Ð-Ø×Ò˜˜v iÔ0Ñ1Ô1Ð1Ø×Ò�G¥I¨iÑ$8Ô$8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r   c                 óš  — |                       d| j        j        ¦  «         t          | j        | j        | j        ¦  «        }|                       d|j        ¦  «         |                       d| j        j        ¦  «         |                       || j        j        ¦  «         |                     t          t          d¦  «        ¦  «        ¦  «         dS )z”
        Test the port is connected at initialization time, and
        C{Protocol.makeConnection} has been called on the desired protocol.
        r   é   rU   N)
rV   r=   Ú	connectedr%   rC   r>   Ú	transportr[   r   r\   )r   r]   s     r   Ú!test_serialPortInitiallyConnectedz6Win32SerialPortTests.test_serialPortInitiallyConnectedw   s®   € ð
 	×Ò˜˜DœMÔ3Ñ4Ô4Ð4å$ T¤]°D´I¸t¼|ÑLÔLˆØ×Ò˜˜DœNÑ+Ô+Ð+Ø×Ò˜˜DœMÔ3Ñ4Ô4Ð4Ø×Ò˜˜tœ}Ô6Ñ7Ô7Ð7Ø×Ò�G¥I¨iÑ$8Ô$8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r   c                 óž  — t          | j        | j        | j        |¬¦  «        }|                     ¦   «          |                     d¦  «         |                     d¦  «         |                     d¦  «         |                     ¦   «          |                     ¦   «          |                     t          t          d¦  «        ¦  «        ¦  «         d S )N©r=   ÚdeviceNameOrPortNumberr>   r'   r   s   abcds   ABCDrU   )
r%   r=   rC   r>   ÚserialReadEventrF   ÚserialWriteEventr[   r   r\   )r   r'   r]   s      r   Úcommon_exerciseHandleAccessz0Win32SerialPortTests.common_exerciseHandleAccess„   s½   € Ý$Ø”]Ø#'¤9Ø”LØð	
ñ 
ô 
ˆð 	×ÒÑÔÐØ�
Š
�3‰ŒˆØ�
Š
�7ÑÔÐØ�
Š
�7ÑÔÐØ×ÒÑÔÐØ×ÒÑÔÐØ×Ò�G¥I¨iÑ$8Ô$8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r   c                 ó2   — |                       d¬¦  «         d S ©NF©r'   ©ri   r   s    r   Útest_exerciseHandleAccess_1z0Win32SerialPortTests.test_exerciseHandleAccess_1–   s   € Ø×(Ò(°Ð(Ñ7Ô7Ð7Ð7Ð7r   c                 ó2   — |                       d¬¦  «         d S ©NTrl   rm   r   s    r   Útest_exerciseHandleAccess_2z0Win32SerialPortTests.test_exerciseHandleAccess_2™   s   € Ø×(Ò(°Ð(Ñ6Ô6Ð6Ð6Ð6r   c                 óD  — t          ¦   «         }t          || j        | j        |¬¦  «        }|                     ¦   «          |                      t          d„ |j        D ¦   «         ¦  «        ¦  «         |                     t          t          d¦  «        ¦  «        ¦  «         d S )Nre   c              3   ó@   K  — | ]}t          |t          ¦  «        V — Œd S r   )Ú
isinstanceÚbytes)Ú.0Úds     r   ú	<genexpr>zEWin32SerialPortTests.common_serialPortReturnsBytes.<locals>.<genexpr>¦   s,   è è € ÐQÐQ°Q�J q­%Ñ0Ô0ÐQÐQÐQÐQÐQÐQr   rU   )r1   r%   rC   r>   rg   Ú
assertTrueÚallr3   r[   r   r\   )r   r'   r=   r]   s       r   Úcommon_serialPortReturnsBytesz2Win32SerialPortTests.common_serialPortReturnsBytesœ   s›   € Ý*Ñ,Ô,ˆå$ØØ#'¤9Ø”LØð	
ñ 
ô 
ˆð 	×ÒÑÔÐØ�Š�ÐQÐQ¸(Ô:PÐQÑQÔQÑQÔQÑRÔRÐRØ×Ò�G¥I¨iÑ$8Ô$8Ñ9Ô9Ñ:Ô:Ð:Ð:Ð:r   c                 ó2   — |                       d¬¦  «         d S rk   ©r{   r   s    r   Útest_serialPortReturnsBytes_1z2Win32SerialPortTests.test_serialPortReturnsBytes_1©   s   € Ø×*Ò*°5Ð*Ñ9Ô9Ð9Ð9Ð9r   c                 ó2   — |                       d¬¦  «         d S rp   r}   r   s    r   Útest_serialPortReturnsBytes_2z2Win32SerialPortTests.test_serialPortReturnsBytes_2¬   s   € Ø×*Ò*°4Ð*Ñ8Ô8Ð8Ð8Ð8r   N)r   r    r!   Ú__doc__ÚtestingForcedr   Ú	isWindowsÚskipr	   rH   rL   r^   rc   ri   rn   rq   r{   r~   r€   r   r   r   r9   r9   I   sè   € € € € € ðð ð ð CØ!ˆxÔ!Ñ#Ô#ð 	CØ3ˆDˆDàð 	CØBˆDð
ð 
ð 
ð&ð &ð &ð;ð ;ð ;ð&;ð ;ð ;ð;ð ;ð ;ð$8ð 8ð 8ð7ð 7ð 7ð;ð ;ð ;ð:ð :ð :ð9ð 9ð 9ð 9ð 9r   r9   )r�   rB   rJ   r?   Útwisted.internet.protocolr   Ú%twisted.internet.test.test_serialportr   Útwisted.python.failurer   Útwisted.python.runtimer   Útwisted.trialr   Úenvironr‚   r)   Útwisted.internetr	   ÚImportErrorÚSerialr   Ú
SerialPortr%   r1   ÚTestCaser9   r   r   r   ú<module>r�      sµ  ððð ð 
€	€	€	Ø €€€Ø €€€à .Ð .Ð .Ð .Ð .Ð .Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø *Ð *Ð *Ð *Ð *Ð *Ø +Ð +Ð +Ð +Ð +Ð +Ø "Ð "Ð "Ð "Ð "Ð "à,°´
Ð:€ð	Ø€M€M€Mà+Ð+Ð+Ð+Ð+Ð+Ð+øØð ð ð Øð Øà€JØ€F€F€Fðøøøð Ðð
ð 
ð 
ð 
ð 
˜FœMñ 
ô 
ð 
ð&ð &ð &ð &ð & 
Ô 5ñ &ô &ð &ð$(ð (ð (ð (ð (˜hñ (ô (ð (ðd9ð d9ð d9ð d9ð d9˜8Ô,ñ d9ô d9ð d9ð d9ð d9s   ·
A ÁAÁA