a
    ñ»jð  ã                   @   sb   d Z ddlZg d¢ZG dd„ deƒZdd„ Zdd	„ Zd
d„ Zdd„ Zddd„Z	dd„ Z
dd„ ZdS )z8Tools not exempt from being descended into in tracebacksé    N)Úmake_decoratorÚraisesÚ	set_traceÚtimedÚ
with_setupÚTimeExpiredÚistestÚnottestc                   @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r   r   ú;E:\soccer\ml_env\Lib\site-packages\nose/tools/nontrivial.pyr      s   r   c                    s   ‡ fdd„}|S )zžWraps a test decorator so as to properly replicate metadata
    of the decorated function, including nose's additional stuff
    (namely, setup and teardown).c                    sl   t ˆ dƒrˆ j}nˆ j}ˆ j| _ˆ j| _ˆ j| _t | dƒsDˆ jj| _z
|| _W n t	yf   || _Y n0 | S )NÚcompat_func_nameÚcompat_co_firstlineno)
Úhasattrr   r
   Ú__dict__Ú__doc__r   Ú__code__Úco_firstlinenor   Ú	TypeError)ÚnewfuncÚname©Úfuncr   r   Údecorate   s    



z make_decorator.<locals>.decorater   )r   r   r   r   r   r      s    r   c                     s&   d  dd„ ˆ D ƒ¡‰‡ ‡fdd„}|S )a‡  Test must raise one of expected exceptions to pass.

    Example:

      @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.z or c                 S   s   g | ]
}|j ‘qS r   )r
   )Ú.0Úer   r   r   Ú
<listcomp>1   ó    zraises.<locals>.<listcomp>c                    s(   ˆ j ‰‡‡ ‡‡fdd„}tˆ ƒ|ƒ}|S )Nc                     sP   zˆ| i |¤Ž W n$ ˆ y$   Y n( t y6   ‚ Y n0 dˆˆf }t|ƒ‚d S )Nz%s() did not raise %s)Ú	ExceptionÚAssertionError)ÚargÚkwÚmessage)Ú
exceptionsr   r   Úvalidr   r   r   6   s    z)raises.<locals>.decorate.<locals>.newfunc)r
   r   ©r   r   ©r%   r&   )r   r   r   r   3   s    zraises.<locals>.decorate)Újoin)r%   r   r   r(   r   r   "   s    r   c                  C   s0   ddl } ddl}|j|_|  ¡  | ¡ j¡ dS )z½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!r   N)ÚpdbÚsysÚ
__stdout__ÚstdoutZPdbr   Ú	_getframeÚf_back)r*   r+   r   r   r   r   F   s    r   c                    s   ‡ fdd„}|S )z�Test must finish within specified time limit to pass.
    Example:
        @timed(.1)
        def test_that_fails():
            time.sleep(.2) c                    s   ‡ ‡fdd„}t ˆ ƒ|ƒ}|S )Nc                     s:   t   ¡ }ˆ | i |¤Ž}t   ¡ }|| ˆkr6tdˆ ƒ‚|S )NzTime limit (%s) exceeded)Útimer   )r"   r#   ÚstartÚresultÚend)r   Úlimitr   r   r   W   s    z(timed.<locals>.decorate.<locals>.newfunc)r   r'   ©r4   r   r   r   V   s    ztimed.<locals>.decorater   )r4   r   r   r5   r   r   P   s    
r   c                 C   s   | |fdd„}|S )a  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                    sd   ˆr0t | dƒr*| j‰ ‡ ‡fdd„}|| _nˆ| _ˆr`t | dƒrZ| j‰‡‡fdd„}|| _nˆ| _| S )NÚsetupc                      s   ˆƒ  ˆ ƒ  d S ©Nr   r   )Ú_old_sr6   r   r   Ú_sq   s    z(with_setup.<locals>.decorate.<locals>._sÚteardownc                      s   ˆ ƒ  ˆƒ  d S r7   r   r   )Ú_old_tr:   r   r   Ú_t|   s    z(with_setup.<locals>.decorate.<locals>._t)r   r6   r:   )r   r6   r:   r9   r<   r   )r8   r;   r6   r:   r   r   l   s    

zwith_setup.<locals>.decorater   )r6   r:   r   r   r   r   r   c   s    	r   c                 C   s
   d| _ | S )z0Decorator to mark a function or method as a testT©Z__test__r   r   r   r   r   ‡   s    r   c                 C   s
   d| _ | S )z6Decorator to mark a function or method as *not* a testFr=   r   r   r   r   r	   �   s    r	   )NN)r   r0   Ú__all__r!   r   r   r   r   r   r   r   r	   r   r   r   r   Ú<module>   s   $

$