Ë
    oj~  ã                   óÆ   — 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    úB/usr/lib/python3/dist-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   „ òñ (¨Ó5ˆLòñ  ,Ð,<Ó=Ðòñ !-Ð->Ó ?Ñ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Ñ4´u¼e°nÔEØ×Ñ˜×+Ñ+×3Ñ3´UÔ;à×Ñ˜×,Ñ,×5Ñ5¼¼xÌÐ7RÔSØ×Ñ˜×,Ñ,×4Ñ4´eÕ<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©Néÿÿÿÿr   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   € ÷	ñ 	ð 	�
‰
”7˜F¡D£FÔ+Ø×Ñœ,¬Õ-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;   € ÷	ñ 	ð 	�
‰
”7˜F¡D£FÔ+Ø×Ñœ,¬¨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 