+
    Dfj~                         R t ^ RIHt ^ RIHt ^ RIHt  ^ RIHt ]t	]	'       d/   ]P                  ! 4       '       d   ^ RIHtHtHt ^ RIHtHtHtHt MRt	 ! R R	]4      tR#   ]
 d    Rt	 LPi ; i)
'
Tests for L{twisted.python._inotify}.
)FilePath)platform)TestCase)_inotifyN)c_char_pc_intc_uint32)INotifyErroraddinitinitializeModulec                   T   a  ] tR t^t o Rt]f   RtR tR tR t	R t
R tR	 tR
tV tR# )INotifyTestsr   Nz&This platform doesn't support INotify.c                Z     ! R R4      pV P                  \        \        V! 4       4       R# )zq
If the I{libc} object passed to L{initializeModule} has no
C{inotify_init} attribute, L{ImportError} is raised.
c                   ,   a  ] tR t^)t o R tR tRtV tR# )+INotifyTests.test_missingInit.<locals>.libcc                    R # N selfs   &B/usr/lib/python3/dist-packages/twisted/python/test/test_inotify.pyinotify_add_watch=INotifyTests.test_missingInit.<locals>.libc.inotify_add_watch*           c                    R # r   r   r   s   &r   inotify_rm_watch<INotifyTests.test_missingInit.<locals>.libc.inotify_rm_watch-   r   r   r   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   libcr   )         r   r(   NassertRaisesImportErrorr   r   r(   s   & r   test_missingInitINotifyTests.test_missingInit#   #    	 	 	+'7@r   c                Z     ! R R4      pV P                  \        \        V! 4       4       R# )zv
If the I{libc} object passed to L{initializeModule} has no
C{inotify_add_watch} attribute, L{ImportError} is raised.
c                   ,   a  ] tR t^8t o R tR tRtV tR# )*INotifyTests.test_missingAdd.<locals>.libcc                    R # r   r   r   s   &r   inotify_init7INotifyTests.test_missingAdd.<locals>.libc.inotify_init9   r   r   c                    R # r   r   r   s   &r   r   ;INotifyTests.test_missingAdd.<locals>.libc.inotify_rm_watch<   r   r   r   N)r    r!   r"   r#   r5   r   r$   r%   r&   s   @r   r(   r3   8   r)   r   r(   Nr*   r-   s   & r   test_missingAddINotifyTests.test_missingAdd2   r0   r   c                Z     ! R R4      pV P                  \        \        V! 4       4       R# )zu
If the I{libc} object passed to L{initializeModule} has no
C{inotify_rm_watch} attribute, L{ImportError} is raised.
c                   ,   a  ] tR t^Gt o R tR tRtV tR# )-INotifyTests.test_missingRemove.<locals>.libcc                    R # r   r   r   s   &r   r5   :INotifyTests.test_missingRemove.<locals>.libc.inotify_initH   r   r   c                    R # r   r   r   s   &r   r   ?INotifyTests.test_missingRemove.<locals>.libc.inotify_add_watchK   r   r   r   N)r    r!   r"   r#   r5   r   r$   r%   r&   s   @r   r(   r=   G   r)   r   r(   Nr*   r-   s   & r   test_missingRemoveINotifyTests.test_missingRemoveA   r0   r   c                P    ! R R4      pV! 4       p\        V4       V P                  VP                  P                  . 4       V P                  VP                  P                  \
        4       V P                  VP                  P                  \
        \
        .4       V P                  VP                  P                  \
        4       V P                  VP                  P                  \
        \        \        .4       V P                  VP                  P                  \
        4       R# )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   a  ] tR t^Wt o R t]! ]4      tR t]! ]4      tR t]! ]4      tRtV t	R# )(INotifyTests.test_setTypes.<locals>.libcc                    R # r   r   r   s   &r   r5   5INotifyTests.test_setTypes.<locals>.libc.inotify_initX   r   r   c                    R # r   r   r   s   &r   r   9INotifyTests.test_setTypes.<locals>.libc.inotify_rm_watch]   r   r   c                    R # r   r   r   s   &r   r   :INotifyTests.test_setTypes.<locals>.libc.inotify_add_watchb   r   r   r   N)
r    r!   r"   r#   r5   staticmethodr   r   r$   r%   r&   s   @r   r(   rF   W   s<      (5L  ,,<= !--> ?r   r(   N)
r   assertEqualr5   argtypesrestyper   r   r   r   r	   )r   r(   cs   &  r   test_setTypesINotifyTests.test_setTypesP   s    	@ 	@  F00"5//7++44uenE++33U;,,55x7RS,,44e<r   c                     ! R R4      pV P                  \        RV! 4       4       V P                  \        \        4       R# )zO
If C{inotify_init} returns a negative number, L{init} raises
L{INotifyError}.
c                   &   a  ] tR t^xt o R tRtV tR# )*INotifyTests.test_failedInit.<locals>.libcc                    R#    r   r   s   &r   r5   7INotifyTests.test_failedInit.<locals>.libc.inotify_inity       	r   r   N)r    r!   r"   r#   r5   r$   r%   r&   s   @r   r(   rV   x         r   r(   N)patchinotifyr+   r
   r   r-   s   & r   test_failedInitINotifyTests.test_failedInitr   s0    	 	 	

7FDF+,-r   c                     ! R R4      pV P                  \        RV! 4       4       V P                  \        \        ^\        R4      ^ 4       R# )zS
If C{inotify_add_watch} returns a negative number, L{add}
raises L{INotifyError}.
c                   &   a  ] tR t^t o R tRtV tR# ).INotifyTests.test_failedAddWatch.<locals>.libcc                    R# rX   r   )r   fdpathmasks   &&&&r   r   @INotifyTests.test_failedAddWatch.<locals>.libc.inotify_add_watch   r\   r   r   N)r    r!   r"   r#   r   r$   r%   r&   s   @r   r(   rd      r]   r   r(   z/fooN)r^   r_   r+   r
   r   r   r-   s   & r   test_failedAddWatch INotifyTests.test_failedAddWatch   s;    	 	 	

7FDF+,Q0@!Dr   r   )r    r!   r"   r#   __doc__r_   skipr.   r9   rB   rR   r`   rj   r$   r%   r&   s   @r   r   r      s?      7AAA =D.E Er   r   )rl   twisted.python.filepathr   twisted.python.runtimer   twisted.trial.unittestr   twisted.pythonr   r_   r,   supportsINotifyctypesr   r   r	   twisted.python._inotifyr
   r   r   r   r   r   r   r   <module>ru      sl    - + +' G
x''))00QQGoE8 oE  Gs   A# #	A/.A/