§
    4›jJ4  ã                  óì  — d Z ddlmZ ddlmZ ddlmZ ddlm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mZ ddlmZ ddlmZ er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mZ  ed¦  «        Zed/d„¦   «         Zeddœd0d„¦   «         Zed1d"„¦   «         Z	 d2d3d%„Ze	 d4ddœd5d)„¦   «         Zed6d*„¦   «         Ze fddœd7d,„Z G d-„ dej!        ¦  «        Z"e G d.„ d(e"¦  «        ¦   «         Z#dS )8z/Record warnings during test function execution.é    )Úannotations)ÚCallable)Ú	Generator)ÚIterator©ÚpformatN)ÚTracebackType)ÚAny)Úfinal)Úoverload)ÚTYPE_CHECKING)ÚTypeVar)ÚSelf)Úcheck_ispytest)Úfixture)ÚExit)ÚfailÚTÚreturnúGenerator[WarningsRecorder]c               #  ó�   K  — t          d¬¦  «        } | 5  t          j        d¦  «         | V — ddd¦  «         dS # 1 swxY w Y   dS )z¥Return 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    úL/home/lighthouse/health/venv/lib/python3.11/site-packages/_pytest/recwarn.pyÚrecwarnr    !   sœ   è è € õ  dÐ+Ñ+Ô+€DØ	ð ð ÝÔ˜iÑ(Ô(Ð(Øˆ
ˆ
ˆ
ðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s   •;»?Á?.©Úmatchr"   ústr | re.Pattern[str] | Noner   c                ó   — d S ©N© r!   s    r   Údeprecated_callr'   -   s	   € ð �só    ÚfuncúCallable[..., T]Úargsr
   Úkwargsc                ó   — d S r%   r&   )r)   r+   r,   s      r   r'   r'   3   s   € ØMPÈSr(   úCallable[..., Any] | NoneúWarningsRecorder | Anyc                óZ   — d}| �| g|¢R }t          t          t          t          fg|¢R i |¤ŽS )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

    It can also be used by passing a function and ``*args`` and ``**kwargs``,
    in which case it will ensure calling ``func(*args, **kwargs)`` produces one of
    the warnings types above. The return value is the return value of the function.

    In the context manager form you may use the keyword argument ``match`` to assert
    that the warning matches a text or regex.

    The context manager produces a list of :class:`warnings.WarningMessage` objects,
    one for each warning raised.
    T)ÚwarnsÚDeprecationWarningÚPendingDeprecationWarningÚFutureWarning)r)   r+   r,   Ú__tracebackhide__s       r   r'   r'   7   sT   € ð4 ÐØÐØˆ}�tˆ}ˆ}ˆÝÝ	Õ6½ÐFðØIMðð ð ØQWðð ð r(   Úexpected_warningú)type[Warning] | tuple[type[Warning], ...]ÚWarningsCheckerc               ó   — d S r%   r&   )r6   r"   s     r   r1   r1   Y   s	   € ð
 �cr(   c                ó   — d S r%   r&   )r6   r)   r+   r,   s       r   r1   r1   a   s	   € ð 	ˆr(   úWarningsChecker | Anyc               ó„  — d}|sI|r5d                      t          |¦  «        ¦  «        }t          d|› d�¦  «        ‚t          | |d¬¦  «        S |d         }t	          |¦  «        s"t          |›dt          |¦  «        › d�¦  «        ‚t          | d¬	¦  «        5   ||d
d…         i |¤Žcddd¦  «         S # 1 swxY w Y   dS )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 can be used as a context manager::

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

    In the context manager form you may use the keyword argument ``match`` 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: DID NOT WARN. No warnings of type ...UserWarning... were emitted...

    **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.

    Tz, z5Unexpected keyword arguments passed to pytest.warns: z"
Use context-manager form instead?)Ú
match_exprr   r   z object (type: z) must be callabler   é   N)ÚjoinÚsortedÚ	TypeErrorr8   ÚcallableÚtype)r6   r"   r+   r,   r5   Úargnamesr)   s          r   r1   r1   j   sA  € ð^ ÐØð -Øð 	Ø—y’y¥¨¡¤Ñ0Ô0ˆHÝð6Èð 6ð 6ð 6ñô ð õ Ð/¸EÈTÐRÑRÔRÐRà�AŒwˆÝ˜‰~Œ~ð 	VÝ˜tÐTÐTµd¸4±j´jÐTÐTÐTÑUÔUÐUÝÐ-¸Ð>Ñ>Ô>ð 	-ð 	-Ø�4˜˜a˜b˜bœÐ, VÐ,Ð,ð	-ð 	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-ð 	-ð 	-s   ÂB5Â5B9Â<B9c                  ó†   ‡ — e Zd ZdZddœdˆ fd„Zed d
„¦   «         Zd!d„Zd"d„Zd#d„Z	e
fd$d„Zd%d„Zd&ˆ fd„Zd'ˆ fd„Zˆ xZS )(r   aF  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   r   Úboolr   ÚNonec               ó†   •— t          |¦  «         t          ¦   «                              d¬¦  «         d| _        g | _        d S )NT)ÚrecordF)r   ÚsuperÚ__init__Ú_enteredÚ_list)Úselfr   Ú	__class__s     €r   rK   zWarningsRecorder.__init__·   s>   ø€ Ý�yÑ!Ô!Ð!Ý‰Œ×Ò ÐÑ%Ô%Ð%ØˆŒØ46ˆŒ
ˆ
ˆ
r(   úlist[warnings.WarningMessage]c                ó   — | j         S )zThe list of recorded warnings.©rM   ©rN   s    r   ÚlistzWarningsRecorder.list½   s   € ð ŒzÐr(   ÚiÚintúwarnings.WarningMessagec                ó   — | j         |         S )z Get a recorded warning by index.rR   )rN   rU   s     r   Ú__getitem__zWarningsRecorder.__getitem__Â   s   € àŒz˜!Œ}Ðr(   ú!Iterator[warnings.WarningMessage]c                ó*   — t          | j        ¦  «        S )z&Iterate through the recorded warnings.)ÚiterrM   rS   s    r   Ú__iter__zWarningsRecorder.__iter__Æ   s   € å�D”JÑÔÐr(   c                ó*   — t          | j        ¦  «        S )z The number of recorded warnings.)ÚlenrM   rS   s    r   Ú__len__zWarningsRecorder.__len__Ê   s   € å�4”:‰ŒÐr(   Úclsútype[Warning]c                ód  — d}t          | j        ¦  «        D ]j\  }}|j        |k    r| j                             |¦  «        c S t	          |j        |¦  «        r)|�%t	          |j        | j        |         j        ¦  «        s|}Œk|�| j                             |¦  «        S d}t          |›d�¦  «        ‚)zÁPop 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)Ú	enumeraterM   ÚcategoryÚpopÚ
issubclassÚAssertionError)rN   ra   Úbest_idxrU   Úwr5   s         r   rf   zWarningsRecorder.popÎ   sÄ   € ð
  $ˆÝ˜dœjÑ)Ô)ð 	ð 	‰DˆAˆqØŒz˜SÒ Ð Ø”z—~’~ aÑ(Ô(Ð(Ð(Ð(Ý˜!œ* cÑ*Ô*ð ØÐ Ý! !¤*¨d¬j¸Ô.BÔ.KÑLÔLð !ð �øØÐØ”:—>’> (Ñ+Ô+Ð+Ø ÐÝ ÐAÐAÐAÑBÔBÐBr(   c                ó   — g | j         dd…<   dS )z$Clear the list of recorded warnings.NrR   rS   s    r   ÚclearzWarningsRecorder.cleará   s   € àˆŒ
�1�1�1‰ˆˆr(   r   c                ó¾   •— | j         rd}t          d| ›d�¦  «        ‚t          ¦   «                              ¦   «         }|€J ‚|| _        t          j        d¦  «         | S )NTzCannot enter z twiceÚalways)rL   ÚRuntimeErrorrJ   Ú	__enter__rM   r   r   )rN   r5   rM   rO   s      €r   rp   zWarningsRecorder.__enter__ç   sk   ø€ ØŒ=ð 	?Ø $ÐÝÐ=¨tÐ=Ð=Ð=Ñ>Ô>Ð>Ý‘”×!Ò!Ñ#Ô#ˆàÐ Ð Ð ØˆŒ
ÝÔ˜hÑ'Ô'Ð'Øˆr(   Úexc_typeútype[BaseException] | NoneÚexc_valúBaseException | NoneÚexc_tbúTracebackType | Nonec                ó”   •— | j         sd}t          d| ›d�¦  «        ‚t          ¦   «                              |||¦  «         d| _         d S )NTzCannot exit z without entering firstF)rL   ro   rJ   Ú__exit__)rN   rq   rs   ru   r5   rO   s        €r   rx   zWarningsRecorder.__exit__ò   sY   ø€ ð Œ}ð 	OØ $ÐÝÐM¨dÐMÐMÐMÑNÔNÐNå‰Œ×Ò˜ 7¨FÑ3Ô3Ð3ð ˆŒˆˆr(   )r   rF   r   rG   )r   rP   )rU   rV   r   rW   )r   rZ   )r   rV   )ra   rb   r   rW   )r   rG   )r   r   ©rq   rr   rs   rt   ru   rv   r   rG   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rK   ÚpropertyrT   rY   r]   r`   ÚWarningrf   rl   rp   rx   Ú__classcell__©rO   s   @r   r   r   ª   s%  ø€ € € € € ð
ð 
ð -2ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð ðð ð ñ „Xððð ð ð ð ð  ð  ð  ðð ð ð ð (/ð Cð Cð Cð Cð Cð&ð ð ð ð	ð 	ð 	ð 	ð 	ð 	ðð ð ð ð ð ð ð ð ð r(   c                  ó@   ‡ — e Zd Zedfddœdˆ fd„Zdd„Zdˆ fd„Zˆ xZS )r8   NFr   r6   r7   r=   r#   r   rF   r   rG   c               óÆ  •— t          |¦  «         t          ¦   «                              d¬¦  «         d}t          |t          ¦  «        r<|D ]6}t          |t          ¦  «        st          |t          |¦  «        z  ¦  «        ‚Œ7|}nMt          |t          ¦  «        rt          |t          ¦  «        r|f}nt          |t          |¦  «        z  ¦  «        ‚|| _	        || _
        d S )NTr   z/exceptions must be derived from Warning, not %s)r   rJ   rK   Ú
isinstanceÚtuplerg   r   rA   rC   r6   r=   )rN   r6   r=   r   ÚmsgÚexcÚexpected_warning_tuprO   s          €r   rK   zWarningsChecker.__init__  só   ø€ õ 	�yÑ!Ô!Ð!Ý‰Œ×Ò 4ÐÑ(Ô(Ð(à?ˆÝÐ&­Ñ.Ô.ð 
	:Ø'ð 5ð 5�Ý! #¥wÑ/Ô/ð 5Ý# C­$¨s©)¬)¡OÑ4Ô4Ð4ð5à#3Ð Ð ÝÐ(­$Ñ/Ô/ð 	:µJØ�gñ5
ô 5
ð 	:ð %5Ð#6Ð Ð å˜C¥$Ð'7Ñ"8Ô"8Ñ8Ñ9Ô9Ð9à 4ˆÔØ$ˆŒˆˆr(   ÚwarningrW   c                óÌ   — | j         €J ‚t          |j        | j         ¦  «        oAt          | j        d u p+t          j        | j        t          |j        ¦  «        ¦  «        ¦  «        S r%   )	r6   rg   re   rF   r=   ÚreÚsearchÚstrÚmessage)rN   r‰   s     r   ÚmatcheszWarningsChecker.matches  sc   € ØÔ$Ð0Ð0Ð0Ý˜'Ô*¨DÔ,AÑBÔBð 
ÅtØŒO˜tÐ#ÐW¥r¤y°´Å#ÀgÄoÑBVÔBVÑ'WÔ'WñH
ô H
ð 	
r(   rq   rr   rs   rt   ru   rv   c                ó  •‡ — t          ¦   «                              |||¦  «         d}|�,t          |t          ¦  «        rt          |t          ¦  «        rd S dˆ fd„}	 t          ˆ fd„‰ D ¦   «         ¦  «        s$t          d‰ j        › d |¦   «         › d�¦  «         nFt          ˆ fd	„‰ D ¦   «         ¦  «        s+t          d‰ j        › d
‰ j        › d |¦   «         › d�¦  «         ‰ D ]O}‰  	                    |¦  «        s8t          j        |j        |j        |j        |j        |j        |j        ¬¦  «         ŒP‰ D ]z}t%          |j        ¦  «        t&          urŒ|j        j        sŒ+|j        j        d         }t          |t*          ¦  «        rŒSt-          d|›dt%          |¦  «        j        › d�¦  «        ‚d S # ‰ D ]O}‰  	                    |¦  «        s8t          j        |j        |j        |j        |j        |j        |j        ¬¦  «         ŒP‰ D ]z}t%          |j        ¦  «        t&          urŒ|j        j        sŒ+|j        j        d         }t          |t*          ¦  «        rŒSt-          d|›dt%          |¦  «        j        › d�¦  «        ‚w xY w)NTr   r�   c                 ó:   •— t          d„ ‰ D ¦   «         d¬¦  «        S )Nc                ó   — g | ]	}|j         ‘Œ
S r&   )rŽ   )Ú.0rI   s     r   ú
<listcomp>z?WarningsChecker.__exit__.<locals>.found_str.<locals>.<listcomp>;  s   € Ð>Ð>Ð>¨v˜FœNÐ>Ð>Ð>r(   é   )Úindentr   rS   s   €r   Ú	found_strz+WarningsChecker.__exit__.<locals>.found_str:  s%   ø€ ÝÐ>Ð>¸Ð>Ñ>Ô>ÀqÐIÑIÔIÐIr(   c              3  óL   •K  — | ]}t          |j        ‰j        ¦  «        V — Œd S r%   )rg   re   r6   ©r“   rj   rN   s     €r   ú	<genexpr>z+WarningsChecker.__exit__.<locals>.<genexpr>>  s2   øè è € ÐSÐSÈ•z !¤*¨dÔ.CÑDÔDÐSÐSÐSÐSÐSÐSr(   z"DID NOT WARN. No warnings of type z" were emitted.
 Emitted warnings: ú.c              3  óB   •K  — | ]}‰                      |¦  «        V — Œd S r%   )r�   r™   s     €r   rš   z+WarningsChecker.__exit__.<locals>.<genexpr>C  s-   øè è € Ð7Ð7¨Q˜Ÿš a™œÐ7Ð7Ð7Ð7Ð7Ð7r(   z* matching the regex were emitted.
 Regex: z
 Emitted warnings: )rŽ   re   ÚfilenameÚlinenoÚmoduleÚsourcer   z$Warning must be str or Warning, got z (type ú))r   r�   )rJ   rx   r„   Ú	Exceptionr   Úanyr   r6   r=   r�   r   Úwarn_explicitrŽ   re   r�   rž   r{   r    rC   ÚUserWarningr+   r�   rA   rz   )	rN   rq   rs   ru   r5   r—   rj   r†   rO   s	   `       €r   rx   zWarningsChecker.__exit__%  sI  øø€ õ 	‰Œ×Ò˜ 7¨FÑ3Ô3Ð3à Ðð ÐÝ˜7¥IÑ.Ô.ð õ ˜'¥4Ñ(Ô(ð ð
 ˆFð	Jð 	Jð 	Jð 	Jð 	Jð 	Jð2	ÝÐSÐSÐSÐSÈdÐSÑSÔSÑSÔSð 
Ýð9¸Ô9Nð 9ð 9Ø*3¨)©+¬+ð9ð 9ð 9ñô ð ð õ Ð7Ð7Ð7Ð7°$Ð7Ñ7Ô7Ñ7Ô7ð Ýð9¸Ô9Nð 9ð 9Ø#œð9ð 9à*3¨)©+¬+ð9ð 9ð 9ñô ð ð ð 	ð 	�Ø—|’| A‘”ð ÝÔ*Ø !¤	Ø!"¤Ø!"¤Ø œxØ œ|Ø œxðñ ô ð øð" ð ð �Ý˜œ	‘?”?­+Ð5Ð5ð Ø”y”~ð àØ”i”n QÔ'�Ý˜c¥3Ñ'Ô'ð Øõ  Ø^¸3Ð^Ð^ÍÈcÉÌÔI[Ð^Ð^Ð^ñô ð ðð øð' ð 	ð 	�Ø—|’| A‘”ð ÝÔ*Ø !¤	Ø!"¤Ø!"¤Ø œxØ œ|Ø œxðñ ô ð øð" ð ð �Ý˜œ	‘?”?­+Ð5Ð5ð Ø”y”~ð àØ”i”n QÔ'�Ý˜c¥3Ñ'Ô'ð Øõ  Ø^¸3Ð^Ð^ÍÈcÉÌÔI[Ð^Ð^Ð^ñô ð ðøøøs   ÁBF3 Æ3CJ)r6   r7   r=   r#   r   rF   r   rG   )r‰   rW   r   rF   ry   )rz   r{   r|   r   rK   r�   rx   r€   r�   s   @r   r8   r8     s—   ø€ € € € € ð GNØ37ð%ð
  ð%ð %ð %ð %ð %ð %ð %ð %ð4
ð 
ð 
ð 
ðJð Jð Jð Jð Jð Jð Jð Jð Jð Jr(   )r   r   )r"   r#   r   r   )r)   r*   r+   r
   r,   r
   r   r   r%   )r)   r.   r+   r
   r,   r
   r   r/   ).)r6   r7   r"   r#   r   r8   )
r6   r7   r)   r*   r+   r
   r,   r
   r   r   )
r6   r7   r+   r
   r"   r#   r,   r
   r   r;   )$r}   Ú
__future__r   Úcollections.abcr   r   r   Úpprintr   r‹   Útypesr	   Útypingr
   r   r   r   r   Útyping_extensionsr   r   Ú_pytest.deprecatedr   Ú_pytest.fixturesr   Ú_pytest.outcomesr   r   r   r    r'   r1   r   Úcatch_warningsr   r8   r&   r(   r   ú<module>r°      sâ  ðà 5Ð 5à "Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø %Ð %Ð %Ð %Ð %Ð %Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð ð ð 'Ø&Ð&Ð&Ð&Ð&Ð&à €€€à -Ð -Ð -Ð -Ð -Ð -Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø !Ð !Ð !Ð !Ð !Ð !ð €GˆC�L„L€ð 	ðð ð ñ 	„ðð 
à-0ðð ð ð ð ñ 
„ðð
 
Ø PÐ PÐ Pñ 
„Ø Pð '+ðð ð ð ð ðD 
àBEðð +.ðð ð ð ð ñ 
„ðð 
ðð ð ñ 
„ðð CJð=-ð +/ð=-ð =-ð =-ð =-ð =-ð =-ð@Vð Vð Vð Vð V�xÔ.ñ Vô Vð Vðr ðkð kð kð kð kÐ&ñ kô kñ „ðkð kð kr(   