
    i                     R    S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	   " S S\
5      rg)	z$Call tracking and checks for spiess.    )unicode_literals)	iteritems	text_type)FunctionSig)format_spy_kwargsc                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)SpyCall
   zRecords arguments made to a spied function call.

SpyCalls are created and stored by a FunctionSpy every time it is
called. They're accessible through the FunctionSpy's ``calls`` attribute.
c                 D    Xl         X l        X0l        SU l        SU l        g)a  Initialize the call.

Args:
    spy (kgb.spies.FunctionSpy):
        The function spy that the call was made on.

    args (tuple):
        A tuple of positional arguments from the spy. These correspond
        to positional arguments in the function's signature.

    kwargs (dict):
        A dictionary of keyword arguments from the spy. These
        correspond to keyword arguments in the function's signature.
N)spyargskwargsreturn_value	exception)selfr   r   r   s       H/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/kgb/calls.py__init__SpyCall.__init__   s"     	     c                    [        U5      [        U R                  5      :  a  gU R                  S[        U5       U:w  a  gU R                  R                  R                  nU R                  R
                  [        R                  [        R                  4;   a  USS n[        [        X0R                  5      5      nUR                  U R                  5        [        U5       H  u  pVXT;  d
  XE   U:w  d  M    g   g)a  Return whether this call was made with the given arguments.

Not every argument and keyword argument made in the call must be
provided to this method. These can be a subset of the positional and
keyword arguments in the call, but cannot contain any arguments not
made in the call.

Args:
    *args (tuple):
        The positional arguments made in the call, or a subset of
        those arguments (starting with the first argument).

    **kwargs (dict):
        The keyword arguments made in the call, or a subset of those
        arguments.

Returns:
    bool:
    ``True`` if the call's arguments match the provided arguments.
    ``False`` if they do not.
FN   T)lenr   r   _sig	arg_names	func_typer   TYPE_BOUND_METHODTYPE_UNBOUND_METHODdictzipupdater   r   )r   r   r   pos_argsall_argskeyvalues          r   called_withSpyCall.called_with&   s    , t9s499~%99Zc$i D(88==**88+"?"?"-"A"A"C C|HHii01$#F+JC"hmu&< , r   c                      U R                   U:H  $ )zReturn whether this call returned the given value.

Args:
    value (object):
        The expected returned value from the call.

Returns:
    bool:
    ``True`` if this call returned the given value. ``False`` if it
    did not.
)r   )r   r$   s     r   returnedSpyCall.returnedQ   s       E))r   c                 p    U R                   SL =(       a    USL =(       d    [        U R                   5      UL $ )zReturn whether this call raised this exception.

Args:
    exception_cls (type):
        The expected type of exception raised by the call.

Returns:
    bool:
    ``True`` if this call raised the given exception type.
    ``False`` if it did not.
N)r   type)r   exception_clss     r   raisedSpyCall.raised_   s5     4'AMT,A 6T^^$5	7r   c                     U R                   SL=(       a0    U R                  U5      =(       a    [        U R                   5      U:H  $ )aY  Return whether this call raised this exception and message.

Args:
    exception_cls (type):
        The expected type of exception raised by the call.

    message (unicode):
        The expected message from the exception.

Returns:
    bool:
    ``True`` if this call raised the given exception type and message.
    ``False`` if it did not.
N)r   r-   r   )r   r,   messages      r   raised_with_messageSpyCall.raised_with_messagen   s<     d* 5M*5$..)W4	6r   c           	          SU R                   < S[        U R                  5      < SU R                  < SU R                  < S3	$ )Nz<SpyCall(args=z	, kwargs=z, returned=z	, raised=z)>)r   r   r   r   r   )r   s    r   __repr__SpyCall.__repr__   s.    II(5t7H7HNN 	r   )r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r%   r(   r-   r1   r4   __static_attributes__ r   r   r	   r	   
   s&    *)V*76&r   r	   N)r:   
__future__r   kgb.pycompatr   r   kgb.signaturer   	kgb.utilsr   objectr	   r<   r   r   <module>rB      s"    * ' - % 'zf zr   