
    tf~                         d Z ddlmZ ddlmZ ddlmZ 	 ddlmZ eZ	n# e
$ r dZ	Y nw xY w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dS )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dS )
INotifyTestsz/
    Tests for L{twisted.python._inotify}.
    Nz&This platform doesn't support INotify.c                 r     G d d          }|                      t          t           |                       dS )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dS )+INotifyTests.test_missingInit.<locals>.libcc                     d S N selfs    _/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/test/test_inotify.pyinotify_add_watchz=INotifyTests.test_missingInit.<locals>.libc.inotify_add_watch*           c                     d S 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   )   2              r   r!   NassertRaisesImportErrorr   r   r!   s     r   test_missingInitzINotifyTests.test_missingInit#   Q    	 	 	 	 	 	 	 	 	+'7@@@@@r   c                 r     G d d          }|                      t          t           |                       dS )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dS )*INotifyTests.test_missingAdd.<locals>.libcc                     d S r   r   r   s    r   inotify_initz7INotifyTests.test_missingAdd.<locals>.libc.inotify_init9   r   r   c                     d S 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                 r     G d d          }|                      t          t           |                       dS )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dS )-INotifyTests.test_missingRemove.<locals>.libcc                     d S r   r   r   s    r   r-   z:INotifyTests.test_missingRemove.<locals>.libc.inotify_initH   r   r   c                     d S 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                 ,    G d d          } |            }t          |           |                     |j        j        g            |                     |j        j        t
                     |                     |j        j        t
          t
          g           |                     |j        j        t
                     |                     |j        j        t
          t          t          g           |                     |j        j        t
                     dS )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                   b    e Zd Zd Z ee          Zd Z ee          Zd Z ee          ZdS )(INotifyTests.test_setTypes.<locals>.libcc                     d S r   r   r   s    r   r-   z5INotifyTests.test_setTypes.<locals>.libc.inotify_initX   r   r   c                     d S r   r   r   s    r   r   z9INotifyTests.test_setTypes.<locals>.libc.inotify_rm_watch]   r   r   c                     d S 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   st           (<55L    ,|,<==   !--> ? ?r   r!   N)
r   assertEqualr-   argtypesrestyper   r   r   r   r	   )r   r!   cs      r   test_setTypeszINotifyTests.test_setTypesP   s   	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@  DFF0"555/777+4uenEEE+3U;;;,5x7RSSS,4e<<<<<r   c                      G d d          }|                      t          d |                       |                     t          t                     dS )zg
        If C{inotify_init} returns a negative number, L{init} raises
        L{INotifyError}.
        c                       e Zd Zd ZdS )*INotifyTests.test_failedInit.<locals>.libcc                     dS Nr   r   s    r   r-   z7INotifyTests.test_failedInit.<locals>.libc.inotify_inity       rr   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   sd    	 	 	 	 	 	 	 	 	

7FDDFF+++,-----r   c                      G d d          }|                      t          d |                       |                     t          t          dt          d          d           dS )zk
        If C{inotify_add_watch} returns a negative number, L{add}
        raises L{INotifyError}.
        c                       e Zd Zd ZdS ).INotifyTests.test_failedAddWatch.<locals>.libcc                     dS 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   sr    	 	 	 	 	 	 	 	 	

7FDDFF+++,Q0@0@!DDDDDr   )r   r   r    __doc__rK   skipr'   r/   r5   rA   rL   rU   r   r   r   r   r      s          7A A AA A AA A A =  =  =D. . .E E E E 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_      s<    - , , , , , + + + + + + + + + + + +'''''' GG    GGG
  'x')) 0000000000QQQQQQQQQQQQQGoE oE oE oE oE8 oE oE oE oE oEs    ))