ó
    Ö›‘h‚H  ã                   ó–   • S r SSKrSSKJrJr  SSKJrJr  SSKJ	r	  SSK
Jr  \	" S5      b  SSKJr  OSr " S	 S
\R                  5      rg)z?
Tests for the inotify wrapper in L{twisted.internet.inotify}.
é    N)ÚdeferÚreactor)ÚfilepathÚruntime)ÚrequireModule)Úunittestztwisted.python._inotify)Úinotifyc                   ó  • \ rS rSrSr\R                  R                  5       (       d  SrS r	S r
S"S jrS rS	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S  r$S!r%g)#ÚINotifyTestsé   zQ
Define all the tests for the basic functionality exposed by
L{inotify.INotify}.
z&This platform doesn't support INotify.c                 ó<  • [         R                  " U R                  5       5      U l        U R                  R	                  5         [
        R                  " 5       U l        U R
                  R                  5         U R                  U R
                  R                  5        g ©N)
r   ÚFilePathÚmktempÚdirnameÚcreateDirectoryr	   ÚINotifyÚstartReadingÚ
addCleanupÚloseConnection©Úselfs    ÚfC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_inotify.pyÚsetUpÚINotifyTests.setUp   s^   € Ü×(Ò(¨¯©«Ó7ˆŒØ�‰×$Ñ$Ô&Ü—’Ó(ˆŒØ�‰×!Ñ!Ô#Ø�‰˜Ÿ™×3Ñ3Õ4ó    c                 óÀ   •  " S S5      nU R                  [        R                  SU" 5       5        U R                  [        R                  [        R                  5        g)zð
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                   ó   • \ rS rSrS rSrg)Ú;INotifyTests.test_initializationErrors.<locals>.FakeINotifyé-   c                 ó,   • [         R                  " 5       er   )r	   ÚINotifyErrorr   s    r   ÚinitÚ@INotifyTests.test_initializationErrors.<locals>.FakeINotify.init.   s   € Ü×*Ò*Ó,Ð,r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r#   Ú__static_attributes__r%   r   r   ÚFakeINotifyr   -   s   † õ-r   r+   Ú_inotifyN)Úpatchr	   r   ÚassertRaisesr"   )r   r+   s     r   Útest_initializationErrorsÚ&INotifyTests.test_initializationErrors$   s>   € ÷	-ñ 	-ð 	�
‰
”7—?‘? J±³Ô>Ø×Ñœ'×.Ñ.´·±Õ@r   Nc                 ó
  ^ ^^^• Tc  T R                   R                  S5      m[        R                  " 5       mUUU 4S jnTR	                  U5        T R
                  R                  T R                   TU4S j/S9  U" T5        T$ )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                 ó”   >• U u  pnTR                  UR                  5       TR                  5       5        TR                  UT-  5        g r   )ÚassertEqualÚasBytesModeÚ
assertTrue)ÚresultÚwatchÚfilenameÚeventsÚexpectedPathÚmaskr   s       €€€r   Ú
cbNotifiedÚ2INotifyTests._notificationTest.<locals>.cbNotifiedK   s?   ø€ Ø(.Ñ%ˆU˜fØ×Ñ˜X×1Ñ1Ó3°\×5MÑ5MÓ5OÔPØ�O‰O˜F T™MÕ*r   c                  ó&   >• TR                  U 5      $ r   ©Úcallback©ÚargsÚnotifieds    €r   Ú<lambda>Ú0INotifyTests._notificationTest.<locals>.<lambda>S   s   ø€ ¸h×>OÑ>OÐPTÔ>Ur   ©r;   Ú	callbacks)r   Úchildr   ÚDeferredÚaddCallbackr	   r7   )r   r;   Ú	operationr:   r<   rC   s   `` ` @r   Ú_notificationTestÚINotifyTests._notificationTest4   su   û€ ð& ÑØŸ<™<×-Ñ-¨iÓ8ˆLÜ—>’>Ó#ˆ÷	+ð
 	×Ñ˜ZÔ(à�‰×ÑØ�L‰L˜tÔ0UÐ/Vð 	ñ 	
ñ 	�,ÔØˆr   c                 óH   • S nU R                  [        R                  U5      $ )zc
Reading from a file in a monitored directory sends an
C{inotify.IN_ACCESS} event to the callback.
c                 óF   • U R                  S5        U R                  5         g )Nó   foo)Ú
setContentÚ
getContent©Úpaths    r   rK   Ú+INotifyTests.test_access.<locals>.operation^   s   € Ø�O‰O˜FÔ#Ø�O‰OÕr   )rL   r	   Ú	IN_ACCESS©r   rK   s     r   Útest_accessÚINotifyTests.test_accessX   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   • S nU R                  [        R                  U5      $ )za
Writing to a file in a monitored directory sends an
C{inotify.IN_MODIFY} event to the callback.
c                 ó|   • U R                  S5       nUR                  S5        S S S 5        g ! , (       d  f       g = f)NÚwrP   )ÚopenÚwrite)rT   ÚfObjs     r   rK   Ú+INotifyTests.test_modify.<locals>.operationj   s%   € Ø—‘˜3” 4Ø—
‘
˜6Ô"÷  —–ús   ’-­
;)rL   r	   Ú	IN_MODIFYrW   s     r   Útest_modifyÚINotifyTests.test_modifyd   s"   € ò	#ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   • S nU R                  [        R                  U5      $ )zo
Changing the metadata of a file in a monitored directory
sends an C{inotify.IN_ATTRIB} event to the callback.
c                 óD   • U R                  5         U R                  5         g r   )ÚtouchrS   s    r   rK   Ú+INotifyTests.test_attrib.<locals>.operationv   s   € Ø�J‰JŒLØ�J‰J�Lr   )rL   r	   Ú	IN_ATTRIBrW   s     r   Útest_attribÚINotifyTests.test_attribp   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   • S nU R                  [        R                  U5      $ )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   • U R                  S5      R                  5         g ©Nr\   ©r]   ÚcloserS   s    r   rK   Ú/INotifyTests.test_closeWrite.<locals>.operationƒ   ó   € Ø�I‰I�c‹N× Ñ Õ"r   )rL   r	   ÚIN_CLOSE_WRITErW   s     r   Útest_closeWriteÚINotifyTests.test_closeWrite|   s"   € ò	#ð ×%Ñ%¤g×&<Ñ&<¸iÓHÐHr   c                 óH   • S nU R                  [        R                  U5      $ )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   • U R                  5         U R                  S5      R                  5         g )NÚr)rf   r]   ro   rS   s    r   rK   Ú1INotifyTests.test_closeNoWrite.<locals>.operation�   s   € Ø�J‰JŒLØ�I‰I�c‹N× Ñ Õ"r   )rL   r	   ÚIN_CLOSE_NOWRITErW   s     r   Útest_closeNoWriteÚINotifyTests.test_closeNoWriteˆ   s"   € ò	#ð ×%Ñ%¤g×&>Ñ&>À	ÓJÐJr   c                 óH   • S nU R                  [        R                  U5      $ )z\
Opening a file in a monitored directory sends an
C{inotify.IN_OPEN} event to the callback.
c                 óB   • U R                  S5      R                  5         g rm   rn   rS   s    r   rK   Ú)INotifyTests.test_open.<locals>.operation›   rq   r   )rL   r	   ÚIN_OPENrW   s     r   Ú	test_openÚINotifyTests.test_open•   s    € ò	#ð ×%Ñ%¤g§o¡o°yÓAÐAr   c                 óP   ^ • U 4S jnT R                  [        R                  U5      $ )ze
Moving a file out of a monitored directory sends an
C{inotify.IN_MOVED_FROM} event to the callback.
c                 óª   >• U R                  S5      R                  5         U R                  [        R                  " TR                  5       5      5        g rm   )r]   ro   ÚmoveTor   r   r   ©rT   r   s    €r   rK   Ú.INotifyTests.test_movedFrom.<locals>.operation¦   s4   ø€ Ø�I‰I�c‹N× Ñ Ô"Ø�K‰Kœ×)Ò)¨$¯+©+«-Ó8Õ9r   )rL   r	   ÚIN_MOVED_FROMrW   s   ` r   Útest_movedFromÚINotifyTests.test_movedFrom    s#   ø€ õ	:ð ×%Ñ%¤g×&;Ñ&;¸YÓGÐGr   c                 óP   ^ • U 4S jnT R                  [        R                  U5      $ )za
Moving a file into a monitored directory sends an
C{inotify.IN_MOVED_TO} event to the callback.
c                 ó�   >• [         R                  " TR                  5       5      nUR                  5         UR	                  U 5        g r   )r   r   r   rf   r„   )rT   Úpr   s     €r   rK   Ú,INotifyTests.test_movedTo.<locals>.operation²   s-   ø€ Ü×!Ò! $§+¡+£-Ó0ˆAØ�G‰GŒIØ�H‰H�T�Nr   )rL   r	   ÚIN_MOVED_TOrW   s   ` r   Útest_movedToÚINotifyTests.test_movedTo¬   s#   ø€ õ	ð
 ×%Ñ%¤g×&9Ñ&9¸9ÓEÐEr   c                 óH   • S nU R                  [        R                  U5      $ )z_
Creating a file in a monitored directory sends an
C{inotify.IN_CREATE} event to the callback.
c                 óB   • U R                  S5      R                  5         g rm   rn   rS   s    r   rK   Ú+INotifyTests.test_create.<locals>.operation¿   rq   r   )rL   r	   Ú	IN_CREATErW   s     r   Útest_createÚINotifyTests.test_create¹   s"   € ò	#ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óH   • S nU R                  [        R                  U5      $ )z_
Deleting a file in a monitored directory sends an
C{inotify.IN_DELETE} event to the callback.
c                 óD   • U R                  5         U R                  5         g r   )rf   ÚremoverS   s    r   rK   Ú+INotifyTests.test_delete.<locals>.operationÊ   s   € Ø�J‰JŒLØ�K‰K�Mr   )rL   r	   Ú	IN_DELETErW   s     r   Útest_deleteÚINotifyTests.test_deleteÄ   s"   € ò	ð ×%Ñ%¤g×&7Ñ&7¸ÓCÐCr   c                 óX   • S nU R                  [        R                  XR                  S9$ )zc
Deleting the monitored directory itself sends an
C{inotify.IN_DELETE_SELF} event to the callback.
c                 ó$   • U R                  5         g r   )r™   rS   s    r   rK   Ú/INotifyTests.test_deleteSelf.<locals>.operationÖ   s   € Ø�K‰K�Mr   ©r:   )rL   r	   ÚIN_DELETE_SELFr   rW   s     r   Útest_deleteSelfÚINotifyTests.test_deleteSelfÐ   s0   € ò	ð ×%Ñ%Ü×"Ñ" I¿L¹Lð &ð 
ð 	
r   c                 óê   ^ ^• U 4S jnT R                   R                  T R                  SU4S j/S9  [        R                  " 5       mTR                  U5        T R                  R                  5         T$ )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                 óÄ   >• U u  pnTR                  UR                  5       TR                  R                  5       5        TR                  U[        R
                  -  5        g r   )r3   r4   r   r5   r	   r¢   )r6   r7   r8   r9   r   s       €r   r<   Ú6INotifyTests.test_deleteSelfForced.<locals>.cbNotifiedä   sJ   ø€ Ø(.Ñ%ˆU˜fØ×Ñ˜X×1Ñ1Ó3°T·\±\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   r   c                  ó&   >• TR                  U 5      $ r   r?   )rB   Úds    €r   rD   Ú4INotifyTests.test_deleteSelfForced.<locals>.<lambda>ê   s   ø€ ¸Q¿Z¹ZÈÔ=Mr   rF   )r	   r7   r   r   rI   rJ   r™   )r   r<   r©   s   ` @r   Útest_deleteSelfForcedÚ"INotifyTests.test_deleteSelfForcedÝ   s_   ù€ õ	=ð
 	�‰×ÑØ�L‰L˜sÔ/MÐ.Nð 	ñ 	
ô �NŠNÓˆØ	�‰�jÔ!à�‰×ÑÔØˆr   c                 ób   ^ • U 4S jnT R                  [        R                  UT R                  S9$ )za
Renaming the monitored directory itself sends an
C{inotify.IN_MOVE_SELF} event to the callback.
c                 ól   >• U R                  [        R                  " TR                  5       5      5        g r   )r„   r   r   r   r…   s    €r   rK   Ú-INotifyTests.test_moveSelf.<locals>.operationù   s    ø€ Ø�K‰Kœ×)Ò)¨$¯+©+«-Ó8Õ9r   r¡   )rL   r	   ÚIN_MOVE_SELFr   rW   s   ` r   Útest_moveSelfÚINotifyTests.test_moveSelfó   s3   ø€ õ	:ð ×%Ñ%Ü× Ñ  )¸$¿,¹,ð &ð 
ð 	
r   c                 ó,  ^ ^^• UU U4S jn[         R                  [         R                  -  nT R                   R                  T R                  USU/S9  T R                  R                  S5      m[        R                  " 5       mTR                  5         T$ )zt
L{inotify.INotify} when initialized with autoAdd==True adds
also adds the created subdirectories to the watchlist.
c                 óD   >• UUU4S jn[         R                  " SU5        g )Nc                  ó¾   >•  TR                  TR                  R                  T5      5        T R                  S 5        g ! [         a    T R                  5          g f = fr   )r5   r	   Ú
_isWatchedr@   Ú	ExceptionÚerrback©r©   r   Úsubdirs   €€€r   Ú_ÚIINotifyTests.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)Úwpr8   r;   r»   r©   r   rº   s       €€€r   Ú	_callbackÚ>INotifyTests.test_simpleSubdirectoryAutoAdd.<locals>._callback  ó   ø€ ÷ ô ×Ò˜a Õ#r   T©r;   ÚautoAddrG   Útest©	r	   ÚIN_ISDIRr”   r7   r   rH   r   rI   r   ©r   rÁ   Ú	checkMaskr©   rº   s   `  @@r   Útest_simpleSubdirectoryAutoAddÚ+INotifyTests.test_simpleSubdirectoryAutoAdd   sy   ú€ ÷
	$ô ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ñ 	
ð —‘×#Ñ# FÓ+ˆÜ�NŠNÓˆØ×ÑÔ Øˆr   c                 ó4  ^ ^^^• / mUUU U4S jn[         R                  [         R                  -  nT R                   R                  T R                  USU/S9  T R                  R                  S5      m[        R                  " 5       mTR                  5         T$ )zb
L{inotify.INotify} removes a directory from the watchlist when
it's removed from the filesystem.
c                 ó´   >• UUU4S jnUUU4S jnT(       d)  TR                  U5        [        R                  " SU5        g [        R                  " SU5        g )Nc                  ó¼   >•  TR                  TR                  R                  T5      5        TR                  5         g ! [         a    T R                  5          g f = fr   )r5   r	   r¶   r™   r·   r¸   r¹   s   €€€r   r»   ÚEINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._%  sD   ø€ ð Ø—O‘O D§L¡L×$;Ñ$;¸FÓ$CÔDØ—M‘M•OøÜ ó  Ø—I‘I–Kð ús   ƒ:> ¾AÁAc                  ó¾   >•  TR                  TR                  R                  T5      5        T R                  S 5        g ! [         a    T R                  5          g f = fr   ©ÚassertFalser	   r¶   r@   r·   r¸   r¹   s   €€€r   Ú_ebÚGINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._eb,  sI   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸VÓ%DÔEØ—J‘J˜tÕ$øÜ ó  Ø—I‘I–Kð úr½   r   )Úappendr   r¿   )	rÀ   r8   r;   r»   rÔ   Úcallsr©   r   rº   s	        €€€€r   rÁ   Ú:INotifyTests.test_simpleDeleteDirectory.<locals>._callback"  s@   ø€ ÷ ÷ ö à—‘˜XÔ&Ü×!Ò! ! QÕ'ô ×!Ò! ! SÕ)r   TrÄ   rÆ   rÇ   )r   rÁ   rÊ   r×   r©   rº   s   `  @@@r   Útest_simpleDeleteDirectoryÚ'INotifyTests.test_simpleDeleteDirectory  s…   û€ ð
 ˆ÷	*ð 	*ô4 ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ñ 	
ð —‘×#Ñ# FÓ+ˆÜ�NŠNÓˆØ×ÑÔ Øˆr   c                 óR  ^ ^^• UU 4S jnT R                  T R                  R                  T R                  [        R                  U4S j/S95        [
        R                  " 5       mTR                  U5        T R                  R                  5         [
        R                  " 5       mT$ )z‚
L{inotify.INotify} closes the file descriptor after removing a
directory from the filesystem (and therefore from the watchlist).
c                 ó   >• UU4S jnU u  p#nTR                  UR                  5       TR                  R                  5       5        TR                  U[        R
                  -  5        [        R                  " SU5        g )Nc                  ó  >•  TR                  TR                  R                  TR                  5      5        TR                  TR                  R                  5        T R                  S 5        g ! [         a    T R                  5          g f = fr   )rÓ   r	   r¶   r   Ú	connectedr@   r·   r¸   )r©   r   s   €€r   r»   ÚIINotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotified.<locals>._L  se   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸T¿\¹\Ó%JÔKØ×$Ñ$ T§\¡\×%;Ñ%;Ô<Ø—J‘J˜tÕ$øÜ ó  Ø—I‘I–Kð ús   ƒA*A. Á.BÂ
Br   )r3   r4   r   r5   r	   r¢   r   r¿   )r6   r»   Úignoredr8   r9   r©   r   s        €€r   r<   Ú>INotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotifiedK  sa   ø€ ö ð +1Ñ'ˆW Ø×Ñ˜X×1Ñ1Ó3°T·\±\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Ô<Ü×Ò˜a Õ#r   c                  ó&   >• TR                  U 5      $ r   r?   rA   s    €r   rD   Ú<INotifyTests.test_deleteSelfLoseConnection.<locals>.<lambda>]  s   ø€ ¨×):Ñ):¸4Ô)@r   rF   )	r5   r	   r7   r   r¢   r   rI   rJ   r™   )r   r<   r©   rC   s   ` @@r   Útest_deleteSelfLoseConnectionÚ*INotifyTests.test_deleteSelfLoseConnectionE  s€   ú€ ö	$ð 	�‰Ø�L‰L×ÑØ—‘Ü×+Ñ+Ü@ÐAð ð ô	
ô —>’>Ó#ˆØ×Ñ˜ZÔ(à�‰×ÑÔÜ�NŠNÓˆØˆr   c                 óf  • U R                   R                  U R                  SS9  U R                  U R                   R	                  U R                  5      5        U R                   R                  U R                  5        U R                  U R                   R	                  U R                  5      5        g)zB
L{inotify.INotify.ignore} removes a directory from the watchlist
T)rÅ   N)r	   r7   r   r5   r¶   ÚignorerÓ   r   s    r   Útest_ignoreDirectoryÚ!INotifyTests.test_ignoreDirectoryh  su   € ð 	�‰×Ñ˜4Ÿ<™<°ÐÑ6Ø�‰˜Ÿ™×/Ñ/°·±Ó=Ô>Ø�‰×Ñ˜DŸL™LÔ)Ø×Ñ˜Ÿ™×0Ñ0°·±Ó>Õ?r   c                 óN  • [         R                   H.  u  pU R                  [         R                  " U5      S   U5        M0     [         R                  [         R
                  -  [         R                  -  nU R                  [        [         R                  " U5      5      1 Sk5        g)za
L{inotify.humaReadableMask} translates all the possible event
masks to a human readable string.
r   >   r]   ÚaccessÚclose_writeN)r	   Ú_FLAG_TO_HUMANr3   ÚhumanReadableMaskrr   rV   r   Úset)r   r;   ÚvaluerÊ   s       r   Útest_humanReadableMaskÚ#INotifyTests.test_humanReadableMaskq  s{   € ô
 #×1Ô1‰KˆDØ×ÑœW×6Ò6°tÓ<¸QÑ?ÀÖGñ 2ô ×*Ñ*¬W×->Ñ->Ñ>ÄÇÁÑPˆ	Ø×ÑÜ”×)Ò)¨)Ó4Ó5Ú-õ	
r   c                 óœ  • U R                   R                  S5      nUR                  S5      nUR                  S5      nUR                  5         XU/nU R                  R	                  U R                   SS9  U R                  R	                  U R                   SS9  U H-  nU R                  U R                  R                  U5      5        M/     g)zv
L{inotify.INotify.watch} with recursive==True will add all the
subdirectories under the given path to the watchlist.
rÆ   Útest2Útest3T)Ú	recursiveN)r   rH   Úmakedirsr	   r7   r5   r¶   )r   rº   Úsubdir2Úsubdir3Údirsr©   s         r   Útest_recursiveWatchÚ INotifyTests.test_recursiveWatch  s¥   € ð
 —‘×#Ñ# FÓ+ˆØ—,‘,˜wÓ'ˆØ—-‘- Ó(ˆØ×ÑÔØ Ð)ˆØ�‰×Ñ˜4Ÿ<™<°4ÐÑ8à�‰×Ñ˜4Ÿ<™<°4ÐÑ8ÛˆAØ�O‰O˜DŸL™L×3Ñ3°AÓ6Ö7ò r   c                 ó¬   • SSK n[        R                  " 5       nUR                  UR                  5        UR                  5         U R                  5         g)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   ro   Ú_fdr   ÚflushLoggedErrors)r   rþ   Úin_s      r   Útest_connectionLostErrorÚ%INotifyTests.test_connectionLostError�  s;   € ó
 	ä�oŠoÓˆØ
�‰�—‘ÔØ×ÑÔØ×ÑÕ r   c                 ó,  ^ ^^• UU U4S jn[         R                  [         R                  -  nT R                   R                  T R                  USU/S9  T R                  R                  S5      m[        R                  " 5       mTR                  5         T$ )z|
L{inotify.INotify.watch} with autoAdd==False will stop inotify
from watching subdirectories created under the watched one.
c                 óD   >• UUU4S jn[         R                  " SU5        g )Nc                  ó¾   >•  TR                  TR                  R                  T5      5        T R                  S 5        g ! [         a    T R                  5          g f = fr   rÒ   r¹   s   €€€r   r»   ÚEINotifyTests.test_noAutoAddSubdirectory.<locals>._callback.<locals>._¤  sI   ø€ ð Ø×$Ñ$ T§\¡\×%<Ñ%<¸VÓ%DÔEØ—J‘J˜tÕ$øÜ ó  Ø—I‘I–Kð úr½   r   r¾   )rÀ   Úfpr;   r»   r©   r   rº   s       €€€r   rÁ   Ú:INotifyTests.test_noAutoAddSubdirectory.<locals>._callback¡  rÃ   r   FrÄ   rÆ   rÇ   rÉ   s   `  @@r   Útest_noAutoAddSubdirectoryÚ'INotifyTests.test_noAutoAddSubdirectory›  sy   ú€ ÷
	$ô ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°%ÀIÀ;ð 	ñ 	
ð —‘×#Ñ# FÓ+ˆÜ�NŠNÓˆØ×ÑÔ Øˆr   c                 óä  ^ ^^• T R                   R                  S5      mTR                  5         [        R                  " 5       mUU 4S jnU4S jnT R                  T R                  R                  TU/S95        T R                  R                  T5        T R                  T R                  R                  T[        R                  U/S95        TR                  U5        TR                  5         T$ )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                 ó°   >• U u  pnTR                  UR                  5       TR                  5       5        TR                  U[        R                  -  5        g r   ©r3   r4   r5   r	   r¢   )r6   rà   r8   r9   r:   r   s       €€r   r<   Ú<INotifyTests.test_seriesOfWatchAndIgnore.<locals>.cbNotifiedÀ  sF   ø€ Ø*0Ñ'ˆW Ø×Ñ˜X×1Ñ1Ó3°\×5MÑ5MÓ5OÔPØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   c                  ó(   >• TR                  U 5        g r   r?   rA   s    €r   ÚcallItÚ8INotifyTests.test_seriesOfWatchAndIgnore.<locals>.callItÅ  ó   ø€ Ø×Ñ˜dÕ#r   ©rG   rF   )r   rH   rf   r   rI   r5   r	   r7   rç   r¢   rJ   r™   )r   r<   r  r:   rC   s   `  @@r   Útest_seriesOfWatchAndIgnoreÚ(INotifyTests.test_seriesOfWatchAndIgnore¶  sÆ   ú€ ð
 —|‘|×)Ñ)¨*Ó5ˆØ×ÑÔä—>’>Ó#ˆö	=õ
	$ð 	�‰˜Ÿ™×*Ñ*¨<ÀFÀ8Ð*ÐLÔMØ�‰×Ñ˜LÔ)Ø�‰Ø�L‰L×ÑØ¤7×#9Ñ#9ÀfÀXð ð ô	
ð 	×Ñ˜ZÔ(ð 	×ÑÔàˆr   c                 óx  ^ ^^• T R                   R                  S5      nUR                  5         T R                   R                  S5      mTR                  5         [        R                  " 5       mUU 4S jnU4S jnT R                  T R                  R                  U[        R                  U/S95        TR                  U5        T R                  T R                  R                  T[        R                  U/S95        T R                  R                  U5        UR                  5         TR                  5         T$ )zZ
L{inotify.INotify} will ignore a filepath after it has been removed from
the watch list.
r  zfoo.bar3c                 ó°   >• U u  pnTR                  UR                  5       TR                  5       5        TR                  U[        R                  -  5        g r   r  )r6   rà   r8   r9   ÚexpectedPath2r   s       €€r   r<   Ú4INotifyTests.test_ignoreFilePath.<locals>.cbNotifiedç  sF   ø€ Ø*0Ñ'ˆW Ø×Ñ˜X×1Ñ1Ó3°]×5NÑ5NÓ5PÔQØ�O‰O˜F¤W×%;Ñ%;Ñ;Õ<r   c                  ó(   >• TR                  U 5        g r   r?   rA   s    €r   r  Ú0INotifyTests.test_ignoreFilePath.<locals>.callItì  r  r   r  )r   rH   rf   r   rI   r5   r	   r7   r¢   rJ   rç   r™   )r   r:   r<   r  r  rC   s   `   @@r   Útest_ignoreFilePathÚ INotifyTests.test_ignoreFilePathÛ  sþ   ú€ ð
 —|‘|×)Ñ)¨*Ó5ˆØ×ÑÔØŸ™×*Ñ*¨:Ó6ˆØ×ÑÔä—>’>Ó#ˆö	=õ
	$ð 	�‰Ø�L‰L×Ñ˜|¬W×-CÑ-CÐPVÈxÐÐXô	
ð 	×Ñ˜ZÔ(à�‰Ø�L‰L×ÑØœw×5Ñ5À&Àð ð ô	
ð 	�‰×Ñ˜LÔ)à×ÑÔØ×ÑÔàˆr   c                 ó°   • U R                   R                  S5      nUR                  5         U R                  [        U R
                  R                  U5        g)zN
L{inotify.INotify} will raise KeyError if a non-watched filepath is
ignored.
zfoo.ignoredN)r   rH   rf   r.   ÚKeyErrorr	   rç   )r   r:   s     r   Útest_ignoreNonWatchedFileÚ&INotifyTests.test_ignoreNonWatchedFile  s@   € ð
 —|‘|×)Ñ)¨-Ó8ˆØ×ÑÔà×Ñœ( D§L¡L×$7Ñ$7¸ÕFr   c                 óš  ^ ^^^^^	^
• [        5       mUUU UUU	U
4S jn[        R                  [        R                  -  nT R                  R	                  T R
                  USU/S9  T R
                  R                  S5      mTR                  S5      m	T	R                  S5      m
[        R                  " 5       mT
R                  5         TR                  S5      T	R                  S5      T
R                  S	5      /m[        T5       HB  u  p4UR                  UR                  R                  [        R                  " 5       5      5        MD     T$ )
a  
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                 ól  >• TR                  U5        [        T5      S:X  aî   TR                  TR                  R	                  T	5      5        TR                  TR                  R	                  T
5      5        TR                  TR                  R	                  T5      5        TT	T
T/-   nU Vs1 s H  oDR                  5       iM     nnTR                  [        T5      [        U5      5        TR                  TU5        TR                  S 5        g g s  snf ! [         a    TR                  5          g f = f)Né   )
ÚaddÚlenr5   r	   r¶   r4   r3   r@   r·   r¸   )rÀ   r8   r;   ÚcreatedÚfr×   r©   r   Ú	someFilesrº   rø   rù   s        €€€€€€€r   rÁ   Ú?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Ÿ}™}ž¹�GÐ@Ø×$Ñ$¤S¨£Z´°W³Ô>Ø×$Ñ$ U¨GÔ4ð —J‘J˜tÕ$ð ùò Aøô !ó  Ø—I‘I–Kð ús$   £B
D Â-DÃ8D ÄD ÄD3Ä2D3TrÄ   rÆ   rô   rõ   z	file1.datz	file2.datz	file3.dat)rï   r	   rÈ   r”   r7   r   rH   r   rI   r÷   Ú	enumeraterQ   rT   ÚencodeÚsysÚgetfilesystemencoding)r   rÁ   rÊ   Úir8   r×   r©   r+  rº   rø   rù   s   `    @@@@@@r   Útest_complexSubdirectoryAutoAddÚ,INotifyTests.test_complexSubdirectoryAutoAdd  s	  þ€ ô “ˆ÷	%ó 	%ô  ×$Ñ$¤w×'8Ñ'8Ñ8ˆ	Ø�‰×ÑØ�L‰L˜y°$À9À+ð 	ñ 	
ð —‘×#Ñ# FÓ+ˆØ—,‘,˜wÓ'ˆØ—-‘- Ó(ˆÜ�NŠNÓˆØ×ÑÔð �L‰L˜Ó%Ø�M‰M˜+Ó&Ø�M‰M˜+Ó&ð
ˆ	ô % YÖ/‰KˆAØ×Ñ §¡× 4Ñ 4´S×5NÒ5NÓ5PÓ QÖRñ 0àˆr   )r   r	   r   )&r&   r'   r(   r)   Ú__doc__r   ÚplatformÚsupportsINotifyÚskipr   r/   rL   rX   rb   ri   rs   rz   r€   rˆ   r�   r•   rœ   r£   r«   r±   rË   rÙ   rä   rè   rñ   rû   r  r
  r  r  r"  r2  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   )r4  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   