
    Vh}                     N   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZ d d
lmZ d dlmZ d dlmZ d dlmZmZmZm Z  d dl!m"Z" d dl#m$Z$m%Z%  G d d      Z& e
e$       G d d             Z' G d d      Z( G d de(ejR                        Z* G d de(ejR                        Z+ G d d      Z, G d de,ejR                        Z- G d de,ejR                        Z. G d  d!e,ejR                        Z/ G d" d#ejR                        Z0 G d$ d%ejR                        Z1 G d& d'ejR                        Z2 G d( d)e2      Z3 G d* d+ejh                        Z5 G d, d-ejR                        Z6 G d. d/ejR                        Z7 G d0 d1      Z8 G d2 d3e8e7      Z9 G d4 d5e8e7      Z: G d6 d7ejR                        Z; G d8 d9ejR                        Z< G d: d;ejR                        Z= G d< d=ejR                        Z> G d> d?ejR                        Z?y)@    N)StringIO)List)implementer)verifyObject)plugin)defer)twisted_trial)failurelogreflect)FilePathnamedAny)trial)reporterrunnerunittestutil) _ForceGarbageCollectionDecorator)	IReporter	ITestCasec                       e Zd Zd Zd Zy)CapturingDebuggerc                     g | _         y N)_callsselfs    N/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/test/test_runner.py__init__zCapturingDebugger.__init__   s	        c                 V    | j                   j                  d        |d   |dd  i | y )Nruncallr      r   append)r   argskwargss      r   r#   zCapturingDebugger.runcall"   s-    9%Qab$V$r!   N)__name__
__module____qualname__r    r#    r!   r   r   r      s    %r!   r   c                   r    e Zd ZdZdZdZdZdZdZddZ	d Z
d Zd Zd Zd Zd	 Zd
 ZddZddZd Zd Zy)CapturingReporterzC
    Reporter that keeps a log of all actions performed on it.
    Nc                 X    g | _         d| _        || _        || _        || _        || _        y)z.
        Create a capturing reporter.
        FN)r   
shouldStop_stream	_tbformat	_rterrors
_publisher)r   streamtbformatrterrors	publishers        r   r    zCapturingReporter.__init__3   s.     !!#r!   c                 :    | j                   j                  d       y)z
        Report the beginning of a run of a single test method
        @param method: an object that is adaptable to ITestMethod
        	startTestNr%   r   methods     r   r:   zCapturingReporter.startTest>   s    
 	;'r!   c                 :    | j                   j                  d       y)z}
        Report the status of a single test method
        @param method: an object that is adaptable to ITestMethod
        stopTestNr%   r;   s     r   r>   zCapturingReporter.stopTestE   s    
 	:&r!   c                 :    | j                   j                  d       y)zcalled when the reactor has been left in a 'dirty' state
        @param errs: a list of L{twisted.python.failure.Failure}s
        cleanupErrorNr%   )r   errss     r   cleanupErrorszCapturingReporter.cleanupErrorsL   s     	>*r!   c                 :    | j                   j                  d       y )N
addSuccessr%   r   tests     r   rD   zCapturingReporter.addSuccessR   s    <(r!   c                      y)z@
        Do nothing. These tests don't care about done.
        Nr,   r   s    r   donezCapturingReporter.doneU       r!   c                      y)zD
        Do nothing. These tests don't care about addError.
        Nr,   r   rF   errors      r   addErrorzCapturingReporter.addErrorZ   rI   r!   c                      y)zF
        Do nothing. These tests don't care about addFailure.
        Nr,   )r   rF   r
   s      r   
addFailurezCapturingReporter.addFailure_   rI   r!   c                      y)zN
        Do nothing. These tests don't care about addExpectedFailure.
        Nr,   )r   rF   r
   todos       r   addExpectedFailurez$CapturingReporter.addExpectedFailured   rI   r!   c                      y)zP
        Do nothing. These tests don't care about addUnexpectedSuccess.
        Nr,   )r   rF   rQ   s      r   addUnexpectedSuccessz&CapturingReporter.addUnexpectedSuccessi   rI   r!   c                      y)zC
        Do nothing. These tests don't care about addSkip.
        Nr,   )r   rF   reasons      r   addSkipzCapturingReporter.addSkipn   rI   r!   c                      y)zI
        Do nothing. These tests don't care about wasSuccessful.
        Nr,   r   s    r   wasSuccessfulzCapturingReporter.wasSuccessfuls   rI   r!   )NNNNr   )r)   r*   r+   __doc__r5   r6   r'   	separatortestsRunr    r:   r>   rB   rD   rH   rM   rO   rR   rT   rW   rY   r,   r!   r   r.   r.   '   s^     FHDIH	$('+)





r!   r.   c                   (    e Zd ZdZd Zd Zd Zd Zy)TrialRunnerTestsMixinz9
    Mixin defining tests for L{runner.TrialRunner}.
    c                      y)z=
        Empty test method, used by the other tests.
        Nr,   r   s    r   
test_emptyz TrialRunnerTestsMixin.test_empty~   rI   r!   c                 6    t         j                  j                  S r   )r   theLogPublisher	observersr   s    r   _getObserversz#TrialRunnerTestsMixin._getObservers   s    "",,,r!   c                     t        | j                               }| j                  j                  | j                         t        | j                               }| j                  ||       y)zn
        Any log system observers L{TrialRunner.run} adds are removed by the
        time it returns.
        N)lenrd   r   runrF   assertEqual)r   originalCountnewCounts      r   test_addObserversz'TrialRunnerTestsMixin.test_addObservers   sN    
 D..01		"t))+,=1r!   c                 p   t        | j                  j                        j                  | j                  j                        }t        d      D ]f  }| j                  j                  | j                         |j                          | j                  |j                                |j                          h y)z=
        Test that a new file is opened on each run.
           N)r   r   workingDirectorychildlogfilerangerg   rF   restat
assertTrueexistsremove)r   logPathis      r   test_logFileAlwaysActivez.TrialRunnerTestsMixin.test_logFileAlwaysActive   s}     4;;778>>t{{?R?RSq 	AKKOODII&NNOOGNN,- NN	r!   N)r)   r*   r+   rZ   r`   rd   rk   rx   r,   r!   r   r^   r^   y   s    
-2r!   r^   c                       e Zd ZdZd Zd Zy)TrialRunnerTestszm
    Tests for L{runner.TrialRunner} with the feature to turn unclean errors
    into warnings disabled.
    c                     t               | _        t        j                  t        | j                        | _        t        d      | _        y )Nr5   r`   r   r5   r   TrialRunnerr.   rz   rF   r   s    r   setUpzTrialRunnerTests.setUp   s0    j(():4;;O$\2	r!   c                 x    | j                   j                         }| j                  |j                  t               y)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assertIdenticalr4   r   r   results     r   test_publisherzTrialRunnerTests.test_publisher   s,    
 ((*V..4r!   N)r)   r*   r+   rZ   r   r   r,   r!   r   rz   rz      s    
3
5r!   rz   c                       e Zd ZdZd Zy)+TrialRunnerWithUncleanWarningsReporterTestsza
    Tests for the TrialRunner's interaction with an unclean-error suppressing
    reporter.
    c                     t               | _        t        j                  t        | j                  d      | _        t        d      | _        y )NTr5   uncleanWarningsr`   r}   r   s    r   r   z1TrialRunnerWithUncleanWarningsReporterTests.setUp   s6    j((dkk4
 %\2	r!   Nr)   r*   r+   rZ   r   r,   r!   r   r   r      s    
3r!   r   c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)DryRunMixinze
    Mixin for testing that 'dry run' mode works with various
    L{pyunit.TestCase} subclasses.
    c                     g | _         t               | _        t        j                  t
        t        j                  j                  | j                        | _        | j                          y )Nr|   )r   r   r5   r   r~   r.   DRY_RUNmakeTestFixturesr   s    r   r   zDryRunMixin.setUp   sI    j((v1199$++
 	r!   c                      y)zh
        Set C{self.test} and C{self.suite}, where C{self.suite} is an empty
        TestSuite.
        Nr,   r   s    r   r   zDryRunMixin.makeTestFixtures   rI   r!   c                     | j                   j                  t        j                               }| j                  |j                  g        y)zf
        If there are no tests, the reporter should not receive any events to
        report.
        N)r   rg   	TestSuiterh   r   r   s     r   r`   zDryRunMixin.test_empty   s3    
 !1!1!34+r!   c                     | j                   j                  | j                        }| j                  |j                  g d       y)z
        If we are running a single test, check the reporter starts, passes and
        then stops the test during a dry run.
        r:   rD   r>   N)r   rg   rF   rh   r   r   s     r   test_singleCaseReportingz$DryRunMixin.test_singleCaseReporting   s/    
 +(OPr!   c                     | j                   j                  | j                         | j                  | j                  g        y)zT
        When we are doing a dry run, the tests should not actually be run.
        N)r   rg   rF   rh   r   r   s    r   test_testsNotRunzDryRunMixin.test_testsNotRun   s,     			"2&r!   N)	r)   r*   r+   rZ   r   r   r`   r   r   r,   r!   r   r   r      s!    
 ,Q'r!   r   c                       e Zd ZdZd Zy)SynchronousDryRunTestszS
    Check that 'dry run' mode works well with trial's L{SynchronousTestCase}.
    c                      G d dt         j                        } |d      | _        t        j                         | _        y )Nc                       e Zd Zd Zy);SynchronousDryRunTests.makeTestFixtures.<locals>.PyunitCasec                      y r   r,   r   s    r   test_foozDSynchronousDryRunTests.makeTestFixtures.<locals>.PyunitCase.test_foo       r!   Nr)   r*   r+   r   r,   r!   r   
PyunitCaser          r!   r   r   )r   SynchronousTestCaserF   pyunitr   suiter   r   s     r   r   z'SynchronousDryRunTests.makeTestFixtures   s2    	55 	 z*	%%'
r!   Nr)   r*   r+   rZ   r   r,   r!   r   r   r          (r!   r   c                       e Zd ZdZd Zy)DryRunTestsz@
    Check that 'dry run' mode works well with Trial tests.
    c                       G  fddt         j                        } |d       _        t        j                          _        y )Nc                       e Zd Z fdZy).DryRunTests.makeTestFixtures.<locals>.MockTestc                 <    j                   j                  d       y )Nr   )r   r&   )rF   r   s    r   r   z7DryRunTests.makeTestFixtures.<locals>.MockTest.test_foo  s    
+r!   Nr   r   s   r   MockTestr     s    ,r!   r   r   )r   TestCaserF   r   r   r   )r   r   s   ` r   r   zDryRunTests.makeTestFixtures  s3    	,x(( 	, Z(	%%'
r!   Nr   r,   r!   r   r   r      r   r!   r   c                       e Zd ZdZd Zy)PyUnitDryRunTestszJ
    Check that 'dry run' mode works well with stdlib unittest tests.
    c                      G d dt         j                        } |d      | _        t        j                         | _        y )Nc                       e Zd Zd Zy)6PyUnitDryRunTests.makeTestFixtures.<locals>.PyunitCasec                      y r   r,   r   s    r   r   z?PyUnitDryRunTests.makeTestFixtures.<locals>.PyunitCase.test_foo  r   r!   Nr   r,   r!   r   r   r     r   r!   r   r   )r   r   rF   r   r   r   s     r   r   z"PyUnitDryRunTests.makeTestFixtures  s0    	 	 z*	%%'
r!   Nr   r,   r!   r   r   r     r   r!   r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Z e       Zd Zd Zy)RunnerTestsc                 X    t        j                          _        t        j                  t
              j                  d      }dj                  |d d       }|d   }t        j                  d|ddd |      g fd}t        j                   _        |t        _        g dd	z   _        y )
N.zTest Helper ReporterzUtility for unit testing.	capturing)descriptionlongOptshortOptklassc                 t    j                  | t               t         j                  | g|i |      z   S r   )rh   r   listoriginal)ifaceakwpluginsr   s      r   
getPluginsz%RunnerTests.setUp.<locals>.getPlugins/  s8    UI.T-$--"@"@R"@AAAr!   r   
   )r   Optionsconfigr   qualr.   splitjoinr	   	_Reporterr   r   r   standardReport)r   partspackager   r   r   s   `    @r   r   zRunnerTests.setUp  s    mmo ./55c:((5":&b	##&7#	
	B ))&
 FJr!   c                 .    | j                   t        _        y r   )r   r   r   r   s    r   tearDownzRunnerTests.tearDown;  s     MMr!   c                 :    | j                   j                  |       y r   )r   parseOptionsr   r'   s     r   r   zRunnerTests.parseOptions>  s      &r!   c                 b    t        j                  | j                        }t               |_        |S r   )r   _makeRunnerr   r   r5   )r   rs     r   	getRunnerzRunnerTests.getRunnerA  s$    dkk*:r!   c                     | j                  g        | j                  d   }| j                         }| j                  | |j                         j
                         y Nr   )r   r   r   rh   r   	__class__)r   r   r   s      r   test_runner_can_get_reporterz(RunnerTests.test_runner_can_get_reporterF  sL    "Z(!!3!3!3!5!?!?@r!   c                     | j                  g        | j                         } |j                         }| j                  |j                  | j
                  d          y r   )r   r   r   rh   r   r   r   r   r   s      r   test_runner_get_resultz"RunnerTests.test_runner_get_resultL  sK    "!###%))4;;z+BCr!   c                     | j                  g        | j                         }| j                   |j                         t        j
                         y)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   assertNotIsInstancer   r   UncleanWarningsReporterWrapperr   r   s     r    test_uncleanWarningsOffByDefaultz,RunnerTests.test_uncleanWarningsOffByDefaultR  sB     	"!  F ("I"I	
r!   c                     | j                  dg       | j                         }| j                   |j                         t        j
                         y)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   assertIsInstancer   r   r   r   s     r   test_getsUncleanWarningsz$RunnerTests.test_getsUncleanWarnings^  sF     	/01!F ("I"I	
r!   c                     | j                  ddg       | j                         }| j                  |j                  d       y )N--temp-directory	some_path)r   r   rh   rn   r   s     r   test_runner_working_directoryz)RunnerTests.test_runner_working_directoryj  s8    -{;<!00+>r!   c                    | j                  g        | j                  t        j                  t        j                                t        | j                               j                          t        j                  j                         | j                         }| j                         i  G fddt        j                        |j                   d            }|j                  |j                  z   }|r| j                  |d   d          | j!                  j#                  d      j                  j#                  d      j                  d       y	)
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.
        c                   (    e Zd Z fdZfdZy)KRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCasec                     t        j                         xd<   }t        j                  j                         | j	                  t         j                  |       j                   d             y)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path
addCleanuprg   )r   subsequentDirectoryConcurrentCaserunDirectorysecondRunnerwheres     r   
test_firstzVRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCase.test_first  sS     =?IIKGl#&9**+*=>  !>?r!   c                 4    t        j                         d<   y)zR
                Record the working directory for later analysis.
                recordN)r   r   )r   r   s    r   r   zWRunnerTests.test_concurrentImplicitWorkingDirectory.<locals>.ConcurrentCase.test_second  s     #%))+hr!   N)r)   r*   r+   r   r   )r   r   r   r   s   r   r   r     s    @.r!   r   r   r   r$   _trial_tempz_trial_temp-1)r   r  N)r   r   r   r   r   r   mktempmakedirsr   r   r   r   rg   errorsfailuresfailrh   ro   )r   firstRunnerr   badr   r   r   r   s       @@@@r   'test_concurrentImplicitWorkingDirectoryz3RunnerTests.test_concurrentImplicitWorkingDirectoryo  s    	" 	"))+.
  .
""#nn&~~'	. 	.X99 	.* !=>mmfoo-IIc!fQi *00?DD&,,_=BB	
r!   c                    | j                  dt        j                  j                  | j	                               g       t        j
                         }| j                  t        j                  |       | j                         }| j                          G fddt        j                        |j                   d            }|j                  |j                  z   }|r| j                  |d   d          yy)z
        If a working directory which is already in use is explicitly specified,
        L{TrialRunner.run} raises L{_WorkingDirectoryBusy}.
        r   c                        e Zd Z fdZd Zy)KRunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCasec                 h    | j                  t        j                  j                   d             y)z
                Try to start another runner in the same working directory and
                assert that it raises L{_WorkingDirectoryBusy}.
                test_failureN)assertRaisesr   _WorkingDirectoryBusyrg   )r   r   r   s    r   test_concurrentz[RunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCase.test_concurrent  s-    
 !!.. $$">2r!   c                 &    | j                  d       y)zE
                Should not be called, always fails.
                z$test_failure should never be called.N)r  r   s    r   r  zXRunnerTests.test_concurrentExplicitWorkingDirectory.<locals>.ConcurrentCase.test_failure  s     		@Ar!   N)r)   r*   r+   r  r  )r   r   s   r   r   r    s    	Br!   r   r  r   r$   N)r   r   r   abspathr  r   r   r   r   r   r   rg   r  r  r  )r   initialDirectoryr	  r   r
  r   r   s        @@r   'test_concurrentExplicitWorkingDirectoryz3RunnerTests.test_concurrentExplicitWorkingDirectory  s    
 	-rwwt{{}/MNO99;"23nn&~~'	BX99 	B$ 0A!BCmmfoo-IIc!fQi  r!   c                 &   | j                  d| j                         dddg       | j                         }t        j                         }|j                  dd      }|j                  |      }| j                  | j                  |j                         y )Nr   
--reporterr   twisted.trial.test.sampleT)
r   r  r   r   
TestLoader
loadByNamerg   rh   r   r   )r   	my_runnerloaderr   r   s        r   test_runner_normalzRunnerTests.test_runner_normal  s    "+	
 NN$	""$!!"=tDu%,,fmm<r!   c                 p    t        j                         }|j                  dd      }|j                  |      S )Nr  T)r   r  r  rg   )r   r  r  r   s       r   runSampleSuitezRunnerTests.runSampleSuite  s2    ""$!!"=tD}}U##r!   c                    | j                  g d       | j                         }t               x}|_        | j	                  |      }| j                  | j                  |j                         | j                  dg|j                         y)zL
        Trial uses its debugger if the `--debug` option is passed.
        )r  r   --debugr  r#   N)r   r   r   debuggerr!  rh   r   r   )r   r  r$  r   s       r   test_runnerDebugzRunnerTests.test_runnerDebug  ss     	O	
 NN$	(9(;;9%$$Y/,,fmm<)hoo6r!   c                 0     j                  ddg       t        d      }|j                          d _         fd} j	                  t
        j                  d|        j                   j                                 j                   j                         y)zL
        Trial uses pdb if no debugger is specified by `--debugger`
        r#  r  pdbrcFc                     d_         y NTruncall_calledpdbr   r   r   s      r   r#   z=RunnerTests.test_runnerDebuggerDefaultsToPdb.<locals>.runcall      "&Dr!   r#   N)
r   r   touchr+  patchr-  Pdbr!  r   rs   )r   	pdbrcFiler#   s   `  r    test_runnerDebuggerDefaultsToPdbz,RunnerTests.test_runnerDebuggerDefaultsToPdb  sw     	9&ABCW%	#	' 	

377Iw/DNN,-++,r!   c                       j                  g d       d _         fd} j                  t        j                  d|        j                   j                                 j                   j                         y)zU
        Trial uses pdb if pdb is passed explicitly to the `--debugger` arg.
        )r  r   
--debuggerr-  r#  r  Fc                     d_         y r)  r*  r,  s      r   r#   zGRunnerTests.test_runnerDebuggerWithExplicitlyPassedPdb.<locals>.runcall  r.  r!   r#   N)r   r+  r0  r-  r1  r!  r   rs   )r   r#   s   ` r   *test_runnerDebuggerWithExplicitlyPassedPdbz6RunnerTests.test_runnerDebuggerWithExplicitlyPassedPdb  sd     			
 $	' 	

377Iw/DNN,-++,r!   c                    | j                  g d       | j                         }| j                  |      }| j                  | j                  |j
                         | j                  dg|j                  j
                         y)zM
        Trial uses specified debugger if the debugger is available.
        )r  r   r5  z4twisted.trial.test.test_runner.RunnerTests.cdebuggerr#  r  r#   N)r   r   r!  rh   r   r   r$  )r   r  r   s      r   test_runnerDebuggerzRunnerTests.test_runnerDebugger  sm     			
 NN$	$$Y/,,fmm<)i&8&8&?&?@r!   c                     | j                  dg       | j                         } |j                         }| j                  |t        j
                         y)z
        If trial was passed the C{--exitfirst} option, the constructed test
        result object is wrapped with L{reporter._ExitWrapper}.
        z--exitfirstN)r   r   r   r   r   _ExitWrapperr   s      r   test_exitfirstzRunnerTests.test_exitfirst0  sF    
 	=/*!###%fh&;&;<r!   N)r)   r*   r+   r   r   r   r   r   r   r   r   r   r  r  r  r!  r%  r3  r7  r   	cdebuggerr9  r<  r,   r!   r   r   r     sm    KB*'
AD



?
7
r"!H= $
7-&-4 "#IA&=r!   r   c                       e Zd Zd Zy)TrialSuiteTestsc                     t        d       y )Nztwisted.trial.runner.TrialSuiter   r   s    r   test_importszTrialSuiteTests.test_imports<  s    23r!   N)r)   r*   r+   rA  r,   r!   r   r?  r?  ;  s    4r!   r?  c                   T    e Zd Z G d dej                        Zd Zd Zd Zd Z	d Z
y)	UntilFailureTestsc                   ,    e Zd ZU dZg Zed   ed<   d Zy)UntilFailureTests.FailAfterzC
        A test case that fails when run 3 times in a row.
        Ncountc                     | j                   j                  d        t        | j                         dk(  r| j                  d       y y )N   zCount reached 3)rF  r&   rf   r  r   s    r   r   z$UntilFailureTests.FailAfter.test_fooI  s6    JJd#4::!#		+, $r!   )r)   r*   r+   rZ   rF  r   __annotations__r   r,   r!   r   	FailAfterrE  B  s    	 tDz	-r!   rJ  c                     g t         j                  _        t         j                  d      | _        t	               | _        t        j                  t        j                  | j
                        | _        y )Nr   r|   )
rC  rJ  rF  rF   r   r5   r   r~   r   Reporterr   s    r   r   zUntilFailureTests.setUpN  sJ    ,.##)%//
;	j(():):4;;Or!   c                    | j                   j                  | j                        }| j                  |j                  d       | j                  |j                                | j                  | j                  |      d       y)zl
        Test that the runUntilFailure method of the runner actually fail after
        a few runs.
        r$   N)r   runUntilFailurerF   rh   r\   assertFalserY   _getFailuresr   s     r   test_runUntilFailurez&UntilFailureTests.test_runUntilFailureT  sb    
 ,,TYY7!,--/0**62A6r!   c                 ,    t        |j                        S )zL
        Get the number of failures that were reported to a result.
        )rf   r  r   s     r   rP  zUntilFailureTests._getFailures^  s     6??##r!   c                 @   g fd}| j                  t        d|       | j                  j                  | j                        }| j                  |j                  d       | j                  t              d       | j                  | j                  t        fg       y)z
        C{runUntilFailure} doesn't decorate the tests uselessly: it does it one
        time when run starts, but not at each turn.
        c                 .    j                  | |f       | S r   r&   rF   	interface	decorateds     r   decoratez@UntilFailureTests.test_runUntilFailureDecorate.<locals>.decoratek      dI./Kr!   rY  r$   N)	r0  r   r   rN  rF   rh   r\   rf   r   r   rY  r   rX  s      @r   test_runUntilFailureDecoratez.UntilFailureTests.test_runUntilFailureDecorated  s}    
 		 	

8Z2,,TYY7!,Y+dii%;$<=r!   c                    g fd}| j                  t        d|       d| j                  _        | j                  j	                  | j
                        }| j                  |j                  d       | j                  t              d       | j                  | j
                  t        f| j
                  t        fg       y)z
        C{runUntilFailure} applies the force-gc decoration after the standard
        L{ITestCase} decoration, but only one time.
        c                 .    j                  | |f       | S r   rU  rV  s     r   rY  zGUntilFailureTests.test_runUntilFailureForceGCDecorate.<locals>.decorate}  rZ  r!   rY  Tr$   rm   N)r0  r   r   _forceGarbageCollectionrN  rF   rh   r\   rf   r   r   r[  s      @r   #test_runUntilFailureForceGCDecoratez5UntilFailureTests.test_runUntilFailureForceGCDecoratev  s    
 		 	

8Z2.2+,,TYY7!,Y+ii#dii1Q%RS	
r!   N)r)   r*   r+   r   r   rJ  r   rQ  rP  r\  r`  r,   r!   r   rC  rC  A  s,    
-FOO 
-P7$>$
r!   rC  c                       e Zd ZdZd Zd Zy)UncleanUntilFailureTestszh
    Test that the run-until-failure feature works correctly with the unclean
    error suppressor.
    c                     t         j                  |        t        j                  t        j
                  | j                  d      | _        y )NTr   )rC  r   r   r~   r   rL  r5   r   s    r   r   zUncleanUntilFailureTests.setUp  s3    %((dkk4
r!   c                 @    t        |j                  j                        S )z
        Get the number of failures that were reported to a result that
        is wrapped in an UncleanFailureWrapper.
        )rf   _originalReporterr  r   s     r   rP  z%UncleanUntilFailureTests._getFailures  s    
 6++4455r!   N)r)   r*   r+   rZ   r   rP  r,   r!   r   rb  rb    s    

6r!   rb  c                       e Zd ZdZd Zy)BreakingSuitez;
    A L{TestSuite} that logs an error when it is run.
    c                     	 t        d      # t         $ r* t        j                  t        j                                Y y w xY w)Nz#error that occurs outside of a test)RuntimeErrorr   errr
   Failurer   s     r   rg   zBreakingSuite.run  s5    	'DEE 	'GGGOO%&	's    0A A N)r)   r*   r+   rZ   rg   r,   r!   r   rg  rg    s    'r!   rg  c                   "    e Zd ZdZd Zd Zd Zy)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.
    c                 .    | j                  t               y r   )flushLoggedErrorsri  r   s    r   r   zLoggedErrorsTests.tearDown  s    |,r!   c                 l    t        j                         }| j                  |j                         d       y)zg
        Check that we can construct a L{runner.LoggedSuite} and that it
        starts empty.
        r   N)r   LoggedSuiterh   countTestCases)r   r   s     r   test_constructz LoggedErrorsTests.test_construct  s+    
 ""$--/3r!   c                    t        j                         }t        j                  t	               g      }|j                  |       | j                  t        |j                        d       | j                  |j                  d   d   j                         t        j                         | j                  |j                  d   d   j                  t                     y)zU
        Chek that a L{LoggedSuite} reports any logged errors to its result.
        r$   r   N)r   
TestResultr   rq  rg  rg   rh   rf   r  idNOT_IN_TESTrs   checkri  )r   r   r   s      r   test_capturesErrorz$LoggedErrorsTests.test_capturesError  s     $$&""MO#45		&V]]+Q/q)!,//163E3EFa(+11,?@r!   N)r)   r*   r+   rZ   r   rs  ry  r,   r!   r   rm  rm    s    -4	Ar!   rm  c                   $    e Zd Zd Zd Zd Zd Zy)TestHolderTestsc                 Z    d| _         t        j                  | j                         | _        y Nr   )r   r   
TestHolderholderr   s    r   r   zTestHolderTests.setUp  s"    (''(8(89r!   c                     | j                  | j                  j                         | j                         | j                  | j                  j	                         | j                         y)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)rh   r  rv  r   shortDescriptionr   s    r   test_holderzTestHolderTests.test_holder  sH     	)4+;+;<5579I9IJr!   c                     | j                  | j                  t        | j                               | j                  t	        t        | j                        | j                  dt        d       y)z?
        L{runner.TestHolder} implements L{ITestCase}.
        z claims to provide z but does not do so correctly.N)r   r  r   rs   r   r   s    r   test_holderImplementsITestCasez.TestHolderTests.test_holderImplementsITestCase  sI     	T[[)DKK*@ADKK0{{I'	
r!   c                     t        j                         }| j                  j                  |       | j	                  |j                                | j                  d|j                         y)zc
        A L{runner.TestHolder} can run against the standard Python
        C{TestResult}.
        r$   N)r   ru  r  rg   rs   rY   rh   r\   r   s     r   test_runsWithStandardResultz+TestHolderTests.test_runsWithStandardResult  sK    
 ""$,,./FOO,r!   N)r)   r*   r+   r   r  r  r  r,   r!   r   r{  r{    s    :K	
-r!   r{  c                   R    e Zd ZdZ ed      Z G d d      Zd Zd Zd Z	d Z
d	 Zy
)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                   (    e Zd ZdZd Zd Zd Zd Zy)$ErrorHolderTestsMixin.TestResultStubz)
        Stub for L{TestResult}.
        c                     g | _         y r   )r  r   s    r   r    z-ErrorHolderTestsMixin.TestResultStub.__init__  s	    DKr!   c                      y r   r,   rE   s     r   r:   z.ErrorHolderTestsMixin.TestResultStub.startTest      r!   c                      y r   r,   rE   s     r   r>   z-ErrorHolderTestsMixin.TestResultStub.stopTest  r  r!   c                 >    | j                   j                  ||f       y r   )r  r&   rK   s      r   rM   z-ErrorHolderTestsMixin.TestResultStub.addError  s    KKe}-r!   N)r)   r*   r+   rZ   r    r:   r>   rM   r,   r!   r   TestResultStubr    s    					.r!   r  c                     t        j                         }| j                  j                  |       | j	                  |j                                | j                  d|j                         y)zd
        A L{runner.ErrorHolder} can run against the standard Python
        C{TestResult}.
        r$   N)r   ru  r  rg   rO  rY   rh   r\   r   s     r   r  z1ErrorHolderTestsMixin.test_runsWithStandardResult  sM    
 ""$--/0FOO,r!   c                 2   | j                   j                  | j                         | j                  | j                  j                  | j                   | j
                  j                  | j
                  j                  | j
                  j                  ffg       y)zM
        L{runner.ErrorHolder} adds an error to the result when run.
        N)	r  rg   r   rh   r  rL   typevaluetbr   s    r   test_runzErrorHolderTestsMixin.test_run  sc     	$KKkkDJJOOTZZ-=-=tzz}}MNO	
r!   c                    | j                  | j                         | j                  | j                  j                  | j                   | j                  j
                  | j                  j                  | j                  j                  ffg       y)zP
        L{runner.ErrorHolder} adds an error to the result when called.
        N)r  r   rh   r  rL   r  r  r  r   s    r   	test_callzErrorHolderTestsMixin.test_call"  s_     	DKK KKkkDJJOOTZZ-=-=tzz}}MNO	
r!   c                 X    | j                  | j                  j                         d       y)zH
        L{runner.ErrorHolder.countTestCases} always returns 0.
        r   N)rh   r  rr  r   s    r   test_countTestCasesz)ErrorHolderTestsMixin.test_countTestCases,  s!     	335q9r!   c                     dj                  t        | j                  j                  d               }| j	                  t        | j                        |       y)zh
        L{runner.ErrorHolder.__repr__} returns a string describing the error it
        holds.
        z0<ErrorHolder description='description' error={}>r$   N)formatreprr  rL   rh   )r   expecteds     r   	test_reprzErrorHolderTestsMixin.test_repr2  sG    
 IOO""1%&
 	dkk*H5r!   N)r)   r*   r+   rZ   ZeroDivisionErrorexceptionForTestsr  r  r  r  r  r  r,   r!   r   r  r    s8     **NO. ."-

:	6r!   r  c                       e Zd ZdZd Zy)FailureHoldingErrorHolderTestsz
    Tests for L{runner.ErrorHolder} behaving similarly to L{runner.TestHolder}
    when constructed with a L{Failure} representing its error.
    c                    d| _         	 | j                  # t        $ r t        j                         | _        Y nw xY wt        j                  | j                   | j
                        | _        | j                         | _
        y r}  )r   r  r  r
   rk  rL   r   ErrorHolderr  r  r   r   s    r   r   z$FailureHoldingErrorHolderTests.setUpD  sf    (	+(((  	+ *DJ	+(()9)94::F))+s    "::Nr   r,   r!   r   r  r  >  s    
,r!   r  c                       e Zd ZdZd Zy)ExcInfoHoldingErrorHolderTestsz
    Tests for L{runner.ErrorHolder} behaving similarly to L{runner.TestHolder}
    when constructed with a C{exc_info}-style tuple representing its error.
    c                    d| _         	 | j                  # t        $ r0 t        j                         }t        j                         | _        Y nw xY wt        j                  | j                   |      | _
        | j                         | _        y r}  )r   r  r  sysexc_infor
   rk  rL   r   r  r  r  r   )r   exceptionInfos     r   r   z$ExcInfoHoldingErrorHolderTests.setUpU  so    (	+(((  	+LLNM *DJ	+ (()9)9=I))+s    6AANr   r,   r!   r   r  r  O  s    
	,r!   r  c                   R    e Zd ZdZ G d dej
                        Zd Zd Zd Z	d Z
y)	MalformedMethodTestszR
    Test that trial manages when test methods don't have correct signatures.
    c                   @    e Zd ZdZd Zd Z ej                  e      Zy)%MalformedMethodTests.ContainMalformedzV
        This TestCase holds malformed test methods that trial should handle.
        c                      y r   r,   )r   blahs     r   r   z.MalformedMethodTests.ContainMalformed.test_fook  r  r!   c                       y r   r,   r,   r!   r   test_barz.MalformedMethodTests.ContainMalformed.test_barn  r  r!   N)	r)   r*   r+   rZ   r   r  r   inlineCallbacks	test_spamr,   r!   r   ContainMalformedr  f  s%    			 *E))(3	r!   r  c                 n   t               }t        j                  t        j                  |      }t
        j                  |      }|j                  |      }| j                  |j                  d       | j                  |j                                | j                  t        |j                        d       y)zL
        Wrapper for one of the test method of L{ContainMalformed}.
        r|   r$   N)r   r   r~   r   rL  r  r  rg   rh   r\   rO  rY   rf   r  )r   r<   r5   trialRunnerrF   r   s         r   _testzMalformedMethodTests._tests  s     (():):6J#44V<&!,--/0V]]+Q/r!   c                 &    | j                  d       y)zE
        Test when the method has extra (useless) arguments.
        r   Nr  r   s    r   test_extraArgz"MalformedMethodTests.test_extraArg       	

:r!   c                 &    | j                  d       y)zJ
        Test when the method doesn't have even self as argument.
        r  Nr  r   s    r   
test_noArgzMalformedMethodTests.test_noArg  r  r!   c                 &    | j                  d       y)z5
        Test a decorated method also fails.
        r  Nr  r   s    r   test_decoratedz#MalformedMethodTests.test_decorated  s     	

;r!   N)r)   r*   r+   rZ   r   r   r  r  r  r  r  r,   r!   r   r  r  a  s+    46?? 4
0 r!   r  c                   "    e Zd ZdZd Zd Zd Zy)DestructiveTestSuiteTestsz2
    Test for L{runner.DestructiveTestSuite}.
    c                 P   g  G fddt         j                        } |d      }t        j                         }t	        j
                  |g      }| j                  g        |j                  |       | j                  dg       | j                  |j                         d       y)zL
        Thes destructive test suite should run the tests normally.
        c                       e Zd Z fdZy)6DestructiveTestSuiteTests.test_basic.<locals>.MockTestc                 (    j                  d       y r)  rU  rF   calleds    r   r   z?DestructiveTestSuiteTests.test_basic.<locals>.MockTest.test_foo  s    d#r!   Nr   r  s   r   r   r    s    $r!   r   r   Tr   N)	r   r   r   ru  r   DestructiveTestSuiterh   rg   rr  )r   r   rF   r   r   r  s        @r   
test_basicz$DestructiveTestSuiteTests.test_basic  s     	$v 	$ 
#$$&++TF3$		&$(--/3r!   c                    g  G fddt         j                        }t        j                         }t	        j
                         }t        j                  |_        |j                  |      }| j                  g        |j                  |       | j                  dg       | j                  |j                         d       y)zu
        Test the C{shouldStop} management: raising a C{KeyboardInterrupt} must
        interrupt the suite.
        c                   (    e Zd Z fdZd Z fdZy);DestructiveTestSuiteTests.test_shouldStop.<locals>.MockTestc                 (    j                  d       y )Nr$   rU  r  s    r   	test_foo1zEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo1      a r!   c                     t               r   )KeyboardInterruptrF   s    r   	test_foo2zEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo2  s    '))r!   c                 (    j                  d       y )Nrm   rU  r  s    r   	test_foo3zEDestructiveTestSuiteTests.test_shouldStop.<locals>.MockTest.test_foo3  r  r!   N)r)   r*   r+   r  r  r  r  s   r   r   r    s    !*!r!   r   r$   N)r   r   r   ru  r   r  r  suiteFactory	loadClassrh   rg   rr  )r   r   r   r  r   r  s        @r   test_shouldStopz)DestructiveTestSuiteTests.test_shouldStop  s    
 	!x(( 	! $$&""$$99  *$		&!%--/3r!   c                 <    G d dt         j                        } |d      }t        j                         }t	        j
                  |g      }| j                  |j                         d       |j                  |       | j                  |j                         d       y)zn
        Checks that the test suite cleanups its tests during the run, so that
        it ends empty.
        c                       e Zd Zd Zy)8DestructiveTestSuiteTests.test_cleanup.<locals>.MockTestc                      y r   r,   r  s    r   r   zADestructiveTestSuiteTests.test_cleanup.<locals>.MockTest.test_foo  r   r!   Nr   r,   r!   r   r   r    r   r!   r   r   r$   r   N)	r   r   r   ru  r   r  rh   rr  rg   )r   r   rF   r   r   s        r   test_cleanupz&DestructiveTestSuiteTests.test_cleanup  s|    	v 	 
#$$&++TF3--/3		&--/3r!   N)r)   r*   r+   rZ   r  r  r  r,   r!   r   r  r    s    4$464r!   r  c                   6    e Zd Z G d dej                        Zy)RunnerDeprecationTestsc                   4    e Zd ZdZdZdZdZd Zd Zd Z	d Z
y)#RunnerDeprecationTests.FakeReporterz
        Fake reporter that does *not* implement done() but *does* implement
        printErrors, separator, printSummary, stream, write and writeln
        without deprecations.
        Nc                      y r   r,   r   s     r   printErrorsz/RunnerDeprecationTests.FakeReporter.printErrors  r  r!   c                      y r   r,   r   s     r   printSummaryz0RunnerDeprecationTests.FakeReporter.printSummary  r  r!   c                      y r   r,   r   s     r   writez)RunnerDeprecationTests.FakeReporter.write  r  r!   c                      y r   r,   r   s     r   writelnz+RunnerDeprecationTests.FakeReporter.writeln  r  r!   )r)   r*   r+   rZ   rH   r[   r5   r  r  r  r  r,   r!   r   FakeReporterr    s,    	 					r!   r  N)r)   r*   r+   r   rL  r  r,   r!   r   r  r    s    x(( r!   r  c                       e Zd ZdZd Zy)QualifiedNameWalkerTestsz<
    Tests for L{twisted.trial.runner._qualNameWalker}.
    c                 |    t        t        j                  d            }| j                  |dg fddgfdddgfg       y)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.
        zwalker.texas.rangerzwalker.texasrangerwalkertexasN)r   r   _qualNameWalkerrh   )r   walkerResultss     r   test_walksDownPathz+QualifiedNameWalkerTests.test_walksDownPath  sO     V334IJK&+(,GX./	
r!   N)r)   r*   r+   rZ   r  r,   r!   r   r  r    s    
r!   r  c                       e Zd ZdZd Zy)TrialMainDoesNothingTestszl
    Importing L{twisted.trial.__main__} will not run the script
    unless it is actually C{__main__}.
    c                     t        d       y)zO
        If we import L{twisted.trial.__main__}, it should do nothing.
        ztwisted.trial.__main__N)
__import__r   s    r   test_importDoesNothingz0TrialMainDoesNothingTests.test_importDoesNothing  s    
 	+,r!   N)r)   r*   r+   rZ   r  r,   r!   r   r  r    s    
-r!   r  )@r   r-  r  r   r   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.trialr   r   r   twisted.trial._asyncrunnerr   twisted.trial.itrialr   r   r   r.   r^   r   rz   r   r   r   r   r   r   r?  rC  rb  r   rg  rm  r{  r  r  r  r  r  r  r  r  r,   r!   r   <module>r
     s   
 
 
    & .  " ) 0 0 , + ! : : G 5% % YN N Nb# #L5,h.J.J 5(38773 )' )'X([(*F*F ((+x;; ((X%A%A (_=(.. _=D	4h22 4I
44 I
X60 6(	'F$$ 	'A44 A>!-h22 !-HK6 K6\,%:O ,",%:O ,$. 877 . bA4 < < A4HX99 2
x;; 
.- < < -r!   