ó
¯9ùTc           @   sÍ   d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z y d d l m	 Z	 Wn e
 k
 rz d „  Z	 n Xe Z d e f d „  ƒ  YZ d	 e j f d
 „  ƒ  YZ d e j f d „  ƒ  YZ d S(   s   Running testsiÿÿÿÿN(   t   u(   t   result(   t   registerResultc         C   s   d  S(   N(    (   t   _(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR      s    t   _WritelnDecoratorc           B   s,   e  Z d  Z d „  Z d „  Z d d „ Z RS(   s@   Used to decorate file-like objects with a handy 'writeln' methodc         C   s   | |  _  d  S(   N(   t   stream(   t   selfR   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   __init__   s    c         C   s+   | d k r t  | ƒ ‚ n  t |  j | ƒ S(   NR   t   __getstate__(   R   R   (   t   AttributeErrort   getattrR   (   R   t   attr(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   __getattr__   s    c         C   s-   | r |  j  | ƒ n  |  j  t d ƒ ƒ d  S(   Ns   
(   t   writeR    (   R   t   arg(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   writeln   s    N(   t   __name__t
   __module__t   __doc__R   R   t   NoneR   (    (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR      s   		t   TextTestResultc           B   sš   e  Z d  Z e d d ƒ Z e d 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(   sh   A test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    t   =iF   t   -c         C   sP   t  t |  ƒ j | | | ƒ | |  _ | d k |  _ | d k |  _ | |  _ d  S(   Ni   (   t   superR   R   R   t   showAllt   dotst   descriptions(   R   R   R   t	   verbosity(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR   ,   s
    	c         C   sB   | j  ƒ  } |  j r4 | r4 d j t | ƒ | f ƒ St | ƒ Sd  S(   Ns   
(   t   shortDescriptionR   t   joint   str(   R   t   testt   doc_first_line(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   getDescription3   s    c         C   s\   t  t |  ƒ j | ƒ |  j rX |  j j |  j | ƒ ƒ |  j j d ƒ |  j j ƒ  n  d  S(   Ns    ... (   R   R   t	   startTestR   R   R   R!   t   flush(   R   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR"   :   s
    	c         C   s_   t  t |  ƒ j | ƒ |  j r2 |  j j d ƒ n) |  j r[ |  j j d ƒ |  j j ƒ  n  d  S(   Nt   okt   .(	   R   R   t
   addSuccessR   R   R   R   R   R#   (   R   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR&   A   s    		c         C   sb   t  t |  ƒ j | | ƒ |  j r5 |  j j d ƒ n) |  j r^ |  j j d ƒ |  j j ƒ  n  d  S(   Nt   ERRORt   E(	   R   R   t   addErrorR   R   R   R   R   R#   (   R   R   t   err(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR)   I   s    		c         C   sb   t  t |  ƒ j | | ƒ |  j r5 |  j j d ƒ n) |  j r^ |  j j d ƒ |  j j ƒ  n  d  S(   Nt   FAILt   F(	   R   R   t
   addFailureR   R   R   R   R   R#   (   R   R   R*   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR-   Q   s    		c         C   si   t  t |  ƒ j | | ƒ |  j r< |  j j d | f ƒ n) |  j re |  j j d ƒ |  j j ƒ  n  d  S(   Ns
   skipped %rt   s(	   R   R   t   addSkipR   R   R   R   R   R#   (   R   R   t   reason(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR/   Y   s    		c         C   sb   t  t |  ƒ j | | ƒ |  j r5 |  j j d ƒ n) |  j r^ |  j j d ƒ |  j j ƒ  n  d  S(   Ns   expected failuret   x(	   R   R   t   addExpectedFailureR   R   R   R   R   R#   (   R   R   R*   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR2   a   s    		c         C   s_   t  t |  ƒ j | ƒ |  j r2 |  j j d ƒ n) |  j r[ |  j j d ƒ |  j j ƒ  n  d  S(   Ns   unexpected successR    (	   R   R   t   addUnexpectedSuccessR   R   R   R   R   R#   (   R   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR3   i   s    		c         C   sL   |  j  s |  j r" |  j j ƒ  n  |  j d |  j ƒ |  j d |  j ƒ d  S(   NR'   R+   (   R   R   R   R   t   printErrorListt   errorst   failures(   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   printErrorsq   s    c         C   sx   xq | D]i \ } } |  j  j |  j ƒ |  j  j d | |  j | ƒ f ƒ |  j  j |  j ƒ |  j  j d | ƒ q Wd  S(   Ns   %s: %ss   %s(   R   R   t
   separator1R!   t
   separator2(   R   t   flavourR5   R   R*   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR4   w   s
    #c         C   s!   t  t |  ƒ j ƒ  |  j ƒ  d  S(   N(   R   R   t   stopTestRunR7   (   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR;   ~   s    (   R   R   R   R    R8   R9   R   R!   R"   R&   R)   R-   R/   R2   R3   R7   R4   R;   (    (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR   $   s   											t   TextTestRunnerc           B   sG   e  Z d  Z e Z e j e d e e d e d „ Z
 d „  Z d „  Z RS(   sÉ   A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    i   c         C   sX   t  | ƒ |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | d k	 rT | |  _ n  d S(   s‰   Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N(	   R   R   R   R   t   failfastt   buffert	   tb_localsR   t   resultclass(   R   R   R   R   R=   R>   R@   R?   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR   ‹   s    					c         C   s   |  j  |  j |  j |  j ƒ S(   N(   R@   R   R   R   (   R   (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   _makeResultœ   s    c         C   sß  |  j  ƒ  } |  j | _ |  j | _ |  j | _ t | ƒ t j ƒ  } t | d d ƒ } | d k	 rn | ƒ  n  z | | ƒ Wd t | d d ƒ } | d k	 r§ | ƒ  n
 | j ƒ  Xt j ƒ  } | | } t	 | d ƒ rí |  j
 j | j ƒ n  | j } |  j
 j t d ƒ | | d k rd p d | f ƒ |  j
 j ƒ  d	 }	 }
 } y% t t | j | j | j f ƒ } Wn t k
 r~n X| \ }	 }
 } g  } | j ƒ  s|  j
 j t d
 ƒ ƒ t t | j | j f ƒ \ } } | r÷| j t d ƒ | ƒ n  | r0| j t d ƒ | ƒ q0n |  j
 j t d ƒ ƒ | rP| j t d ƒ | ƒ n  |	 rp| j t d ƒ |	 ƒ n  |
 r| j t d ƒ |
 ƒ n  | rÅ|  j
 j t d ƒ t d ƒ j | ƒ f ƒ n |  j
 j t d ƒ ƒ | S(   s&   Run the given test case or test suite.t   startTestRunNR;   R9   s   Ran %d test%s in %.3fsi   R.   t    i    t   FAILEDs   failures=%ds	   errors=%dt   OKs
   skipped=%ds   expected failures=%ds   unexpected successes=%ds    (%s)s   , s   
(   RA   R=   R>   R?   R   t   timeR
   R   R7   t   hasattrR   R   R9   t   testsRunR    t   mapt   lent   expectedFailurest   unexpectedSuccessest   skippedR	   t   wasSuccessfulR   R6   R5   t   appendR   (   R   R   R   t	   startTimeRB   R;   t   stopTimet	   timeTakent   runt   expectedFailsRL   RM   t   resultst   infost   failedt   errored(    (    s/   lib/python2.7/site-packages/unittest2/runner.pyRS   Ÿ   sd    



	#!/N(   R   R   R   R   R@   t   syst   stderrt   Truet   FalseR   R   RA   RS   (    (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyR<   ƒ   s   		(   R   RY   RF   t   unittestt   sixR    t	   unittest2R   t   unittest2.signalsR   t   ImportErrorR[   t
   __unittestt   objectR   t
   TestResultR   R<   (    (    (    s/   lib/python2.7/site-packages/unittest2/runner.pyt   <module>   s   _