
    zi(              	      n   U d Z ddlmZ ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
Z
ddlmZ ddlZddlmZ dd	lmZ dd
lmZ ddlZej        dk    rddlmZ ej        j        ZdJdZ G d dej                  Zej        Zded<   dKdZdKdZ dLdZ!dMdNd"Z"dOd$Z#d%dd&dPd-Z$dQd.Z%d/  e&d0          D             Z'e'(                     e)d1          d2 e)d3          d4 e)d5          d6i           dRd9Z*d: Z+d; Z,dSd>Z-dTd?Z.dUdAZ/ej        dBk    rddClm0Z0 ndVdFZ0 G dG dH          Z1dWdIZ2dS )Xz?Python version compatibility code and random general utilities.    )annotations)CallableN)	Parameter)	Signature)Path)Any)Final)NoReturn      )Formatpathstr | os.PathLike[str]returnLEGACY_PATHc                     t          |           S )zBInternal wrapper to prepare lazy proxies for legacy_path instances)r   )r   s    Q/root/projects/openclaw-proxy/venv/lib/python3.11/site-packages/_pytest/compat.pylegacy_pathr   #   s    t    c                      e Zd ZdZdS )
NotSetTyper   N)__name__
__module____qualname__token r   r   r   r   +   s        EEEr   r   r	   NOTSETfuncobjectboolc                L    t          j        |           pt          | dd          S )az  Return True if func is a coroutine function (a function defined with async
    def syntax, and doesn't contain yield), or a function decorated with
    @asyncio.coroutine.

    Note: copied and modified from Python 3.5's builtin coroutines.py to avoid
    importing asyncio directly, which in turns also initializes the "logging"
    module as a side-effect (see issue #8).
    _is_coroutineF)inspectiscoroutinefunctiongetattrr   s    r   r%   r%   1   s&     &t,,Uou0U0UUr   c                H    t          |           pt          j        |           S )zZReturn True if the given function seems to be an async function or
    an async generator.)r%   r$   isasyncgenfunctionr'   s    r   is_async_functionr*   =   s"     t$$H(B4(H(HHr   objCallable[..., Any]r   c                    t           j        dk    r t          j        | t          j                  S t          j        |           S )z0Return signature without evaluating annotations.r   )annotation_format)sysversion_infor$   	signaturer   STRINGr+   s    r   r1   r1   C   s9    
7"" FFFFS!!!r   curdirstr | os.PathLike[str] | Nonestrc                    t          |           } t          t          j        |                     }| j        j        }|0	 |                    |          }| d|dz    S # t          $ r Y nw xY w| d|dz    S )N:   )get_real_funcr   r$   getfile__code__co_firstlinenorelative_to
ValueError)functionr4   fnlinenorelfns        r   getlocationrD   J   s    X&&H	goh''	(	(B-F	+NN6**E **fqj***  	 	 	D	 6A:s    A 
A,+A,intc                P   t          | dd          }|sdS t          t          j                            d          dt	                                t          t          j                            d          dt	                                t          fd|D                       S )z>Return number of arguments used up by mock arguments (if any).	patchingsNr   mockDEFAULTzunittest.mockc                F    g | ]}|j         s|j        u s	|j        u |S r   )attribute_namenew).0pmock_sentinelut_mock_sentinels     r   
<listcomp>z'num_mock_patch_args.<locals>.<listcomp>b   sM     	
 	
 	
#	
 -''154D+D+D  ,E+D+Dr   )r&   r/   modulesgetr    len)r@   rG   rO   rP   s     @@r   num_mock_patch_argsrU   X   s    +t44I qCKOOF33YIIMs{??FHHUU	
 	
 	
 	
 	
	
 	
 	
  r    )nameclsr@   Callable[..., object]rW   rX   type | Nonetuple[str, ...]c                  	 t          |           j                                        }n7# t          t          f$ r#}ddlm}  |d| d| d           Y d}~nd}~ww xY wt          d |D                       }|s| j        }t          d	 |D                       s6|r4t          t          j        ||d
          t                    s
|dd         }t          | d          r|t          |           d         }|S )a   Return the names of a function's mandatory arguments.

    Should return the names of all function arguments that:
    * Aren't bound to an instance or type as in instance or class methods.
    * Don't have default values.
    * Aren't bound with functools.partial.
    * Aren't replaced with mocks.

    The cls arguments indicate that the function should be treated as a bound
    method even though it's not unless the function is a static method.

    The name parameter should be the original name in which the function was collected.
    r   )failz!Could not determine arguments of z: F)pytraceNc              3     K   | ]D}|j         t          j        u s|j         t          j        u r|j        t          j        u ;|j        V  Ed S Nkindr   POSITIONAL_OR_KEYWORDKEYWORD_ONLYdefaultemptyrW   rM   rN   s     r   	<genexpr>z"getfuncargnames.<locals>.<genexpr>   sa        Fi555v///I(( 	
 )((( r   c              3  <   K   | ]}|j         t          j        u V  d S r`   )rb   r   POSITIONAL_ONLYrg   s     r   rh   z"getfuncargnames.<locals>.<genexpr>   s,      GGqqv22GGGGGGr   )re   r9   __wrapped__)r1   
parametersvaluesr?   	TypeError_pytest.outcomesr]   tupler   any
isinstancer$   getattr_staticstaticmethodhasattrrU   )r@   rW   rX   rl   er]   	arg_namess          r   getfuncargnamesrx   k   sx   8
x((3::<<

	" 
 
 
))))))AAAaAA	
 	
 	
 	
 	
 	
 	
 	
 	

       I  ! 
 GGJGGGGG " 	" "3d;;;\
 
	" abbM	x'' ?1(;;==>	s   &) AAAc                |    t          d t          |           j                                        D                       S )Nc              3     K   | ]=}|j         t          j        t          j        fv r|j        t          j        u4|j        V  >d S r`   ra   rg   s     r   rh   z(get_default_arg_names.<locals>.<genexpr>   sY        6i5y7MNNNIY_,, 	
 -,,,	 r   )rp   r1   rl   rm   )r@   s    r   get_default_arg_namesr{      sI       8$$/6688     r   c                @    i | ]}|t          d d          v|d|dS )       z\x02x)range)rM   is     r   
<dictcomp>r      s;     ( ( (AU2s^^,C,CA}Q}}},C,C,Cr      	z\tz\r
z\nvalbytes | strc                    t          | t                    r|                     dd          }n(|                     d                              d          }|                    t
                    S )a	  If val is pure ASCII, return it as an str, otherwise, escape
    bytes objects into a sequence of escaped bytes:

    b'\xc3\xb4\xc5\xd6' -> r'\xc3\xb4\xc5\xd6'

    and escapes strings into a sequence of escaped unicode ids, e.g.:

    r'4\nV\U00043efa\x0eMXWB\x1e\u3028\u15fd\xcd\U0007d944'

    Note:
       The obvious "v.decode('unicode-escape')" will return
       valid UTF-8 unicode if it finds them in bytes, but we
       want to return escaped bytes for any byte, even if they match
       a UTF-8 string.
    asciibackslashreplaceunicode_escape)rr   bytesdecodeencode	translate$_non_printable_ascii_translate_table)r   rets     r   ascii_escapedr      s_      #u ;jj"455jj)**11'::===>>>r   c                p    t          j        |           } t          | t          j                  r| j        } | S )z{Get the real function object of the (possibly) wrapped object by
    :func:`functools.wraps`, or :func:`functools.partial`.)r$   unwraprr   	functoolspartialr   r3   s    r   r:   r:      s4     .

C#y()) hJr   c                6    	 | j         S # t          $ r | cY S w xY wr`   )__func__AttributeErrorr'   s    r   	getimfuncr      s3    }   s   	 r   re   c                L    ddl m} 	 t          | ||          S # |$ r |cY S w xY w)aR  Like getattr but return default upon any Exception or any OutcomeException.

    Attribute access can potentially fail for 'evil' Python objects.
    See issue #214.
    It catches OutcomeException because of #2490 (issue #580), new outcomes
    are derived from BaseException instead of Exception (for more details
    check #2707).
    r   )TEST_OUTCOME)ro   r   r&   )r    rW   re   r   s       r   safe_getattrr      sQ     .-----vtW---   s    ##c                N    	 t          j        |           S # t          $ r Y dS w xY w)z0Ignore any exception via isinstance on Python 3.F)r$   isclass	Exceptionr3   s    r   safe_isclassr      s9    s###   uus    
$$
int | Nonec                     t           j        dk    st           j        dk    rdS d} t          j                    }|| k    r|ndS )zReturn the current process's real user id or None if it could not be
    determined.

    :return: The user id or None if it could not be determined.
    win32
emscriptenN)r/   platformosgetuid)ERRORuids     r   get_user_idr     sH     |w#,,">"> t ikkUllss,r   )r      )assert_nevervaluer
   c                H    J d|  dt          |           j         d            )NFzUnhandled value: z ())typer   )r   s    r   r   r     s-    JJ%JJ4;;3GJJJJJJr   c                  *    e Zd ZdZd
dZddZddZd	S )CallableBoola'  
    A bool-like object that can also be called, returning its true/false value.

    Used for backwards compatibility in cases where something was supposed to be a method
    but was implemented as a simple attribute by mistake (see `TerminalReporter.isatty`).

    Do not use in new code.
    r   r!   r   Nonec                    || _         d S r`   _value)selfr   s     r   __init__zCallableBool.__init__+  s    r   c                    | j         S r`   r   r   s    r   __bool__zCallableBool.__bool__.  
    {r   c                    | j         S r`   r   r   s    r   __call__zCallableBool.__call__1  r   r   N)r   r!   r   r   r   r!   )r   r   r   __doc__r   r   r   r   r   r   r   r   !  sZ                    r   r   c                 <    ddg} t          d | D                       S )z0Check if we're currently running on a CI system.CIBUILD_NUMBERc              3  T   K   | ]#}t           j                            |          V  $d S r`   )r   environrS   )rM   vars     r   rh   z running_on_ci.<locals>.<genexpr>:  s0      77srz~~c""777777r   )rq   )env_varss    r   running_on_cir   5  s+     n%H77h777777r   )r   r   r   r   )r   r    r   r!   )r+   r,   r   r   r`   )r4   r5   r   r6   )r   rE   )r@   rY   rW   r6   rX   rZ   r   r[   )r@   r,   r   r[   )r   r   r   r6   )r    r   rW   r6   re   r   r   r   )r+   r    r   r!   )r   r   )r   r
   r   r
   r   )3r   
__future__r   collections.abcr   enumr   r$   r   r   r   pathlibr   r/   typingr   r	   r
   pyr0   annotationlibr   r   localr   r   Enumr   r   r   __annotations__r%   r*   r1   rD   rU   rx   r{   r   r   updateordr   r:   r   r   r   r   r   r   r   r   r   r   <module>r      sd   E E E " " " " " " $ $ $ $ $ $                   				       



                   				 w$$$$$$ gn                   	V 	V 	V 	VI I I I" " " "            , 	A A A A A AH	 	 	 	( (#eCjj( ( ( $ % + +SYYss4yy%TE:  
? ? ? ?.       "   - - - -* w#######K K K K       (8 8 8 8 8 8r   