+
    Spj36                       R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	t	^ RI
Ht ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ]'       d   ^ RIHt ^ RIHt ]! R4      t^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ]! R4      t]R R l4       t]RR/R R ll4       t ]R R l4       t R)R R llt ]R*RR/R R  lll4       t!]R! R" l4       t!]"R3R# R$ llt! ! R% R&]PF                  4      t$] ! R' R(]$4      4       t%R# )+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                   V ^8  d   QhRR/# )   returnzGenerator[WarningsRecorder] )formats   "6/tmp/pip-target-d46v3snk/lib/python/_pytest/recwarn.py__annotate__r   %   s      ,     c               #     "   \        RR7      p V ;_uu_ 4        \        P                  ! R4       V x  RRR4       R#   + '       g   i     R# ; i5i)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    r   recwarnr%   $   s4      d+D	i(
 
s   A>
AA			Amatch.c                    V ^8  d   QhRRRR/# )r   r&   str | re.Pattern[str] | Noner   r!   r   )r   s   "r   r   r   1   s      *r   c                    R # Nr   )r&   s   $r   deprecated_callr+   0   s     r   c               (    V ^8  d   QhRRRRRRRR/# )	r   funcCallable[P, T]argsP.argskwargsP.kwargsr   r   r   )r   s   "r   r   r   7   s     V V. V V8 VPQ Vr   c                    R # r*   r   )r-   r/   r1   s   &*,r   r+   r+   6   s    SVr   c               (    V ^8  d   QhRRRRRRRR/# )r   r-   zCallable[..., Any] | Noner/   r   r1   r   zWarningsRecorder | Anyr   )r   s   "r   r   r   :   s,     % %
#%36%BE%%r   c                    Rp\         \        \        3pV f   \        V.VO5/ VB # \        V4      ;_uu_ 4        V ! V/ VB uuRRR4       #   + '       g   i     R# ; i)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/   r1   __tracebackhide__dep_warningss   &*,  r   r+   r+   :   sX    2 &(A=QL|\3D3F33	|		T$V$ 
			s   AA	c               $    V ^8  d   QhRRRRRR/# )r   expected_warning)type[Warning] | tuple[type[Warning], ...]r&   r(   r   WarningsCheckerr   )r   s   "r   r   r   ]   s(      ? ( 	r   c                   R # r*   r   )r=   r&   s   &$r   r9   r9   \   s    
 r   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r=   r>   r-   r.   r/   r0   r1   r2   r   r   r   )r   s   "r   r   r   e   s:      ?
  	
 r   c                    R # r*   r   )r=   r-   r/   r1   s   &&*,r   r9   r9   d   s     	r   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r   r=   r>   r-   zCallable[..., object] | Noner/   r   r1   r   zWarningsChecker | Anyr   )r   s   "r   r   r   m   s:     ?) ?)??)
&?) ?) 	?)
 ?)r   c                   RpVfY   V'       gQ   VP                  RR4      pV'       d*   RP                  \        V4      4      p\        RV R24      h\	        WRR7      # \        V4      '       g   \        V: R\        V4       R	24      h\	        V RR
7      ;_uu_ 4        V! V/ VB uuRRR4       #   + '       g   i     R# ; i)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	TypeErrorr?   callabletype)r=   r-   r/   r1   r:   r&   argnamess   &&*,   r   r9   r9   m   s    b |D.4jj$.Gyy0HGz56  /TRR~~thod4j\ASTUU->>(( ?>>>s    B33C	c                     a  ] tR t^tRtRR/R V 3R lllt]R R l4       tR R	 ltR
 R lt	R R lt
]3R R lltR R ltR V 3R lltR V 3R lltRtV ;t# )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`.

r   Fc                    V ^8  d   QhRRRR/# )r   r   boolr   Noner   )r   s   "r   r   WarningsRecorder.__annotate__   s     7 7T 7d 7r   c               	Z   < \        V4       \        SV `	  R R7       RV n        . V n        R# )T)recordFN)r   super__init___entered_list)selfr   	__class__s   &$r   rU   WarningsRecorder.__init__   s)    y!%46
r   c                   V ^8  d   QhRR/# )r   r   zlist[warnings.WarningMessage]r   )r   s   "r   r   rQ      s      3 r   c                    V P                   # )zThe list of recorded warnings.rW   rX   s   &r   listWarningsRecorder.list   s     zzr   c                    V ^8  d   QhRRRR/# )r   iintr   warnings.WarningMessager   )r   s   "r   r   rQ      s      S %< r   c                (    V P                   V,          # )z Get a recorded warning by index.r]   )rX   rb   s   &&r   __getitem__WarningsRecorder.__getitem__   s    zz!}r   c                   V ^8  d   QhRR/# )r   r   z!Iterator[warnings.WarningMessage]r   )r   s   "r   r   rQ      s        ;  r   c                ,    \        V P                  4      # )z&Iterate through the recorded warnings.)iterrW   r^   s   &r   __iter__WarningsRecorder.__iter__   s    DJJr   c                   V ^8  d   QhRR/# )r   r   rc   r   )r   s   "r   r   rQ      s       r   c                ,    \        V P                  4      # )z The number of recorded warnings.)lenrW   r^   s   &r   __len__WarningsRecorder.__len__   s    4::r   c                    V ^8  d   QhRRRR/# )r   clsztype[Warning]r   rd   r   )r   s   "r   r   rQ      s     C C} C3J Cr   c                   Rp\        V P                  4       F  w  r4VP                  V8X  d   V P                  P                  V4      u # \	        VP                  V4      '       g   KQ  Ve:   \	        VP                  V P                  V,          P                  4      '       d   K  TpK  	  Ve   V P                  P                  V4      # Rp\        V: R24      h)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)	enumeraterW   categoryrF   
issubclassAssertionError)rX   rs   best_idxrb   wr:   s   &&    r   rF   WarningsRecorder.pop   s    
  $djj)DAzzS zz~~a((!**c** !!**djj.B.K.KLL * ::>>(++ w&@ABBr   c                   V ^8  d   QhRR/# )r   r   rP   r   )r   s   "r   r   rQ      s      t r   c                $    . V P                   R&   R# )z$Clear the list of recorded warnings.:NNNNr]   r^   s   &r   clearWarningsRecorder.clear   s    

1r   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   rQ      s     	 	4 	r   c                	   < V P                   '       d   R p\        RV : R24      h\        SV `  4       pVf   Q hW n        \
        P                  ! R4       V # )TzCannot enter z twicealways)rV   RuntimeErrorrT   	__enter__rW   r"   r#   )rX   r:   rW   rY   s   &  r   r   WarningsRecorder.__enter__   sW    === $thf=>>!#   
h'r   c               (    V ^8  d   QhRRRRRRRR/# 	r   exc_typeztype[BaseException] | Noneexc_valzBaseException | Noneexc_tbzTracebackType | Noner   rP   r   )r   s   "r   r   rQ      s2      , & %	
 
r   c                	~   < V P                   '       g   R p\        RV : R24      h\        SV `  WV4       RV n         R# )TzCannot exit z without entering firstFN)rV   r   rT   __exit__)rX   r   r   r   r:   rY   s   &&&& r   r   WarningsRecorder.__exit__   sA     }}} $dX5LMNNF3 r   )rV   rW   )__name__
__module____qualname____firstlineno____doc__rU   propertyr_   rf   rk   rp   WarningrF   r~   r   r   __static_attributes____classcell__rY   s   @r   r!   r!      s`    
7E 7 7    (/ C&	 	 r   r!   c                  \   a  ] tR tRt]R3RR/R V 3R lllltR R ltR	 V 3R
 lltRtV ;t	# )r?   i  Nr   Fc               (    V ^8  d   QhRRRRRRRR/# )	r   r=   r>   rE   r(   r   rO   r   rP   r   )r   s   "r   r   WarningsChecker.__annotate__
  s2     % %C% 1%
 % 
%r   c               	  < \        V4       \        SV `	  R R7       Rp\        V\        4      '       d>   V F4  p\        V\        4      '       d   K  \        V\        V4      ,          4      h	  TpMK\        V\        4      '       d   \        V\        4      '       d   V3pM\        V\        V4      ,          4      hW`n	        W n
        R# )Tr   z/exceptions must be derived from Warning, not %sN)r   rT   rU   
isinstancetuplerw   r   rI   rK   r=   rE   )rX   r=   rE   r   msgexcexpected_warning_tuprY   s   &&&$   r   rU   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                    V ^8  d   QhRRRR/# )r   warningrd   r   rO   r   )r   s   "r   r   r   $  s     
 
6 
4 
r   c                	   V P                   f   Q h\        VP                  V P                   4      ;'       dT    \        V P                  R J ;'       g5    \
        P                  ! V P                  \        VP                  4      4      4      # r*   )	r=   rw   rv   rO   rE   researchstrmessage)rX   r   s   &&r   matchesWarningsChecker.matches$  sm    $$000'**D,A,AB 
 
tOOt#WWryy#gooBV'WH
 	
r   c               (    V ^8  d   QhRRRRRRRR/# r   r   )r   s   "r   r   r   *  s8     Q Q,Q &Q %	Q
 
Qr   c                	  <a  \         S	S `  WV4       R pVe/   \        V\        4      '       d   \        V\        4      '       d   R# R V 3R llp \
        ;QJ d    V 3R lS  4       F  '       g   K   R M	  RM! V 3R lS  4       4      '       g#   \        RS P                   RV! 4        R24       M\
        ;QJ d    V 3R	 lS  4       F  '       g   K   R M	  RM! V 3R	 lS  4       4      '       g   R
p\        S P                  \        4      '       dC   \
        ;QJ d    V 3R lS  4       F  '       g   K   R M	  RM! V 3R lS  4       4      '       d   Rp\        R\        S 4       RS P                  : RV! 4        RV 24       S  Ft  pS P                  V4      '       d   K  \        P                  ! VP                  VP                  VP                   VP"                  VP$                  VP&                  R7       Kv  	  S  F  p\)        VP                  4      \*        Jd   K"  VP                  P,                  '       g   K@  VP                  P,                  ^ ,          p\        V\        4      '       d   Ku  \/        RV: R\)        V4      P0                   R24      h	  R#   S  Ft  pS P                  T4      '       d   K  \        P                  ! TP                  TP                  TP                   TP"                  TP$                  TP&                  R7       Kv  	  S  F  p\)        TP                  4      \*        Jd   K"  TP                  P,                  '       g   K@  TP                  P,                  ^ ,          p\        T\        4      '       d   Ku  \/        RT: R\)        T4      P0                   R24      h	  i ; i)TNc                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   .WarningsChecker.__exit__.<locals>.__annotate__?  s     	J 	J3 	Jr   c                 Z   < \        S U u. uF  q P                  NK  	  up ^R7      # u up i )r   )indent)r   r   )rS   rX   s    r   	found_str+WarningsChecker.__exit__.<locals>.found_str?  s$    >vNN>qII>s   (c              3  d   <"   T F%  p\        VP                  SP                  4      x  K'  	  R # 5ir*   )rw   rv   r=   .0rz   rX   s   & r   	<genexpr>+WarningsChecker.__exit__.<locals>.<genexpr>C  s%     Sdz!**d.C.CDDds   -0Fz"DID NOT WARN. No warnings of type z" were emitted.
 Emitted warnings: .c              3  F   <"   T F  pSP                  V4      x  K  	  R # 5ir*   )r   r   s   & r   r   r   H  s     7$Qa$s   ! c              3     <"   T FO  p\        VP                  SP                  4      '       g   K+  SP                  \	        VP
                  4      8H  x  KQ  	  R # 5ir*   )rw   rv   r=   rE   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   rv   filenamelinenomodulesourcez$Warning must be str or Warning, got z (type ))rT   r   r   	Exceptionr   anyr   r=   rE   r   ro   r   r"   warn_explicitr   rv   r   r   r   r   rK   UserWarningr/   rI   r   )
rX   r   r   r   r:   r   escape_hintrz   r   rY   s
   f&&&     r   r   WarningsChecker.__exit__*  s    	F3  7I..'4((	J 	J9	3SdS333SdSSS89N9N8O P**3+a9 S7$7SSS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\\]^  sP   
J" J" 3J" ,J" >J" J" 3,J"  J" 7J" 2J" "N=BN=A N=)r=   rE   )
r   r   r   r   r   rU   r   r   r   r   r   s   @r   r?   r?     s2     GN37%
  % %4
Q Qr   r?   r*   ).)&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+   r9   r   catch_warningsr!   r?   r   r   r   <module>r      s   5 " $ % $  	        +&#A  - $ ! ! CL 	 	 
-0 

 
 V 
 V%D 
 +. 
 
 
 CJ)-?)DVx.. Vr r& r rr   