
    Vh~                         d Z ddlmZ ddlmZ ddlmZ 	 ddlmZ eZ	e	r( ej                         rddlmZmZmZ ddlmZmZmZmZ ndZ	 G d	 d
e      Zy# e
$ r dZ	Y Aw xY w)z'
Tests for L{twisted.python._inotify}.
    )FilePath)platform)TestCase)_inotifyN)c_char_pc_intc_uint32)INotifyErroraddinitinitializeModulec                   <    e Zd ZdZedZd Zd Zd Zd Z	d Z
d	 Zy)
INotifyTestsz/
    Tests for L{twisted.python._inotify}.
    Nz&This platform doesn't support INotify.c                 X     G d d      }| j                  t        t         |              y)z
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_init} attribute, L{ImportError} is raised.
        c                       e Zd Zd Zd Zy)+INotifyTests.test_missingInit.<locals>.libcc                      y N selfs    P/home/dcms/DCMS/lib/python3.12/site-packages/twisted/python/test/test_inotify.pyinotify_add_watchz=INotifyTests.test_missingInit.<locals>.libc.inotify_add_watch*           c                      y r   r   r   s    r   inotify_rm_watchz<INotifyTests.test_missingInit.<locals>.libc.inotify_rm_watch-   r   r   N)__name__
__module____qualname__r   r   r   r   r   libcr   )       r   r!   NassertRaisesImportErrorr   r   r!   s     r   test_missingInitzINotifyTests.test_missingInit#   #    	 	 	+'7@r   c                 X     G d d      }| j                  t        t         |              y)z
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_add_watch} attribute, L{ImportError} is raised.
        c                       e Zd Zd Zd Zy)*INotifyTests.test_missingAdd.<locals>.libcc                      y r   r   r   s    r   inotify_initz7INotifyTests.test_missingAdd.<locals>.libc.inotify_init9   r   r   c                      y r   r   r   s    r   r   z;INotifyTests.test_missingAdd.<locals>.libc.inotify_rm_watch<   r   r   N)r   r   r    r-   r   r   r   r   r!   r+   8   r"   r   r!   Nr#   r&   s     r   test_missingAddzINotifyTests.test_missingAdd2   r(   r   c                 X     G d d      }| j                  t        t         |              y)z
        If the I{libc} object passed to L{initializeModule} has no
        C{inotify_rm_watch} attribute, L{ImportError} is raised.
        c                       e Zd Zd Zd Zy)-INotifyTests.test_missingRemove.<locals>.libcc                      y r   r   r   s    r   r-   z:INotifyTests.test_missingRemove.<locals>.libc.inotify_initH   r   r   c                      y r   r   r   s    r   r   z?INotifyTests.test_missingRemove.<locals>.libc.inotify_add_watchK   r   r   N)r   r   r    r-   r   r   r   r   r!   r2   G   r"   r   r!   Nr#   r&   s     r   test_missingRemovezINotifyTests.test_missingRemoveA   r(   r   c                 N    G d d      } |       }t        |       | j                  |j                  j                  g        | j                  |j                  j                  t
               | j                  |j                  j                  t
        t
        g       | j                  |j                  j                  t
               | j                  |j                  j                  t
        t        t        g       | j                  |j                  j                  t
               y)z
        If the I{libc} object passed to L{initializeModule} has all of the
        necessary attributes, it sets the C{argtypes} and C{restype} attributes
        of the three ctypes methods used from libc.
        c                   N    e Zd Zd Z ee      Zd Z ee      Zd Z ee      Zy)(INotifyTests.test_setTypes.<locals>.libcc                      y r   r   r   s    r   r-   z5INotifyTests.test_setTypes.<locals>.libc.inotify_initX   r   r   c                      y r   r   r   s    r   r   z9INotifyTests.test_setTypes.<locals>.libc.inotify_rm_watch]   r   r   c                      y r   r   r   s    r   r   z:INotifyTests.test_setTypes.<locals>.libc.inotify_add_watchb   r   r   N)r   r   r    r-   staticmethodr   r   r   r   r   r!   r8   W   s9     (5L  ,,<= !--> ?r   r!   N)
r   assertEqualr-   argtypesrestyper   r   r   r   r	   )r   r!   cs      r   test_setTypeszINotifyTests.test_setTypesP   s    	@ 	@  F00"5//7++44uenE++33U;,,55x7RS,,44e<r   c                      G d d      }| j                  t        d |              | j                  t        t               y)zg
        If C{inotify_init} returns a negative number, L{init} raises
        L{INotifyError}.
        c                       e Zd Zd Zy)*INotifyTests.test_failedInit.<locals>.libcc                      yNr   r   s    r   r-   z7INotifyTests.test_failedInit.<locals>.libc.inotify_inity       r   N)r   r   r    r-   r   r   r   r!   rD   x       r   r!   N)patchinotifyr$   r
   r   r&   s     r   test_failedInitzINotifyTests.test_failedInitr   s0    	 	 	

7FDF+,-r   c                      G d d      }| j                  t        d |              | j                  t        t        dt        d      d       y)zk
        If C{inotify_add_watch} returns a negative number, L{add}
        raises L{INotifyError}.
        c                       e Zd Zd Zy).INotifyTests.test_failedAddWatch.<locals>.libcc                      yrF   r   )r   fdpathmasks       r   r   z@INotifyTests.test_failedAddWatch.<locals>.libc.inotify_add_watch   rH   r   N)r   r   r    r   r   r   r   r!   rO      rI   r   r!      z/foor   N)rJ   rK   r$   r
   r   r   r&   s     r   test_failedAddWatchz INotifyTests.test_failedAddWatch   s;    	 	 	

7FDF+,Q0@!Dr   )r   r   r    __doc__rK   skipr'   r/   r5   rA   rL   rU   r   r   r   r   r      s6     7AAA =D.Er   r   )rV   twisted.python.filepathr   twisted.python.runtimer   twisted.trial.unittestr   twisted.pythonr   rK   r%   supportsINotifyctypesr   r   r	   twisted.python._inotifyr
   r   r   r   r   r   r   r   <module>r_      sl    - + +' G
'x'')00QQGoE8 oE  Gs   A A A 