
~Mc           @   s  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 m	 Z	 d  d l
 m Z m Z m Z m Z d  d l m Z 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 d  d l m Z e d  Z d e  f d     YZ! d e  f d     YZ" d d5 d     YZ# d e# e j$ f d     YZ% d e# e j$ f d     YZ& d e  f d     YZ' d e' e j$ f d     YZ( d e' e j$ f d     YZ) d e j$ f d     YZ* d e j$ f d      YZ+ d! e j$ f d"     YZ, d# e j$ f d$     YZ- d% e- f d&     YZ. d' e j/ f d(     YZ0 d) e j$ f d*     YZ1 d+ e j$ f d,     YZ2 d- e2 f d.     YZ3 d/ e j$ f d0     YZ4 d1 e j$ f d2     YZ5 d3 e j$ f d4     YZ6 d S(6   iN(   t
   implements(   t   verifyObject(   t	   IReportert	   ITestCase(   t   unittestt   runnert   reportert   util(   t   failuret   logt   reflectt   filepath(   t   FilePath(   t   trial(   t   twisted_trial(   t   plugin(   t   deferR   t   CapturingDebuggerc           B   s   e  Z d    Z d   Z RS(   c         C   s   g  |  _  d  S(   N(   t   _calls(   t   self(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   __init__   s    c         O   s)   |  j  j d  | d | d |   d  S(   Nt   runcalli    i   (   R   t   append(   R   t   argst   kwargs(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR      s    (   t   __name__t
   __module__R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR      s   	t   CapturingReporterc           B   sx   e  Z d  Z e e  d Z d Z d Z d Z	 d Z
 d d d d d  Z d   Z d   Z d   Z d   Z d   Z RS(   sC   
    Reporter that keeps a log of all actions performed on it.
    c         C   s:   g  |  _  t |  _ | |  _ | |  _ | |  _ | |  _ d S(   s.   
        Create a capturing reporter.
        N(   R   t   Falset
   shouldStopt   _streamt	   _tbformatt	   _rterrorst
   _publisher(   R   t   streamt   tbformatt   rterrorst	   publisher(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   1   s    					c         C   s   |  j  j d  d S(   s   
        Report the beginning of a run of a single test method
        @param method: an object that is adaptable to ITestMethod
        t	   startTestN(   R   R   (   R   t   method(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR&   >   s    c         C   s   |  j  j d  d S(   s}   
        Report the status of a single test method
        @param method: an object that is adaptable to ITestMethod
        t   stopTestN(   R   R   (   R   R'   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR(   F   s    c         C   s   |  j  j d  d S(   s   called when the reactor has been left in a 'dirty' state
        @param errs: a list of L{twisted.python.failure.Failure}s
        t   cleanupErrorN(   R   R   (   R   t   errs(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   cleanupErrorsN   s    c         C   s   |  j  j d  d  S(   Nt
   addSuccess(   R   R   (   R   t   test(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR,   U   s    c         C   s   d S(   s@   
        Do nothing. These tests don't care about done.
        N(    (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   doneY   s    N(   R   R   t   __doc__R    R   t   NoneR"   R#   R   t	   separatort   testsRunR   R&   R(   R+   R,   R.   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   $   s   
					t   TrialRunnerTestsMixinc           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s9   
    Mixin defining tests for L{runner.TrialRunner}.
    c         C   s   |  j  j   d  S(   N(   R   t   _tearDownLogFile(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   tearDownd   s    c         C   s   d S(   s=   
        Empty test method, used by the other tests.
        N(    (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt
   test_emptyh   s    c         C   s
   t  j j S(   N(   R	   t   theLogPublishert	   observers(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   _getObserversn   s    c         C   sK   t  |  j    } |  j j |  j  t  |  j    } |  j | |  d S(   sn   
        Any log system observers L{TrialRunner.run} adds are removed by the
        time it returns.
        N(   t   lenR9   R   t   runR-   t   assertEqual(   R   t   originalCountt   newCount(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_addObserversr   s    c            s    j  j   g       f d   } |  j  _  j  j  j   j  j  j   j t   d   j  d  d k d  d S(   s=   
        Test that a new file is opened on each run.
        c              s        j   j j  d  S(   N(   R   R   t   _logFileObserver(    (   t   oldSetUpLogFileR   t   l(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   setUpLogFile   s    i   i    i   s'   Should have created a new file observerN(   R   t   _setUpLogFileR;   R-   t   failUnlessEqualR:   t   failIf(   R   RC   (    (   RA   R   RB   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_logFileAlwaysActive}   s    c            st    j  j   g       f d   } |  j  _  j  j  j   j t   d   j  d j  d S(   sB   
        Test that file created is closed during the run.
        c              s        j   j j  d  S(   N(   R   R   t   _logFileObject(    (   RA   R   RB   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRC      s    i   i    N(   R   RD   R;   R-   RE   R:   t
   failUnlesst   closed(   R   RC   (    (   RA   R   RB   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_logFileGetsClosed   s    (	   R   R   R/   R5   R6   R9   R?   RG   RK   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR3   `   s   					t   TestTrialRunnerc           B   s    e  Z d  Z d   Z d   Z RS(   sm   
    Tests for L{runner.TrialRunner} with the feature to turn unclean errors
    into warnings disabled.
    c         C   s=   t  j    |  _ t j t d |  j |  _ t d  |  _ d  S(   NR"   R6   (   t   StringIOR"   R   t   TrialRunnerR   RL   R-   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   setUp   s    c         C   s&   |  j  j   } |  j | j t  d S(   s   
        The reporter constructed by L{runner.TrialRunner} is passed
        L{twisted.python.log} as the value for the C{publisher} parameter.
        N(   R   t   _makeResultt   assertIdenticalR!   R	   (   R   t   result(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_publisher   s    (   R   R   R/   RO   RS   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRL      s   	t&   TrialRunnerWithUncleanWarningsReporterc           B   s   e  Z d  Z d   Z RS(   sa   
    Tests for the TrialRunner's interaction with an unclean-error suppressing
    reporter.
    c         C   sC   t  j    |  _ t j t d |  j d t |  _ t d  |  _ d  S(   NR"   t   uncleanWarningsR6   (   RM   R"   R   RN   R   t   TrueRL   R-   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO      s    (   R   R   R/   RO   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRT      s   t   DryRunMixinc           B   sP   e  Z e j d  e d d  g Z d   Z d   Z d   Z d   Z d   Z	 RS(   t   categoryt   messages'   Test visitors deprecated in Twisted 8.0c         C   sJ   g  |  _  t j   |  _ t j t t j j d |  j |  _ |  j   d  S(   NR"   (   R	   RM   R"   R   RN   R   t   DRY_RUNt   makeTestFixtures(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO      s    		c         C   s   d S(   sh   
        Set C{self.test} and C{self.suite}, where C{self.suite} is an empty
        TestSuite.
        N(    (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR[      s    c         C   s/   |  j  j t  j    } |  j | j g   d S(   sf   
        If there are no tests, the reporter should not receive any events to
        report.
        N(   R   R;   t	   TestSuiteR<   R   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR6      s    c         C   s5   |  j  j |  j  } |  j | j d d d g  d S(   s   
        If we are running a single test, check the reporter starts, passes and
        then stops the test during a dry run.
        R&   R,   R(   N(   R   R;   R-   R<   R   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_singleCaseReporting   s    c         C   s*   |  j  j |  j  |  j |  j g   d S(   sT   
        When we are doing a dry run, the tests should not actually be run.
        N(   R   R;   R-   R<   R	   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_testsNotRun   s    (
   R   R   R   t   suppresst   DeprecationWarningRO   R[   R6   R]   R^   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRW      s   								t
   DryRunTestc           B   s   e  Z d  Z d   Z RS(   s@   
    Check that 'dry run' mode works well with Trial tests.
    c            sA   d t  j f   f d     Y} | d    _ t j     _ d  S(   Nt   MockTestc              s   e  Z   f d    Z RS(   c            s     j  j d  d  S(   Nt   test_foo(   R	   R   (   R-   (   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc      s    (   R   R   Rc   (    (   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRb      s   Rc   (   R   t   TestCaseR-   R   R\   t   suite(   R   Rb   (    (   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR[      s    (   R   R   R/   R[   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRa      s   t   PyUnitDryRunTestc           B   s   e  Z d  Z d   Z RS(   sJ   
    Check that 'dry run' mode works well with stdlib unittest tests.
    c         C   s;   d t  j f d     Y} | d  |  _ t  j   |  _ d  S(   Nt
   PyunitCasec           B   s   e  Z d    Z RS(   c         S   s   d  S(   N(    (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc     s    (   R   R   Rc   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRg     s   Rc   (   t   pyunitRd   R-   R\   Re   (   R   Rg   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR[     s    (   R   R   R/   R[   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRf      s   t
   TestRunnerc           B   s}   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 RS(   c            s   t  j     _ t j t  j d  } d j | d   } | d } t j	 d | d d d d d d  d	 | g     f d
   } t j   _ | t _ d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d g   _ d  S(   Nt   .is   Test Helper Reportert   descriptions   Utility for unit testing.t   longOptt	   capturingt   shortOptt   klassc            s-     j  |  t   t   j |  | |   S(   N(   R<   R   t   listt   original(   t   ifacet   at   kw(   R   t   plugins(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt
   getPlugins!  s    R&   R,   R(   (   R   t   Optionst   configR
   t   qualR   t   splitt   joinR   t	   _ReporterR0   R   Rv   Rq   t   standardReport(   R   t   partst   packageRo   Rv   (    (   R   Ru   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO     s0    
										c         C   s   |  j  t _ d  S(   N(   Rq   R   Rv   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR5   4  s    c         C   s   |  j  j |  d  S(   N(   Rx   t   parseOptions(   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   8  s    c         C   sD   t  j |  j  } t j   | _ |  j | j  t j   | _	 | S(   N(
   R   t   _makeRunnerRx   RM   R"   t
   addCleanupR4   R	   t   LogPublishert   _log(   R   t   r(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt	   getRunner<  s
    c         C   sC   |  j  g   |  j d } |  j   } |  j | | j   j  d  S(   NR   (   R   Rx   R   R<   RP   t	   __class__(   R   RR   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runner_can_get_reporterM  s    c         C   sC   |  j  g   |  j   } | j   } |  j | j |  j d  d  S(   NR   (   R   R   RP   R<   R   Rx   (   R   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runner_get_resultT  s    c         C   s6   |  j  g   |  j   } |  j | j   t j  d S(   s   
        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.TestDirtyReactor}.
        N(   R   R   t   assertNotIsInstanceRP   R   t   UncleanWarningsReporterWrapper(   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt    test_uncleanWarningsOffByDefault[  s    c         C   s9   |  j  d g  |  j   } |  j | j   t j  d S(   s   
        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.TestDirtyReactor} for implications.
        s   --unclean-warningsN(   R   R   t   assertIsInstanceRP   R   R   (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_getsUncleanWarningsg  s    c         C   s6   |  j  d d g  |  j   } |  j | j d  d  S(   Ns   --temp-directoryt	   some_path(   R   R   t   assertEqualst   workingDirectory(   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runner_working_directorys  s    c            s  |  j  g   |  j t j t j    t |  j        j   t j   j  |  j	   } |  j	    i   d t
 j f      f d     Y | j  d   } | j | j } | r |  j | d d  n  |  j  i   j d  j d 6  j d  j d	 6 d
 S(   s   
        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.
        t   ConcurrentCasec              s/   e  Z      f d    Z  f d   Z RS(   c            sN   t  j    d <} t  j   j  |  j t  j |   j  d   d S(   s   
                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.
                t
   concurrentt   test_secondN(   t   ost   getcwdt   chdirt   pathR   R;   (   R   t   subsequentDirectory(   t   runDirectoryt   whereR   t   secondRunner(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt
   test_first  s    c            s   t  j     d <d S(   sR   
                Record the working directory for later analysis.
                t   recordN(   R   R   (   R   (   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s    (   R   R   R   R   (    (   R   R   R   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   R   i    i   t   _trial_tempR   s   _trial_temp-1R   N(   R   R   R   R   R   R   t   mktempt   makedirsR   R   R   Rd   R;   t   errorst   failurest   failR<   t   child(   R   t   firstRunnerRR   t   bad(    (   R   R   R   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt'   test_concurrentImplicitWorkingDirectoryy  s"    
(c            s   |  j  d t j j |  j    g  t j   } |  j t j |  |  j   } |  j    d t	 j
 f    f d     Y  | j   d   } | j | j } | r |  j | d d  n  d S(   s   
        If a working directory which is already in use is explicitly specified,
        L{TrialRunner.run} raises L{_WorkingDirectoryBusy}.
        s   --temp-directoryR   c              s#   e  Z    f d    Z d   Z RS(   c            s#   |  j  t j  j   d   d S(   s   
                Try to start another runner in the same working directory and
                assert that it raises L{_WorkingDirectoryBusy}.
                t   test_failureN(   t   assertRaisesR   t   _WorkingDirectoryBusyR;   (   R   (   R   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_concurrent  s    c         S   s   |  j  d  d S(   sE   
                Should not be called, always fails.
                s$   test_failure should never be called.N(   R   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s    (   R   R   R   R   (    (   R   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   	R   i    i   N(   R   R   R   t   abspathR   R   R   R   R   R   Rd   R;   R   R   R   (   R   t   initialDirectoryR   RR   R   (    (   R   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt'   test_concurrentExplicitWorkingDirectory  s    %"c         C   su   |  j  d |  j   d d d g  |  j   } t j   } | j d t  } | j |  } |  j |  j	 | j
  d  S(   Ns   --temp-directorys
   --reporterRm   s   twisted.trial.test.sample(   R   R   R   R   t
   TestLoadert
   loadByNameRV   R;   R<   R}   R   (   R   t	   my_runnert   loaderRe   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runner_normal  s    
c            s   |  j  d d d d g  |  j   } t       f d   } | | _ t j   } | j d t  } | j |  } |  j	 |  j
 | j  |  j	 d g   j  d  S(   Ns
   --reporterRm   s   --debugs   twisted.trial.test.samplec              s     S(   N(    (    (   t   debugger(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   get_debugger  s    R   (   R   R   R   t   _getDebuggerR   R   R   RV   R;   R<   R}   R   (   R   R   R   R   Re   RR   (    (   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runner_debug  s    		(   R   R   RO   R5   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRi     s   	&									7	#	t   RemoveSafelyTestsc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s%   
    Tests for L{_removeSafely}.
    c         C   sE   |  j    } t j |  t j |  } |  j t j t j |  d S(   s   
        If a path doesn't contain a node named C{"_trial_marker"}, that path is
        not removed by L{runner._removeSafely} and a L{runner._NoTrialMarker}
        exception is raised instead.
        N(	   R   R   t   mkdirR   R   R   R   t   _NoTrialMarkert   _removeSafely(   R   t	   directoryt   dirPath(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_removeSafelyNoTrialMarker  s    c         C   s   d   } t  j    } |  j t d |  |  j   } t j |  t j |  } | j d  j	   | | _
 t j |  |  j d | j    d S(   s   
        If an L{OSError} is raised while removing a path in
        L{runner._removeSafely}, an attempt is made to move the path to a new
        name.
        c           S   s   t     d S(   s   
            Raise an C{OSError} to emulate the branch of L{runner._removeSafely}
            in which path removal fails.
            N(   t   OSError(    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   dummyRemove  s    t   stdoutt   _trial_markers   could not remove FilePathN(   RM   t   patcht   sysR   R   R   R   R   R   t   toucht   removeR   R   t   assertInt   getvalue(   R   R   t   outR   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt(   test_removeSafelyRemoveFailsMoveSucceeds  s    		c         C   s   d   } d   } t  j    } |  j t d |  |  j   } t j |  t j |  } | j d  j	   | | _
 | | _ |  j t t j |  } |  j t |  d  |  j d | j    d S(   s   
        If an L{OSError} is raised while removing a path in
        L{runner._removeSafely}, an attempt is made to move the path to a new
        name. If that attempt fails, the L{OSError} is re-raised.
        c           S   s   t  d   d S(   s   
            Raise an C{OSError} to emulate the branch of L{runner._removeSafely}
            in which path removal fails.
            s   path removal failedN(   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   !  s    c         S   s   t  d   d S(   s   
            Raise an C{OSError} to emulate the branch of L{runner._removeSafely}
            in which path movement fails.
            s   path movement failedN(   R   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   dummyMoveTo(  s    R   R   s   path movement faileds   could not remove FilePathN(   RM   R   R   R   R   R   R   R   R   R   R   t   moveToR   R   R   R   R   t   strR   R   (   R   R   R   R   R   R   t   error(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt%   test_removeSafelyRemoveFailsMoveFails  s    				(   R   R   R/   R   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   		t   TestTrialSuitec           B   s   e  Z d    Z RS(   c         C   s   d d l  m } d  S(   Ni(   t
   TrialSuite(   t   twisted.trial.runnerR   (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_importsE  s    (   R   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   C  s   t   TestUntilFailurec           B   sN   e  Z d  e j f d     YZ d   Z d   Z d   Z d   Z d   Z	 RS(   t	   FailAfterc           B   s   e  Z d  Z g  Z d   Z RS(   sD   
        A test  case that fails when run 3 times in a row.
        c         C   s9   |  j  j d   t |  j   d k r5 |  j d  n  d  S(   Ni   s   Count reached 3(   t   countR   R0   R:   R   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc   R  s    (   R   R   R/   R   Rc   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   M  s   c         C   sO   g  t  j _ t  j d  |  _ t j   |  _ t j t j	 d |  j |  _ d  S(   NRc   R"   (
   R   R   R   R-   RM   R"   R   RN   R   t   Reporter(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO   X  s    c         C   sX   |  j  j |  j  } |  j | j d  |  j | j    |  j |  j |  d  d S(   sl   
        Test that the runUntilFailure method of the runner actually fail after
        a few runs.
        i   N(	   R   t   runUntilFailureR-   RE   R2   RF   t   wasSuccessfulR   t   _getFailures(   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runUntilFailure_  s    c         C   s   t  | j  S(   sL   
        Get the number of failures that were reported to a result.
        (   R:   R   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   j  s    c            s   g      f d   } |  j  t d |  |  j j |  j  } |  j | j d  |  j t    d  |  j   |  j t	 f g  d S(   s   
        C{runUntilFailure} doesn't decorate the tests uselessly: it does it one
        time when run starts, but not at each turn.
        c            s     j  |  | f  |  S(   N(   R   (   R-   t	   interface(   t	   decorated(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   decoratew  s    R   i   N(
   R   R   R   R   R-   RE   R2   R   R:   R   (   R   R   RR   (    (   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runUntilFailureDecorateq  s    c            s   g      f d   } |  j  t d |  t |  j _ |  j j |  j  } |  j | j d  |  j	 t
    d  |  j	   |  j t f |  j t j f g  d S(   s   
        C{runUntilFailure} applies the force-gc decoration after the standard
        L{ITestCase} decoration, but only one time.
        c            s     j  |  | f  |  S(   N(   R   (   R-   R   (   R   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s    R   i   i   N(   R   R   RV   R   t   _forceGarbageCollectionR   R-   RE   R2   R   R:   R   t    _ForceGarbageCollectionDecorator(   R   R   RR   (    (   R   sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt#   test_runUntilFailureForceGCDecorate  s    	(
   R   R   R   Rd   R   RO   R   R   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR   L  s   				t   UncleanUntilFailureTestsc           B   s    e  Z d  Z d   Z d   Z RS(   sh   
    Test that the run-until-failure feature works correctly with the unclean
    error suppressor.
    c         C   s5   t  j |   t j t j d |  j d t |  _ d  S(   NR"   RU   (   R   RO   R   RN   R   R   R"   RV   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO     s    c         C   s   t  | j j  S(   s   
        Get the number of failures that were reported to a result that
        is wrapped in an UncleanFailureWrapper.
        (   R:   t   _originalReporterR   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s    (   R   R   R/   RO   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   	t   BreakingSuitec           B   s   e  Z d  Z d   Z RS(   s;   
    A L{TestSuite} that logs an error when it is run.
    c         C   s;   y t  d   Wn$ t  k
 r6 t j t j    n Xd  S(   Ns#   error that occurs outside of a test(   t   RuntimeErrorR	   t   errR   t   Failure(   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR;     s    (   R   R   R/   R;   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   t   TestLoggedErrorsc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s  
    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         C   s   |  j  t  d  S(   N(   t   flushLoggedErrorsR   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR5     s    c         C   s&   t  j   } |  j | j   d  d S(   sg   
        Check that we can construct a L{runner.LoggedSuite} and that it
        starts empty.
        i    N(   R   t   LoggedSuiteR<   t   countTestCases(   R   Re   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_construct  s    c         C   s   t  j   } t j t   g  } | j |  |  j t | j  d  |  j | j d d j	   t j
  |  j | j d d j t   d S(   sU   
        Chek that a L{LoggedSuite} reports any logged errors to its result.
        i   i    N(   R   t
   TestResultR   R   R   R;   R<   R:   R   t   idt   NOT_IN_TESTRI   t   checkR   (   R   RR   Re   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_capturesError  s    $(   R   R   R/   R5   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   			t   TestTestHolderc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s"   d |  _  t j |  j   |  _ d  S(   NRk   (   Rk   R   t
   TestHoldert   holder(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO     s    	c         C   s<   |  j  |  j j   |  j  |  j  |  j j   |  j  d S(   s   
        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<   R   R   Rk   t   shortDescription(   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_holder  s    c         C   sI   |  j  |  j t |  j   |  j t t |  j  d |  j t f  d S(   s?   
        L{runner.TestHolder} implements L{ITestCase}.
        s5   %r claims to provide %r but does not do so correctly.N(   RQ   R   R   t
   assertTrueR   (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_holderImplementsITestCase  s
    c         C   sF   t  j   } |  j j |  |  j | j    |  j d | j  d S(   sc   
        A L{runner.TestHolder} can run against the standard Python
        C{TestResult}.
        i   N(   Rh   R   R   R;   R   R   R   R2   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_runsWithStandardResult  s    (   R   R   RO   R   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   		
	t   TestErrorHolderc           B   s    e  Z d  Z d   Z d   Z RS(   sP   
    Test L{runner.ErrorHolder} shares behaviour with L{runner.TestHolder}.
    c         C   sQ   d |  _  y d d Wn t k
 r4 t j   } n Xt j |  j  |  |  _ d  S(   NRk   i   i    (   Rk   t   ZeroDivisionErrorR   R   R   t   ErrorHolderR   (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRO     s    	c         C   sF   t  j   } |  j j |  |  j | j    |  j d | j  d S(   sd   
        A L{runner.ErrorHolder} can run against the standard Python
        C{TestResult}.
        i   N(   Rh   R   R   R;   t   assertFalseR   R   R2   (   R   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s    (   R   R   R/   RO   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR     s   	
t   TestMalformedMethodc           B   sK   e  Z d  Z d e j f d     YZ d   Z d   Z d   Z d   Z	 RS(   sR   
    Test that trial manages when test methods don't have correct signatures.
    t   ContainMalformedc           B   s/   e  Z d  Z d   Z d   Z e j e  Z RS(   sV   
        This TestCase holds malformed test methods that trial should handle.
        c         C   s   d  S(   N(    (   R   t   blah(    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc   %  s    c           C   s   d  S(   N(    (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_bar'  s    (   R   R   R/   Rc   R  R   t   deferredGeneratort	   test_spam(    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR  !  s   		c         C   s   t  j    } t j t j d | } t j |  } | j |  } |  j | j	 d  |  j
 | j    |  j t | j  d  d S(   sL   
        Wrapper for one of the test method of L{ContainMalformed}.
        R"   i   N(   RM   R   RN   R   R   R  R  R;   RE   R2   RF   R   R:   R   (   R   R'   R"   t   trialRunnerR-   RR   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   _test+  s    c         C   s   |  j  d  d S(   sE   
        Test when the method has extra (useless) arguments.
        Rc   N(   R  (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_extraArg7  s    c         C   s   |  j  d  d S(   sJ   
        Test when the method doesn't have even self as argument.
        R  N(   R  (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt
   test_noArg=  s    c         C   s   |  j  d  d S(   s5   
        Test a decorated method also fails.
        R  N(   R  (   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_decoratedC  s    (
   R   R   R/   R   Rd   R  R  R	  R
  R  (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR    s   
			t   DestructiveTestSuiteTestCasec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s2   
    Test for L{runner.DestructiveTestSuite}.
    c            s   g    d t  j f   f d     Y} | d  } t j   } t j | g  } |  j   g   | j |  |  j   t g  |  j | j	   d  d S(   sL   
        Thes destructive test suite should run the tests normally.
        Rb   c              s   e  Z   f d    Z RS(   c            s     j  t  d  S(   N(   R   RV   (   R-   (   t   called(    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc   V  s    (   R   R   Rc   (    (   R  (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRb   U  s   Rc   i    N(
   R   Rd   R   R   R   t   DestructiveTestSuiteR   R;   RV   R   (   R   Rb   R-   RR   Re   (    (   R  sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt
   test_basicP  s    c            s   g    d t  j f   f d     Y} t j   } t j   } t j | _ | j |  } |  j	   g   | j
 |  |  j	   d g  |  j	 | j   d  d S(   su   
        Test the C{shouldStop} management: raising a C{KeyboardInterrupt} must
        interrupt the suite.
        Rb   c              s/   e  Z   f d    Z d   Z   f d   Z RS(   c            s     j  d  d  S(   Ni   (   R   (   R-   (   R  (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt	   test_foo1h  s    c         S   s   t     d  S(   N(   t   KeyboardInterrupt(   R-   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt	   test_foo2j  s    c            s     j  d  d  S(   Ni   (   R   (   R-   (   R  (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt	   test_foo3l  s    (   R   R   R  R  R  (    (   R  (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRb   g  s   	i   N(   R   Rd   R   R   R   R   R  t   suiteFactoryt	   loadClassR   R;   R   (   R   Rb   RR   R   Re   (    (   R  sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_shouldStopa  s    c         C   s   d t  j f d     Y} | d  } t j   } t j | g  } |  j | j   d  | j |  |  j | j   d  d S(   sn   
        Checks that the test suite cleanups its tests during the run, so that
        it ends empty.
        Rb   c           B   s   e  Z d    Z RS(   c         S   s   d  S(   N(    (   R-   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRc     s    (   R   R   Rc   (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyRb   ~  s   Rc   i   i    N(	   R   Rd   R   R   R   R  R   R   R;   (   R   Rb   R-   RR   Re   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_cleanupy  s    (   R   R   R/   R  R  R  (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR  K  s   		t   TestRunnerDeprecationc           B   s*   e  Z d  e j f d     YZ d   Z RS(   t   FakeReporterc           B   sD   e  Z d  Z d Z d Z d Z d   Z d   Z d   Z	 d   Z
 RS(   s   
        Fake reporter that does *not* implement done() but *does* implement
        printErrors, separator, printSummary, stream, write and writeln
        without deprecations.
        c         G   s   d  S(   N(    (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   printErrors  s    c         G   s   d  S(   N(    (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   printSummary  s    c         G   s   d  S(   N(    (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   write  s    c         G   s   d  S(   N(    (   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   writeln  s    N(   R   R   R/   R0   R.   R1   R"   R  R  R  R  (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR    s   			c            sf   t  j d   |  j       f d    _  f d   } |  j t d t j   j	  t
 |  d S(   sk   
        The runner emits a warning if it is using a result that doesn't
        implement 'done'.
        c              s     S(   N(    (    (   RR   (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   <lambda>  s    c              s     j  t j d   d  S(   NR   (   R;   Rh   Rd   (    (   R  (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   f  s    sR   %s should implement done() but doesn't. Falling back to printErrors() and friends.N(   R   RN   R0   R  RP   t   assertWarnsR`   R
   Ry   R   t   __file__(   R   R  (    (   RR   R  sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   test_reporterDeprecations  s    (   R   R   R   R   R  R"  (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyR    s   (    (7   RM   R   R   t   zope.interfaceR    t   zope.interface.verifyR   t   twisted.trial.itrialR   R   t   twisted.trialR   R   R   R   t   twisted.pythonR   R	   R
   R   t   twisted.python.filepathR   t   twisted.scriptsR   t   twisted.pluginsR   t   twistedR   t   twisted.internetR   t
   __import__Rh   t   objectR   R   R3   Rd   RL   RT   RW   Ra   Rf   Ri   R   R   R   R   R\   R   R   R   R   R  R  R  (    (    (    sB   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_runner.pyt   <module>   s@   $""<=2U	K"(.?