§
    ×Ž’j®7  ã                  ó
  — 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mZ  ed¦  «        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d4d„¦   «         Zeddœd5d„¦   «         Z ed6d%„¦   «         Z 	 d7d8d)„Z e	 d9ddœd:d-„¦   «         Z!ed;d.„¦   «         Z!e"dfd<d1„Z! G d2„ dej#        ¦  «        Z$e G d3„ d,e$¦  «        ¦   «         Z%dS )=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Ú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    ú=C:\Projects\DSCons\.venv\Lib\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)   0   s	   € ð �só    ÚfuncúCallable[P, T]ÚargsúP.argsÚkwargsúP.kwargsc                ó   — d S r'   r(   )r+   r-   r/   s      r!   r)   r)   6   s   € ØSVÐSVr*   úCallable[..., Any] | Noner
   úWarningsRecorder | Anyc                ó´   — d}t           t          t          f}| €t          |g|¢R i |¤ŽS t          |¦  «        5   | |i |¤Žcddd¦  «         S # 1 swxY w Y   dS )aR  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)   :   s¾   € ð2 ÐÝ&Õ(AÅ=ÐQ€LØ€|Ý�\Ð3 DÐ3Ð3Ð3¨FÐ3Ð3Ð3å	ˆ|Ñ	Ô	ð %ð %Øˆt�TÐ$˜VÐ$Ð$ð%ð %ð %ð %ñ %ô %ð %ð %ð %ð %ð %ð %øøøð %ð %ð %ð %ð %ð %s   ¸AÁAÁAÚexpected_warningú)type[Warning] | tuple[type[Warning], ...]ÚWarningsCheckerc               ó   — d S r'   r(   )r;   r$   s     r!   r8   r8   \   s	   € ð
 �cr*   c                ó   — d S r'   r(   )r;   r+   r-   r/   s       r!   r8   r8   d   s	   € ð 	ˆr*   úCallable[..., object] | NoneúWarningsChecker | Anyc                ó”  — d}|€a|s_|                      dd¦  «        }|r5d                     t          |¦  «        ¦  «        }t          d|› d�¦  «        ‚t	          | |d¬¦  «        S t          |¦  «        s"t          |›dt          |¦  «        › d	�¦  «        ‚t	          | d¬
¦  «        5   ||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 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-   r/   r9   r$   Úargnamess          r!   r8   r8   m   sD  € ðb ÐØ€|˜D€|Ø.4¯jªj¸À$Ñ.GÔ.GˆØð 	Ø—y’y¥¨¡¤Ñ0Ô0ˆHÝð6Èð 6ð 6ð 6ñô ð õ Ð/¸EÈTÐRÑRÔRÐRå˜‰~Œ~ð 	VÝ˜tÐTÐTµd¸4±j´jÐTÐTÐTÑUÔUÐUÝÐ-¸Ð>Ñ>Ô>ð 	)ð 	)Ø�4˜Ð( Ð(Ð(ð	)ð 	)ð 	)ð 	)ñ 	)ô 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)øøøð 	)ð 	)ð 	)ð 	)ð 	)ð 	)s   Â(B=Â=CÃC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!   rQ   zWarningsRecorder.__init__¼   s>   ø€ Ý�yÑ!Ô!Ð!Ý‰Œ×Ò ÐÑ%Ô%Ð%ØˆŒØ46ˆŒ
ˆ
ˆ
r*   úlist[warnings.WarningMessage]c                ó   — | j         S )zThe list of recorded warnings.©rS   ©rT   s    r!   ÚlistzWarningsRecorder.listÂ   s   € ð ŒzÐr*   ÚiÚintúwarnings.WarningMessagec                ó   — | j         |         S )z Get a recorded warning by index.rX   )rT   r[   s     r!   Ú__getitem__zWarningsRecorder.__getitem__Ç   s   € àŒz˜!Œ}Ðr*   ú!Iterator[warnings.WarningMessage]c                ó*   — t          | j        ¦  «        S )z&Iterate through the recorded warnings.)ÚiterrS   rY   s    r!   Ú__iter__zWarningsRecorder.__iter__Ë   s   € å�D”JÑÔÐr*   c                ó*   — t          | j        ¦  «        S )z The number of recorded warnings.)ÚlenrS   rY   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)Ú	enumeraterS   ÚcategoryrD   Ú
issubclassÚAssertionError)rT   rg   Úbest_idxr[   Úwr9   s         r!   rD   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.NrX   rY   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)rR   ÚRuntimeErrorrP   Ú	__enter__rS   r   r   )rT   r9   rS   rU   s      €r!   ru   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)rR   rt   rP   Ú__exit__)rT   rv   rx   rz   r9   rU   s        €r!   r}   zWarningsRecorder.__exit__÷   sY   ø€ ð Œ}ð 	OØ $ÐÝÐM¨dÐMÐMÐMÑNÔNÐNå‰Œ×Ò˜ 7¨FÑ3Ô3Ð3ð ˆŒˆˆr*   )r   rL   r   rM   )r   rV   )r[   r\   r   r]   )r   r`   )r   r\   )rg   rh   r   r]   )r   rM   )r   r   ©rv   rw   rx   ry   rz   r{   r   rM   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rQ   ÚpropertyrZ   r_   rc   rf   ÚWarningrD   rq   ru   r}   Ú__classcell__©rU   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 )r=   NFr   r;   r<   rC   r%   r   rL   r   rM   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   rP   rQ   Ú
isinstanceÚtuplerl   r„   rG   rI   r;   rC   )rT   r;   rC   r   ÚmsgÚexcÚexpected_warning_tuprU   s          €r!   rQ   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*   Úwarningr]   c                óÌ   — | j         €J ‚t          |j        | j         ¦  «        oAt          | j        d u p+t          j        | j        t          |j        ¦  «        ¦  «        ¦  «        S r'   )	r;   rl   rk   rL   rC   ÚreÚsearchÚstrÚmessage)rT   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*   rv   rw   rx   ry   rz   r{   c                ó”  •‡ — t          ¦   «                              |||¦  «         d}|�,t          |t          ¦  «        rt          |t          ¦  «        rd S dˆ fd„}	 t          ˆ fd„‰ D ¦   «         ¦  «        s$t          d‰ j        › d |¦   «         › d�¦  «         n‰t          ˆ fd	„‰ D ¦   «         ¦  «        snd
}t          ‰ j        t          ¦  «        rt          ˆ fd„‰ D ¦   «         ¦  «        rd}t          dt          ‰ ¦  «        › 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“   )Ú.0rO   s     r!   ú
<listcomp>z?WarningsChecker.__exit__.<locals>.found_str.<locals>.<listcomp>@  s   € Ð>Ð>Ð>¨v˜FœNÐ>Ð>Ð>r*   é   )Úindentr   rY   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'   )rl   rk   r;   ©r˜   ro   rT   s     €r!   ú	<genexpr>z+WarningsChecker.__exit__.<locals>.<genexpr>C  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>H  s-   øè è € Ð7Ð7¨Q˜Ÿš a™œÐ7Ð7Ð7Ð7Ð7Ð7r*   Ú c              3  ó†   •K  — | ];}t          |j        ‰j        ¦  «        ¯‰j        t	          |j        ¦  «        k    V — Œ<d S r'   )rl   rk   r;   rC   r’   r“   rž   s     €r!   rŸ   z+WarningsChecker.__exit__.<locals>.<genexpr>J  s[   øè è € ð <ð <àÝ! !¤*¨dÔ.CÑDÔDð<Ø”O¥s¨1¬9¡~¤~Ò5ð<ð <ð <ð <ð <ð <r*   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“   rk   ÚfilenameÚlinenoÚmoduleÚsourcer   z$Warning must be str or Warning, got z (type ú))r   r’   )rP   r}   r‰   Ú	Exceptionr   Úanyr   r;   rC   r’   re   r”   r   Úwarn_explicitr“   rk   r¤   r¥   r€   r§   rI   ÚUserWarningr-   rG   r   )
rT   rv   rx   rz   r9   rœ   Úescape_hintro   r‹   rU   s
   `        €r!   r}   zWarningsChecker.__exit__*  s·  øø€ õ 	‰Œ×Ò˜ 7¨FÑ3Ô3Ð3à Ðð ÐÝ˜7¥IÑ.Ô.ð õ ˜'¥4Ñ(Ô(ð ð
 ˆFð	Jð 	Jð 	Jð 	Jð 	Jð 	Jð9	ÝÐ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ð Ø �Ý˜dœo­sÑ3Ô3ð P½ð <ð <ð <ð <à!ð<ñ <ô <ñ 9ô 9ð Pð
 #P�KÝðF½cÀ$¹i¼ið Fð FØ#œðFð Fà*3¨)©+¬+ðFð Fà8CðFð Fñô ð ð ð 	ð 	�Ø—|’| 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   ÁCG6 Ç6CK)r;   r<   rC   r%   r   rL   r   rM   )rŽ   r]   r   rL   r~   )r   r€   r�   r„   rQ   r”   r}   r…   r†   s   @r!   r=   r=     s—   ø€ € € € € ð GNØ37ð%ð
  ð%ð %ð %ð %ð %ð %ð %ð %ð4
ð 
ð 
ð 
ðQð Qð Qð Qð Qð Qð Qð Qð Qð Qr*   )r   r   )r$   r%   r   r   )r+   r,   r-   r.   r/   r0   r   r   r'   )r+   r2   r-   r
   r/   r
   r   r3   ).)r;   r<   r$   r%   r   r=   )
r;   r<   r+   r,   r-   r.   r/   r0   r   r   )
r;   r<   r+   r@   r-   r
   r/   r
   r   rA   )&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)   r8   r„   Úcatch_warningsr   r=   r(   r*   r!   ú<module>r¸      sõ  ðà 5Ð 5à "Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ø %Ð %Ð %Ð %Ð %Ð %Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð ð ð Ø+Ð+Ð+Ð+Ð+Ð+Ø&Ð&Ð&Ð&Ð&Ð&àˆ	�#‰Œ€Aà €€€à -Ð -Ð -Ð -Ð -Ð -Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø !Ð !Ð !Ð !Ð !Ð !ð €GˆC�L„L€ð 	ðð ð ñ 	„ðð 
à-0ðð ð ð ð ñ 
„ðð
 
Ø VÐ VÐ Vñ 
„Ø Vð '+ð%ð %ð %ð %ð %ðD 
àBEðð +.ðð ð ð ð ñ 
„ðð 
ðð ð ñ 
„ðð CJØ)-ð?)ð ?)ð ?)ð ?)ð ?)ðDVð Vð Vð Vð V�xÔ.ñ Vô Vð Vðr ðrð rð rð rð rÐ&ñ rô rñ „ðrð rð rr*   