Ñò
‘à"Ic           @   sã   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l Z l Z l	 Z	 d  d k
 Z
 d Z d Z e o d „  Z n
 d „  Z d „  Z d e
 i f d	 „  ƒ  YZ d d
 „ Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   verboset   TestSkippedt   run_unittests   I wish to buy a fish license.
s   For my pet fish, Eric.
c         C   s	   |  GHd  S(   N(    (   t   msg(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt   debug   s    c         C   s   d  S(   N(    (   R   (    (    s*   /mit/python/lib/python2.6/test/test_pty.pyR      s    c         C   sF   |  i  d ƒ o |  i d d ƒ S|  i  d ƒ o |  i d d ƒ S|  S(   Ns   
s   
s   
(   t   endswitht   replace(   t   data(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt   normalize_output   s
    t   PtyTestc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s,   t  i  t  i |  i ƒ |  _ t  i d ƒ d  S(   Ni
   (   t   signalt   SIGALRMt
   handle_sigt	   old_alarmt   alarm(   t   self(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt   setUp/   s    c         C   s'   t  i d ƒ t  i  t  i |  i ƒ d  S(   Ni    (   R
   R   R   R   (   R   (    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt   tearDown5   s    c         C   s   |  i  d ƒ d  S(   Ns   isatty hung(   t   fail(   R   t   sigt   frame(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyR   :   s    c         C   sô  yb t  d ƒ t i ƒ  \ } } t  d | | f ƒ t  d | f ƒ t i | ƒ } t  d | ƒ Wn t j
 o t d ‚ n X|  i t i | ƒ d ƒ t	 i	 | t	 i
 ƒ } t	 i	 | t	 i | t i Bƒ y& t i | d ƒ } |  i d | ƒ Wn/ t j
 o# } | i t i j o ‚  q$n Xt	 i	 | t	 i | ƒ t  d	 ƒ t i | t ƒ t i | d ƒ } |  i d
 t | ƒ ƒ t  d ƒ t i | t d  ƒ t i | t d ƒ t i | d ƒ } |  i d t | ƒ ƒ t i | ƒ t i | ƒ d  S(   Ns   Calling master_open()s#   Got master_fd '%d', slave_name '%s's   Calling slave_open(%r)s   Got slave_fd '%d's,   Pseudo-terminals (seemingly) not functional.s   slave_fd is not a ttyi   t    s   Writing to slave_fds   I wish to buy a fish license.
s   Writing chunked outputi   s   For my pet fish, Eric.
(   R   t   ptyt   master_opent
   slave_opent   OSErrorR   t
   assertTruet   ost   isattyt   fcntlt   F_GETFLt   F_SETFLt
   O_NONBLOCKt   readt   assertEqualst   errnot   EAGAINt   writet   TEST_STRING_1R   t   TEST_STRING_2t   close(   R   t	   master_fdt
   slave_namet   slave_fdt
   orig_flagst   s1t   et   s2(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt
   test_basic=   s@    

	
c         C   s$  t  d ƒ t i ƒ  \ } } | t i j oÄ t i d ƒ p t  d ƒ t i d ƒ n t  d ƒ y t i ƒ  WnV t j
 o t  d ƒ nR t	 j
 o t  d ƒ n6 t  d ƒ t i d ƒ n Xt  d	 ƒ t i d
 ƒ t i d ƒ n$t  d | ƒ xa t
 oY y t i | d ƒ } Wn t j
 o Pn X| p Pn t i i | i d d ƒ ƒ qWt i | d ƒ \ } } | d ?} t  d | | | f ƒ | d j o |  i d ƒ n[ | d
 j o |  i d ƒ n= | d j o |  i d ƒ n | d j o |  i d ƒ n t i | ƒ d  S(   Ns   calling pty.fork()i   s   Child's fd 1 is not a tty?!i   s   In child, calling os.setsid()s   Good: OSError was raised.s   No setsid() available?s   An unexpected error was raised.s   os.setsid() succeeded! (bad!)i   i   s!   Waiting for child (%d) to finish.iP   s   
s   
i    i   s&   Child (%d) exited with status %d (%d).s3   Child raised an unexpected exception in os.setsid()s1   pty.fork() failed to make child a session leader.s8   Child spawned by pty.fork() did not have a tty as stdouts&   pty.fork() failed for unknown reasons.(   R   R   t   forkt   CHILDR   R   t   _exitt   setsidR   t   AttributeErrort   TrueR!   t   syst   stdoutR%   R   t   waitpidR   R(   (   R   t   pidR)   R   t   statust   res(    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt	   test_forkl   sV    






 !

(   t   __name__t
   __module__R   R   R   R0   R=   (    (    (    s*   /mit/python/lib/python2.6/test/test_pty.pyR	   .   s
   				/c         C   s   t  t ƒ d  S(   N(   R   R	   (   R    (    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt	   test_mainÀ   s    t   __main__(   R#   R   R   R   R7   R
   t   test.test_supportR    R   R   t   unittestR&   R'   R   R   t   TestCaseR	   t   NoneR@   R>   (    (    (    s*   /mit/python/lib/python2.6/test/test_pty.pyt   <module>   s"   		’