
    Mh                        S SK Jr  S SKJrJr  S SKrS SKrS SKrS SKJ	r	J
r
Jr  S SKrS SKJr  \	(       a  S SKJrJr  \\SSSS4           SS	 jj5       rSS
 jr          SS jr      SS jr      SS jr    SS jrg)    )annotations)contextmanagernullcontextN)TYPE_CHECKINGLiteralcast)PY311)	GeneratorSequencealwaysTc           
   #    #    Sn[         R                  " SS9 n[         R                  " U5         Uv   U (       a#  [        [        [
           U 5      n [        UU UUS9  U(       a
  [        UU S9  SSS5        g! U (       a#  [        [        [
           U 5      n [        UU UUS9  U(       a  [        UU S9  f f = f! , (       d  f       g= f7f)aX  
Context manager for running code expected to either raise a specific warning,
multiple specific warnings, or not raise any warnings. Verifies that the code
raises the expected warning(s), and that it does not raise any other unexpected
warnings. It is basically a wrapper around ``warnings.catch_warnings``.

Parameters
----------
expected_warning : {Warning, False, tuple[Warning, ...], None}, default Warning
    The type of Exception raised. ``exception.Warning`` is the base
    class for all warnings. To raise multiple types of exceptions,
    pass them as a tuple. To check that no warning is returned,
    specify ``False`` or ``None``.
filter_level : str or None, default "always"
    Specifies whether warnings are ignored, displayed, or turned
    into errors.
    Valid values are:

    * "error" - turns matching warnings into exceptions
    * "ignore" - discard the warning
    * "always" - always emit a warning
    * "default" - print the warning the first time it is generated
      from each location
    * "module" - print the warning the first time it is generated
      from each module
    * "once" - print the warning the first time it is generated

check_stacklevel : bool, default True
    If True, displays the line that called the function containing
    the warning to show were the function is called. Otherwise, the
    line that implements the function is displayed.
raise_on_extra_warnings : bool, default True
    Whether extra warnings not of the type `expected_warning` should
    cause the test to fail.
match : str, optional
    Match warning message.

Examples
--------
>>> import warnings
>>> with assert_produces_warning():
...     warnings.warn(UserWarning())
...
>>> with assert_produces_warning(False):
...     warnings.warn(RuntimeWarning())
...
Traceback (most recent call last):
    ...
AssertionError: Caused unexpected warning(s): ['RuntimeWarning'].
>>> with assert_produces_warning(UserWarning):
...     warnings.warn(RuntimeWarning())
Traceback (most recent call last):
    ...
AssertionError: Did not see expected warning of class 'UserWarning'.

..warn:: This is *not* thread-safe.
T)record)caught_warningsexpected_warningmatchcheck_stacklevel)r   r   N)warningscatch_warningssimplefilterr   typeWarning_assert_caught_expected_warning _assert_caught_no_extra_warnings)r   filter_levelr   raise_on_extra_warningsr   __tracebackhide__ws          K/var/www/html/env/lib/python3.13/site-packages/pandas/_testing/_warnings.pyassert_produces_warningr      s     F 		 	 	-l+	G#'W7G#H /$%%5%5	 '0$%%5 
.	-
  #'W7G#H /$%%5%5	 '0$%%5 ' 
.	-s2   CB:A9;B:0	C9>B77B::
CCc                <    U(       a  [        U 40 UD6$ [        5       $ )zP
Return a context manager that possibly checks a warning based on the condition
)r   r   )warning	conditionkwargss      r   maybe_produces_warningr$   s   s     &w9&99}    c                   SnSn/ nU  H  n[        UR                  U5      (       d  M   SnU(       a  [        U5        Uc  M9  [        R                  " U[        UR                  5      5      (       a  SnMl  UR                  UR                  5        M     U(       d!  [        S[        UR                  5       35      eU(       a/  U(       d'  [        S[        UR                  5       SU SU 35      egg)zEAssert that there was the expected warning among the caught warnings.FTNz&Did not see expected warning of class zDid not see warning z matching 'z$'. The emitted warning messages are )
issubclasscategory&_assert_raised_with_correct_stacklevelresearchstrmessageappendAssertionErrorrepr__name__)r   r   r   r   saw_warningmatched_messageunmatched_messagesactual_warnings           r   r   r   }   s     KO)n--/?@@K6~F 99UC(>(>$?@@&*O&--n.D.DE * 4$--./1
 	

 _"4(8(A(A#B"C DC!"$
 	
 %ur%   c                   / nU  H  n[        X15      (       d  M  UR                  [        :X  aB  S[        UR                  5      ;   a  MD  [        S [        R                   5       5      (       a  Mk  [        (       a  UR                  [        :X  a  M  UR                  UR                  R                  UR                  UR                  UR                  45        M     U(       a  [        S[        U5       35      eg)zFAssert that no extra warnings apart from the expected ones are caught.zunclosed <ssl.SSLSocketc              3  ,   #    U  H
  nS U;   v   M     g7f)
matplotlibN ).0mods     r   	<genexpr>3_assert_caught_no_extra_warnings.<locals>.<genexpr>   s     Bks|s*ks   zCaused unexpected warning(s): N)_is_unexpected_warningr(   ResourceWarningr,   r-   anysysmodulesr	   EncodingWarningr.   r1   filenamelinenor/   r0   )r   r   extra_warningsr5   s       r   r   r      s     N)!.CC&&/9 -N4J4J0KK BckkBBBu00OC !!"++44"**"++"))	% *6 =d>>R=STUU r%   c                    U (       a  U(       d  g[        [        [           U5      n[        [	        U R
                  U5      (       + 5      $ )z1Check if the actual warning issued is unexpected.T)r   r   r   boolr'   r(   )r5   r   s     r   r>   r>      s;    
 .DM+;<J~668HIIJJr%   c                   [         R                  " 5       n[        S5       H  nUR                  nM      [         R                  " U5      nASU R
                   SU SU R                   3nU R
                  U:X  d   U5       eg ! Af = f)N   zGWarning not set with correct stacklevel. File where warning is raised: z != z. Warning message: )inspectcurrentframerangef_backgetfilerD   r-   )r5   frame_caller_filenamemsgs        r   r)   r)      s       "E1X !//%0 	))7)@)@(A
.~/E/E.F	H 
 ""o5:s:5 s   B B)r   7type[Warning] | bool | tuple[type[Warning], ...] | Noner   zALiteral['error', 'ignore', 'always', 'default', 'module', 'once']r   rH   r   rH   r   
str | Nonereturnz4Generator[list[warnings.WarningMessage], None, None])r!   type[Warning]r"   rH   )
r   !Sequence[warnings.WarningMessage]r   rW   r   rU   r   rH   rV   None)r   rX   r   rT   rV   rY   )r5   warnings.WarningMessager   rT   rV   rH   )r5   rZ   rV   rY   )
__future__r   
contextlibr   r   rK   r*   rA   typingr   r   r   r   pandas.compatr	   collections.abcr
   r   r   r   r$   r   r   r>   r)   r9   r%   r   <module>r`      s4   "  	 
 
   PW 	!$(UMUU
 U "U U :U Up$
6$
 $$
 	$

 $
 
$
N$V6$V N$V 
	$VNK+KMK 
K;+;	;r%   