AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_inotify.cpython-310.pyc
o

�b�H�@sxdZddlZddlmZmZddlmZmZddlm	Z	ddl
mZe	d�dur/ddlmZndZGd	d
�d
ej
�ZdS)z?
Tests for the inotify wrapper in L{twisted.internet.inotify}.
�N)�defer�reactor)�filepath�runtime)�
requireModule)�unittestztwisted.python._inotify)�inotifyc@seZdZdZej��s
dZdd�Zdd�Z	d<dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#dS)=�INotifyTestsz]
    Define all the tests for the basic functionality exposed by
    L{inotify.INotify}.
    z&This platform doesn't support INotify.cCs@t�|���|_|j��t��|_|j��|�|jj	�dS�N)
r�FilePath�mktemp�dirname�createDirectoryr�INotify�startReading�
addCleanup�loseConnection��self�r�D/usr/lib/python3/dist-packages/twisted/internet/test/test_inotify.py�setUps



zINotifyTests.setUpcCs4Gdd�d�}|�tjd|��|�tjtj�dS)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@seZdZdd�ZdS)z;INotifyTests.test_initializationErrors.<locals>.FakeINotifycSst���r
)r�INotifyErrorrrrr�init.sz@INotifyTests.test_initializationErrors.<locals>.FakeINotify.initN)�__name__�
__module__�__qualname__rrrrr�FakeINotify-sr�_inotifyN)�patchrr�assertRaisesr)rrrrr�test_initializationErrors$s	z&INotifyTests.test_initializationErrorsNcs`�dur
�j�d��t������fdd�}��|��jj�j��fdd�gd�|���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.
        Nzfoo.barcs0|\}}}��|��������|�@�dSr
)�assertEqual�asBytesMode�
assertTrue��result�watch�filename�events)�expectedPath�maskrrr�
cbNotifiedKs
z2INotifyTests._notificationTest.<locals>.cbNotifiedc�
��|�Sr
��callback��args��notifiedrr�<lambda>S�
z0INotifyTests._notificationTest.<locals>.<lambda>�r+�	callbacks)r
�childr�Deferred�addCallbackrr')rr+�	operationr*r,r)r*r+r3rr�_notificationTest4s
�zINotifyTests._notificationTestcC�dd�}|�tj|�S)z{
        Reading from a file in a monitored directory sends an
        C{inotify.IN_ACCESS} event to the callback.
        cSs|�d�|��dS)N�foo)�
setContent�
getContent��pathrrrr;^s
z+INotifyTests.test_access.<locals>.operation)r<r�	IN_ACCESS�rr;rrr�test_accessX�zINotifyTests.test_accesscCr=)zy
        Writing to a file in a monitored directory sends an
        C{inotify.IN_MODIFY} event to the callback.
        cSs:|�d��}|�d�Wd�dS1swYdS)N�wr>)�open�write)rB�fObjrrrr;js"�z+INotifyTests.test_modify.<locals>.operation)r<r�	IN_MODIFYrDrrr�test_modifydrFzINotifyTests.test_modifycCr=)z�
        Changing the metadata of a file in a monitored directory
        sends an C{inotify.IN_ATTRIB} event to the callback.
        cSs|��|��dSr
)�touchrArrrr;v�z+INotifyTests.test_attrib.<locals>.operation)r<r�	IN_ATTRIBrDrrr�test_attribprFzINotifyTests.test_attribcCr=)z�
        Closing a file which was open for writing in a monitored
        directory sends an C{inotify.IN_CLOSE_WRITE} event to the
        callback.
        cS�|�d���dS�NrG�rH�closerArrrr;��z/INotifyTests.test_closeWrite.<locals>.operation)r<r�IN_CLOSE_WRITErDrrr�test_closeWrite|szINotifyTests.test_closeWritecCr=)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.
        cSs|��|�d���dS)N�r)rMrHrTrArrrr;�sz1INotifyTests.test_closeNoWrite.<locals>.operation)r<r�IN_CLOSE_NOWRITErDrrr�test_closeNoWrite�szINotifyTests.test_closeNoWritecCr=)zt
        Opening a file in a monitored directory sends an
        C{inotify.IN_OPEN} event to the callback.
        cSrQrRrSrArrrr;�rUz)INotifyTests.test_open.<locals>.operation)r<r�IN_OPENrDrrr�	test_open��zINotifyTests.test_openc��fdd�}��tj|�S)z}
        Moving a file out of a monitored directory sends an
        C{inotify.IN_MOVED_FROM} event to the callback.
        cs&|�d���|�t������dSrR)rHrT�moveTorrrrArrrr;�sz.INotifyTests.test_movedFrom.<locals>.operation)r<r�
IN_MOVED_FROMrDrrr�test_movedFrom�szINotifyTests.test_movedFromcr^)zy
        Moving a file into a monitored directory sends an
        C{inotify.IN_MOVED_TO} event to the callback.
        cs$t�����}|��|�|�dSr
)rrrrMr_)rB�prrrr;�sz,INotifyTests.test_movedTo.<locals>.operation)r<r�IN_MOVED_TOrDrrr�test_movedTo�szINotifyTests.test_movedTocCr=)zw
        Creating a file in a monitored directory sends an
        C{inotify.IN_CREATE} event to the callback.
        cSrQrRrSrArrrr;�rUz+INotifyTests.test_create.<locals>.operation)r<r�	IN_CREATErDrrr�test_create�r]zINotifyTests.test_createcCr=)zw
        Deleting a file in a monitored directory sends an
        C{inotify.IN_DELETE} event to the callback.
        cSs|��|��dSr
)rM�removerArrrr;�rNz+INotifyTests.test_delete.<locals>.operation)r<r�	IN_DELETErDrrr�test_delete�rFzINotifyTests.test_deletecCsdd�}|jtj||jd�S)z{
        Deleting the monitored directory itself sends an
        C{inotify.IN_DELETE_SELF} event to the callback.
        cSs|��dSr
)rgrArrrr;�sz/INotifyTests.test_deleteSelf.<locals>.operation�r*)r<r�IN_DELETE_SELFr
rDrrr�test_deleteSelf�s
�zINotifyTests.test_deleteSelfcsJ�fdd�}�jj�jd�fdd�gd�t�����|��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().
        cs4|\}}}��|���j�����|tj@�dSr
)r"r#r
r$rrkr%rrrr,�s
z6INotifyTests.test_deleteSelfForced.<locals>.cbNotifiedrcr-r
r.r0)�drrr4�r5z4INotifyTests.test_deleteSelfForced.<locals>.<lambda>r6)rr'r
rr9r:rg�rr,r�rmrr�test_deleteSelfForced�s�

z"INotifyTests.test_deleteSelfForcedcs �fdd�}�jtj|�jd�S)zy
        Renaming the monitored directory itself sends an
        C{inotify.IN_MOVE_SELF} event to the callback.
        cs|�t������dSr
)r_rrrrArrrr;�sz-INotifyTests.test_moveSelf.<locals>.operationrj)r<r�IN_MOVE_SELFr
rDrrr�
test_moveSelf�s
�zINotifyTests.test_moveSelfc�T���fdd�}tjtjB}�jj�j|d|gd��j�d��t�������S)z�
        L{inotify.INotify} when initialized with autoAdd==True adds
        also adds the created subdirectories to the watchlist.
        c� ���fdd�}t�d|�dS)Nc�@z���j������d�WdSty���YdSwr
)r$r�
_isWatchedr/�	Exception�errbackr�rmr�subdirrr�_	��zIINotifyTests.test_simpleSubdirectoryAutoAdd.<locals>._callback.<locals>._r�r�	callLater)�wpr(r+r{ryrr�	_callback�z>INotifyTests.test_simpleSubdirectoryAutoAdd.<locals>._callbackT�r+�autoAddr7�test�	r�IN_ISDIRrer'r
r8rr9r�rr��	checkMaskrryr�test_simpleSubdirectoryAutoAdd��z+INotifyTests.test_simpleSubdirectoryAutoAddcsZg�����fdd�}tjtjB}�jj�j|d|gd��j�d��t�������S)zz
        L{inotify.INotify} removes a directory from the watchlist when
        it's removed from the filesystem.
        csN���fdd�}���fdd�}�s��|�t�d|�dSt�d|�dS)Ncs>z���j�������WdSty���YdSwr
)r$rrvrgrwrxrryrrr{%s�zEINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._crur
��assertFalserrvr/rwrxrryrr�_eb,s�zGINotifyTests.test_simpleDeleteDirectory.<locals>._callback.<locals>._ebr)�appendrr~)rr(r+r{r���callsrmrrzrrr�"s
z:INotifyTests.test_simpleDeleteDirectory.<locals>._callbackTr�r�r�r�rr�r�test_simpleDeleteDirectorys�z'INotifyTests.test_simpleDeleteDirectorycs\��fdd�}���jj�jtj�fdd�gd��t�����|��j��t����S)z�
        L{inotify.INotify} closes the file descriptor after removing a
        directory from the filesystem (and therefore from the watchlist).
        csN��fdd�}|\}}}��|���j�����|tj@�t�d|�dS)NcsPz���j��j�����jj���d�WdSty'���YdSwr
)r�rrvr
�	connectedr/rwrxrrorrr{Ls�zIINotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotified.<locals>._r)r"r#r
r$rrkrr~)r&r{�ignoredr(r)rorrr,Ks

z>INotifyTests.test_deleteSelfLoseConnection.<locals>.cbNotifiedcr-r
r.r0r2rrr4]r5z<INotifyTests.test_deleteSelfLoseConnection.<locals>.<lambda>r6)	r$rr'r
rkrr9r:rgrnr)rmr3rr�test_deleteSelfLoseConnectionEs��

z*INotifyTests.test_deleteSelfLoseConnectioncCsL|jj|jdd�|�|j�|j��|j�|j�|�|j�|j��dS)zR
        L{inotify.INotify.ignore} removes a directory from the watchlist
        T)r�N)rr'r
r$rv�ignorer�rrrr�test_ignoreDirectoryhsz!INotifyTests.test_ignoreDirectorycCsVtjD]\}}|�t�|�d|�qtjtjBtjB}|�tt�|��hd��dS)zy
        L{inotify.humaReadableMask} translates all the possible event
        masks to a human readable string.
        r>rH�access�close_writeN)r�_FLAG_TO_HUMANr"�humanReadableMaskrVrCr[�set)rr+�valuer�rrr�test_humanReadableMaskqs�z#INotifyTests.test_humanReadableMaskcCsv|j�d�}|�d�}|�d�}|��|||g}|jj|jdd�|jj|jdd�|D]}|�|j�|��q-dS)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
r8�makedirsrr'r$rv)rrz�subdir2�subdir3�dirsrmrrr�test_recursiveWatchs


�z INotifyTests.test_recursiveWatchcCs0ddl}t��}|�|j�|��|��dS)z�
        L{inotify.INotify.connectionLost} if there's a problem while closing
        the fd shouldn't raise the exception but should log the error
        rN)�osrrrT�_fdr�flushLoggedErrors)rr��in_rrr�test_connectionLostError�s
z%INotifyTests.test_connectionLostErrorcrs)z�
        L{inotify.INotify.watch} with autoAdd==False will stop inotify
        from watching subdirectories created under the watched one.
        crt)Ncrur
r�rryrrr{�r|zEINotifyTests.test_noAutoAddSubdirectory.<locals>._callback.<locals>._rr})r�fpr+r{ryrrr��r�z:INotifyTests.test_noAutoAddSubdirectory.<locals>._callbackFr�r�r�r�rryr�test_noAutoAddSubdirectory�r�z'INotifyTests.test_noAutoAddSubdirectorycs��j�d�����t�����fdd�}�fdd�}���jj�|gd���j������jj�tj	|gd����
|�����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�2|\}}}��|��������|tj@�dSr
�r"r#r$rrk�r&r�r(r))r*rrrr,��
z<INotifyTests.test_seriesOfWatchAndIgnore.<locals>.cbNotifiedc���|�dSr
r.r0r2rr�callIt��z8INotifyTests.test_seriesOfWatchAndIgnore.<locals>.callIt�r7r6)r
r8rMrr9r$rr'r�rkr:rg)rr,r�r)r*r3rr�test_seriesOfWatchAndIgnore�s
��
z(INotifyTests.test_seriesOfWatchAndIgnorecs��j�d�}|���j�d�����t�����fdd�}�fdd�}���jj|tj|gd����	|����jj�tj|gd���j�
|�|������S)zr
        L{inotify.INotify} will ignore a filepath after it has been removed from
        the watch list.
        r�zfoo.bar3cr�r
r�r�)�
expectedPath2rrrr,�r�z4INotifyTests.test_ignoreFilePath.<locals>.cbNotifiedcr�r
r.r0r2rrr��r�z0INotifyTests.test_ignoreFilePath.<locals>.callItr�)r
r8rMrr9r$rr'rkr:r�rg)rr*r,r�r)r�r3rr�test_ignoreFilePath�s(�

��z INotifyTests.test_ignoreFilePathcCs*|j�d�}|��|�t|jj|�dS)zf
        L{inotify.INotify} will raise KeyError if a non-watched filepath is
        ignored.
        zfoo.ignoredN)r
r8rMr �KeyErrorrr�)rr*rrr�test_ignoreNonWatchedFilesz&INotifyTests.test_ignoreNonWatchedFilecs�t���������fdd�}tjtjB}�jj�j|d|gd��j�d����d����d��t�����	���d���d	���d
�g�t
��D]\}}|�|j�
t����qK�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.
        cs���|�t��dkr\z;���j�������j�������j��������g}dd�|D�}��t��t|�����|�WntyT���YdSw��d�dSdS)N�cSsh|]}|���qSr)r#)�.0�frrr�	<setcomp>szRINotifyTests.test_complexSubdirectoryAutoAdd.<locals>._callback.<locals>.<setcomp>)	�add�lenr$rrvr"rwrxr/)rr(r+�created�r�rmr�	someFilesrzr�r�rrr�s
��z?INotifyTests.test_complexSubdirectoryAutoAdd.<locals>._callbackTr�r�r�r�z	file1.datz	file2.datz	file3.dat)r�rr�rer'r
r8rr9r��	enumerater?rB�encode�sys�getfilesystemencoding)rr�r��ir(rr�r�test_complexSubdirectoryAutoAdds$	�

�z,INotifyTests.test_complexSubdirectoryAutoAddr
)$rrr�__doc__r�platform�supportsINotify�skiprr!r<rErLrPrWrZr\rardrfrirlrprrr�r�r�r�r�r�r�r�r�r�r�r�rrrrr	s@

$



*#	%&
r	)r�r��twisted.internetrr�twisted.pythonrr�twisted.python.reflectr�
twisted.trialrr�TestCaser	rrrr�<module>s

Anon7 - 2022
AnonSec Team