B
    ِ<[J                 @   sn   d Z ddlZddddddd	d
g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   4lib/python3.7/site-packages/nose/tools/nontrivial.pyr   
   s   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                sn   t  dr j}n j} j| _ j| _ j| _t | dsD jj| _y
|| _W n t	k
rh   || _Y nX | 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    c                 s&   d dd  D  fdd}|S )a  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.
    z or c             S   s   g | ]
}|j qS r   )r
   ).0er   r   r   
<listcomp>7   s    zraises.<locals>.<listcomp>c                s(    j  fdd}t |}|S )Nc                 sH   y| | W n   k
r"   Y n"    Y nX df }t |d S )Nz%s() did not raise %s)AssertionError)argkwmessage)
exceptionsr   r   validr   r   r   :   s    z)raises.<locals>.decorate.<locals>.newfunc)r
   r   )r   r   )r"   r#   )r   r   r   r   8   s    
zraises.<locals>.decorate)join)r"   r   r   )r"   r#   r   r   '   s    c              C   s6   ddl } ddl}|j}|j|_|  | j dS )zCall 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
__stdout__ZPdbr   	_getframef_back)r%   r&   r'   r   r   r   r   I   s
    c                s    fdd}|S )zTest must finish within specified time limit to pass.

    Example use::

      @timed(.1)
      def test_that_fails():
          time.sleep(.2)
    c                s    fdd}t  |}|S )Nc                 s6   t   } | |}t   }|| kr2td |S )NzTime limit (%s) exceeded)timer   )r   r    startresultend)r   limitr   r   r   _   s    
z(timed.<locals>.decorate.<locals>.newfunc)r   )r   r   )r/   )r   r   r   ^   s    ztimed.<locals>.decorater   )r/   r   r   )r/   r   r   U   s    	
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_sr0   r   r   _sy   s    z(with_setup.<locals>.decorate.<locals>._steardownc                  s        d S )Nr   r   )_old_tr3   r   r   _t   s    z(with_setup.<locals>.decorate.<locals>._t)r   r0   r3   )r   r0   r3   r2   r5   r   )r1   r4   r0   r3   r   r   u   s    

zwith_setup.<locals>.decorater   )r0   r3   r   r   r   r   r   k   s    
c             C   s
   d| _ | S )z5Decorator to mark a function or method as a test
    T)__test__)r   r   r   r   r      s    c             C   s
   d| _ | S )z;Decorator to mark a function or method as *not* a test
    F)r6   )r   r   r   r   r	      s    )NN)r   r+   __all__r   r   r   r   r   r   r   r   r	   r   r   r   r   <module>   s   

"
!