mò
­fIc           @   s³   d  k  Z  d  k Z d  k Z d  k Z d k l Z l Z l Z l Z y e i	 Wn e
 j
 o e d ‚ n Xd „  Z d „  Z d „  Z d „  Z d „  Z e ƒ  e ƒ  e ƒ  d  S(   N(   s   verifys   verboses   TestSkippeds   TESTFNs-   select.poll not defined -- skipping test_pollc         C   s=   g  } x0 |  D]( \ } } | | @o | i | ƒ q q W| S(   N(   t   matcht   readyt   fdt   modet   flagt   append(   R   R   R   R   R    (    (    t+   /mit/python/lib/python2.4/test/test_poll.pyt   find_ready_matching   s     c          C   sé  d GHt  i ƒ  } d } d }  t |  ƒ } g  } g  } h  }
 h  } xz t | ƒ D]l } t i ƒ  \ } }	 | i | t  i ƒ | i |	 t  i ƒ | i | ƒ | i |	 ƒ |	 |
 | <| | |	 <qN Wx| o| i ƒ  } t | t  i ƒ } | p t d ‚ n t i | ƒ }	 t i |	 |  ƒ | i ƒ  } t | t  i ƒ } | p t d ‚ n t i | ƒ } t i | | ƒ } t t | ƒ | j ƒ | GHt i  |
 | ƒ t i  | ƒ | i! |
 | ƒ | i! | ƒ | i" |
 | ƒ qÁ Wt# ƒ  d GHd S(   si   Basic functional test of poll object

    Create a bunch of pipe and test that poll works with them.
    s   Running poll test 1i   s    This is a test.s   no pipes ready for writings   no pipes ready for readings   Poll test 1 completeN($   t   selectt   pollt   pt	   NUM_PIPESt   MSGt   lent   MSG_LENt   readerst   writerst   r2wt   w2rt   ranget   it   ost   pipet   rdt   wrt   registert   POLLINt   POLLOUTR   R   R   t   ready_writerst   RuntimeErrort   randomt   choicet   writet   ready_readerst   readt   buft   verifyt   closet
   unregistert   removet   poll_unit_tests(   R   R   R   R   R   R   R   R   R!   R   R   R#   R   R
   R   (    (    R   t
   test_poll1   sR      
 c          C   s=  d } y t i | ƒ Wn t j
 o n Xt i ƒ  } | i | ƒ | i ƒ  } t	 | d | t i
 f j ƒ t t d ƒ } | i ƒ  } t i ƒ  } | i | ƒ | i ƒ  } t	 | d d | j ƒ | i ƒ  | i ƒ  } t	 | d | t i
 f j ƒ t i t ƒ t i ƒ  } y | i | ƒ Wn t j
 o n Xd GHy | i | ƒ Wn t j
 o n Xd GHt i ƒ  } y | i d ƒ Wn t j
 o n Xd GHt i ƒ  } d f  d	 „  ƒ  Y}  d
 f  d „  ƒ  Y} y | i |  ƒ  d ƒ Wn t j
 o n Xd GHy | i | ƒ  d ƒ Wn t j
 o n Xd GHd  S(   Ni*   i    t   ws+   Bogus register call did not raise TypeErrors-   Bogus unregister call did not raise TypeErrori   s,   Bogus unregister call did not raise KeyErrort   Nopec           B   s   t  Z RS(   N(   t   __name__t
   __module__(    (    (    R   R+   u   s   t   Almostc           B   s   t  Z d „  Z RS(   Nc         C   s   d S(   Nt   fileno(    (   t   self(    (    R   R/   y   s    (   R,   R-   R/   (    (    (    R   R.   x   s   s(   expected TypeError exception, not raised(   t   FDR   R%   t   OSErrorR   R	   R
   R   t   rR$   t   POLLNVALt   opent   TESTFNt   fR/   R   t   unlinkt	   TypeErrorR&   t   KeyErrort   pollsterR+   R.   (   R+   R7   R.   R;   R
   R3   R1   R   (    (    R   R(   D   sb    
  c          C   sB  d GHd } t i | d ƒ } t i ƒ  }  |  i | t i ƒ xð d d d D]à } t
 o d G| GHn |  i | ƒ } | g  j o qK n | d \ } } | t i @o) | i ƒ  } | d j o	 d GHqK qK qK | t i @oE | i ƒ  } t
 o t | ƒ GHn | p t
 o	 d GHn PqK qK qK d G| GHqK W| i ƒ  d GHd  S(   Ns   Running poll test 2s?   for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; doneR3   i    iè  iÐ  i   i@  i€>  iÿÿÿÿi
   s	   timeout =t    s6   error: pipe seems to be closed, but still returns datat   EOFs)   Unexpected return value from select.poll:s   Poll test 2 complete(   i    iè  iÐ  i   i@  i€>  (   iÿÿÿÿ(   t   cmdR   t   popenR
   R   R	   R;   R   R   t   toutt   verboset   fdlistR   t   flagst   POLLHUPt   readlinet   linet   reprR%   (   R;   RB   R>   RC   R
   R@   R   RF   (    (    R   t
   test_poll2Š   s<     		
c          C   sw   d GHt  i ƒ  } | i d ƒ y | i d d >ƒ Wn t j
 o n Xd GHd d }  |  d j o	 d	 GHn d
 GHd  S(   Ns   Running poll test 3i   l    i@   s-   Expected OverflowError with excessive timeouti   i   i   s   Overflow must have occurreds   Poll test 3 complete(   R   R	   R;   R   t   OverflowErrort   x(   RJ   R;   (    (    R   t
   test_poll3«   s    
	(   t   sysR   R   R   t   test.test_supportR$   RA   t   TestSkippedR6   R	   t   AttributeErrorR   R)   R(   RH   RK   (   R(   RN   RA   R$   R   RL   RH   R6   R)   R   R   R   RK   (    (    R   t   ?   s   $		1	F	!	