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

�b��@s�ddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZmZdd
lmZddlmZddlmZdd
lmZmZmZm Z ddl!m"Z"ddl#m$Z$m%Z%Gdd�d�Z&e
e$�Gdd�d��Z'Gdd�d�Z(Gdd�de(ej)�Z*Gdd�de(ej)�Z+Gdd�d�Z,Gdd�de,ej)�Z-Gdd�de,ej)�Z.Gd d!�d!e,ej)�Z/Gd"d#�d#ej)�Z0Gd$d%�d%ej)�Z1Gd&d'�d'ej)�Z2Gd(d)�d)e2�Z3Gd*d+�d+ej4�Z5Gd,d-�d-ej)�Z6Gd.d/�d/ej)�Z7Gd0d1�d1�Z8Gd2d3�d3e8e7�Z9Gd4d5�d5e8e7�Z:Gd6d7�d7ej)�Z;Gd8d9�d9ej)�Z<Gd:d;�d;ej)�Z=Gd<d=�d=ej)�Z>Gd>d?�d?ej)�Z?dS)@�N)�StringIO)�List)�implementer)�verifyObject)�plugin)�defer)�
twisted_trial)�failure�log�reflect)�FilePath��namedAny)�trial)�reporter�runner�unittest�util)� _ForceGarbageCollectionDecorator)�	IReporter�	ITestCasec@seZdZdd�Zdd�ZdS)�CapturingDebuggercC�
g|_dS�N)�_calls��self�r�@/usr/lib/python3/dist-packages/twisted/trial/test/test_runner.py�__init__�
zCapturingDebugger.__init__cOs*|j�d�|d|dd�i|��dS)N�runcallr��r�append)r�args�kwargsrrrr!"szCapturingDebugger.runcallN)�__name__�
__module__�__qualname__rr!rrrrrsrc@s�eZdZdZdZdZdZdZdZddd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zddd�Zddd�Zdd�Zdd�ZdS)�CapturingReporterzC
    Reporter that keeps a log of all actions performed on it.
    NcCs(g|_d|_||_||_||_||_dS)z.
        Create a capturing reporter.
        FN)r�
shouldStop�_stream�	_tbformat�	_rterrors�
_publisher)r�stream�tbformat�rterrors�	publisherrrrr3s
zCapturingReporter.__init__cC�|j�d�dS)z�
        Report the beginning of a run of a single test method
        @param method: an object that is adaptable to ITestMethod
        �	startTestNr#�r�methodrrrr5>�zCapturingReporter.startTestcCr4)z}
        Report the status of a single test method
        @param method: an object that is adaptable to ITestMethod
        �stopTestNr#r6rrrr9Er8zCapturingReporter.stopTestcCr4)z�called when the reactor has been left in a 'dirty' state
        @param errs: a list of L{twisted.python.failure.Failure}s
        �cleanupErrorNr#)r�errsrrr�
cleanupErrorsL�zCapturingReporter.cleanupErrorscCs|j�d�dS)N�
addSuccessr#�r�testrrrr>R�zCapturingReporter.addSuccesscC�dS)z@
        Do nothing. These tests don't care about done.
        Nrrrrr�doneU�zCapturingReporter.donecCrB)zD
        Do nothing. These tests don't care about addError.
        Nr�rr@�errorrrr�addErrorZrDzCapturingReporter.addErrorcCrB)zF
        Do nothing. These tests don't care about addFailure.
        Nr)rr@r	rrr�
addFailure_rDzCapturingReporter.addFailurecCrB)zN
        Do nothing. These tests don't care about addExpectedFailure.
        Nr)rr@r	�todorrr�addExpectedFailuredrDz$CapturingReporter.addExpectedFailurecCrB)zP
        Do nothing. These tests don't care about addUnexpectedSuccess.
        Nr)rr@rIrrr�addUnexpectedSuccessirDz&CapturingReporter.addUnexpectedSuccesscCrB)zC
        Do nothing. These tests don't care about addSkip.
        Nr)rr@�reasonrrr�addSkipnrDzCapturingReporter.addSkipcCrB)zI
        Do nothing. These tests don't care about wasSuccessful.
        Nrrrrr�
wasSuccessfulsrDzCapturingReporter.wasSuccessful)NNNNr)r'r(r)�__doc__r0r1r%�	separator�testsRunrr5r9r<r>rCrGrHrJrKrMrNrrrrr*'s&


r*c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�TrialRunnerTestsMixinz9
    Mixin defining tests for L{runner.TrialRunner}.
    cCs|j��dSr)r�_tearDownLogFilerrrr�tearDown~�zTrialRunnerTestsMixin.tearDowncCrB)z=
        Empty test method, used by the other tests.
        Nrrrrr�
test_empty�rDz TrialRunnerTestsMixin.test_emptycCstjjSr)r
�theLogPublisher�	observersrrrr�
_getObservers�sz#TrialRunnerTestsMixin._getObserverscCs6t|���}|j�|j�t|���}|�||�dS)zn
        Any log system observers L{TrialRunner.run} adds are removed by the
        time it returns.
        N)�lenrYr�runr@�assertEqual)r�
originalCount�newCountrrr�test_addObservers�sz'TrialRunnerTestsMixin.test_addObserverscsl�jj�g����fdd�}|�j_�j��j��j��j���t��d����d�dud�dS)z=
        Test that a new file is opened on each run.
        c������jj�dSr)r$r�_logFileObserverr��l�oldSetUpLogFilerrr�setUpLogFile��zDTrialRunnerTestsMixin.test_logFileAlwaysActive.<locals>.setUpLogFile�rr"z'Should have created a new file observerN)r�
_setUpLogFiler[r@r\rZ�assertFalse�rrerrbr�test_logFileAlwaysActive�sz.TrialRunnerTestsMixin.test_logFileAlwaysActivecsV�jj�g����fdd�}|�j_�j��j���t��d����dj�dS)zB
        Test that file created is closed during the run.
        cr`r)r$r�_logFileObjectrrbrrre�rfzBTrialRunnerTestsMixin.test_logFileGetsClosed.<locals>.setUpLogFiler"rN)rrhr[r@r\rZ�
assertTrue�closedrjrrbr�test_logFileGetsClosed�sz,TrialRunnerTestsMixin.test_logFileGetsClosedN)
r'r(r)rOrTrVrYr_rkrorrrrrRys
rRc@� eZdZdZdd�Zdd�ZdS)�TrialRunnerTestszm
    Tests for L{runner.TrialRunner} with the feature to turn unclean errors
    into warnings disabled.
    cCs(t�|_tjt|jd�|_td�|_dS)N�r0rV�rr0r�TrialRunnerr*rqr@rrrr�setUp�szTrialRunnerTests.setUpcCs|j��}|�|jt�dS)z�
        The reporter constructed by L{runner.TrialRunner} is passed
        L{twisted.python.log} as the value for the C{publisher} parameter.
        N)r�_makeResult�assertIdenticalr/r
�r�resultrrr�test_publisher�s
zTrialRunnerTests.test_publisherN)r'r(r)rOrurzrrrrrq�srqc@�eZdZdZdd�ZdS)�+TrialRunnerWithUncleanWarningsReporterTestsza
    Tests for the TrialRunner's interaction with an unclean-error suppressing
    reporter.
    cCs*t�|_tjt|jdd�|_td�|_dS)NT�r0�uncleanWarningsrVrsrrrrru�s
�z1TrialRunnerWithUncleanWarningsReporterTests.setUpN�r'r(r)rOrurrrrr|�sr|c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�DryRunMixinze
    Mixin for testing that 'dry run' mode works with various
    L{pyunit.TestCase} subclasses.
    cCs2g|_t�|_tjttjj|jd�|_|��dS)Nrr)r
rr0rrtr*�DRY_RUN�makeTestFixturesrrrrru�s�zDryRunMixin.setUpcCrB)zh
        Set C{self.test} and C{self.suite}, where C{self.suite} is an empty
        TestSuite.
        Nrrrrrr��rDzDryRunMixin.makeTestFixturescCs"|j�t���}|�|jg�dS)zf
        If there are no tests, the reporter should not receive any events to
        report.
        N)rr[�	TestSuiter\rrxrrrrV�szDryRunMixin.test_emptycCs$|j�|j�}|�|jgd��dS)z�
        If we are running a single test, check the reporter starts, passes and
        then stops the test during a dry run.
        )r5r>r9N)rr[r@r\rrxrrr�test_singleCaseReporting�sz$DryRunMixin.test_singleCaseReportingcCs |j�|j�|�|jg�dS)zT
        When we are doing a dry run, the tests should not actually be run.
        N)rr[r@r\r
rrrr�test_testsNotRun�szDryRunMixin.test_testsNotRunN)	r'r(r)rOrur�rVr�r�rrrrr��sr�c@r{)�SynchronousDryRunTestszS
    Check that 'dry run' mode works well with trial's L{SynchronousTestCase}.
    cCs*Gdd�dtj�}|d�|_t��|_dS)Nc@�eZdZdd�ZdS)z;SynchronousDryRunTests.makeTestFixtures.<locals>.PyunitCasecS�dSrrrrrr�test_foo�zDSynchronousDryRunTests.makeTestFixtures.<locals>.PyunitCase.test_fooN�r'r(r)r�rrrr�
PyunitCase�r�r�)r�SynchronousTestCaser@�pyunitr��suite�rr�rrrr�
�
z'SynchronousDryRunTests.makeTestFixturesN�r'r(r)rOr�rrrrr��r�c@r{)�DryRunTestsz@
    Check that 'dry run' mode works well with Trial tests.
    cs.G�fdd�dtj�}|d��_t���_dS)Nc�eZdZ�fdd�ZdS)z.DryRunTests.makeTestFixtures.<locals>.MockTestcs�j�d�dS)Nr�)r
r$�r@rrrr�rAz7DryRunTests.makeTestFixtures.<locals>.MockTest.test_fooNr�rrrr�MockTest�r�r�)r�TestCaser@rr�r�)rr�rrrr�s
zDryRunTests.makeTestFixturesNr�rrrrr�r�r�c@r{)�PyUnitDryRunTestszJ
    Check that 'dry run' mode works well with stdlib unittest tests.
    cCs*Gdd�dtj�}|d�|_t��|_dS)Nc@r�)z6PyUnitDryRunTests.makeTestFixtures.<locals>.PyunitCasecSr�rrrrrrr�(r�z?PyUnitDryRunTests.makeTestFixtures.<locals>.PyunitCase.test_fooNr�rrrrr�'r�r�r�)r�r�r@r�r�r�rrrr�&r�z"PyUnitDryRunTests.makeTestFixturesNr�rrrrr�!r�r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Ze�Zd!d"�Zd#d$�Zd%S)&�RunnerTestscsvt���_t�t��d�}d�|dd��}|d}tj	d|ddd|d�g���fdd�}t
j�_|t
_gd	��_
dS)
N�.���zTest Helper ReporterzUtility for unit testing.�	capturing)�description�longOpt�shortOpt�klasscs,��|t��t�j|g|�Ri|���Sr)r\r�list�original)�iface�a�kw��pluginsrrr�
getPluginsEs z%RunnerTests.setUp.<locals>.getPlugins)r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9r5r>r9)r�Options�configr�qualr*�split�joinr�	_Reporterrr�r��standardReport)r�parts�packager�r�rr�rru0s"
��
zRunnerTests.setUpcCs|jt_dSr)r�rr�rrrrrTmszRunnerTests.tearDowncCs|j�|�dSr)r��parseOptions�rr%rrrr�prAzRunnerTests.parseOptionscCs.t�|j�}t�|_|�|j�t��|_	|Sr)
r�_makeRunnerr�rr0�
addCleanuprSr
�LogPublisher�_log)r�rrrr�	getRunnerss

zRunnerTests.getRunnercCs2|�g�|jd}|��}|�||��j�dS�Nr)r�r�r�r\rv�	__class__)rryrrrr�test_runner_can_get_reporter�s

z(RunnerTests.test_runner_can_get_reportercCs2|�g�|��}|��}|�|j|jd�dSr�)r�r�rvr\r�r��rrryrrr�test_runner_get_result�s
z"RunnerTests.test_runner_get_resultcCs(|�g�|��}|�|��tj�dS)z�
        By default Trial sets the 'uncleanWarnings' option on the runner to
        False. This means that dirty reactor errors will be reported as
        errors. See L{test_reporter.DirtyReactorTests}.
        N)r�r��assertNotIsInstancervr�UncleanWarningsReporterWrapper�rrrrr� test_uncleanWarningsOffByDefault�s


�z,RunnerTests.test_uncleanWarningsOffByDefaultcCs*|�dg�|��}|�|��tj�dS)z�
        Specifying '--unclean-warnings' on the trial command line will cause
        reporters to be wrapped in a device which converts unclean errors to
        warnings.  See L{test_reporter.DirtyReactorTests} for implications.
        z--unclean-warningsN)r�r��assertIsInstancervrr�r�rrr�test_getsUncleanWarnings�s

�z$RunnerTests.test_getsUncleanWarningscCs(|�ddg�|��}|�|jd�dS)N�--temp-directory�	some_path)r�r�r\�workingDirectoryr�rrr�test_runner_working_directory�sz)RunnerTests.test_runner_working_directorycs�|�g�|�tjt���t|�������t��j�|�	�}|�	��i�G����fdd�dt
j��|��d��}|j
|j}|rN|�|dd�|����d�j��d�jd��d	S)
z�
        If no working directory is explicitly specified and the default
        working directory is in use by another runner, L{TrialRunner.run}
        selects a different default working directory to use.
        cs*eZdZ����fdd�Z�fdd�ZdS)zKRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCasecs<t���d<}t��j�|�tj|����d��dS)z�
                Start a second test run which will have a default working
                directory which is the same as the working directory of the
                test run already in progress.
                �
concurrent�test_secondN)�os�getcwd�chdir�pathr�r[)r�subsequentDirectory��ConcurrentCase�runDirectory�secondRunner�whererr�
test_first�szVRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCase.test_firstcst���d<dS)zR
                Record the working directory for later analysis.
                �recordN)r�r�r)r�rrr��r=zWRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCase.test_secondN)r'r(r)r�r�rr�rrr��sr�r�rr"�_trial_tempz
_trial_temp-1)r�r�N)r�r�r�r�r�r�mktemp�makedirsr�r�rr�r[�errors�failures�failr\�child)r�firstRunnerry�badrr�r�'test_concurrentImplicitWorkingDirectory�s&


��z3RunnerTests.test_concurrentImplicitWorkingDirectorycs�|�dtj�|���g�t��}|�tj|�|��}|���G��fdd�dt	j
��|��d��}|j|j
}|rF|�|dd�dSdS)z�
        If a working directory which is already in use is explicitly specified,
        L{TrialRunner.run} raises L{_WorkingDirectoryBusy}.
        r�cs"eZdZ��fdd�Zdd�ZdS)zKRunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCasecs|�tj�j�d��dS)z�
                Try to start another runner in the same working directory and
                assert that it raises L{_WorkingDirectoryBusy}.
                �test_failureN)�assertRaisesr�_WorkingDirectoryBusyr[r�r�r�rr�test_concurrent�s
�z[RunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCase.test_concurrentcS�|�d�dS)zE
                Should not be called, always fails.
                z$test_failure should never be called.N)r�rrrrr���zXRunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCase.test_failureN)r'r(r)r�r�rr�rrr��sr�r�rr"N)r�r�r��abspathr�r�r�r�r�rr�r[r�r�r�)r�initialDirectoryr�ryr�rr�r�'test_concurrentExplicitWorkingDirectory�s�z3RunnerTests.test_concurrentExplicitWorkingDirectorycCsR|�d|��dddg�|��}t��}|�dd�}|�|�}|�|j|j	�dS)Nr��
--reporterr��twisted.trial.test.sampleT)
r�r�r�r�
TestLoader�
loadByNamer[r\r�r)r�	my_runner�loaderr�ryrrr�test_runner_normal	s��	
zRunnerTests.test_runner_normalcCst��}|�dd�}|�|�S)Nr�T)rr�r�r[)rr�r�r�rrr�runSampleSuites
zRunnerTests.runSampleSuitecCsP|�gd��|��}t�}|_|�|�}|�|j|j�|�dg|j�dS)zL
        Trial uses its debugger if the `--debug` option is passed.
        )r�r��--debugr�r!N)r�r�r�debuggerr�r\r�r)rr�r�ryrrr�test_runnerDebugs�
zRunnerTests.test_runnerDebugcs^��ddg�td�}|��d�_�fdd�}��tjd|���������	�j�dS)	zL
        Trial uses pdb if no debugger is specified by `--debugger`
        r�r��pdbrcFc�
d�_dS�NT��runcall_called��pdbr�ryrrrr!5r z=RunnerTests.test_runnerDebuggerDefaultsToPdb.<locals>.runcallr!N)
r�r�touchr��patchr��Pdbr�r�rm)r�	pdbrcFiler!rrr� test_runnerDebuggerDefaultsToPdb+sz,RunnerTests.test_runnerDebuggerDefaultsToPdbcsN��gd��d�_�fdd�}��tjd|����������j�dS)zU
        Trial uses pdb if pdb is passed explicitly to the `--debugger` arg.
        )r�r��
--debuggerr�r�r�Fcr�r�r�r�rrrr!Or zGRunnerTests.test_runnerDebuggerWithExplicitlyPassedPdb.<locals>.runcallr!N)r�r�rr�rr�r�rm)rr!rrr�*test_runnerDebuggerWithExplicitlyPassedPdb>s�z6RunnerTests.test_runnerDebuggerWithExplicitlyPassedPdbcCsF|�gd��|��}|�|�}|�|j|j�|�dg|jj�dS)zM
        Trial uses specified debugger if the debugger is available.
        )r�r�rz4twisted.trial.test.test_runner.RunnerTests.cdebuggerr�r�r!N)r�r�r�r\r�rr�)rr�ryrrr�test_runnerDebuggerZs�

zRunnerTests.test_runnerDebuggercCs.|�dg�|��}|��}|�|tj�dS)z�
        If trial was passed the C{--exitfirst} option, the constructed test
        result object is wrapped with L{reporter._ExitWrapper}.
        z--exitfirstN)r�r�rvr�r�_ExitWrapperr�rrr�test_exitfirstmszRunnerTests.test_exitfirstN)r'r(r)rurTr�r�r�r�r�r�r�r�r�r�r�r�rrr�	cdebuggerrr	rrrrr�/s(=9$
r�c@r�)�TrialSuiteTestscCstd�dS)Nztwisted.trial.runner.TrialSuiter
rrrr�test_importsyszTrialSuiteTests.test_importsN)r'r(r)rrrrrrxr�rc@sFeZdZGdd�dej�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
S)�UntilFailureTestsc@s*eZdZUdZgZeded<dd�ZdS)zUntilFailureTests.FailAfterzC
        A test case that fails when run 3 times in a row.
        N�countcCs,|j�d�t|j�dkr|�d�dSdS)N�zCount reached 3)rr$rZr�rrrrr��s�z$UntilFailureTests.FailAfter.test_foo)r'r(r)rOrr�__annotations__r�rrrr�	FailAfters
rcCs4gtj_t�d�|_t�|_tjtj	|jd�|_dS)Nr�rr)
r
rrr@rr0rrtr�Reporterrrrrru�szUntilFailureTests.setUpcCs@|j�|j�}|�|jd�|�|���|�|�|�d�dS)zl
        Test that the runUntilFailure method of the runner actually fail after
        a few runs.
        r"N)r�runUntilFailurer@r\rQrirN�_getFailuresrxrrr�test_runUntilFailure�sz&UntilFailureTests.test_runUntilFailurecCs
t|j�S)zL
        Get the number of failures that were reported to a result.
        )rZr�rxrrrr�s
zUntilFailureTests._getFailurescsbg��fdd�}|�td|�|j�|j�}|�|jd�|�t��d�|��|jtfg�dS)z�
        C{runUntilFailure} doesn't decorate the tests uselessly: it does it one
        time when run starts, but not at each turn.
        c���||f�|Sr�r$�r@�	interface��	decoratedrr�decorate��z@UntilFailureTests.test_runUntilFailureDecorate.<locals>.decoraterr"N)	rrrrr@r\rQrZr�rrryrrr�test_runUntilFailureDecorate�sz.UntilFailureTests.test_runUntilFailureDecoratecsrg��fdd�}|�td|�d|j_|j�|j�}|�|jd�|�t��d�|��|jt	f|jt
fg�dS)z�
        C{runUntilFailure} applies the force-gc decoration after the standard
        L{ITestCase} decoration, but only one time.
        crrrrrrrr�rzGUntilFailureTests.test_runUntilFailureForceGCDecorate.<locals>.decoraterTr"rgN)rrr�_forceGarbageCollectionrr@r\rQrZrrrrrr�#test_runUntilFailureForceGCDecorate�s�z5UntilFailureTests.test_runUntilFailureForceGCDecorateN)r'r(r)r�r�rrurrrr!rrrrr
~s
r
c@rp)�UncleanUntilFailureTestszh
    Test that the run-until-failure feature works correctly with the unclean
    error suppressor.
    cCs$t�|�tjtj|jdd�|_dS)NTr})r
rurrtrrr0rrrrru�s

�zUncleanUntilFailureTests.setUpcCst|jj�S)z�
        Get the number of failures that were reported to a result that
        is wrapped in an UncleanFailureWrapper.
        )rZ�_originalReporterr�rxrrrr��z%UncleanUntilFailureTests._getFailuresN)r'r(r)rOrurrrrrr"�sr"c@r{)�
BreakingSuitez;
    A L{TestSuite} that logs an error when it is run.
    cCs,ztd��tyt�t���YdSw)Nz#error that occurs outside of a test)�RuntimeErrorr
�errr	�Failurerxrrrr[�s
�zBreakingSuite.runN)r'r(r)rOr[rrrrr%�r�r%c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�LoggedErrorsTestsa

    It is possible for an error generated by a test to be logged I{outside} of
    any test. The log observers constructed by L{TestCase} won't catch these
    errors. Here we try to generate such errors and ensure they are reported to
    a L{TestResult} object.
    cCs|�t�dSr)�flushLoggedErrorsr&rrrrrT�rUzLoggedErrorsTests.tearDowncCst��}|�|��d�dS)zg
        Check that we can construct a L{runner.LoggedSuite} and that it
        starts empty.
        rN)r�LoggedSuiter\�countTestCases)rr�rrr�test_construct�sz LoggedErrorsTests.test_constructcCslt��}t�t�g�}|�|�|�t|j�d�|�|jdd�	�tj
�|�|jdd�t
��dS)zU
        Chek that a L{LoggedSuite} reports any logged errors to its result.
        r"rN)r�
TestResultrr,r%r[r\rZr��id�NOT_IN_TESTrm�checkr&)rryr�rrr�test_capturesError�s
z$LoggedErrorsTests.test_capturesErrorN)r'r(r)rOrTr.r3rrrrr*�s
r*c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestHolderTestscCsd|_t�|j�|_dS�Nr�)r�r�
TestHolder�holderrrrrru
rfzTestHolderTests.setUpcCs,|�|j��|j�|�|j��|j�dS)z�
        Check that L{runner.TestHolder} takes a description as a parameter
        and that this description is returned by the C{id} and
        C{shortDescription} methods.
        N)r\r7r0r��shortDescriptionrrrr�test_holderszTestHolderTests.test_holdercCs6|�|jt|j��|�tt|j�d|jtf�dS)z?
        L{runner.TestHolder} implements L{ITestCase}.
        z5%r claims to provide %r but does not do so correctly.N)rwr7rrmrrrrr�test_holderImplementsITestCases
��z.TestHolderTests.test_holderImplementsITestCasecC�4t��}|j�|�|�|���|�d|j�dS)zc
        A L{runner.TestHolder} can run against the standard Python
        C{TestResult}.
        r"N)r�r/r7r[rmrNr\rQrxrrr�test_runsWithStandardResult"�z+TestHolderTests.test_runsWithStandardResultN)r'r(r)rur9r:r<rrrrr4	s
	r4c@sNeZdZdZed�ZGdd�d�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�ZdS)�ErrorHolderTestsMixinaa
    This mixin defines test methods which can be applied to a
    L{runner.ErrorHolder} constructed with either a L{Failure} or a
    C{exc_info}-style tuple.

    Subclass this and implement C{setUp} to create C{self.holder} referring to a
    L{runner.ErrorHolder} instance and C{self.error} referring to a L{Failure}
    which the holder holds.
    z"integer division or modulo by zeroc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)z$ErrorHolderTestsMixin.TestResultStubz)
        Stub for L{TestResult}.
        cCrr)r�rrrrr?r z-ErrorHolderTestsMixin.TestResultStub.__init__cCr�rrr?rrrr5Br�z.ErrorHolderTestsMixin.TestResultStub.startTestcCr�rrr?rrrr9Er�z-ErrorHolderTestsMixin.TestResultStub.stopTestcCs|j�||f�dSr)r�r$rErrrrGHsz-ErrorHolderTestsMixin.TestResultStub.addErrorN)r'r(r)rOrr5r9rGrrrr�TestResultStub:sr?cCr;)zd
        A L{runner.ErrorHolder} can run against the standard Python
        C{TestResult}.
        r"N)r�r/r7r[rirNr\rQrxrrrr<Kr=z1ErrorHolderTestsMixin.test_runsWithStandardResultcCs<|j�|j�|�|jj|j|jj|jj|jjffg�dS)zM
        L{runner.ErrorHolder} adds an error to the result when run.
        N)	r7r[ryr\r�rF�type�value�tbrrrr�test_runUs
�zErrorHolderTestsMixin.test_runcCs:|�|j�|�|jj|j|jj|jj|jjffg�dS)zP
        L{runner.ErrorHolder} adds an error to the result when called.
        N)r7ryr\r�rFr@rArBrrrr�	test_call_s
�zErrorHolderTestsMixin.test_callcCs|�|j��d�dS)zH
        L{runner.ErrorHolder.countTestCases} always returns 0.
        rN)r\r7r-rrrr�test_countTestCasesisz)ErrorHolderTestsMixin.test_countTestCasescCs,d�t|jjd��}|�t|j�|�dS)zh
        L{runner.ErrorHolder.__repr__} returns a string describing the error it
        holds.
        z0<ErrorHolder description='description' error={}>r"N)�format�reprr7rFr\)r�expectedrrr�	test_repros�zErrorHolderTestsMixin.test_reprN)r'r(r)rO�ZeroDivisionError�exceptionForTestsr?r<rCrDrErIrrrrr>-s



r>c@r{)�FailureHoldingErrorHolderTestsz�
    Tests for L{runner.ErrorHolder} behaving similarly to L{runner.TestHolder}
    when constructed with a L{Failure} representing its error.
    cCsJd|_z|j�tyt��|_Ynwt�|j|j�|_|�	�|_
dSr5)r�rKrJr	r(rFr�ErrorHolderr7r?ryrrrrru�s�z$FailureHoldingErrorHolderTests.setUpNrrrrrrL{�rLc@r{)�ExcInfoHoldingErrorHolderTestsz�
    Tests for L{runner.ErrorHolder} behaving similarly to L{runner.TestHolder}
    when constructed with a C{exc_info}-style tuple representing its error.
    cCsPd|_z|j�tyt��}t��|_Ynwt�	|j|�|_
|��|_dSr5)
r�rKrJ�sys�exc_infor	r(rFrrMr7r?ry)r�
exceptionInforrrru�s�z$ExcInfoHoldingErrorHolderTests.setUpNrrrrrrO�rNrOc@sBeZdZdZGdd�dej�Zdd�Zdd�Zdd	�Z	d
d�Z
dS)
�MalformedMethodTestszR
    Test that trial manages when test methods don't have correct signatures.
    c@s*eZdZdZdd�Zdd�Ze�e�ZdS)z%MalformedMethodTests.ContainMalformedzV
        This TestCase holds malformed test methods that trial should handle.
        cCr�rr)r�blahrrrr��r�z.MalformedMethodTests.ContainMalformed.test_foocCr�rrrrrr�test_bar�r�z.MalformedMethodTests.ContainMalformed.test_barN)	r'r(r)rOr�rUr�inlineCallbacks�	test_spamrrrr�ContainMalformed�s
rXcCs\t�}tjtj|d�}t�|�}|�|�}|�|j	d�|�
|���|�t|j
�d�dS)zL
        Wrapper for one of the test method of L{ContainMalformed}.
        rrr"N)rrrtrrrSrXr[r\rQrirNrZr�)rr7r0�trialRunnerr@ryrrr�_test�s

zMalformedMethodTests._testcCr�)zE
        Test when the method has extra (useless) arguments.
        r�N�rZrrrr�
test_extraArg�r�z"MalformedMethodTests.test_extraArgcCr�)zJ
        Test when the method doesn't have even self as argument.
        rUNr[rrrr�
test_noArg�r�zMalformedMethodTests.test_noArgcCr�)z5
        Test a decorated method also fails.
        rWNr[rrrr�test_decorated�r�z#MalformedMethodTests.test_decoratedN)r'r(r)rOr�r�rXrZr\r]r^rrrrrS�s
rSc@r))	�DestructiveTestSuiteTestsz2
    Test for L{runner.DestructiveTestSuite}.
    csng�G�fdd�dtj�}|d�}t��}t�|g�}|��g�|�|�|��dg�|�|��d�dS)zL
        Thes destructive test suite should run the tests normally.
        cr�)z6DestructiveTestSuiteTests.test_basic.<locals>.MockTestc���d�dSr�rr���calledrrr��rUz?DestructiveTestSuiteTests.test_basic.<locals>.MockTest.test_fooNr�rrarrr��r�r�r�TrN)	r�r�rr/r�DestructiveTestSuiter\r[r-�rr�r@ryr�rrar�
test_basic�s
z$DestructiveTestSuiteTests.test_basiccstg�G�fdd�dtj�}t��}t��}tj|_|�|�}|�	�g�|�
|�|�	�dg�|�	|��d�dS)zu
        Test the C{shouldStop} management: raising a C{KeyboardInterrupt} must
        interrupt the suite.
        cs,eZdZ�fdd�Zdd�Z�fdd�ZdS)z;DestructiveTestSuiteTests.test_shouldStop.<locals>.MockTestcr`)Nr"rr�rarr�	test_foo1�rUzEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo1cSst��r)�KeyboardInterruptr�rrr�	test_foo2�szEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo2cr`)Nrgrr�rarr�	test_foo3�rUzEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo3N)r'r(r)rfrhrirrarrr��sr�r"N)rr�rr/rr�rc�suiteFactory�	loadClassr\r[r-)rr�ryr�r�rrar�test_shouldStop�s


z)DestructiveTestSuiteTests.test_shouldStopcCs\Gdd�dtj�}|d�}t��}t�|g�}|�|��d�|�|�|�|��d�dS)zn
        Checks that the test suite cleanups its tests during the run, so that
        it ends empty.
        c@r�)z8DestructiveTestSuiteTests.test_cleanup.<locals>.MockTestcSr�rrr�rrrr�r�zADestructiveTestSuiteTests.test_cleanup.<locals>.MockTest.test_fooNr�rrrrr�r�r�r�r"rN)	r�r�rr/rrcr\r-r[rdrrr�test_cleanups
z&DestructiveTestSuiteTests.test_cleanupN)r'r(r)rOrerlrmrrrrr_�s
r_c@s&eZdZGdd�dej�Zdd�ZdS)�RunnerDeprecationTestsc@s<eZdZdZdZdZdZdd�Zdd�Zdd�Z	d	d
�Z
dS)z#RunnerDeprecationTests.FakeReporterz�
        Fake reporter that does *not* implement done() but *does* implement
        printErrors, separator, printSummary, stream, write and writeln
        without deprecations.
        NcGr�rrr�rrr�printErrorsr�z/RunnerDeprecationTests.FakeReporter.printErrorscGr�rrr�rrr�printSummary"r�z0RunnerDeprecationTests.FakeReporter.printSummarycGr�rrr�rrr�write%r�z)RunnerDeprecationTests.FakeReporter.writecGr�rrr�rrr�writeln(r�z+RunnerDeprecationTests.FakeReporter.writeln)r'r(r)rOrCrPr0rorprqrrrrrr�FakeReportersrscs�t�d��|����fdd��_�fdd�}|�|�|jg�}|�|ddt�|�|ddd	t�	�j
��|�t�
|dd
��|�t|�d�dS)zk
        The runner emits a warning if it is using a result that doesn't
        implement 'done'.
        Ncs�Srrr)ryrr�<lambda>2rDzBRunnerDeprecationTests.test_reporterDeprecations.<locals>.<lambda>cs��t�d��dS)Nr0)r[r�r�r)rYrr�f4sz;RunnerDeprecationTests.test_reporterDeprecations.<locals>.fr�category�messagezR%s should implement done() but doesn't. Falling back to printErrors() and friends.�filenamer")rrtrsrv�
flushWarnings�test_reporterDeprecationsr\�DeprecationWarningrr�r�rm�__file__�
startswithrZ)rru�warningsr)ryrYrrz+s


��z0RunnerDeprecationTests.test_reporterDeprecationsN)r'r(r)rrrsrzrrrrrnsrnc@r{)�QualifiedNameWalkerTestsz<
    Tests for L{twisted.trial.runner._qualNameWalker}.
    cCs6tt�d��}|�|dgfddgfdddgfg�dS)z�
        C{_qualNameWalker} is a generator that, when given a Python qualified
        name, yields that name, and then the parent of that name, and so forth,
        along with a list of the tried components, in a 2-tuple.
        zwalker.texas.rangerzwalker.texas�ranger�walker�texasN)r�r�_qualNameWalkerr\)r�
walkerResultsrrr�test_walksDownPathKs
��z+QualifiedNameWalkerTests.test_walksDownPathN)r'r(r)rOr�rrrrrFr�rc@r{)�TrialMainDoesNothingTestszl
    Importing L{twisted.trial.__main__} will not run the script
    unless it is actually C{__main__}.
    cCstd�dS)zO
        If we import L{twisted.trial.__main__}, it should do nothing.
        ztwisted.trial.__main__N)�
__import__rrrr�test_importDoesNothingcr$z0TrialMainDoesNothingTests.test_importDoesNothingN)r'r(r)rOr�rrrrr�]rNr�)@r�r�rPrr��ior�typingr�zope.interfacer�zope.interface.verifyr�twistedr�twisted.internetr�twisted.pluginsr�twisted.pythonr	r
r�twisted.python.filepathr�twisted.python.reflectr�twisted.scriptsr�
twisted.trialrrr�twisted.trial._asyncrunnerr�twisted.trial.itrialrrrr*rRr�rqr|r�r�r�r�r�rr
r"r�r%r*r4r>rLrOrSr_rnrr�rrrr�<module>s^	Q<
�,KL$N1D3

Anon7 - 2022
AnonSec Team