
    ~/j36                    <   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	r	SSK
Jr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \(       a  SSKJr  SSKJr  \" S5      rSSKrSSKJr  SSKJr  SSKJr  SSKJr  \" S5      r\S#S j5       r\SS.   S$S jj5       r \S%S j5       r  S&       S'S jjr \ S(SS.     S)S jjj5       r!\          S*S j5       r!\"S4         S+S  jjr! " S! S\RF                  5      r$\ " S" S\$5      5       r%g),z/Record warnings during test function execution.    )annotations)Callable)	Generator)Iterator)pformatN)TracebackType)Any)final)overload)TYPE_CHECKING)TypeVar)	ParamSpec)SelfP)check_ispytest)fixture)Exit)failTc               #     #    [        SS9n U    [        R                  " S5        U v   SSS5        g! , (       d  f       g= f7f)zReturn a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.

See :ref:`warnings` for information on warning categories.
T	_ispytestdefaultN)WarningsRecorderwarningssimplefilter)wrecs    N/root/lseg-credit/backend/venv/lib/python3.13/site-packages/_pytest/recwarn.pyrecwarnr   $   s0      d+D	i(
 
s   A2	A
A A.matchr   c                    g N r    s    r   deprecated_callr%   0   s         c                    g r#   r$   )funcargskwargss      r   r%   r%   6   s    SVr&   c                    Sn[         [        [        4nU c  [        U/UQ70 UD6$ [        U5         U " U0 UD6sSSS5        $ ! , (       d  f       g= f)a  Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning`` or ``FutureWarning``.

This function can be used as a context manager::

    >>> import warnings
    >>> def api_call_v2():
    ...     warnings.warn('use v3 of this api', DeprecationWarning)
    ...     return 200

    >>> import pytest
    >>> with pytest.deprecated_call():
    ...    assert api_call_v2() == 200
    >>> with pytest.deprecated_call(match="^use v3 of this api$") as warning_messages:
    ...    assert api_call_v2() == 200

You may use the keyword argument ``match`` to assert
that the warning matches a text or regex.

The return value is a list of :class:`warnings.WarningMessage` objects,
one for each warning emitted
(regardless of whether it is an ``expected_warning`` or not).
TN)DeprecationWarningPendingDeprecationWarningFutureWarningwarns)r(   r)   r*   __tracebackhide__dep_warningss        r   r%   r%   :   sR    2 &(A=QL|\3D3F33	|	T$V$ 
		s   A
AWarningsCheckerc                   g r#   r$   )expected_warningr!   s     r   r/   r/   \   s    
 r&   c                    g r#   r$   )r4   r(   r)   r*   s       r   r/   r/   d   s     	r&   c                b   SnUcS  U(       dL  UR                  SS5      nU(       a)  SR                  [        U5      5      n[        SU S35      e[	        XSS9$ [        U5      (       d  [        U< S[        U5       S	35      e[	        U SS
9   U" U0 UD6sSSS5        $ ! , (       d  f       g= f)a  Assert that code raises a particular class of warning.

Specifically, the parameter ``expected_warning`` can be a warning class or tuple
of warning classes, and the code inside the ``with`` block must issue at least one
warning of that class or classes.

This helper produces a list of :class:`warnings.WarningMessage` objects, one for
each warning emitted (regardless of whether it is an ``expected_warning`` or not).
Since pytest 8.0, unmatched warnings are also re-emitted when the context closes.

This function should be used as a context manager::

    >>> import pytest
    >>> with pytest.warns(RuntimeWarning):
    ...    warnings.warn("my warning", RuntimeWarning)

The ``match`` keyword argument can be used to assert
that the warning matches a text or regex::

    >>> with pytest.warns(UserWarning, match='must be 0 or None'):
    ...     warnings.warn("value must be 0 or None", UserWarning)

    >>> with pytest.warns(UserWarning, match=r'must be \d+$'):
    ...     warnings.warn("value must be 42", UserWarning)

    >>> with pytest.warns(UserWarning):  # catch re-emitted warning
    ...     with pytest.warns(UserWarning, match=r'must be \d+$'):
    ...         warnings.warn("this is not here", UserWarning)
    Traceback (most recent call last):
      ...
    Failed: Regex pattern did not match any of the 1 warnings emitted.
     Regex: ...
     Emitted warnings: ...UserWarning...

**Using with** ``pytest.mark.parametrize``

When using :ref:`pytest.mark.parametrize ref` it is possible to parametrize tests
such that some runs raise a warning and others do not.

This could be achieved in the same way as with exceptions, see
:ref:`parametrizing_conditional_raising` for an example.

TNr!   z, z5Unexpected keyword arguments passed to pytest.warns: z"
Use context-manager form instead?)
match_exprr   z object (type: z) must be callabler   )popjoinsorted	TypeErrorr2   callabletype)r4   r(   r)   r*   r0   r!   argnamess          r   r/   r/   m   s    b |D.4jj$.Gyy0HGz56  /TRR~~thod4j\ASTUU->(( ?>>s   B  
B.c                     ^  \ rS rSrSrSS.SU 4S jjjr\SS j5       rSS jrSS jr	SS	 jr
\4SS
 jjrSS jrSU 4S jjr        SU 4S jjrSrU =r$ )r      a.  A context manager to record raised warnings.

Each recorded warning is an instance of :class:`warnings.WarningMessage`.

Adapted from `warnings.catch_warnings`.

.. note::
    ``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated
    differently; see :ref:`ensuring_function_triggers`.

Fr   c               R   > [        U5        [        TU ]	  SS9  SU l        / U l        g )NT)recordF)r   super__init___entered_list)selfr   	__class__s     r   rD   WarningsRecorder.__init__   s)    y!%46
r&   c                    U R                   $ )zThe list of recorded warnings.rF   rG   s    r   listWarningsRecorder.list   s     zzr&   c                     U R                   U   $ )z Get a recorded warning by index.rK   )rG   is     r   __getitem__WarningsRecorder.__getitem__   s    zz!}r&   c                ,    [        U R                  5      $ )z&Iterate through the recorded warnings.)iterrF   rL   s    r   __iter__WarningsRecorder.__iter__   s    DJJr&   c                ,    [        U R                  5      $ )z The number of recorded warnings.)lenrF   rL   s    r   __len__WarningsRecorder.__len__   s    4::r&   c                   Sn[        U R                  5       H  u  p4UR                  U:X  a  U R                  R                  U5      s  $ [	        UR                  U5      (       d  MO  Ub4  [	        UR                  U R                  U   R                  5      (       a  M  UnM     Ub  U R                  R                  U5      $ Sn[        U< S35      e)zPop the first recorded warning which is an instance of ``cls``,
but not an instance of a child class of any other match.
Raises ``AssertionError`` if there is no match.
NTz not found in warning list)	enumeraterF   categoryr8   
issubclassAssertionError)rG   clsbest_idxrP   wr0   s         r   r8   WarningsRecorder.pop   s    
  $djj)DAzzS zz~~a((!**c** !!**djj.B.K.KLL * ::>>(++ w&@ABBr&   c                "    / U R                   SS& g)z$Clear the list of recorded warnings.NrK   rL   s    r   clearWarningsRecorder.clear   s    

1r&   c                   > U R                   (       a  Sn[        SU < S35      e[        TU ]  5       nUc   eX l        [
        R                  " S5        U $ )NTzCannot enter z twicealways)rE   RuntimeErrorrC   	__enter__rF   r   r   )rG   r0   rF   rH   s      r   rj   WarningsRecorder.__enter__   sU    == $thf=>>!#   
h'r&   c                z   > U R                   (       d  Sn[        SU < S35      e[        TU ]  XU5        SU l         g )NTzCannot exit z without entering firstF)rE   ri   rC   __exit__)rG   exc_typeexc_valexc_tbr0   rH   s        r   rm   WarningsRecorder.__exit__   s?     }} $dX5LMNNF3 r&   )rE   rF   )r   boolreturnNone)rs   zlist[warnings.WarningMessage])rP   intrs   warnings.WarningMessage)rs   z!Iterator[warnings.WarningMessage])rs   ru   )r`   ztype[Warning]rs   rv   )rs   rt   )rs   r   rn   ztype[BaseException] | Nonero   zBaseException | Nonerp   zTracebackType | Noners   rt   )__name__
__module____qualname____firstlineno____doc__rD   propertyrM   rQ   rU   rY   Warningr8   re   rj   rm   __static_attributes____classcell__rH   s   @r   r   r      s    
 -2 7 7    (/ C&	, & %	
 
 r&   c                  t   ^  \ rS rSr\S4SS.       S	U 4S jjjjrS
S jr        SU 4S jjrSrU =r	$ )r2   i  NFr   c               v  > [        U5        [        TU ]	  SS9  Sn[        U[        5      (       a8  U H/  n[        U[        5      (       a  M  [        U[        U5      -  5      e   UnOE[        U[        5      (       a  [        U[        5      (       a  U4nO[        U[        U5      -  5      eX`l	        X l
        g )NTr   z/exceptions must be derived from Warning, not %s)r   rC   rD   
isinstancetupler^   r~   r;   r=   r4   r7   )rG   r4   r7   r   msgexcexpected_warning_tuprH   s          r   rD   WarningsChecker.__init__
  s     	y!4(?&..'!#w//#C$s)O44 ( $4 ($//Jg5
 5
 %5#6 C$'7"8899 4$r&   c                   U R                   c   e[        UR                  U R                   5      =(       aR    [        U R                  S L =(       d4    [
        R                  " U R                  [        UR                  5      5      5      $ r#   )	r4   r^   r]   rr   r7   researchstrmessage)rG   warnings     r   matchesWarningsChecker.matches$  se    $$000'**D,A,AB 
tOOt#Wryy#gooBV'WH
 	
r&   c                b  >^  [         T	T ]  XU5        SnUb+  [        U[        5      (       a  [        U[        5      (       a  g SU 4S jjn [        U 4S jT  5       5      (       d"  [        ST R                   SU" 5        S35        O[        U 4S jT  5       5      (       dm  Sn[        T R                  [        5      (       a  [        U 4S	 jT  5       5      (       a  S
n[        S[        T 5       ST R                  < SU" 5        SU 35        T  Hp  nT R                  U5      (       a  M  [        R                  " UR                  UR                  UR                   UR"                  UR$                  UR&                  S9  Mr     T  H  n[)        UR                  5      [*        La  M!  UR                  R,                  (       d  M>  UR                  R,                  S   n[        U[        5      (       a  Mn  [/        SU< S[)        U5      R0                   S35      e   g ! T  Hp  nT R                  U5      (       a  M  [        R                  " UR                  UR                  UR                   UR"                  UR$                  UR&                  S9  Mr     T  H  n[)        UR                  5      [*        La  M!  UR                  R,                  (       d  M>  UR                  R,                  S   n[        U[        5      (       a  Mn  [/        SU< S[)        U5      R0                   S35      e   f = f)NTc                 V   > [        T V s/ s H  o R                  PM     sn SS9$ s  sn f )N   )indent)r   r   )rB   rG   s    r   	found_str+WarningsChecker.__exit__.<locals>.found_str?  s$    >vNN>qII>s   &c              3  d   >#    U  H%  n[        UR                  TR                  5      v   M'     g 7fr#   )r^   r]   r4   .0rb   rG   s     r   	<genexpr>+WarningsChecker.__exit__.<locals>.<genexpr>C  s%     Sdz!**d.C.CDDds   -0z"DID NOT WARN. No warnings of type z" were emitted.
 Emitted warnings: .c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr#   )r   r   s     r   r   r   H  s     7$Qa$s   ! c              3     >#    U  HN  n[        UR                  TR                  5      (       d  M*  TR                  [	        UR
                  5      :H  v   MP     g 7fr#   )r^   r]   r4   r7   r   r   r   s     r   r   r   J  s?      <!!!**d.C.CD 6DOOs199~5!s
   )A)Az*
 Did you mean to `re.escape()` the regex?z'Regex pattern did not match any of the z warnings emitted.
 Regex: z
 Emitted warnings: )r   r]   filenamelinenomodulesourcer   z$Warning must be str or Warning, got z (type ))rs   r   )rC   rm   r   	Exceptionr   anyr   r4   r7   r   rX   r   r   warn_explicitr   r]   r   r   ry   r   r=   UserWarningr)   r;   rx   )
rG   rn   ro   rp   r0   r   escape_hintrb   r   rH   s
   `        r   rm   WarningsChecker.__exit__*  s    	F3  7I..'4((	J9	SdSSS89N9N8O P**3+a9 7$777 doos33 <!< 9 9
 #PK=c$i[ I#1 2**3+a}F ||A** !		!"!" xx || xx & 		?+5 yy~~iinnQ'c3''  :3'cI[I[H\\]^  ' ||A** !		!"!" xx || xx & 		?+5 yy~~iinnQ'c3''  :3'cI[I[H\\]^  s   CH L.<C2L.)r4   r7   )r4   )type[Warning] | tuple[type[Warning], ...]r7   str | re.Pattern[str] | Noner   rr   rs   rt   )r   rv   rs   rr   rw   )
rx   ry   rz   r{   r~   rD   r   rm   r   r   r   s   @r   r2   r2     s     GN37%
  %C% 1%
 % 
% %4
Q,Q &Q %	Q
 
Q Qr&   )rs   zGenerator[WarningsRecorder])r!   r   rs   r   )r(   Callable[P, T]r)   P.argsr*   P.kwargsrs   r   r#   )r(   zCallable[..., Any] | Noner)   r	   r*   r	   rs   zWarningsRecorder | Any).)r4   r   r!   r   rs   r2   )
r4   r   r(   r   r)   r   r*   r   rs   r   )
r4   r   r(   zCallable[..., object] | Noner)   r	   r*   r	   rs   zWarningsChecker | Any)&r|   
__future__r   collections.abcr   r   r   pprintr   r   typesr   typingr	   r
   r   r   r   typing_extensionsr   r   r   r   _pytest.deprecatedr   _pytest.fixturesr   _pytest.outcomesr   r   r   r   r%   r/   r~   catch_warningsr   r2   r$   r&   r   <module>r      s   5 " $ % $  	        +&#A  - $ ! ! CL 	 	 
-0* 

 
 V 
 V '+%
#%36%BE%%D 
BE +.? ( 	 
 
?
  	
  
 CJ)-?)??)
&?) ?) 	?)
 ?)DVx.. Vr r& r rr&   