ó
kž6Sc           @   s   d  Z  d d l Z d d d d d d d	 d
 g Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d d d „ Z
 d „  Z d „  Z d S(   s8   Tools not exempt from being descended into in tracebacksiÿÿÿÿNt   make_decoratort   raisest	   set_tracet   timedt
   with_setupt   TimeExpiredt   istestt   nottestc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   
   s   c            s   ‡  f d †  } | S(   s¨   
    Wraps a test decorator so as to properly replicate metadata
    of the decorated function, including nose's additional stuff
    (namely, setup and teardown).
    c            s—   t  ˆ  d ƒ r ˆ  j } n	 ˆ  j } ˆ  j |  _ ˆ  j |  _ ˆ  j |  _ t  |  d ƒ si ˆ  j j |  _ n  y | |  _ Wn t	 k
 r’ | |  _ n X|  S(   Nt   compat_func_namet   compat_co_firstlineno(
   t   hasattrR
   R   t   __dict__t   __doc__R	   t	   func_codet   co_firstlinenoR   t	   TypeError(   t   newfunct   name(   t   func(    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyt   decorate   s    	(    (   R   R   (    (   R   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR       s    c             s;   d j  g  ˆ  D] } | j ^ q ƒ ‰ ‡  ‡ f d †  } | S(   s‘  Test must raise one of expected exceptions to pass.

    Example use::

      @raises(TypeError, ValueError)
      def test_raises_type_error():
          raise TypeError("This test passes")

      @raises(Exception)
      def test_that_fails_by_passing():
          pass

    If you want to test many assertions about exceptions in a single test,
    you may want to use `assert_raises` instead.
    s    or c            s7   ˆ  j  ‰ ‡ ‡  ‡ ‡ f d †  } t ˆ  ƒ | ƒ } | S(   Nc             sN   y ˆ |  | Ž  Wn ˆ  k
 r$ n& ‚  n Xd ˆ ˆ f } t  | ƒ ‚ d  S(   Ns   %s() did not raise %s(   t   AssertionError(   t   argt   kwt   message(   t
   exceptionsR   R   t   valid(    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   :   s    (   R   R    (   R   R   (   R   R   (   R   R   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   8   s    	
(   t   joinR   (   R   t   eR   (    (   R   R   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   '   s    %c          C   sM   d d l  }  d d l } | j } | j | _ |  j ƒ  j | j ƒ  j ƒ d S(   sÂ   Call pdb.set_trace in the calling frame, first restoring
    sys.stdout to the real output stream. Note that sys.stdout is NOT
    reset to whatever it was before the call once pdb is done!
    iÿÿÿÿN(   t   pdbt   syst   stdoutt
   __stdout__t   PdbR   t	   _getframet   f_back(   R   R   R    (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   I   s
    	c            s   ‡  f d †  } | S(   s•   Test must finish within specified time limit to pass.

    Example use::

      @timed(.1)
      def test_that_fails():
          time.sleep(.2)
    c            s(   ‡  ‡ f d †  } t  ˆ  ƒ | ƒ } | S(   Nc             sN   t  j  ƒ  } ˆ  |  | Ž  } t  j  ƒ  } | | ˆ k rJ t d ˆ ƒ ‚ n  | S(   Ns   Time limit (%s) exceeded(   t   timeR   (   R   R   t   startt   resultt   end(   R   t   limit(    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   _   s    (   R    (   R   R   (   R)   (   R   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   ^   s    (    (   R)   R   (    (   R)   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   U   s    	
c         C   s   |  | d „ } | S(   s  Decorator to add setup and/or teardown methods to a test function::

      @with_setup(setup, teardown)
      def test_something():
          " ... "

    Note that `with_setup` is useful *only* for test functions, not for test
    methods or inside of TestCase subclasses.
    c            s”   ˆ rH t  |  d ƒ r< |  j ‰  ‡  ‡ f d †  } | |  _ qH ˆ |  _ n  ˆ r t  |  d ƒ r„ |  j ‰ ‡ ‡ f d †  } | |  _ q ˆ |  _ n  |  S(   Nt   setupc              s   ˆ ƒ  ˆ  ƒ  d  S(   N(    (    (   t   _old_sR*   (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyt   _sy   s    t   teardownc              s   ˆ  ƒ  ˆ ƒ  d  S(   N(    (    (   t   _old_tR-   (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyt   _t‚   s    (   R   R*   R-   (   R   R*   R-   R,   R/   (    (   R+   R.   R*   R-   s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   u   s    		(    (   R*   R-   R   (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   k   s    
c         C   s   t  |  _ |  S(   s5   Decorator to mark a function or method as a test
    (   t   Truet   __test__(   R   (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   Œ   s    	c         C   s   t  |  _ |  S(   s;   Decorator to mark a function or method as *not* a test
    (   t   FalseR1   (   R   (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyR   “   s    	(   R   R%   t   __all__R   R   R    R   R   R   t   NoneR   R   R   (    (    (    s4   lib/python2.7/site-packages/nose/tools/nontrivial.pyt   <module>   s   		"		!	