ó
[³XMc           @   s”   d  Z  d d l Z d d l Z d d l Z y d d l Z Wn e k
 rS d Z n Xd d l m Z d Z d d l
 m Z d e f d „  ƒ  YZ d S(   s;   
Tests for POSIX-based L{IReactorProcess} implementations.
iÿÿÿÿNs   non-POSIX platform(   t   process(   t   TestCaset   FileDescriptorTestsc           B   s&   e  Z d  Z e Z d „  Z d „  Z RS(   s<   
    Tests for L{twisted.internet.process._listOpenFDs}
    c         C   sn   xg t  j ƒ  D]Y } y t j | t j ƒ Wq t k
 re } |  j t j | j d | | j f ƒ q Xq Wd S(   sµ   
        File descriptors returned by L{_listOpenFDs} are mostly open.

        This test assumes that zero-legth writes fail with EBADF on closed
        file descriptors.
        s2   fcntl(%d, F_GETFL) failed with unexpected errno %dN(   R    t   _listOpenFDst   fcntlt   F_GETFLt   IOErrort   assertEqualst   errnot   EBADF(   t   selft   fdt   err(    (    sK   /usr/lib/python2.7/dist-packages/twisted/internet/test/test_posixprocess.pyt   test_openFDs   s    c         C   s¸   t  j ƒ  } x6 t j t j t j f D] } |  j | j ƒ  | ƒ q% Wt t	 j
 ƒ } t	 j | j ƒ  ƒ } z$ | j ƒ  |  j | t  j ƒ  ƒ Wd t	 j | ƒ X|  j | t  j ƒ  ƒ d S(   sB   
        L{_listOpenFDs} lists expected file descriptors.
        N(   R    R   t   syst   stdint   stdoutt   stderrt   assertInt   filenot   filet   ost   devnullt   dupt   closet   assertNotIn(   R
   t   openfdst   fR   (    (    sK   /usr/lib/python2.7/dist-packages/twisted/internet/test/test_posixprocess.pyt   test_expectedFDs,   s    
(   t   __name__t
   __module__t   __doc__t   platformSkipt   skipR   R   (    (    (    sK   /usr/lib/python2.7/dist-packages/twisted/internet/test/test_posixprocess.pyR      s   	(   R   R   R   R   R   t   ImportErrorR    t   twisted.internetR    t   Nonet   twisted.trial.unittestR   R   (    (    (    sK   /usr/lib/python2.7/dist-packages/twisted/internet/test/test_posixprocess.pyt   <module>   s   $
