HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/trial/test/__pycache__/test_script.cpython-38.pyc
U


W[t�@s�ddlmZmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZmZddlmZed
�Zdd�ZGdd�dej �Z!Gdd�dej �Z"Gdd�dej �Z#Gdd�dej �Z$Gdd�dej �Z%Gdd�dej&�Z'Gdd�dej&�Z(Gdd�dej&�Z)Gd d!�d!ej&�Z*Gd"d#�d#ej&�Z+Gd$d%�d%ej&�Z,dS)&�)�absolute_import�divisionN)�util)�NativeStringIO)�FilePath)�
UsageError)�trial)�unittest)�DistTrialRunner)�
TestLoader)�TrialRunner�	TestSuite�DestructiveTestSuite)�	testNamesr	cCst�t|�S)z1
    For finding files in twisted/trial/test
    )r�sibpath�__file__)�filename�r�@/usr/lib/python3/dist-packages/twisted/trial/test/test_script.pyrsrc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�ForceGarbageCollectionTestsz*
    Tests for the --force-gc option.
    cCs>t��|_g|_|�td|j�t�|j	�}t
||g�|_dS)N�collect)r�Options�config�log�patch�gcr�pyunitZFunctionTestCase�
simpleTestr
�test)�selfrrrr�setUp's

z!ForceGarbageCollectionTests.setUpcCs|j�d�dS)zD
        A simple test method that records that it was run.
        rN�r�append�rrrrr/sz&ForceGarbageCollectionTests.simpleTestcCs|j�d�dS)zI
        A replacement for gc.collect that logs calls to itself.
        rNr!r#rrrr6sz#ForceGarbageCollectionTests.collectcCst�|j�}t�|_|S)zN
        Return a L{TrialRunner} object that is safe to use in tests.
        )r�_makeRunnerrr�stream�rZrunnerrrr�
makeRunner=sz&ForceGarbageCollectionTests.makeRunnerc	CsFd|jd<|j��|��}|�|j�|�|jddddddg�dS)z�
        Passing the --force-gc option to the trial script forces the garbage
        collector to run before and after each test.
        Tzforce-gcrrN�rZpostOptionsr'�runr�assertEqualrr&rrr�test_forceGcFs

�z(ForceGarbageCollectionTests.test_forceGccCs4|j��|��}|�|j�|�|jddg�dS)z>
        By default, no garbage collection is forced.
        rNr(r&rrr�test_unforceGcSs
z*ForceGarbageCollectionTests.test_unforceGcN)
�__name__�
__module__�__qualname__�__doc__r rrr'r+r,rrrrr"s	
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SuiteUsedTestsz?
    Check the category of tests suite used by the loader.
    cCst��|_dS)z6
        Create a trial configuration object.
        N�rrrr#rrrr cszSuiteUsedTests.setUpcCst�|j�}|�|jt�dS)zK
        By default, the loader should use L{DestructiveTestSuite}
        N)r�
_getLoaderrr*�suiteFactoryr�r�loaderrrr�test_defaultSuitejsz SuiteUsedTests.test_defaultSuitecCs(d|jd<t�|j�}|�|jt�dS)zw
        The C{until-failure} configuration uses the L{TestSuite} to keep
        instances alive across runs.
        Tz
until-failureN)rrr3r*r4r
r5rrr�test_untilFailureSuiters
z%SuiteUsedTests.test_untilFailureSuiteN)r-r.r/r0r r7r8rrrrr1^sr1c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5S)6�TestModuleTestscCst��|_dS�Nr2r#rrrr ~szTestModuleTests.setUpcCs
d|_dSr:)rr#rrr�tearDown�szTestModuleTests.tearDowncCs|�t|�|��g�dS)zq
        Check that the testNames helper method accurately collects the
        names of tests in suite.
        N)r*r�idr#rrr�test_testNames�szTestModuleTests.test_testNamescCsBt�}t|�}ttt|j|���}|��|��|�||�dSr:)rrr
�map�
loadByName�sortr*)rZtest1�namesr6Znames1Znames2rrr�assertSuitesEqual�sz!TestModuleTests.assertSuitesEqualcCs|�dt|jd��dS)Nr�tests)r*�lenrr#rrr�test_baseState�szTestModuleTests.test_baseStatecCs*|j�td��|�t�|j�dg�dS)z�
        Check that --testmodule loads a suite which contains the tests
        referred to in test-case-name inside its parameter.
        �
moduletest.py�twisted.trial.test.test_logN�r�opt_testmodulerrBr�	_getSuiter#rrr�test_testmoduleOnModule�s�z'TestModuleTests.test_testmoduleOnModulecCs:|j�td��|j�td��|�t�|j�dg�dS)z�
        When the same module is specified with two --testmodule flags, it
        should only appear once in the suite.
        rFrGNrHr#rrr�test_testmoduleTwice�s
�z$TestModuleTests.test_testmoduleTwicecCs:|j�td��|j�td��|�t�|j�dg�dS)z�
        If --testmodule is specified twice, once for module A and once for
        a module which refers to module A, then make sure module A is only
        added once.
        rFztest_log.pyrGNrHr#rrr� test_testmoduleOnSourceAndTarget�s
�z0TestModuleTests.test_testmoduleOnSourceAndTargetcCs*|j�td��|�t�|j�dg�dS)z�
        When given a module that refers to *itself* in the test-case-name
        variable, check that --testmodule only adds the tests once.
        z
moduleself.pyztwisted.trial.test.moduleselfNrHr#rrr�test_testmoduleOnSelfModule�s�z+TestModuleTests.test_testmoduleOnSelfModulecCs,|j�td��|�t�|j�ddg�dS)zm
        Check that --testmodule loads tests referred to in test-case-name
        buffer variables.
        �
scripttest.pyrG�twisted.trial.test.test_runnerNrHr#rrr�test_testmoduleOnScript�s��z'TestModuleTests.test_testmoduleOnScriptcCsbt�}tj|}t_d}z<|j�|�|�dt|jd��|�d|f|���W5|t_XdS)zz
        Check that --testmodule displays a meaningful error message when
        passed a non-existent filename.
        ztest_thisbetternoteverexist.pyrrC�File %r doesn't exist
N�r�sys�stderrrrIr*rD�getvalue)r�buffyrUrrrr� test_testmoduleOnNonexistentFile�s�z0TestModuleTests.test_testmoduleOnNonexistentFilecCs*|j�td��|�dt|jd��dS)z�
        Check that --testmodule adds no tests to the suite for modules
        which lack test-case-name buffer variables.
        �	novars.pyrrCN)rrIrr*rDr#rrr�test_testmoduleOnEmptyVars�sz*TestModuleTests.test_testmoduleOnEmptyVarscCsbt�}tj|}t_d}z<|j�|�|�dt|jd��|�d|f|���W5|t_XdS)z�
        Check that --testmodule does *not* support module names as arguments
        and that it displays a meaningful error message.
        ztwisted.trial.test.test_scriptrrCrRNrS)rrWrUZ
moduleNamerrr�test_testmoduleOnModuleName�s�z+TestModuleTests.test_testmoduleOnModuleNamecCs"d}t�|�}|�ddi|�dS)Nz5-*- test-case-name: twisted.trial.test.test_tests -*-�test-case-name�twisted.trial.test.test_tests�r�_parseLocalVariablesr*�rZdeclaration�	localVarsrrr�test_parseLocalVariable�s
��z'TestModuleTests.test_parseLocalVariablecCs"d}t�|�}|�ddi|�dS)Nz6-*- test-case-name: twisted.trial.test.test_tests; -*-r\r]r^r`rrr�test_trailingSemicolon�s
��z&TestModuleTests.test_trailingSemicoloncCs$d}t�|�}|�ddd�|�dS)Nz?-*- test-case-name: twisted.trial.test.test_tests; foo: bar -*-r]Zbar)r\�foor^r`rrr�test_parseLocalVariables�s
��z(TestModuleTests.test_parseLocalVariablescCs"d}t�|�}|�ddi|�dS)Nz:## -*- test-case-name: twisted.trial.test.test_tests -*- #r\r]r^r`rrr�test_surroundingGuffs
��z$TestModuleTests.test_surroundingGuffcCs|�ttjd�dS�Nrd��assertRaises�
ValueErrorrr_r#rrr�test_invalidLines
�z TestModuleTests.test_invalidLinecCs4|�ttjd�|�ttjd�|�ttjd�dS)Nz-*- foo -*-z-*- foo: bar; qux -*-z-*- foo: bar: baz; qux: qax -*-rhr#rrr�test_invalidDeclarations
�
�
�z'TestModuleTests.test_invalidDeclarationcCs"t�td��}|�ddi|�dS)NrFr\rG�rZloadLocalVariablesrr*�rrarrr�test_variablesFromFiles��z&TestModuleTests.test_variablesFromFilecCst�td��}|�i|�dS)NrYrmrnrrr�test_noVariablesInFile sz&TestModuleTests.test_noVariablesInFilecCs"t�td��}|�ddi|�dS)NrOr\z:twisted.trial.test.test_log,twisted.trial.test.test_runnerrmrnrrr�test_variablesFromScript$s
�z(TestModuleTests.test_variablesFromScriptcCs t�td��}|�|dg�dS)NrFrG)r�getTestModulesrr*�r�modulesrrr�test_getTestModules+sz#TestModuleTests.test_getTestModulescCs"t�td��}|�t|�d�dS)NrYr)rrrrr*rDrsrrr�test_getTestModules_noVars/sz*TestModuleTests.test_getTestModules_noVarscCs*t�td��}|�t|�tddg��dS)NrOrGrP)rrrrr*�setrsrrr�test_getTestModules_multiple3s
��z,TestModuleTests.test_getTestModules_multiplecCsVdD]}|�t�|�d|f�qdtd�td�fD]}|�t�|�d|f�q4dS)N)ztest_script.pyz!twisted/trial/test/test_script.pyz%r should be a test filez twisted/trial/test/moduletest.pyrOztest_foo.batz%r should *not* be a test file)�
assertTruerZ
isTestFilerZassertFalse)rrrrr�test_looksLikeTestModule9s���z(TestModuleTests.test_looksLikeTestModuleN)r-r.r/r r;r=rBrErKrLrMrNrQrXrZr[rbrcrerfrkrlrorprqrurvrxrzrrrrr9}s4	
	
	r9c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�WithoutModuleTestsz*
    Test the C{without-module} flag.
    cCst��|_ttj�|_dS)zl
        Create a L{trial.Options} object to be used in the tests, and save
        C{sys.modules}.
        N)rrr�dictrTrt�savedModulesr#rrrr Hs
zWithoutModuleTests.setUpcCs8dD].}||jkr$|j|tj|<qtj�|d�qdS)z)
        Restore C{sys.modules}.
        )�imaplib�smtplibN)r}rTrt�pop)r�modulerrrr;Qs
zWithoutModuleTests.tearDowncCsddl}|S)zE
        Try to import the C{smtplib} module, and return it.
        rN)r)rrrrr�
_checkSMTP\szWithoutModuleTests._checkSMTPcCsddl}|S)zE
        Try to import the C{imaplib} module, and return it.
        rN)r~)rr~rrr�
_checkIMAPdszWithoutModuleTests._checkIMAPcCs<|j�ddg�|�t|j�tjd=|�|��tj	�dS)zT
        Check that after disabling a module, it can't be imported anymore.
        �--without-modulerN)
r�parseOptionsri�ImportErrorr�rTrt�assertIsInstance�types�
ModuleTyper#rrr�test_disableOneModulelsz(WithoutModuleTests.test_disableOneModulecCsd|j�ddg�|�t|j�|�t|j�tjd=tjd=|�|��t	j
�|�|��t	j
�dS)zE
        Check that several modules can be disabled at once.
        r�zsmtplib,imaplibrr~N)rr�rir�r�r�rTrtr�r�r�r#rrr�test_disableMultipleModulesxsz.WithoutModuleTests.test_disableMultipleModulescCs@|�|��tj�|�tdtj|jj	ddg�|�
t|j�dS)zP
        Disabling an already imported module should produce a warning.
        z4Module 'smtplib' already imported, disabling anyway.r�rN)r�r�r�r�ZassertWarns�RuntimeWarningrrrr�rir�r#rrr�!test_disableAlreadyImportedModule�s�z4WithoutModuleTests.test_disableAlreadyImportedModuleN)r-r.r/r0r r;r�r�r�r�r�rrrrr{Cs	r{c@sDeZdZdZeedd�dkr dZdd�Zdd�Zd	d
�Z	dd�Z
dS)
�
CoverageTestsz+
    Tests for the I{coverage} option.
    �gettraceNz;Cannot test trace hook installation without inspection API.cCs|�tjt���dS)zf
        Arrange for the current trace hook to be restored when the
        test is complete.
        N)�
addCleanuprT�settracer�r#rrrr �szCoverageTests.setUpcCs,t��}|�dg�|�t��|jj�dS)z}
        L{trial.Options} handles C{"--coverage"} by installing a trace
        hook to record coverage information.
        z
--coverageN)rrr�r*rTr�ZtracerZglobaltrace�r�optionsrrr�test_tracerInstalled�sz"CoverageTests.test_tracerInstalledcCs.t��}|�|��td��|ddg��dS)z�
        L{trial.Options.coverdir} returns a L{FilePath} based on the default
        for the I{temp-directory} option if that option is not specified.
        �.ztemp-directory�coverageN)rrr*�coverdirrZ
descendantr�rrr�test_coverdirDefault�s
�z"CoverageTests.test_coverdirDefaultcCs<|��}t��}|�d|g�|�|��t|��d��dS)z�
        If a value is specified for the I{temp-directory} option,
        L{trial.Options.coverdir} returns a child of that path.
        z--temp-directoryr�N)�mktemprrr�r*r�r�child)r�pathr�rrr�test_coverdirOverridden�s�z%CoverageTests.test_coverdirOverridden)r-r.r/r0�getattrrT�skipr r�r�r�rrrrr��s�
r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�OptionsTestsz%
    Tests for L{trial.Options}.
    cCst��|_dS)zE
        Build an L{Options} object to be used in the tests.
        N�rrr�r#rrrr �szOptionsTests.setUpcCsp|�tjt���t��r&|�tj�|j�dddddg�|j�	�}|�
d|�|�d�|�ddg|�dS)z�
        C{_getWorkerArguments} discards options like C{random} as they only
        matter in the manager, and forwards options like C{recursionlimit} or
        C{disablegc}.
        z--recursionlimitZ2000�--random�4z--disablegcN)
r�rT�setrecursionlimit�getrecursionlimitr�	isenabled�enabler�r�Z_getWorkerArguments�assertIn�remover*)r�argsrrr�test_getWorkerArguments�s�

z$OptionsTests.test_getWorkerArgumentscCs,|�t|jjdddg�}|�dt|��dS)z�
        C{parseOptions} raises a C{UsageError} when C{--debug} is passed along
        C{--jobs} as it's not supported yet.

        @see: U{http://twistedmatrix.com/trac/ticket/5825}
        �--jobsr��--debugz+You can't specify --debug when using --jobsN�rirr�r�r*�str�r�errorrrr�test_jobsConflictWithDebug�s��z'OptionsTests.test_jobsConflictWithDebugcCs,|�t|jjdddg�}|�dt|��dS)z�
        C{parseOptions} raises a C{UsageError} when C{--profile} is passed
        along C{--jobs} as it's not supported yet.

        @see: U{http://twistedmatrix.com/trac/ticket/5827}
        r�r�z	--profilez-You can't specify --profile when using --jobsNr�r�rrr�test_jobsConflictWithProfile�s��z)OptionsTests.test_jobsConflictWithProfilecCs,|�t|jjdddg�}|�dt|��dS)z�
        C{parseOptions} raises a C{UsageError} when C{--debug-stacktraces} is
        passed along C{--jobs} as it's not supported yet.

        @see: U{http://twistedmatrix.com/trac/ticket/5826}
        r�r�z--debug-stacktracesz7You can't specify --debug-stacktraces when using --jobsNr�r�rrr�%test_jobsConflictWithDebugStackTraces�s��z2OptionsTests.test_jobsConflictWithDebugStackTracescCs,|�t|jjdddg�}|�dt|��dS)z�
        C{parseOptions} raises a C{UsageError} when C{--exitfirst} is passed
        along C{--jobs} as it's not supported yet.

        @see: U{http://twistedmatrix.com/trac/ticket/6436}
        r�r��--exitfirstz/You can't specify --exitfirst when using --jobsNr�r�rrr�test_jobsConflictWithExitFirsts��z+OptionsTests.test_jobsConflictWithExitFirstcCs.|�t|jjddddg�}|�dt|��dS)zr
        C{parseOptions} raises a C{UsageError} when C{--order} is passed along
        with C{--random}.
        �--order�alphabeticalr�Z1234z-You can't specify --random when using --orderNr�r�rrr�test_orderConflictWithRandoms
��z)OptionsTests.test_orderConflictWithRandomN)r-r.r/r0r r�r�r�r�r�r�rrrrr��s
r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MakeRunnerTestsz.
    Tests for the L{_makeRunner} helper.
    cCst��|_dSr:r�r#rrrr 0szMakeRunnerTests.setUpcCsL|j�dddg�t�|j�}|�|t�|�d|j�|�dg|j�dS)z�
        L{_makeRunner} returns a L{DistTrialRunner} instance when the C{--jobs}
        option is passed, and passes the C{workerNumber} and C{workerArguments}
        parameters to it.
        r�r�z
--force-gc�N)	r�r�rr$r�r
r*Z
_workerNumberZ_workerArgumentsr&rrr�	test_jobs3s
zMakeRunnerTests.test_jobscCs>|j�dddg�t�|j�}|�|t�|�tj|j�dS)z�
        L{_makeRunner} returns a L{TrialRunner} instance in C{DRY_RUN} mode
        when the C{--dry-run} option is passed, even if C{--jobs} is set.
        r�r�z	--dry-runN)	r�r�rr$r�rr*ZDRY_RUN�moder&rrr�test_dryRunWithJobs@sz#MakeRunnerTests.test_dryRunWithJobscsRtjj��fdd�}|�tjd|�t��}|�dddg�|�tjtj|�dS)Ncs|dkrtj�|���|�S)N�	doNotFind)r�reflectZModuleNotFound)Zfqn��namedAnyrr�namedAnyExceptdoNotFindNszFMakeRunnerTests.test_DebuggerNotFound.<locals>.namedAnyExceptdoNotFindr�r�z
--debuggerr�)	rr�r�rrr�ri�_DebuggerNotFoundr$)rr�r�rr�r�test_DebuggerNotFoundKsz%MakeRunnerTests.test_DebuggerNotFoundcCs*|j�dg�t�|j�}|�|j�dS)z�
        Passing C{--exitfirst} wraps the reporter with a
        L{reporter._ExitWrapper} that stops on any non-success.
        r�N)r�r�rr$ryZ
_exitFirstr&rrr�test_exitfirst[szMakeRunnerTests.test_exitfirstN)	r-r.r/r0r r�r�r�r�rrrrr�+s
r�c@s eZdZdZdd�Zdd�ZdS)�RunTestsz(
    Tests for the L{run} function.
    cCs|�tjddd��dS)Nr�cSsdSr:rr#rrr�<lambda>m�z RunTests.setUp.<locals>.<lambda>)rrrr#rrrr jszRunTests.setUpc
Csddd�}|�td|�zt��Wn2tk
rT}z|�dt|��W5d}~XYnX|�d�dS)zY
        When a debugger is not found, an error message is printed to the user.

        c_st�d��dSrg)rr�)r��kwargsrrrr$vsz3RunTests.test_debuggerNotFound.<locals>._makeRunnerr$rdNz0Should have exited due to non-existent debugger!)rrr)�
SystemExitr�r�Zfail)rr$�errr�test_debuggerNotFoundps"zRunTests.test_debuggerNotFoundN)r-r.r/r0r r�rrrrr�esr�c@s eZdZdZdd�Zdd�ZdS)�TestArgumentOrderTestszQ
    Tests for the order-preserving behavior on provided command-line tests.
    cCst��|_t�|_dSr:)rrrrr6r#rrrr �s
zTestArgumentOrderTests.setUpcCsTdddg}|j�|�t�|j�}t|�}tt|jj|��}t|�}|�	||�dS)zN
        Multiple tests passed on the command line are not reordered.
        r]z"twisted.trial.test.test_assertionsz twisted.trial.test.test_deferredN)
rr�rrJrr
r>r6r?r*)rrC�suiterAZ
expectedSuiteZ
expectedNamesrrr�test_preserveArgumentOrder�s�z1TestArgumentOrderTests.test_preserveArgumentOrderN)r-r.r/r0r r�rrrrr��sr�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�
OrderTestsz'
    Tests for the --order option.
    cCst��|_dSr:r2r#rrrr �szOrderTests.setUpcCsJ|j�dddg�t�|j�}|�|jd�}|�t|�ddddg�d	S)
zn
        --order=alphabetical causes trial to run tests alphabetically within
        each test case.
        r�r��%twisted.trial.test.ordertests.FooTestrC�0twisted.trial.test.ordertests.FooTest.test_first�1twisted.trial.test.ordertests.FooTest.test_fourth�1twisted.trial.test.ordertests.FooTest.test_second�0twisted.trial.test.ordertests.FooTest.test_thirdN�rr�rr3�loadByNamesr*r�rr6r�rrr�test_alphabetical�s���zOrderTests.test_alphabeticalc	CsN|j�dddg�t�|j�}|�|jd�}|�t|�ddddd	d
g�dS)zu
        --order=alphabetical causes trial to run test classes within a given
        module alphabetically.
        r�r��twisted.trial.test.ordertestsrC�.twisted.trial.test.ordertests.BarTest.test_bar�.twisted.trial.test.ordertests.BazTest.test_bazr�r�r�r�Nr�r�rrr�test_alphabeticalModule�s"���z"OrderTests.test_alphabeticalModulecCsX|j�dddg�t�|j�}|�|jd�}t|�}|j|dd�|�|t|��dS)z�
        --order=alphabetical causes trial to run test modules within a given
        package alphabetically, with tests within each module alphabetized.
        r�r��twisted.trial.testrCzFailed to load any tests!��msgN)	rr�rr3r�rryr*�sorted�rr6r�rArrr�test_alphabeticalPackage�s�z#OrderTests.test_alphabeticalPackagecCsJ|j�dddg�t�|j�}|�|jd�}|�t|�ddddg�d	S)
z�
        --order=toptobottom causes trial to run test methods within a given
        test case from top to bottom as they are defined in the body of the
        class.
        r��toptobottomr�rCr�r�r�r�Nr�r�rrr�test_toptobottom�s���zOrderTests.test_toptobottomc	CsN|j�dddg�t�|j�}|�|jd�}|�t|�ddddd	d
g�dS)z�
        --order=toptobottom causes trial to run test classes within a given
        module from top to bottom as they are defined in the module's source.
        r�r�r�rCr�r�r�r�r�r�Nr�r�rrr�test_toptobottomModule�s"���z!OrderTests.test_toptobottomModulecCsR|j�dddg�t�|j�}|�|jd�}t|�}|�|t|dd�d��dS)	z�
        --order=toptobottom causes trial to run test modules within a given
        package alphabetically, with tests within each module run top to
        bottom.
        r�r�r�rCcSs|�d�dd�S)Nr�r�)�split)�namerrrr�r�z4OrderTests.test_toptobottomPackage.<locals>.<lambda>)�keyN)rr�rr3r�rr*r�r�rrr�test_toptobottomPackage
s��z"OrderTests.test_toptobottomPackagecCs�|��}t|��d�}|��|�d��d�|�d��t�d��d��|��j	}t
j	�d|�|�t
j	j
|�ddlm}|�t
jjd�|�t
jj|j�|�d��
�|j�d	d
dg�t�|j�}|�|�}|�t|�dd
ddg�dS)z{
        --order=toptobottom detects the source line of methods from modules
        whose source file is missing.
        �twisted_toptobottom_tempz__init__.pyr�ztest_missing.pya
        from twisted.trial.unittest import TestCase
        class TestMissing(TestCase):
            def test_second(self): pass
            def test_third(self): pass
            def test_fourth(self): pass
            def test_first(self): pass
        �utf8r)�test_missingr�r�r�z=twisted_toptobottom_temp.test_missing.TestMissing.test_secondz<twisted_toptobottom_temp.test_missing.TestMissing.test_thirdz=twisted_toptobottom_temp.test_missing.TestMissing.test_fourthz<twisted_toptobottom_temp.test_missing.TestMissing.test_firstN)r�rr��makedirsZ
setContent�textwrap�dedent�encode�parentr�rT�insertr�r�r�r�rtr�r-rr�rr3Z
loadModuler*r)rZtempdir�packageZ	pathEntryr�r6r�rrr�test_toptobottomMissingSources:�
�
��z(OrderTests.test_toptobottomMissingSourcecCs|�t|jjddg�dS)zL
        An unknown order passed to --order raises a L{UsageError}.
        r�z
I don't existN)rirrr�r#rrr�test_unknownOrderCs
�zOrderTests.test_unknownOrderN)
r-r.r/r0r r�r�r�r�r�r�r�r�rrrrr��s&r�c@seZdZdZdd�ZdS)�HelpOrderTestsz+
    Tests for the --help-orders flag.
    cCs�|�tdt��|�tt��jdg�}|�|j	d�tj
��}d}tj�
�D]B\}\}}t�dt�|�t�|�f|�}|j||||fd�qLdS)zS
        --help-orders prints each of the available orders and then exits.
        �stdoutz
--help-ordersrz4%r with its description not properly described in %rz%s.*%sr�N)rrTrrir�rrr�r*�coder�rVZ
_runOrders�items�re�search�escapery)r�exc�outputr�Z	orderNameZ	orderDesc�_�matchrrr�&test_help_ordersPrintsSynopsisAndQuitsQs�
�z5HelpOrderTests.test_help_ordersPrintsSynopsisAndQuitsN)r-r.r/r0rrrrrr�Msr�)-Z
__future__rrrr�rTr�r�Ztwisted.pythonrZtwisted.python.compatrZtwisted.python.filepathrZtwisted.python.usagerZtwisted.scriptsrZ
twisted.trialr	Ztwisted.trial._dist.disttrialr
Ztwisted.trial.runnerrrr
rZtwisted.trial.test.test_loaderr�
__import__rrZSynchronousTestCaserr1r9r{r�ZTestCaser�r�r�r�r�r�rrrr�<module>s<<GQ2e:,