
bc           @   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 d d l m Z e	 Z
 d   Z d Z d	 Z d
 e f d     YZ d S(   s   Test result objectiN(   t   StringIOi   (   t   util(   t   wrapsc            s   t       f d    } | S(   Nc            s/   t  |  d t  r |  j   n    |  | |  S(   Nt   failfast(   t   getattrt   Falset   stop(   t   selft   argst   kw(   t   method(    s%   /usr/lib/python2.7/unittest/result.pyt   inner   s    (   R   (   R
   R   (    (   R
   s%   /usr/lib/python2.7/unittest/result.pyR      s    s   
Stdout:
%ss   
Stderr:
%st
   TestResultc           B   s   e  Z d  Z d Z e Z e Z d d d d  Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z e d	    Z e d
    Z d   Z d   Z d   Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s  Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    c         C   s   t  |  _ g  |  _ g  |  _ d |  _ g  |  _ g  |  _ g  |  _ t  |  _ t  |  _	 d  |  _ d  |  _ t j |  _ t j |  _ t  |  _ d  S(   Ni    (   R   R   t   failurest   errorst   testsRunt   skippedt   expectedFailurest   unexpectedSuccessest
   shouldStopt   buffert   Nonet   _stdout_buffert   _stderr_buffert   syst   stdoutt   _original_stdoutt   stderrt   _original_stderrt   _mirrorOutput(   R   t   streamt   descriptionst	   verbosity(    (    s%   /usr/lib/python2.7/unittest/result.pyt   __init__(   s    											c         C   s   d S(   s#   Called by TestRunner after test runN(    (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   printErrors8   t    c         C   s&   |  j  d 7_  t |  _ |  j   d S(   s-   Called when the given test is about to be runi   N(   R   R   R   t   _setupStdout(   R   t   test(    (    s%   /usr/lib/python2.7/unittest/result.pyt	   startTest;   s    	c         C   sR   |  j  rN |  j d  k r3 t   |  _ t   |  _ n  |  j t _ |  j t _ n  d  S(   N(   R   R   R   R    R   R   R   R   (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyR$   A   s    	c         C   s   d S(   sp   Called once before any tests are executed.

        See startTest for a method called before each test.
        N(    (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   startTestRunI   R#   c         C   s   |  j    t |  _ d S(   s'   Called when the given test has been runN(   t   _restoreStdoutR   R   (   R   R%   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   stopTestO   s    
c         C   s   |  j  r |  j r t j j   } t j j   } | ri | j d  sR | d 7} n  |  j j t	 |  n  | r | j d  s | d 7} n  |  j
 j t |  q n  |  j t _ |  j
 t _ |  j j d  |  j j   |  j j d  |  j j   n  d  S(   Ns   
i    (   R   R   R   R   t   getvalueR   t   endswithR   t   writet   STDOUT_LINER   t   STDERR_LINER   t   seekt   truncateR   (   R   t   outputt   error(    (    s%   /usr/lib/python2.7/unittest/result.pyR(   T   s$    		c         C   s   d S(   sm   Called once after all tests are executed.

        See stopTest for a method called after each test.
        N(    (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   stopTestRuni   R#   c         C   s/   |  j  j | |  j | |  f  t |  _ d S(   sm   Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        N(   R   t   appendt   _exc_info_to_stringt   TrueR   (   R   R%   t   err(    (    s%   /usr/lib/python2.7/unittest/result.pyt   addErroro   s    "c         C   s/   |  j  j | |  j | |  f  t |  _ d S(   sd   Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().N(   R   R4   R5   R6   R   (   R   R%   R7   (    (    s%   /usr/lib/python2.7/unittest/result.pyt
   addFailurew   s    "c         C   s   d S(   s-   Called when a test has completed successfullyN(    (   R   R%   (    (    s%   /usr/lib/python2.7/unittest/result.pyt
   addSuccess~   s    c         C   s   |  j  j | | f  d S(   s   Called when a test is skipped.N(   R   R4   (   R   R%   t   reason(    (    s%   /usr/lib/python2.7/unittest/result.pyt   addSkip   s    c         C   s&   |  j  j | |  j | |  f  d S(   s/   Called when an expected failure/error occurred.N(   R   R4   R5   (   R   R%   R7   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   addExpectedFailure   s    	c         C   s   |  j  j |  d S(   s5   Called when a test was expected to fail, but succeed.N(   R   R4   (   R   R%   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   addUnexpectedSuccess   s    c         C   s*   t  |  j  t  |  j  k o' d k SS(   s.   Tells whether or not this result was a successi    (   t   lenR   R   (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   wasSuccessful   s    c         C   s   t  |  _ d S(   s*   Indicates that the tests should be abortedN(   R6   R   (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyR      s    c   
      C   s%  | \ } } } x" | r3 |  j  |  r3 | j } q W| | j k rm |  j |  } t j | | | |  } n t j | | |  } |  j rt j j	   } t j
 j	   }	 | r | j d  s | d 7} n  | j t |  n  |	 r|	 j d  s|	 d 7}	 n  | j t |	  qn  d j |  S(   s>   Converts a sys.exc_info()-style tuple of values into a string.s   
R#   (   t   _is_relevant_tb_levelt   tb_nextt   failureExceptiont   _count_relevant_tb_levelst	   tracebackt   format_exceptionR   R   R   R*   R   R+   R4   R-   R.   t   join(
   R   R7   R%   t   exctypet   valuet   tbt   lengtht   msgLinesR1   R2   (    (    s%   /usr/lib/python2.7/unittest/result.pyR5      s&    	c         C   s   d | j  j k S(   Nt
   __unittest(   t   tb_framet	   f_globals(   R   RJ   (    (    s%   /usr/lib/python2.7/unittest/result.pyRA      s    c         C   s:   d } x- | r5 |  j  |  r5 | d 7} | j } q	 W| S(   Ni    i   (   RA   RB   (   R   RJ   RK   (    (    s%   /usr/lib/python2.7/unittest/result.pyRD      s
    
c         C   s5   d t  j |  j  |  j t |  j  t |  j  f S(   Ns!   <%s run=%i errors=%i failures=%i>(   R   t   strclasst	   __class__R   R?   R   R   (   R   (    (    s%   /usr/lib/python2.7/unittest/result.pyt   __repr__   s    !N(   t   __name__t
   __module__t   __doc__R   t   _previousTestClassR   t   _testRunEnteredt   _moduleSetUpFailedR!   R"   R&   R$   R'   R)   R(   R3   R   R8   R9   R:   R<   R=   R>   R@   R   R5   RA   RD   RR   (    (    (    s%   /usr/lib/python2.7/unittest/result.pyR      s0   
															(   RU   t   osR   RE   R    R#   R   t	   functoolsR   R6   RM   R   R-   R.   t   objectR   (    (    (    s%   /usr/lib/python2.7/unittest/result.pyt   <module>   s   	