ó
‹DPTc           @   s®   d  Z  d d l Z d d l Z d d l Z d d l m Z m Z e Z d e j	 f d „  ƒ  YZ
 d  e
 f d „  ƒ  YZ	 d e f d „  ƒ  YZ d	 „  Z d
 e f d „  ƒ  YZ d S(   t	   TestSuiteiÿÿÿÿN(   t   caset   utilt   BaseTestSuitec           B   s‰   e  Z d  Z e Z 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(   sN   A simple test suite that doesn't provide class or module shared fixtures.
    c         C   s#   g  |  _  d |  _ |  j | ƒ d  S(   Ni    (   t   _testst   _removed_testst   addTests(   t   selft   tests(    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __init__   s    		c         C   s    d t  j |  j ƒ t |  ƒ f S(   Ns   <%s tests=%s>(   R   t   strclasst	   __class__t   list(   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __repr__   s    c         C   s,   t  | |  j ƒ s t St |  ƒ t | ƒ k S(   N(   t
   isinstanceR   t   NotImplementedR   (   R   t   other(    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __eq__   s    c         C   s   |  | k S(   N(    (   R   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __ne__   s    c         C   s   t  |  j ƒ S(   N(   t   iterR   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __iter__%   s    c         C   s7   |  j  } x' |  D] } | r | | j ƒ  7} q q W| S(   N(   R   t   countTestCases(   R   t   casest   test(    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR   (   s
    	c         C   su   t  | d ƒ s+ t d t | ƒ f ƒ ‚ n  t | t ƒ ra t | t j t f ƒ ra t d ƒ ‚ n  |  j	 j
 | ƒ d  S(   Nt   __call__s   %r is not callablesN   TestCases and TestSuites must be instantiated before passing them to addTest()(   t   hasattrt	   TypeErrort   reprR   t   typet
   issubclassR   t   TestCaseR    R   t   append(   R   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   addTest/   s    c         C   sC   t  | t j ƒ r! t d ƒ ‚ n  x | D] } |  j | ƒ q( Wd  S(   Ns0   tests must be an iterable of tests, not a string(   R   t   sixt   string_typesR   R    (   R   R   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR   9   s    c         C   sQ   xJ t  |  ƒ D]< \ } } | j r& Pn  | | ƒ |  j r |  j | ƒ q q W| S(   N(   t	   enumeratet
   shouldStopt   _cleanupt   _removeTestAtIndex(   R   t   resultt   indexR   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   run?   s    	
	c         C   s]   y |  j  | } Wn t k
 r$ n5 Xt | d ƒ rL |  j | j ƒ  7_ n  d |  j  | <d S(   s2   Stop holding a reference to the TestCase at index.R   N(   R   R   R   R   R   t   None(   R   R(   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR&   H   s    c         O   s   |  j  | | Ž  S(   N(   R)   (   R   t   argst   kwds(    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR   V   s    c         C   s   x |  D] } | j  ƒ  q Wd S(   s7   Run the tests without collecting errors in a TestResultN(   t   debug(   R   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR-   Y   s    (    N(   t   __name__t
   __module__t   __doc__t   TrueR%   R	   R   R   R   R*   t   __hash__R   R   R    R   R)   R&   R   R-   (    (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR      s   						
					c           B   sY   e  Z d  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   s³  A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    c         C   s0  t  } t | d t  ƒ t  k r. t | _ } n  xÕ t |  ƒ D]Ç \ } } | j rT Pn  t | ƒ rÌ |  j | | ƒ |  j | | ƒ |  j	 | | ƒ | j
 | _ t | j
 d t  ƒ s; t | d t  ƒ rÌ q; qÌ n  | sß | | ƒ n
 | j ƒ  |  j r; |  j | ƒ q; q; W| r,|  j d  | ƒ |  j | ƒ n  | S(   Nt   _testRunEnteredt   _classSetupFailedt   _moduleSetUpFailed(   t   Falset   getattrR1   R3   R#   R$   t   _isnotsuitet   _tearDownPreviousClasst   _handleModuleFixturet   _handleClassSetUpR   t   _previousTestClassR-   R%   R&   R*   t   _handleModuleTearDown(   R   R'   R-   t   topLevelR(   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR)   j   s.    		
	c         C   s   t  ƒ  } |  j | t ƒ d S(   s7   Run the tests without collecting errors in a TestResultN(   t   _DebugResultR)   R1   (   R   R-   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR-   Š   s    	c   	      C   s  t  | d d  ƒ } | j } | | k r+ d  S| j r8 d  St  | d t ƒ rN d  Sy t | _ Wn t k
 rn n Xt  | d d  ƒ } | d  k	 r	y | ƒ  Wq	t k
 rt j	 ƒ  d } t
 | t ƒ rÍ ‚  n  t | _ t j | ƒ } d | } |  j | | | ƒ q	Xn  d  S(   NR<   t   __unittest_skip__t
   setUpClassi   s   setUpClass (%s)(   R7   R*   R   R5   R6   R4   R   t	   Exceptiont   syst   exc_infoR   R?   R1   R   R
   t   _addClassOrModuleLevelException(	   R   R   R'   t   previousClasst   currentClassRA   t   et	   classNamet	   errorName(    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR;   ‘   s0    			
c         C   s4   d  } t | d d  ƒ } | d  k	 r0 | j } n  | S(   NR<   (   R*   R7   R/   (   R   R'   t   previousModuleRF   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   _get_previous_module¯   s
    c   	      C   sö   |  j  | ƒ } | j j } | | k r+ d  S|  j | ƒ t | _ y t j | } Wn t k
 rf d  SXt	 | d d  ƒ } | d  k	 rò y | ƒ  Wqò t k
 rî t j ƒ  d } t | t ƒ rÅ ‚  n  t | _ d | } |  j | | | ƒ qò Xn  d  S(   Nt   setUpModulei   s   setUpModule (%s)(   RL   R   R/   R=   R6   R5   RC   t   modulest   KeyErrorR7   R*   RB   RD   R   R?   R1   RE   (	   R   R   R'   RK   t   currentModulet   moduleRM   RH   RJ   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR:   ·   s*    		
c         C   sl   t  | ƒ } t | d d  ƒ } | d  k	 rR t | t j ƒ rR | | t | ƒ ƒ n | j | t j	 ƒ  ƒ d  S(   Nt   addSkip(
   t   _ErrorHolderR7   R*   R   R   t   SkipTestt   strt   addErrorRC   RD   (   R   R'   t	   exceptionRJ   t   errorRR   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyRE   Ñ   s
    c         C   sØ   |  j  | ƒ } | d  k r d  S| j r, d  Sy t j | } Wn t k
 rQ d  SXt | d d  ƒ } | d  k	 rÔ y | ƒ  WqÔ t k
 rÐ t j ƒ  d } t	 | t
 ƒ r° ‚  n  d | } |  j | | | ƒ qÔ Xn  d  S(   Nt   tearDownModulei   s   tearDownModule (%s)(   RL   R*   R5   RC   RN   RO   R7   RB   RD   R   R?   RE   (   R   R'   RK   RQ   RY   RH   RJ   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR=   Ù   s&    	
c   	      C   s  t  | d d  ƒ } | j } | | k r+ d  St  | d t ƒ rA d  St  | d t ƒ rW d  St  | d t ƒ rm d  St  | d d  ƒ } | d  k	 rþ y | ƒ  Wqþ t k
 rú t j ƒ  d } t | t ƒ rË ‚  n  t	 j
 | ƒ } d | } |  j | | | ƒ qþ Xn  d  S(   NR<   R4   R5   R@   t   tearDownClassi   s   tearDownClass (%s)(   R7   R*   R   R6   RB   RC   RD   R   R?   R   R
   RE   (	   R   R   R'   RF   RG   RZ   RH   RI   RJ   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR9   ð   s*    	
(   R.   R/   R0   R6   R)   R-   R;   RL   R:   RE   R=   R9   (    (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR    _   s    						RS   c           B   s\   e  Z d  Z d	 Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z RS(
   s¾   
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    c         C   s   | |  _  d  S(   N(   t   description(   R   R[   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR	     s    c         C   s   |  j  S(   N(   R[   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   id  s    c         C   s   d  S(   N(   R*   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   shortDescription  s    c         C   s   d |  j  f S(   Ns   <ErrorHolder description=%r>(   R[   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR     s    c         C   s
   |  j  ƒ  S(   N(   R\   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   __str__!  s    c         C   s   d  S(   N(    (   R   R'   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR)   $  s    c         C   s   |  j  | ƒ S(   N(   R)   (   R   R'   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR   )  s    c         C   s   d S(   Ni    (    (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR   ,  s    N(   R.   R/   R0   R*   t   failureExceptionR	   R\   R]   R   R^   R)   R   R   (    (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyRS   	  s   							c         C   s'   y t  |  ƒ Wn t k
 r" t SXt S(   s?   A crude way to tell apart testcases and suites with duck-typing(   R   R   R1   R6   (   R   (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR8   /  s
    R?   c           B   s    e  Z d  Z d Z e Z e Z RS(   sC   Used by the TestSuite to hold previous class when running in debug.N(   R.   R/   R0   R*   R<   R6   R5   R$   (    (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyR?   8  s   (   R0   RC   t   unittestR!   t	   unittest2R   R   R1   t
   __unittestR    R   t   objectRS   R8   R?   (    (    (    s.   lib/python2.7/site-packages/unittest2/suite.pyt   <module>   s   Rª&		