ó
[³XMc           @   s   d  Z  d d l m Z d d l m Z e j ƒ  r} d d l m Z m Z d d l	 m
 Z
 d d l m Z m Z m Z m Z n d	 Z
 d e f d „  ƒ  YZ d	 S(
   s'   
Tests for L{twisted.python._inotify}.
iÿÿÿÿ(   t   TestCase(   t   platform(   t   c_intt   c_char_p(   t   _inotify(   t   INotifyErrort   initializeModulet   initt   addt   INotifyTestsc           B   sY   e  Z d  Z e d k r! d Z n  d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   s/   
    Tests for L{twisted.python._inotify}.
    s&   This platform doesn't support INotify.c         C   s-   d d d „  ƒ  Y} |  j  t t | ƒ  ƒ d S(   s‰   
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_init} attribute, L{ImportError} is raised.
        t   libcc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   d  S(   N(    (   t   self(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   inotify_add_watch"   s    c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   inotify_rm_watch$   s    (   t   __name__t
   __module__R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   !   s   	N(    (   t   assertRaisest   ImportErrorR   (   R   R
   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_missingInit   s    c         C   s-   d d d „  ƒ  Y} |  j  t t | ƒ  ƒ d S(   sŽ   
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_add_watch} attribute, L{ImportError} is raised.
        R
   c           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   inotify_init/   s    c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   1   s    (   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   .   s   	N(    (   R   R   R   (   R   R
   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_missingAdd)   s    c         C   s-   d d d „  ƒ  Y} |  j  t t | ƒ  ƒ d S(   s   
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_rm_watch} attribute, L{ImportError} is raised.
        R
   c           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   <   s    c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   >   s    (   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   ;   s   	N(    (   R   R   R   (   R   R
   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_missingRemove6   s    c         C   sI   d d d „  ƒ  Y} | ƒ  } t  | ƒ |  j | j j t t t g ƒ d S(   só   
        If the I{libc} object passed to L{initializeModule} has all
        of the necessary attributes, it sets the C{argtypes} attribute
        of the C{inotify_add_watch} attribute to a list describing the
        argument types.
        R
   c           B   s/   e  Z d  „  Z d „  Z d „  Z e e ƒ Z RS(   c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   K   s    c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   M   s    c         S   s   d  S(   N(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   O   s    (   R   R   R   R   R   t   staticmethod(    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   J   s   			N(    (   R   t   assertEqualsR   t   argtypesR   R   (   R   R
   t   c(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_setAddArgtypesC   s
    	
c         C   s=   d d d „  ƒ  Y} |  j  t d | ƒ  ƒ |  j t t ƒ d S(   sg   
        If C{inotify_init} returns a negative number, L{init} raises
        L{INotifyError}.
        R
   c           B   s   e  Z d  „  Z RS(   c         S   s   d S(   Niÿÿÿÿ(    (   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   ^   s    (   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   ]   s   N(    (   t   patchR   R   R   R   (   R   R
   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_failedInitX   s    c         C   sF   d d d „  ƒ  Y} |  j  t d | ƒ  ƒ |  j t t d d d ƒ d S(   sk   
        If C{inotify_add_watch} returns a negative number, L{add}
        raises L{INotifyError}.
        R
   c           B   s   e  Z d  „  Z RS(   c         S   s   d S(   Niÿÿÿÿ(    (   R   t   fdt   patht   mask(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR   j   s    (   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR
   i   s   i   s   /fooi    N(    (   R   R   R   R   R   (   R   R
   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   test_failedAddWatchd   s    N(   R   R   t   __doc__R   t   Nonet   skipR   R   R   R   R   R    (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyR	      s   						N(   R!   t   twisted.trial.unittestR    t   twisted.python.runtimeR   t   supportsINotifyt   ctypesR   R   t   twisted.pythonR   t   twisted.python._inotifyR   R   R   R   R"   R	   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_inotify.pyt   <module>   s   %