o
    gJ                     @   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   S/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/nose/tools/nontrivial.pyr   
   s    r   c                        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s" jj| _z|| _W | S  t	y5   || _Y | S w )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 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                     sB   z	| i | W n  y   Y d S     df }t |)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   '   s   r   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__Pdbr   	_getframef_back)r)   r*   r+   r   r   r   r   I   s
   r   c                    r   )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                     s:   t   } | i |}t   }|| krt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&   r4   r   r   r   ^   s   ztimed.<locals>.decorater   )r4   r   r   r5   r   r   U   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                    sf   rt | dr| j  fdd}|| _n| _r1t | dr.| jfdd}|| _| S | _| S )Nsetupc                      s        d S Nr   r   )_old_sr6   r   r   _sy      
z(with_setup.<locals>.decorate.<locals>._steardownc                      s        d S r7   r   r   )_old_tr;   r   r   _t   r:   z(with_setup.<locals>.decorate.<locals>._t)r   r6   r;   )r   r6   r;   r9   r=   r   )r8   r<   r6   r;   r   r   u   s   

zwith_setup.<locals>.decorater   )r6   r;   r   r   r   r   r   k   s   
r   c                 C   
   d| _ | S )z5Decorator to mark a function or method as a test
    T__test__r   r   r   r   r         r   c                 C   r>   )z;Decorator to mark a function or method as *not* a test
    Fr?   r   r   r   r   r	      rA   r	   )NN)r   r0   __all__r    r   r   r   r   r   r   r   r	   r   r   r   r   <module>   s    "
!