
    daf+                        d dl Z d dlZd dlZd dlZd dlZd dlmZ  ed      Z ej                   e	ed      d       G d dej                               Z G d d	ej                        Zed
k(  r ej                          yy)    N)import_moduletermiosopenptyzneed os.openpty()c                   x    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestFunctionsc                 J   t        j                         \  }| _        | j                  t         j                  |       | j                  t        | j                  dd            | _        | j                  t        j                  dd            }|j                         | _        y )Nwbr   )	buffering)moder
   )osr   fd
addCleanupcloseenterContextopenstreamtempfileTemporaryFilefilenobad_fd)self	master_fdtmps      ,/root/Python-3.12.4/Lib/test/test_termios.pysetUpzTestFunctions.setUp   so    ZZ\	47),''TWWda(HI 6 6DA NOjjl    c                     | j                  t        j                        5 } ||  d d d        | j                  j                  j
                  d   |       y # 1 sw Y   3xY w)Nr   )assertRaisesr   errorassertEqual	exceptionargs)r   errnocallabler"   cms        r   assertRaisesTermiosErrorz&TestFunctions.assertRaisesTermiosError   sQ    w}}- 	dO	**1-u5	 	s   AA!c                    t         j                  | j                        }| j                  |t               | j                  t        |      d       t        d      D ]  }| j                  ||   t                |\  }}}}}}}	| j                  |	t               | j                  t        |	      t         j                         t        |	      D ]  \  }}
|t         j                  z  dk(  r=|t         j                  k(  s|t         j                  k(  r| j                  |
t               Y| j                  |
t               | j                  t        |
      d        | j                  t         j                  | j                        |       y )N      r      )r   	tcgetattrr   assertIsInstancelistr    lenrangeintNCCS	enumerateICANONVMINVTIMEbytesr   )r   attrsiiflagoflagcflaglflagispeedospeedccxs              r   test_tcgetattrzTestFunctions.test_tcgetattr   s1   !!$''*eT*UQ'q 	1A!!%(C0	19>6ueUFFBb$'R',,/bM 	,DAq'A-gll"a7==&8%%a-%%a/  Q+	, 	**4;;7?r   c                    | j                  t        j                  t        j                  | j
                         | j                  t        t        j                  d       | j                  t        t        j                  ddz         | j                  t        t        j                  t                      | j                  t        t        j                         y N     )r&   r#   ENOTTYr   r+   r   r   
ValueErrorOverflowError	TypeErrorobjectr   s    r   test_tcgetattr_errorsz#TestFunctions.test_tcgetattr_errors,   s    %%ellG4E4Et{{S*g&7&7<-):):AtGD)W%6%6A)W%6%67r   c                    t         j                  | j                        }t         j                  | j                  t         j                  |       t         j                  | j                  t         j
                  |       t         j                  | j                  t         j                  |       t         j                  | j                  t         j                  |       y N)r   r+   r   	tcsetattrTCSANOW	TCSADRAIN	TCSAFLUSHr   )r   r7   s     r   test_tcsetattrzTestFunctions.test_tcsetattr3   s    !!$''*$''7??E:$''7#4#4e<$''7#4#4e<$++w>r   c           
         t         j                  | j                        }| j                  t        t         j
                  | j                  t         j                  t        |             | j                  t        t         j
                  | j                  t         j                  |d d        | j                  t        t         j
                  | j                  t         j                  |dgz          t        d      D ]  }|d d  }ddz  ||<   | j                  t        t         j
                  | j                  t         j                  |       t               ||<   | j                  t        t         j
                  | j                  t         j                  |        | j                  t        t         j
                  | j                  t         j                  |d d |d   d d gz          | j                  t        t         j
                  | j                  t         j                  |d d |d   dgz   gz          t        t        |d               D ]:  }|d d  }|d   d d  |d<   ddz  |d   |<   | j                  t        t         j
                  | j                  t         j                  |       t               |d   |<   | j                  t        t         j
                  | j                  t         j                  |       d|d   |<   | j                  t        t         j
                  | j                  t         j                  |       d|d   |<   | j                  t        t         j
                  | j                  t         j                  |       = | j                  t        t         j
                  | j                  t         j                  t                      | j                  t        t         j
                  | j                  t         j                         | j                  t        j                  t         j
                  | j                  d|       | j                  t        t         j
                  | j                  ddz  |       | j                  t        t         j
                  | j                  t               |       | j                  t        j                  t         j
                  | j                   t         j                  |       | j                  t"        t         j
                  dt         j                  |       | j                  t        t         j
                  ddz  t         j                  |       | j                  t        t         j
                  t               t         j                  |       | j                  t        t         j
                  | j                  t         j                         y )	NrD   r   r)   rE   rF       r   s     )r   r+   r   r   rJ   rP   rQ   tupler/   rI   rK   r.   r&   r#   EINVALrG   r   rH   )r   r7   r8   attrs2s       r   test_tcsetattr_errorsz#TestFunctions.test_tcsetattr_errors:   s   !!$''*)W%6%6RWX]R^_)W%6%6RWX[Y[R\])W%6%6RW[\Z]R]^q 	^A1XF4F1ImW->->Z`aF1Ii):):DGGW__V\]	^ 	)W%6%6RWX[Y[R\`efh`ijmkm`n_oRop)W%6%6RWX[Y[R\`efh`imrls`s_tRtus59~& 
	^A1XFAF2JtGF2JqMmW->->Z`a"HF2JqMi):):DGGW__V\]F2JqMi):):DGGW__V\]#F2JqMi):):DGGW__V\]
	^ 	)W%6%6RXRZ[)W%6%6Q%%ellG4E4EtwwPRTYZ-):):DGGQWeT)W%6%65Q%%ellG4E4Et{{T[TcTcejk*g&7&7W__eT-):):AtGW__V[\)W%6%6'//SXY)W%6%6Qr   c                 ^   	 t         j                  | j                  d       t         j                  | j                  d       y # t         j                  $ rV}|j                  d   t
        j                  k(  r0t        j                  j                  d      r| j                  d        d }~ww xY w)Nr*   r   freebsdzQtermios.tcsendbreak() is not supported with pseudo-terminals (?) on this platform)r   tcsendbreakr   r   r"   r#   rG   sysplatform
startswithskipTestr   )r   excs     r   test_tcsendbreakzTestFunctions.test_tcsendbreak]   s    	+ 	DKK+ }} 	xx{ell*s||/F/Fy/Q K L		s    A B,AB''B,c                    | j                  t        t        j                  | j                  ddz         | j                  t
        t        j                  | j                  d       | j                  t
        t        j                  | j                  t                      | j                  t        j                  t        j                  | j                  d       | j                  t        t        j                  dd       | j                  t        t        j                  ddz  d       | j                  t
        t        j                  t               d       | j                  t
        t        j                  | j                         y )NrE   rF   g        r   rD   )r   rI   r   r]   r   rJ   rK   r&   r#   rG   r   rH   rL   s    r   test_tcsendbreak_errorsz%TestFunctions.test_tcsendbreak_errorsg   s    -)<)<dggq$wO)W%8%8$''3G)W%8%8$''68L%%ellG4G4GVWX*g&9&92qA-)<)<agqI)W%8%8&(AF)W%8%8$''Br   c                     t         j                  | j                         t         j                  | j                         y rO   )r   tcdrainr   r   rL   s    r   test_tcdrainzTestFunctions.test_tcdrainq   s"     $r   c                    | j                  t        j                  t        j                  | j
                         | j                  t        t        j                  d       | j                  t        t        j                  ddz         | j                  t        t        j                  t                      | j                  t        t        j                         y rC   )r&   r#   rG   r   rg   r   r   rH   rI   rJ   rK   rL   s    r   test_tcdrain_errorsz!TestFunctions.test_tcdrain_errorsu   s|    %%ellGOOT[[Q*goor:-!T'B)W__fh?)W__5r   c                    t         j                  | j                  t         j                         t         j                  | j                  t         j                         t         j                  | j                  t         j
                         y rO   )r   tcflushr   TCIFLUSHTCOFLUSH	TCIOFLUSHrL   s    r   test_tcflushzTestFunctions.test_tcflush|   sJ    !1!12!1!12!2!23r   c                    | j                  t        j                  t        j                  | j
                  d       | j                  t        t        j                  | j
                  ddz         | j                  t        t        j                  | j
                  t                      | j                  t        j                  t        j                  | j                  t        j                         | j                  t        t        j                  dt        j                         | j                  t        t        j                  ddz  t        j                         | j                  t        t        j                  t               t        j                         | j                  t        t        j                  | j
                         y rC   )r&   r#   rX   r   rl   r   r   rI   rJ   rK   rG   r   rm   rH   rL   s    r   test_tcflush_errorsz!TestFunctions.test_tcflush_errors   s   %%ellGOOTWWbQ-$''1d7K)W__dggvxH%%ellGOOT[[RYRbRbc*goor7;K;KL-!T'7CSCST)W__fh@P@PQ)W__dgg>r   c                 t   t         j                  | j                  t         j                         t         j                  | j                  t         j                         t         j                  | j                  t         j
                         t         j                  | j                  t         j                         y rO   )r   tcflowr   TCOOFFTCOONTCIOFFTCIONrL   s    r   test_tcflowzTestFunctions.test_tcflow   sZ    tww/tww.tww/tww.r   c                    | j                  t        j                  t        j                  | j
                  d       | j                  t        t        j                  | j
                  ddz         | j                  t        t        j                  | j
                  t                      | j                  t        j                  t        j                  | j                  t        j                         | j                  t        t        j                  dt        j                         | j                  t        t        j                  ddz  t        j                         | j                  t        t        j                  t               t        j                         | j                  t        t        j                  | j
                         y rC   )r&   r#   rX   r   rt   r   r   rI   rJ   rK   rG   r   rv   rH   rL   s    r   test_tcflow_errorsz TestFunctions.test_tcflow_errors   s    %%ellGNNDGGRP-!T'J)W^^TWWfhG%%ellGNNDKKQXQ^Q^_*gnnb'--H-D'--P)W^^VXw}}M)W^^TWW=r   c                 f   t         j                  | j                        }| j                  |t               | j                  t        |      d       | j                  |d   t               | j                  |d   t               | j                  t         j                  | j                        |       y )NrE   r   r*   )	r   tcgetwinsizer   r,   rW   r    r.   r0   r   r   sizes     r   test_tcgetwinsizezTestFunctions.test_tcgetwinsize   s    ##DGG,dE*TA&d1gs+d1gs+--dkk:DAr   c                    | j                  t        j                  t        j                  | j
                         | j                  t        t        j                  d       | j                  t        t        j                  ddz         | j                  t        t        j                  t                      | j                  t        t        j                         y rC   )r&   r#   rG   r   r}   r   r   rH   rI   rJ   rK   rL   s    r   test_tcgetwinsize_errorsz&TestFunctions.test_tcgetwinsize_errors   s    %%ellG4H4H$++V*g&:&:B?-)=)=q$wG)W%9%968D)W%9%9:r   c                    t         j                  | j                        }t         j                  | j                  |       t         j                  | j                  t	        |             t         j                  | j
                  |       y rO   )r   r}   r   tcsetwinsizer-   r   r~   s     r   test_tcsetwinsizezTestFunctions.test_tcsetwinsize   sV    ##DGG,TWWd+TWWd4j1T[[$/r   c           
      "   t         j                  | j                        }| j                  t        t         j
                  | j                  |d d        | j                  t        t         j
                  | j                  |dz          | j                  t        t         j
                  | j                  t                      | j                  t        t         j
                  | j                  |d   ddz  f       | j                  t        t         j
                  | j                  |d   t        |d         f       | j                  t        t         j
                  | j                  |d   t               f       | j                  t        t         j
                  | j                  ddz  |d   f       | j                  t        t         j
                  | j                  t        |d         |d   f       | j                  t        t         j
                  | j                  t               |d   f       | j                  t        j                  t         j
                  | j                  |       | j                  t        t         j
                  d|       | j                  t        t         j
                  ddz  |       | j                  t        t         j
                  t               |       | j                  t        t         j
                  | j                         y )NrD   )r   r   rE   rF   r*   )r   r}   r   r   rJ   r   rK   rI   floatr&   r#   rG   r   rH   r~   s     r   test_tcsetwinsize_errorsz&TestFunctions.test_tcsetwinsize_errors   s#   ##DGG,)W%9%9477D"IN)W%9%9477D4KP)W%9%9477FHM-)=)=twwaRSUYRYHZ[)W%9%9477T!WeTXYZT[nD]^)W%9%9477T!WfhDWX-)=)=twwDRVWXRYHZ[)W%9%9477U4PQ7^UYZ[U\D]^)W%9%9477VXtTUwDWX%%ellG4H4H$++W[\*g&:&:BE-)=)=q$wM)W%9%968TJ)W%9%9477Cr   N)__name__
__module____qualname__r   r&   rA   rM   rT   rZ   rc   re   rh   rj   rp   rr   ry   r{   r   r   r   r    r   r   r   r      sb    #6
@$8?!RF,C%64
?/>B;0Dr   r   c                       e Zd Zd Zd Zy)
TestModulec                    | j                  t        j                  t               | j                  t        j                  t               | j                  t        j
                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                   t               | j                  t        j"                  t               | j%                  t        j                  t        j"                         | j%                  t        j                   t        j"                         y rO   )r,   r   B0r0   B38400rQ   rR   rS   rm   rn   ro   ru   rv   rw   rx   r5   r4   r1   
assertLessrL   s    r   test_constantszTestModule.test_constants   sd   gjj#.gnnc2goos3g//5g//5g..4g..4g//5gnnc2gmmS1gnnc2gmmS1gmmS1gllC0gllC0w||4gll3r   c                     | j                  t        t        j                  t                     | j                  t        t        j                  t                     y rO   )
assertTrue
issubclassr   r   	ExceptionassertFalseOSErrorrL   s    r   test_exceptionzTestModule.test_exception   s2    
7==)<=GMM7;<r   N)r   r   r   r   r   r   r   r   r   r      s    4&=r   r   __main__)r#   r   r^   r   unittesttest.support.import_helperr   r   
skipUnlesshasattrTestCaser   r   r   mainr   r   r   <module>r      s     	 
   4
	
" WR+-@AsDH%% sD BsDl="" =2 zHMMO r   