§
    öyIf5  ã                   óô  — d 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 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 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  ed¦  «        Zede
d         fd„¦   «         Zeddœdeeeee         f                  ddfd„¦   «         Zededef         d ed!edefd"„¦   «         Z	 d+deedef                  d ed!ededef         fd#„Ze	 d,ddœd$eee          eee          df         f         deeeee         f                  dd%fd&„¦   «         Z!ed$eee          eee          df         f         dedef         d ed!edef
d'„¦   «         Z!e fddœd$eee          eee          df         f         d edeeeee         f                  d!eded%ef         f
d(„Z! G d)„ dej"        ¦  «        Z#e	 G d*„ d%e#¦  «        ¦   «         Z$dS )-z/Record warnings during test function execution.é    ©ÚpformatN)ÚTracebackType)ÚAny)ÚCallable)Úfinal)Ú	Generator)ÚIterator)ÚList)ÚOptional)Úoverload)ÚPattern)ÚTuple)ÚType)ÚTypeVar)ÚUnion)Úcheck_ispytest)Úfixture)ÚExit)ÚfailÚTÚreturn)ÚWarningsRecorderNNc               #   ó�   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 https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
    on warning categories.
    T©Ú	_ispytestÚdefaultN)r   ÚwarningsÚsimplefilter)Úwrecs    úC/var/www/piapp/venv/lib/python3.11/site-packages/_pytest/recwarn.pyÚrecwarnr"      sœ   è è € õ  dÐ+Ñ+Ô+€DØ	ð ð ÝÔ˜iÑ(Ô(Ð(Øˆ
ˆ
ˆ
ðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s   •;»?Á?.©Úmatchr$   r   c                 ó   — d S ©N© r#   s    r!   Údeprecated_callr(   ,   s	   € ð ˜ó    ÚfuncÚargsÚkwargsc                 ó   — d S r&   r'   )r*   r+   r,   s      r!   r(   r(   2   s   € ØMPÈSr)   c                 ó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(   6   sT   € ð4 ÐØÐØˆ}�tˆ}ˆ}ˆÝÝ	Õ6½ÐFðØIMðð ð ØQWðð ð r)   Úexpected_warningÚWarningsCheckerc                ó   — d S r&   r'   )r4   r$   s     r!   r/   r/   X   s	   € ð
 ˜r)   c                 ó   — d S r&   r'   )r4   r*   r+   r,   s       r!   r/   r/   `   s	   € ð 	ˆr)   c                ó„  — 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Ú	TypeErrorr5   ÚcallableÚtype)r4   r$   r+   r,   r3   Úargnamesr*   s          r!   r/   r/   i   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eddfˆ fd„Zeded         fd	„¦   «         Zd
e	ddfd„Z
ded         fd„Zde	fd„Zefdee         ddfd„Zdd„Zdˆ fd„Zdeee                  dee         dee         ddfˆ 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   r   Nc                ó†   •— t          |¦  «         t          ¦   «                              d¬¦  «         d| _        g | _        d S )NT)ÚrecordF)r   ÚsuperÚ__init__Ú_enteredÚ_list)Úselfr   Ú	__class__s     €r!   rE   zWarningsRecorder.__init__¶   s>   ø€ Ý�yÑ!Ô!Ð!Ý‰Œ×Ò ÐÑ%Ô%Ð%ØˆŒØ46ˆŒ
ˆ
ˆ
r)   zwarnings.WarningMessagec                 ó   — | j         S )zThe list of recorded warnings.©rG   ©rH   s    r!   ÚlistzWarningsRecorder.list¼   s   € ð ŒzÐr)   Úic                 ó   — | j         |         S )z Get a recorded warning by index.rK   )rH   rN   s     r!   Ú__getitem__zWarningsRecorder.__getitem__Á   s   € àŒz˜!Œ}Ðr)   c                 ó*   — t          | j        ¦  «        S )z&Iterate through the recorded warnings.)ÚiterrG   rL   s    r!   Ú__iter__zWarningsRecorder.__iter__Å   s   € å�D”JÑÔÐr)   c                 ó*   — t          | j        ¦  «        S )z The number of recorded warnings.)ÚlenrG   rL   s    r!   Ú__len__zWarningsRecorder.__len__É   s   € å�4”:‰ŒÐr)   Úclsc                 ó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)Ú	enumeraterG   ÚcategoryÚpopÚ
issubclassÚAssertionError)rH   rW   Úbest_idxrN   Úwr3   s         r!   r[   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.NrK   rL   s    r!   ÚclearzWarningsRecorder.clearà   s   € àˆŒ
�1�1�1‰ˆˆr)   c                 ó¾   •— | j         rd}t          d| ›d�¦  «        ‚t          ¦   «                              ¦   «         }|€J ‚|| _        t          j        d¦  «         | S )NTzCannot enter z twiceÚalways)rF   ÚRuntimeErrorrD   Ú	__enter__rG   r   r   )rH   r3   rG   rI   s      €r!   re   zWarningsRecorder.__enter__æ   sk   ø€ ØŒ=ð 	?Ø $ÐÝÐ=¨tÐ=Ð=Ð=Ñ>Ô>Ð>Ý‘”×!Ò!Ñ#Ô#ˆàÐ Ð Ð ØˆŒ
ÝÔ˜hÑ'Ô'Ð'Øˆr)   Úexc_typeÚexc_valÚexc_tbc                 ó”   •— | j         sd}t          d| ›d�¦  «        ‚t          ¦   «                              |||¦  «         d| _         d S )NTzCannot exit z without entering firstF)rF   rd   rD   Ú__exit__)rH   rf   rg   rh   r3   rI   s        €r!   rj   zWarningsRecorder.__exit__ñ   sY   ø€ ð Œ}ð 	OØ $ÐÝÐM¨dÐMÐMÐMÑNÔNÐNå‰Œ×Ò˜ 7¨FÑ3Ô3Ð3ð ˆŒˆˆr)   )r   N)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚboolrE   Úpropertyr   rM   ÚintrP   r
   rS   rV   ÚWarningr   r[   ra   re   r   ÚBaseExceptionr   rj   Ú__classcell__©rI   s   @r!   r   r   ©   s²  ø€ € € € € ð
ð 
ð -2ð 7ð 7ð 7 Tð 7°dð 7ð 7ð 7ð 7ð 7ð 7ð ð�dÐ4Ô5ð ð ð ñ „Xðð˜Sð Ð%>ð ð ð ð ð ˜(Ð#<Ô=ð  ð  ð  ð  ð˜ð ð ð ð ð (/ð Cð C�t˜G”}ð CÐ3Lð Cð Cð Cð Cð&ð ð ð ð	ð 	ð 	ð 	ð 	ð 	ðà˜4 Ô.Ô/ðð ˜-Ô(ðð ˜Ô'ð	ð
 
ðð ð ð ð ð ð ð ð ð r)   c            
       ó  ‡ — e Zd Zedfddœdeee         eee         df         f         deeee	e         f                  de
ddfˆ fd	„Zd
ej        de
fd„Zdeee                  dee         dee         ddfˆ fd„Zˆ xZS )r5   NFr   r4   .r9   r   r   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   rD   rE   Ú
isinstanceÚtupler\   rr   r=   r?   r4   r9   )rH   r4   r9   r   ÚmsgÚexcÚexpected_warning_tuprI   s          €r!   rE   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)   Úwarningc                 óÌ   — | j         €J ‚t          |j        | j         ¦  «        oAt          | j        d u p+t          j        | j        t          |j        ¦  «        ¦  «        ¦  «        S r&   )	r4   r\   rZ   ro   r9   ÚreÚsearchÚstrÚmessage)rH   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)   rf   rg   rh   c                 ó  •‡ — t          ¦   «                              |||¦  «         d}|�,t          |t          ¦  «        rt          |t          ¦  «        rd S dt
          fˆ 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   c                  ó:   •— t          d„ ‰ D ¦   «         d¬¦  «        S )Nc                 ó   — g | ]	}|j         ‘Œ
S r'   )r‚   )Ú.0rC   s     r!   ú
<listcomp>z?WarningsChecker.__exit__.<locals>.found_str.<locals>.<listcomp>:  s   € Ð>Ð>Ð>¨v˜FœNÐ>Ð>Ð>r)   é   )Úindentr   rL   s   €r!   Ú	found_strz+WarningsChecker.__exit__.<locals>.found_str9  s%   ø€ ÝÐ>Ð>¸Ð>Ñ>Ô>ÀqÐIÑIÔIÐIr)   c              3   óL   •K  — | ]}t          |j        ‰j        ¦  «        V — Œd S r&   )r\   rZ   r4   ©r‡   r_   rH   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>B  s-   øè è € Ð7Ð7¨Q˜Ÿš a™œÐ7Ð7Ð7Ð7Ð7Ð7r)   z* matching the regex were emitted.
 Regex: z
 Emitted warnings: )r‚   rZ   ÚfilenameÚlinenoÚmoduleÚsourcer   z$Warning must be str or Warning, got z (type ú))rD   rj   rx   Ú	Exceptionr   r�   Úanyr   r4   r9   rƒ   r   Úwarn_explicitr‚   rZ   r‘   r’   rl   r”   r?   ÚUserWarningr+   r=   rk   )	rH   rf   rg   rh   r3   r‹   r_   rz   rI   s	   `       €r!   rj   zWarningsChecker.__exit__$  sQ  øø€ õ 	‰Œ×Ò˜ 7¨FÑ3Ô3Ð3à Ðð ÐÝ˜7¥IÑ.Ô.ð õ ˜'¥4Ñ(Ô(ð ð
 ˆFð	J�3ð 	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F: Æ:CJ)rk   rl   rm   rr   r   r   r   r   r�   r   ro   rE   r   ÚWarningMessagerƒ   rs   r   rj   rt   ru   s   @r!   r5   r5     s;  ø€ € € € € ð MTØ9=ð%ð
  ð%ð %ð %à  W¤¨u°T¸'´]ÀCÐ5GÔ/HÐ HÔIð%ð ˜U 3¨°¬Ð#4Ô5Ô6ð%ð
 ð%ð 
ð%ð %ð %ð %ð %ð %ð4
˜xÔ6ð 
¸4ð 
ð 
ð 
ð 
ðJà˜4 Ô.Ô/ðJð ˜-Ô(ðJð ˜Ô'ð	Jð
 
ðJð Jð Jð Jð Jð Jð Jð Jð Jð Jr)   r&   ).)%rn   Úpprintr   r   Útypesr   Útypingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   Ú_pytest.deprecatedr   Ú_pytest.fixturesr   Ú_pytest.outcomesr   r   r   r"   r�   r(   rr   r/   Úcatch_warningsr   r5   r'   r)   r!   ú<module>r¢      sš  ðà 5Ð 5à Ð Ð Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø €€€à -Ð -Ð -Ð -Ð -Ð -Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø !Ð !Ð !Ð !Ð !Ð !ð €GˆC�L„L€ð 	ð	�Ð9Ô:ð 	ð 	ð 	ñ 	„ð	ð 
à36ðð ð Ø�u˜S '¨#¤,Ð.Ô/Ô0ðàðð ð ñ 
„ðð
 
Ø P˜( 3¨ 6Ô*Ð P°3Ð PÀ#Ð PÈ!Ð PÐ PÐ Pñ 
„Ø Pð *.ðð Ø
�8˜C ˜HÔ%Ô
&ðØ69ðØEHðà
Ð˜sÐ"Ô#ðð ð ð ðD 
àHKðð 14ðð ð Ø˜D œM¨5°°g´ÀÐ1CÔ+DÐDÔEðð �E˜#˜w sœ|Ð+Ô,Ô-ðð ð	ð ð ñ 
„ðð 
ðØ˜D œM¨5°°g´ÀÐ1CÔ+DÐDÔEðà
�3˜�6Ô
ðð ðð ð	ð
 ðð ð ñ 
„ðð IPð=-ð 15ð=-ð =-ð =-Ø˜D œM¨5°°g´ÀÐ1CÔ+DÐDÔEð=-àð=-ð �E˜#˜w sœ|Ð+Ô,Ô-ð=-ð ð	=-ð
 Ð˜cÐ!Ô"ð=-ð =-ð =-ð =-ð@Vð Vð Vð Vð V�xÔ.ñ Vô Vð Vðr ðkð kð kð kð kÐ&ñ kô kñ „ðkð kð kr)   