ó
K9•Qc           @   s«   d  Z  d d l Z y d d l m Z Wn! e k
 rI d d l m Z n Xd d l m Z d d l m	 Z	 m
 Z e j d ƒ Z d „  Z d e f d	 „  ƒ  YZ d
 „  Z
 d S(   sì   
Test Result
-----------

Provides a TextTestResult that extends unittest's _TextTestResult to
provide support for error classes (such as the builtin skip and
deprecated classes), and hooks for plugins to take over or extend
reporting.
iÿÿÿÿN(   t   _TextTestResult(   t   Config(   t   isclasst   lns   nose.resultc         C   s*   y t  |  ƒ SWn d t |  ƒ j SXd  S(   Ns   <unprintable %s object>(   t   strt   typet   __name__(   t   exc(    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   _exception_detail   s    t   TextTestResultc           B   st   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d d „ Z d „  Z	 d „  Z
 d „  Z d	 „  Z d d
 „ Z RS(   sÄ   Text test result that extends unittest's default test result
    support for a configurable set of errorClasses (eg, Skip,
    Deprecated, TODO) that extend the errors/failures/success triad.
    c         C   sY   | d  k r i  } n  | |  _ | d  k r6 t ƒ  } n  | |  _ t j |  | | | ƒ d  S(   N(   t   Nonet   errorClassesR   t   configR    t   __init__(   t   selft   streamt   descriptionst	   verbosityR   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR   $   s    			c         C   sh   d d l  m } | |  j k rd |  j | \ } } } | j | | f ƒ |  j | | | d  f ƒ n  d  S(   Niÿÿÿÿ(   t   SkipTest(   t   nose.plugins.skipR   R   t   appendt
   printLabelR
   (   R   t   testt   reasonR   t   storaget   labelt   isfail(    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   addSkip.   s
    c         C   sõ   | \ } } } y |  j  | | ƒ } Wn  t k
 rG |  j  | ƒ } n Xxz |  j j ƒ  D]i \ } \ } }	 }
 t | ƒ rX t | | ƒ rX |
 rš t | _ n  | j | | f ƒ |  j	 |	 | ƒ d SqX W|  j
 j | | f ƒ t | _ |  j	 d ƒ d S(   s»   Overrides normal addError to add support for
        errorClasses. If the exception is a registered class, the
        error will be added to the list for that class, not errors.
        Nt   ERROR(   t   _exc_info_to_stringt	   TypeErrorR   t   itemsR   t
   issubclasst   Falset   passedR   R   t   errors(   R   R   t   errt   ect   evt   tbt   exc_infot   clsR   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   addError6   s    %	c         C   s-   |  j  r | j ƒ  p t | ƒ St | ƒ Sd  S(   N(   R   t   shortDescriptionR   (   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   getDescriptionP   s    	c         C   sœ   t  |  d d  ƒ } | d  k	 r˜ |  j rx | g } | r_ t | d ƒ } | r_ | j | ƒ q_ n  | j d j | ƒ ƒ q˜ |  j r˜ | j | d  ƒ q˜ n  d  S(   NR   i   s   : (	   t   getattrR
   t   showAllR   R   t   writelnt   joint   dotst   write(   R   R   R$   R   t   messaget   detail(    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR   V   s    			c         C   s‚   t  j |  ƒ xF |  j j ƒ  D]5 } |  j | \ } } } | r |  j | | ƒ q q Wt |  d ƒ r~ |  j j j |  j	 ƒ n  d S(   s<   Overrides to print all errorClasses errors as well.
        R   N(
   R    t   printErrorsR   t   keyst   printErrorListt   hasattrR   t   pluginst   reportR   (   R   R)   R   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR5   d   s    c      	   C   s³  |  j  j } |  j  j } t | | ƒ } |  j } | d k rC d pF d } | |  j ƒ | d | | | f ƒ | ƒ  i  } |  j j ƒ  }	 xF |	 D]> }
 |  j |
 \ } } } t | ƒ } | sÄ q n  | | | <q Wt |  j	 ƒ r÷ t |  j	 ƒ | d <n  t |  j
 ƒ rt |  j
 ƒ | d <n  |  j ƒ  s5| d ƒ n
 | d ƒ | j ƒ  } | r¨| j ƒ  | d	 ƒ | d
 j g  | D] \ } } d | | f ^ quƒ ƒ | d ƒ n | ƒ  d S(   sZ   Called by the test runner to print the final summary of test
        run results.
        i   t   st    s   Ran %s test%s in %.3fst   failuresR#   t   FAILEDt   OKs    (s   , s   %s=%st   )N(   R   R2   R/   t   floatt   testsRunt
   separator2R   R6   t   lenR=   R#   t   wasSuccessfulR   t   sortR0   (   R   t   startt   stopR2   R/   t   takent   runt   pluralt   summaryt   eckeysR)   R   R   R   t   countR   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   printSummaryp   s>    	


*c         C   s`   |  j  s |  j r t SxC |  j j ƒ  D]2 } |  j | \ } } } | sN q& n  | r& t Sq& Wt S(   s”   Overrides to check that there are no errors in errorClasses
        lists that are marked as errors and should cause a run to
        fail.
        (   R#   R=   R!   R   R6   t   True(   R   R)   R   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyRE   ™   s    c         C   s‹   y |  j  | | ƒ } Wn  t k
 r8 |  j  | ƒ } n X|  j j | | f ƒ |  j rk |  j j d ƒ n |  j r‡ |  j j d ƒ n  d  S(   NR   t   E(   R   R   R#   R   R.   R   R2   R1   (   R   R   R$   R(   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt	   _addError¨   s    		c         C   sm   d d l  m } t | d | ƒ r1 t | d ƒ Sy t j |  | | ƒ SWn t k
 rh t j |  | ƒ SXd  S(   Niÿÿÿÿ(   R   i    i   (   R   R   R    R   R    R   R   (   R   R$   R   R   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR   ´   s    N(   R   t
   __module__t   __doc__R
   R   R   R*   R,   R   R5   RO   RE   RR   R   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR	      s   						)		c          O   s*   d d l  m } | d t ƒ t |  | Ž  S(   Niÿÿÿÿ(   t   warns‚   ln() has moved to nose.util from nose.result and will be removed from nose.result in a future release. Please update your imports (   t   warningsRU   t   DeprecationWarningt   _ln(   t   argt   kwRU   (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyR   Á   s    (   RT   t   loggingt   unittest.runnerR    t   ImportErrort   unittestt   nose.configR   t	   nose.utilR   R   RX   t	   getLoggert   logR   R	   (    (    (    s/   /sys/lib/python2.7/site-packages/nose/result.pyt   <module>	   s   	¢