Ë
    oj‚H  ã                   ó”   — d Z ddlZddlmZmZ ddlmZmZ ddlm	Z	 ddl
mZ  e	d«      �ddlmZ ndZ G d	„ d
ej                  «      Zy)z?
Tests for the inotify wrapper in L{twisted.internet.inotify}.
é    N)ÚdeferÚreactor)ÚfilepathÚruntime)ÚrequireModule)Úunittestztwisted.python._inotify)Úinotifyc                   óò   — e Zd ZdZej
                  j                  «       sdZd„ Zd„ Z	d d„Z
d„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d„ Z"d„ Z#y)!ÚINotifyTestsz]
    Define all the tests for the basic functionality exposed by
    L{inotify.INotify}.
    z&This platform doesn't support INotify.c                 ó8  — t        j                  | j                  «       «      | _        | j                  j	                  «        t        j                  «       | _        | j
                  j                  «        | j                  | j
                  j                  «       y ©N)
r   ÚFilePathÚmktempÚdirnameÚcreateDirectoryr	   ÚINotifyÚstartReadingÚ
addCleanupÚloseConnection©Úselfs    úD/usr/lib/python3/dist-packages/twisted/internet/test/test_inotify.pyÚsetUpzINotifyTests.setUp   s^   € Ü×(Ñ(¨¯©«Ó7ˆŒØ�‰×$Ñ$Ô&Ü—‘Ó(ˆŒØ�‰×!Ñ!Ô#Ø�‰˜Ÿ™×3Ñ3Õ4ó    c                 óÀ   —  G d„ d«      }| j                  t        j                  d |«       «       | j                  t        j                  t        j                  «       y)a  
        L{inotify.INotify} emits a C{RuntimeError} when initialized
        in an environment that doesn't support inotify as we expect it.

        We just try to raise an exception for every possible case in
        the for loop in L{inotify.INotify._inotify__init__}.
        c                   ó   — e Zd Zd„ Zy)ú;INotifyTests.test_initializationErrors.<locals>.FakeINotifyc                 ó*   — t        j                  «       ‚r   )r	   ÚINotifyErrorr   s    r   Úinitz@INotifyTests.test_initializationErrors.<locals>.FakeINotify.init.   s   € Ü×*Ñ*Ó,Ð,r   N)Ú__name__Ú
__module__Ú__qualname__r    © r   r   ÚFakeINotifyr   -   s   „ ó-r   r%   Ú_inotifyN)Úpatchr	   r   ÚassertRaisesr   )r   r%   s     r   Útest_initializationErrorsz&INotifyTests.test_initializationErrors$   s>   € ÷	-ñ 	-ð 	�
‰
”7—?‘? J±³Ô>Ø×Ñœ'×.Ñ.´·±Õ@r   Nc                 ó  ‡ ‡‡‡— ‰€‰ j                   j                  d«      Št        j                  «       Šˆˆˆ fd„}‰j	                  |«       ‰ j
                  j                  ‰ j                   ‰ˆfd„g¬«        |‰«       ‰S )aæ  
        Test notification from some filesystem operation.

        @param mask: The event mask to use when setting up the watch.

        @param operation: A function which will be called with the
            name of a file in the watched directory and which should
            trigger the event.

        @param expectedPath: Optionally, the name of the path which is
            expected to come back in the notification event; this will
            also be passed to C{operation} (primarily useful when the
            operation is being done to the directory itself, not a
            file in it).

        @return: A L{Deferred} which fires successfully when the
            expected event has been received or fails otherwise.
        zfoo.barc                 ó–   •— | \  }}}‰j                  |j                  «       ‰j                  «       «       ‰j                  |‰z  «       y r   )ÚassertEqualÚasBytesModeÚ
assertTrue)ÚresultÚwatchÚfilenameÚeventsÚexpectedPathÚmaskr   s       €€€r   Ú
cbNotifiedz2INotifyTests._notificationTest.<locals>.cbNotifiedK   sA   ø€ Ø(.Ñ%ˆU�H˜fØ×Ñ˜X×1Ñ1Ó3°\×5MÑ5MÓ5OÔPØ�O‰O˜F T™MÕ*r   c                  ó&   •— ‰j                  | «      S r   ©Úcallback©ÚargsÚnotifieds    €r   ú<lambda>z0INotifyTests._notificationTest.<locals>.<lambda>S   s   ø€ ¸h×>OÑ>OÐPTÓ>U€ r   ©r4   Ú	callbacks)r   Úchildr   ÚDeferredÚaddCallbackr	   r0   )r   r4   Ú	operationr3   r5   r;   s   `` ` @r   Ú_notificationTestzINotifyTests._notificationTest4   su   û€ ð& ÐØŸ<™<×-Ñ-¨iÓ8ˆLÜ—>‘>Ó#ˆö	+ð
 	×Ñ˜ZÔ(à�‰×ÑØ�L‰L˜tÓ0UÐ/Vð 	ô 	
ñ 	�,ÔØˆr   c                 óH   — d„ }| j                  t        j                  |«      S )z{
        Reading from a file in a monitored directory sends an
        C{inotify.IN_ACCESS} event to the callback.
        c                 óF   — | j                  d«       | j                  «        y )Nó   foo)Ú
setContentÚ
getContent©Úpaths    r   rB   z+INotifyTests.test_access.<locals>.operation^   s   € Ø�O‰O˜FÔ#Ø�O‰OÕr   )rC   r	   Ú	IN_ACCESS©r   rB   s     r   Útest_accesszINotifyTests.test_accessX   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   — d„ }| j                  t        j                  |«      S )zy
        Writing to a file in a monitored directory sends an
        C{inotify.IN_MODIFY} event to the callback.
        c                 ór   — | j                  d«      5 }|j                  d«       d d d «       y # 1 sw Y   y xY w)NÚwrF   )ÚopenÚwrite)rJ   ÚfObjs     r   rB   z+INotifyTests.test_modify.<locals>.operationj   s0   € Ø—‘˜3“ð # 4Ø—
‘
˜6Ô"÷#÷ #ñ #ús   ’-­6)rC   r	   Ú	IN_MODIFYrL   s     r   Útest_modifyzINotifyTests.test_modifyd   s"   € ò	#ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   — d„ }| j                  t        j                  |«      S )z‡
        Changing the metadata of a file in a monitored directory
        sends an C{inotify.IN_ATTRIB} event to the callback.
        c                 óD   — | j                  «        | j                  «        y r   )ÚtouchrI   s    r   rB   z+INotifyTests.test_attrib.<locals>.operationv   s   € Ø�J‰JŒLØ�J‰J�Lr   )rC   r	   Ú	IN_ATTRIBrL   s     r   Útest_attribzINotifyTests.test_attribp   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   — d„ }| j                  t        j                  |«      S )zž
        Closing a file which was open for writing in a monitored
        directory sends an C{inotify.IN_CLOSE_WRITE} event to the
        callback.
        c                 óB   — | j                  d«      j                  «        y ©NrP   ©rQ   ÚcloserI   s    r   rB   z/INotifyTests.test_closeWrite.<locals>.operationƒ   ó   € Ø�I‰I�c‹N× Ñ Õ"r   )rC   r	   ÚIN_CLOSE_WRITErL   s     r   Útest_closeWritezINotifyTests.test_closeWrite|   s"   € ò	#ð ×%Ñ%¤g×&<Ñ&<¸iÓHÐHr   c                 óH   — d„ }| j                  t        j                  |«      S )z°
        Closing a file which was open for reading but not writing in a
        monitored directory sends an C{inotify.IN_CLOSE_NOWRITE} event
        to the callback.
        c                 ób   — | j                  «        | j                  d«      j                  «        y )NÚr)rX   rQ   r_   rI   s    r   rB   z1INotifyTests.test_closeNoWrite.<locals>.operation�   s   € Ø�J‰JŒLØ�I‰I�c‹N× Ñ Õ"r   )rC   r	   ÚIN_CLOSE_NOWRITErL   s     r   Útest_closeNoWritezINotifyTests.test_closeNoWriteˆ   s"   € ò	#ð ×%Ñ%¤g×&>Ñ&>À	ÓJÐJr   c                 óH   — d„ }| j                  t        j                  |«      S )zt
        Opening a file in a monitored directory sends an
        C{inotify.IN_OPEN} event to the callback.
        c                 óB   — | j                  d«      j                  «        y r]   r^   rI   s    r   rB   z)INotifyTests.test_open.<locals>.operation›   r`   r   )rC   r	   ÚIN_OPENrL   s     r   Ú	test_openzINotifyTests.test_open•   s    € ò	#ð ×%Ñ%¤g§o¡o°yÓAÐAr   c                 óN   ‡ — ˆ fd„}‰ j                  t        j                  |«      S )z}
        Moving a file out of a monitored directory sends an
        C{inotify.IN_MOVED_FROM} event to the callback.
        c                 ó¨   •— | j                  d«      j                  «        | j                  t        j                  ‰j                  «       «      «       y r]   )rQ   r_   ÚmoveTor   r   r   ©rJ   r   s    €r   rB   z.INotifyTests.test_movedFrom.<locals>.operation¦   s4   ø€ Ø�I‰I�c‹N× Ñ Ô"Ø�K‰Kœ×)Ñ)¨$¯+©+«-Ó8Õ9r   )rC   r	   ÚIN_MOVED_FROMrL   s   ` r   Útest_movedFromzINotifyTests.test_movedFrom    s#   ø€ ô	:ð ×%Ñ%¤g×&;Ñ&;¸YÓGÐGr   c                 óN   ‡ — ˆ fd„}‰ j                  t        j                  |«      S )zy
        Moving a file into a monitored directory sends an
        C{inotify.IN_MOVED_TO} event to the callback.
        c                 óŽ   •— t        j                  ‰j                  «       «      }|j                  «        |j	                  | «       y r   )r   r   r   rX   rn   )rJ   Úpr   s     €r   rB   z,INotifyTests.test_movedTo.<locals>.operation²   s-   ø€ Ü×!Ñ! $§+¡+£-Ó0ˆAØ�G‰GŒIØ�H‰H�T�Nr   )rC   r	   ÚIN_MOVED_TOrL   s   ` r   Útest_movedTozINotifyTests.test_movedTo¬   s#   ø€ ô	ð
 ×%Ñ%¤g×&9Ñ&9¸9ÓEÐEr   c                 óH   — d„ }| j                  t        j                  |«      S )zw
        Creating a file in a monitored directory sends an
        C{inotify.IN_CREATE} event to the callback.
        c                 óB   — | j                  d«      j                  «        y r]   r^   rI   s    r   rB   z+INotifyTests.test_create.<locals>.operation¿   r`   r   )rC   r	   Ú	IN_CREATErL   s     r   Útest_createzINotifyTests.test_create¹   s"   € ò	#ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   — d„ }| j                  t        j                  |«      S )zw
        Deleting a file in a monitored directory sends an
        C{inotify.IN_DELETE} event to the callback.
        c                 óD   — | j                  «        | j                  «        y r   )rX   ÚremoverI   s    r   rB   z+INotifyTests.test_delete.<locals>.operationÊ   s   € Ø�J‰JŒLØ�K‰K�Mr   )rC   r	   Ú	IN_DELETErL   s     r   Útest_deletezINotifyTests.test_deleteÄ   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 ó`   — d„ }| j                  t        j                  || j                  ¬«      S )z{
        Deleting the monitored directory itself sends an
        C{inotify.IN_DELETE_SELF} event to the callback.
        c                 ó$   — | j                  «        y r   )r}   rI   s    r   rB   z/INotifyTests.test_deleteSelf.<locals>.operationÖ   s   € Ø�K‰K�Mr   ©r3   )rC   r	   ÚIN_DELETE_SELFr   rL   s     r   Útest_deleteSelfzINotifyTests.test_deleteSelfÐ   s2   € ò	ð ×%Ñ%Ü×"Ñ" I¸D¿L¹Lð &ó 
ð 	
r   c                 óê   ‡ ‡— ˆ fd„}‰ j                   j                  ‰ j                  dˆfd„g¬«       t        j                  «       Š‰j                  |«       ‰ j                  j                  «        ‰S )z»
        Deleting the monitored directory itself sends an
        C{inotify.IN_DELETE_SELF} event to the callback
        even if the mask isn't specified by the call to watch().
        c                 óÆ   •— | \  }}}‰j                  |j                  «       ‰j                  j                  «       «       ‰j                  |t        j
                  z  «       y r   )r,   r-   r   r.   r	   rƒ   )r/   r0   r1   r2   r   s       €r   r5   z6INotifyTests.test_deleteSelfForced.<locals>.cbNotifiedä   sL   ø€ Ø(.Ñ%ˆU�H˜fØ×Ñ˜X×1Ñ1Ó3°T·\±\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   r   c                  ó&   •— ‰j                  | «      S r   r7   )r:   Úds    €r   r<   z4INotifyTests.test_deleteSelfForced.<locals>.<lambda>ê   s   ø€ ¸Q¿Z¹ZÈÓ=M€ r   r=   )r	   r0   r   r   r@   rA   r}   )r   r5   rˆ   s   ` @r   Útest_deleteSelfForcedz"INotifyTests.test_deleteSelfForcedÝ   s_   ù€ ô	=ð
 	�‰×ÑØ�L‰L˜sÓ/MÐ.Nð 	ô 	
ô �N‰NÓˆØ	�‰�jÔ!à�‰×ÑÔØˆr   c                 óf   ‡ — ˆ fd„}‰ j                  t        j                  |‰ j                  ¬«      S )zy
        Renaming the monitored directory itself sends an
        C{inotify.IN_MOVE_SELF} event to the callback.
        c                 ój   •— | j                  t        j                  ‰j                  «       «      «       y r   )rn   r   r   r   ro   s    €r   rB   z-INotifyTests.test_moveSelf.<locals>.operationù   s    ø€ Ø�K‰Kœ×)Ñ)¨$¯+©+«-Ó8Õ9r   r‚   )rC   r	   ÚIN_MOVE_SELFr   rL   s   ` r   Útest_moveSelfzINotifyTests.test_moveSelfó   s3   ø€ ô	:ð ×%Ñ%Ü× Ñ  )¸$¿,¹,ð &ó 
ð 	
r   c                 ó.  ‡ ‡‡— ˆˆ ˆfd„}t         j                  t         j                  z  }‰ j                   j                  ‰ j                  |d|g¬«       ‰ j                  j                  d«      Št        j                  «       Š‰j                  «        ‰S )zŒ
        L{inotify.INotify} when initialized with autoAdd==True adds
        also adds the created subdirectories to the watchlist.
        c                 ó@   •— ˆˆˆfd„}t        j                  d|«       y )Nc                  ó¼   •— 	 ‰j                  ‰j                  j                  ‰«      «       ‰ j                  d «       y # t        $ r ‰ j                  «        Y y w xY wr   )r.   r	   Ú
_isWatchedr8   Ú	ExceptionÚerrback©rˆ   r   Úsubdirs   €€€r   Ú_zIINotifyTests.test_simpleSubdirectoryAutoAdd.<locals>._callback.<locals>._	  sG   ø€ ð Ø—O‘O D§L¡L×$;Ñ$;¸FÓ$CÔDØ—J‘J˜tÕ$øÜ ò  Ø—I‘I–Kð úó   ƒ;? ¿AÁAr   ©r   Ú	callLater)Úwpr1   r4   r–   rˆ   r   r•   s       €€€r   Ú	_callbackz>INotifyTests.test_simpleSubdirectoryAutoAdd.<locals>._callback  ó   ø€ ö ô ×Ñ˜a Õ#r   T©r4   ÚautoAddr>   Útest©	r	   ÚIN_ISDIRry   r0   r   r?   r   r@   r   ©r   r›   Ú	checkMaskrˆ   r•   s   `  @@r   Útest_simpleSubdirectoryAutoAddz+INotifyTests.test_simpleSubdirectoryAutoAdd   sy   ú€ ö
	$ô ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ô 	
ð —‘×#Ñ# FÓ+ˆÜ�N‰NÓˆØ×ÑÔ Øˆr   c                 ó6  ‡ ‡‡‡— g Šˆˆˆ ˆfd„}t         j                  t         j                  z  }‰ j                   j                  ‰ j                  |d|g¬«       ‰ j                  j                  d«      Št        j                  «       Š‰j                  «        ‰S )zz
        L{inotify.INotify} removes a directory from the watchlist when
        it's removed from the filesystem.
        c                 ó¢   •— ˆˆˆfd„}ˆˆˆfd„}‰s(‰j                  |«       t        j                  d|«       y t        j                  d|«       y )Nc                  óº   •— 	 ‰j                  ‰j                  j                  ‰«      «       ‰j                  «        y # t        $ r ‰ j                  «        Y y w xY wr   )r.   r	   r‘   r}   r’   r“   r”   s   €€€r   r–   zEINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._%  sD   ø€ ð Ø—O‘O D§L¡L×$;Ñ$;¸FÓ$CÔDØ—M‘M•OøÜ ò  Ø—I‘I–Kð ús   ƒ:> ¾AÁAc                  ó¼   •— 	 ‰j                  ‰j                  j                  ‰«      «       ‰ j                  d «       y # t        $ r ‰ j                  «        Y y w xY wr   ©ÚassertFalser	   r‘   r8   r’   r“   r”   s   €€€r   Ú_ebzGINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._eb,  sI   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸VÓ%DÔEØ—J‘J˜tÕ$øÜ ò  Ø—I‘I–Kð úr—   r   )Úappendr   r™   )	rš   r1   r4   r–   r«   Úcallsrˆ   r   r•   s	        €€€€r   r›   z:INotifyTests.test_simpleDeleteDirectory.<locals>._callback"  s@   ø€ ö ö ñ à—‘˜XÔ&Ü×!Ñ! ! QÕ'ô ×!Ñ! ! SÕ)r   Tr�   rŸ   r    )r   r›   r£   r­   rˆ   r•   s   `  @@@r   Útest_simpleDeleteDirectoryz'INotifyTests.test_simpleDeleteDirectory  s€   û€ ð
 ˆ÷	*ô4 ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ô 	
ð —‘×#Ñ# FÓ+ˆÜ�N‰NÓˆØ×ÑÔ Øˆr   c                 óP  ‡ ‡‡— ˆˆ fd„}‰ j                  ‰ j                  j                  ‰ j                  t        j                  ˆfd„g¬«      «       t        j                  «       Š‰j                  |«       ‰ j                  j                  «        t        j                  «       Š‰S )zš
        L{inotify.INotify} closes the file descriptor after removing a
        directory from the filesystem (and therefore from the watchlist).
        c                 óþ   •— ˆˆfd„}| \  }}}‰j                  |j                  «       ‰j                  j                  «       «       ‰j                  |t        j
                  z  «       t        j                  d|«       y )Nc                  ó  •— 	 ‰j                  ‰j                  j                  ‰j                  «      «       ‰j                  ‰j                  j                  «       ‰ j                  d «       y # t        $ r ‰ j                  «        Y y w xY wr   )rª   r	   r‘   r   Ú	connectedr8   r’   r“   )rˆ   r   s   €€r   r–   zIINotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotified.<locals>._L  se   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸T¿\¹\Ó%JÔKØ×$Ñ$ T§\¡\×%;Ñ%;Ô<Ø—J‘J˜tÕ$øÜ ò  Ø—I‘I–Kð ús   ƒA*A. Á.B
Â	B
r   )r,   r-   r   r.   r	   rƒ   r   r™   )r/   r–   Úignoredr1   r2   rˆ   r   s        €€r   r5   z>INotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotifiedK  sc   ø€ õ ð +1Ñ'ˆW�h Ø×Ñ˜X×1Ñ1Ó3°T·\±\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Ô<Ü×Ñ˜a Õ#r   c                  ó&   •— ‰j                  | «      S r   r7   r9   s    €r   r<   z<INotifyTests.test_deleteSelfLoseConnection.<locals>.<lambda>]  s   ø€ ¨×):Ñ):¸4Ó)@€ r   r=   )	r.   r	   r0   r   rƒ   r   r@   rA   r}   )r   r5   rˆ   r;   s   ` @@r   Útest_deleteSelfLoseConnectionz*INotifyTests.test_deleteSelfLoseConnectionE  s€   ú€ õ	$ð 	�‰Ø�L‰L×ÑØ—‘Ü×+Ñ+Û@ÐAð ó ô	
ô —>‘>Ó#ˆØ×Ñ˜ZÔ(à�‰×ÑÔÜ�N‰NÓˆØˆr   c                 ól  — | j                   j                  | j                  d¬«       | j                  | j                   j	                  | j                  «      «       | j                   j                  | j                  «       | j                  | j                   j	                  | j                  «      «       y)zR
        L{inotify.INotify.ignore} removes a directory from the watchlist
        T)rž   N)r	   r0   r   r.   r‘   Úignorerª   r   s    r   Útest_ignoreDirectoryz!INotifyTests.test_ignoreDirectoryh  su   € ð 	�‰×Ñ˜4Ÿ<™<°ÐÔ6Ø�‰˜Ÿ™×/Ñ/°·±Ó=Ô>Ø�‰×Ñ˜DŸL™LÔ)Ø×Ñ˜Ÿ™×0Ñ0°·±Ó>Õ?r   c                 óH  — t         j                  D ]-  \  }}| j                  t        j                  |«      d   |«       Œ/ t         j                  t         j
                  z  t         j                  z  }| j                  t        t        j                  |«      «      h d£«       y)zy
        L{inotify.humaReadableMask} translates all the possible event
        masks to a human readable string.
        r   >   rQ   ÚaccessÚclose_writeN)r	   Ú_FLAG_TO_HUMANr,   ÚhumanReadableMaskra   rK   rj   Úset)r   r4   Úvaluer£   s       r   Útest_humanReadableMaskz#INotifyTests.test_humanReadableMaskq  s„   € ô
 #×1Ñ1ò 	H‰KˆD�%Ø×ÑœW×6Ñ6°tÓ<¸QÑ?ÀÕGð	Hô ×*Ñ*¬W×->Ñ->Ñ>ÄÇÁÑPˆ	Ø×ÑÜ”×)Ñ)¨)Ó4Ó5Ú-õ	
r   c                 ó¦  — | j                   j                  d«      }|j                  d«      }|j                  d«      }|j                  «        |||g}| j                  j	                  | j                   d¬«       | j                  j	                  | j                   d¬«       |D ],  }| j                  | j                  j                  |«      «       Œ. y)zŽ
        L{inotify.INotify.watch} with recursive==True will add all the
        subdirectories under the given path to the watchlist.
        rŸ   Útest2Útest3T)Ú	recursiveN)r   r?   Úmakedirsr	   r0   r.   r‘   )r   r•   Úsubdir2Úsubdir3Údirsrˆ   s         r   Útest_recursiveWatchz INotifyTests.test_recursiveWatch  s¬   € ð
 —‘×#Ñ# FÓ+ˆØ—,‘,˜wÓ'ˆØ—-‘- Ó(ˆØ×ÑÔØ˜ Ð)ˆØ�‰×Ñ˜4Ÿ<™<°4ÐÔ8à�‰×Ñ˜4Ÿ<™<°4ÐÔ8Øò 	8ˆAØ�O‰O˜DŸL™L×3Ñ3°AÓ6Õ7ñ	8r   c                 óª   — ddl }t        j                  «       }|j                  |j                  «       |j                  «        | j                  «        y)zœ
        L{inotify.INotify.connectionLost} if there's a problem while closing
        the fd shouldn't raise the exception but should log the error
        r   N)Úosr	   r   r_   Ú_fdr   ÚflushLoggedErrors)r   rË   Úin_s      r   Útest_connectionLostErrorz%INotifyTests.test_connectionLostError�  s;   € ó
 	ä�o‰oÓˆØ
�‰�—‘ÔØ×ÑÔØ×ÑÕ r   c                 ó.  ‡ ‡‡— ˆˆ ˆfd„}t         j                  t         j                  z  }‰ j                   j                  ‰ j                  |d|g¬«       ‰ j                  j                  d«      Št        j                  «       Š‰j                  «        ‰S )z”
        L{inotify.INotify.watch} with autoAdd==False will stop inotify
        from watching subdirectories created under the watched one.
        c                 ó@   •— ˆˆˆfd„}t        j                  d|«       y )Nc                  ó¼   •— 	 ‰j                  ‰j                  j                  ‰«      «       ‰ j                  d «       y # t        $ r ‰ j                  «        Y y w xY wr   r©   r”   s   €€€r   r–   zEINotifyTests.test_noAutoAddSubdirectory.<locals>._callback.<locals>._¤  sI   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸VÓ%DÔEØ—J‘J˜tÕ$øÜ ò  Ø—I‘I–Kð úr—   r   r˜   )rš   Úfpr4   r–   rˆ   r   r•   s       €€€r   r›   z:INotifyTests.test_noAutoAddSubdirectory.<locals>._callback¡  rœ   r   Fr�   rŸ   r    r¢   s   `  @@r   Útest_noAutoAddSubdirectoryz'INotifyTests.test_noAutoAddSubdirectory›  sy   ú€ ö
	$ô ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°%ÀIÀ;ð 	ô 	
ð —‘×#Ñ# FÓ+ˆÜ�N‰NÓˆØ×ÑÔ Øˆr   c                 óê  ‡ ‡‡— ‰ j                   j                  d«      Š‰j                  «        t        j                  «       Šˆˆ fd„}ˆfd„}‰ j                  ‰ j                  j                  ‰|g¬«      «       ‰ j                  j                  ‰«       ‰ j                  ‰ j                  j                  ‰t        j                  |g¬«      «       ‰j                  |«       ‰j                  «        ‰S )zœ
        L{inotify.INotify} will watch a filepath for events even if the same
        path is repeatedly added/removed/re-added to the watchpoints.
        úfoo.bar2c                 ó²   •— | \  }}}‰j                  |j                  «       ‰j                  «       «       ‰j                  |t        j                  z  «       y r   ©r,   r-   r.   r	   rƒ   )r/   r³   r1   r2   r3   r   s       €€r   r5   z<INotifyTests.test_seriesOfWatchAndIgnore.<locals>.cbNotifiedÀ  sH   ø€ Ø*0Ñ'ˆW�h Ø×Ñ˜X×1Ñ1Ó3°\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   c                  ó(   •— ‰j                  | «       y r   r7   r9   s    €r   ÚcallItz8INotifyTests.test_seriesOfWatchAndIgnore.<locals>.callItÅ  ó   ø€ Ø×Ñ˜dÕ#r   ©r>   r=   )r   r?   rX   r   r@   r.   r	   r0   r·   rƒ   rA   r}   )r   r5   rÚ   r3   r;   s   `  @@r   Útest_seriesOfWatchAndIgnorez(INotifyTests.test_seriesOfWatchAndIgnore¶  sÆ   ú€ ð
 —|‘|×)Ñ)¨*Ó5ˆØ×ÑÔä—>‘>Ó#ˆõ	=ô
	$ð 	�‰˜Ÿ™×*Ñ*¨<ÀFÀ8Ð*ÓLÔMØ�‰×Ñ˜LÔ)Ø�‰Ø�L‰L×ÑØ¤7×#9Ñ#9ÀfÀXð ó ô	
ð 	×Ñ˜ZÔ(ð 	×ÑÔàˆr   c                 ó~  ‡ ‡‡— ‰ j                   j                  d«      }|j                  «        ‰ j                   j                  d«      Š‰j                  «        t        j                  «       Šˆˆ fd„}ˆfd„}‰ j                  ‰ j                  j                  |t        j                  |g¬«      «       ‰j                  |«       ‰ j                  ‰ j                  j                  ‰t        j                  |g¬«      «       ‰ j                  j                  |«       |j                  «        ‰j                  «        ‰S )zr
        L{inotify.INotify} will ignore a filepath after it has been removed from
        the watch list.
        rÖ   zfoo.bar3c                 ó²   •— | \  }}}‰j                  |j                  «       ‰j                  «       «       ‰j                  |t        j                  z  «       y r   rØ   )r/   r³   r1   r2   ÚexpectedPath2r   s       €€r   r5   z4INotifyTests.test_ignoreFilePath.<locals>.cbNotifiedç  sH   ø€ Ø*0Ñ'ˆW�h Ø×Ñ˜X×1Ñ1Ó3°]×5NÑ5NÓ5PÔQØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   c                  ó(   •— ‰j                  | «       y r   r7   r9   s    €r   rÚ   z0INotifyTests.test_ignoreFilePath.<locals>.callItì  rÛ   r   rÜ   )r   r?   rX   r   r@   r.   r	   r0   rƒ   rA   r·   r}   )r   r3   r5   rÚ   rà   r;   s   `   @@r   Útest_ignoreFilePathz INotifyTests.test_ignoreFilePathÛ  sþ   ú€ ð
 —|‘|×)Ñ)¨*Ó5ˆØ×ÑÔØŸ™×*Ñ*¨:Ó6ˆØ×ÑÔä—>‘>Ó#ˆõ	=ô
	$ð 	�‰Ø�L‰L×Ñ˜|¬W×-CÑ-CÐPVÈxÐÓXô	
ð 	×Ñ˜ZÔ(à�‰Ø�L‰L×ÑØœw×5Ñ5À&Àð ó ô	
ð 	�‰×Ñ˜LÔ)à×ÑÔØ×ÑÔàˆr   c                 ó°   — | j                   j                  d«      }|j                  «        | j                  t        | j
                  j                  |«       y)zf
        L{inotify.INotify} will raise KeyError if a non-watched filepath is
        ignored.
        zfoo.ignoredN)r   r?   rX   r(   ÚKeyErrorr	   r·   )r   r3   s     r   Útest_ignoreNonWatchedFilez&INotifyTests.test_ignoreNonWatchedFile  s@   € ð
 —|‘|×)Ñ)¨-Ó8ˆØ×ÑÔà×Ñœ( D§L¡L×$7Ñ$7¸ÕFr   c                 ó˜  ‡ ‡‡‡‡‡	‡
— t        «       Šˆˆˆ ˆˆˆ	ˆ
fd„}t        j                  t        j                  z  }‰ j                  j	                  ‰ j
                  |d|g¬«       ‰ j
                  j                  d«      Š‰j                  d«      Š	‰	j                  d«      Š
t        j                  «       Š‰
j                  «        ‰j                  d«      ‰	j                  d«      ‰
j                  d	«      gŠt        ‰«      D ]A  \  }}|j                  |j                  j                  t        j                  «       «      «       ŒC ‰S )
aB  
        L{inotify.INotify} with autoAdd==True for a watched path
        generates events for every file or directory already present
        in a newly created subdirectory under the watched one.

        This tests that we solve a race condition in inotify even though
        we may generate duplicate events.
        c                 ód  •— ‰j                  |«       t        ‰«      dk(  rì	 ‰j                  ‰j                  j	                  ‰	«      «       ‰j                  ‰j                  j	                  ‰
«      «       ‰j                  ‰j                  j	                  ‰«      «       ‰‰	‰
‰gz   }|D �ch c]  }|j                  «       ’Œ }}‰j                  t        ‰«      t        |«      «       ‰j                  ‰|«       ‰j                  d «       y y c c}w # t        $ r ‰j                  «        Y y w xY w)Né   )
ÚaddÚlenr.   r	   r‘   r-   r,   r8   r’   r“   )rš   r1   r4   ÚcreatedÚfr­   rˆ   r   Ú	someFilesr•   rÆ   rÇ   s        €€€€€€€r   r›   z?INotifyTests.test_complexSubdirectoryAutoAdd.<locals>._callback  sõ   ø€ Ø�I‰I�hÔÜ�5‹z˜QŠð%Ø—O‘O D§L¡L×$;Ñ$;¸FÓ$CÔDØ—O‘O D§L¡L×$;Ñ$;¸GÓ$DÔEØ—O‘O D§L¡L×$;Ñ$;¸GÓ$DÔEØ'¨6°7¸GÐ*DÑD�GØ8?Ö@°1˜qŸ}™}�Ð@�GÐ@Ø×$Ñ$¤S¨£Z´°W³Ô>Ø×$Ñ$ U¨GÔ4ð —J‘J˜tÕ$ð ùò Aøô !ò  Ø—I‘I–Kð ús$   ¢B
D Â,DÃ8D ÄD ÄD/Ä.D/Tr�   rŸ   rÂ   rÃ   z	file1.datz	file2.datz	file3.dat)r¾   r	   r¡   ry   r0   r   r?   r   r@   rÅ   Ú	enumeraterG   rJ   ÚencodeÚsysÚgetfilesystemencoding)r   r›   r£   Úir1   r­   rˆ   rí   r•   rÆ   rÇ   s   `    @@@@@@r   Útest_complexSubdirectoryAutoAddz,INotifyTests.test_complexSubdirectoryAutoAdd  s  þ€ ô “ˆ÷	%ò 	%ô  ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ô 	
ð —‘×#Ñ# FÓ+ˆØ—,‘,˜wÓ'ˆØ—-‘- Ó(ˆÜ�N‰NÓˆØ×ÑÔð �L‰L˜Ó%Ø�M‰M˜+Ó&Ø�M‰M˜+Ó&ð
ˆ	ô % YÓ/ò 	S‰KˆAˆxØ×Ñ §¡× 4Ñ 4´S×5NÑ5NÓ5PÓ QÕRð	Sàˆr   r   )$r!   r"   r#   Ú__doc__r   ÚplatformÚsupportsINotifyÚskipr   r)   rC   rM   rU   rZ   rb   rg   rk   rq   rv   rz   r   r„   r‰   r�   r¤   r®   rµ   r¸   rÀ   rÉ   rÏ   rÔ   rÝ   râ   rå   ró   r$   r   r   r   r      s¾   „ ñð
 ×Ñ×+Ñ+Ô-Ø7ˆò5òAó "òH
Dò
Dò
Dò
IòKò	Bò
HòFò	Dò
Dò
òò,
òò6(òT!òF@ò
ò8ò 
!òò6#òJ$òLGó.r   r   )rô   rð   Útwisted.internetr   r   Útwisted.pythonr   r   Útwisted.python.reflectr   Útwisted.trialr   r	   ÚTestCaser   r$   r   r   ú<module>rý      sC   ðñó ç +ß ,Ý 0Ý "áÐ*Ó+Ð7Þ(à€Gôe�8×$Ñ$õ er   