§
    øÛg#  ã                   óÂ   — d Z ddlZddlZddlZddlZddlZddlZej        d„ ¦   «         Z	d„ Z
dd„Zd„ Z G d„ de¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        ZdS )z4 recording warnings during test function execution. é    Nc              #   óŒ   K  — t          ¦   «         }|5  t          j        d¦  «         |V — ddd¦  «         dS # 1 swxY w Y   dS )a  Return a WarningsRecorder instance that provides these methods:

    * ``pop(category=None)``: return last warning matching the category.
    * ``clear()``: clear list of warnings

    See http://docs.python.org/library/warnings.html for information
    on warning categories.
    ÚdefaultN)ÚWarningsRecorderÚwarningsÚsimplefilter)ÚrequestÚwrecs     úE/granary/edev/quantum/lib/python3.11/site-packages/_pytest/recwarn.pyÚrecwarnr      s—   è è € õ ÑÔ€DØ	ð ð ÝÔ˜iÑ(Ô(Ð(Øˆ
ˆ
ˆ
ðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s   “9¹=Á =c                  ó    — t           t          dœS )N©Údeprecated_callÚwarnsr   © ó    r
   Úpytest_namespacer      s   € Ý.Ýðð ð r   c                 ó²  ‡‡‡	‡
— | st          t          ¬¦  «        S g Šˆˆ
fd„}dˆˆ	fd„	}t          j        Š	t          j        Š
|t          _        |t          _        	  | |i |¤Ž}‰
t          _        ‰	t          _        n# ‰
t          _        ‰	t          _        w xY wt          t
          fŠt          ˆfd„‰D ¦   «         ¦  «        sd}t          | ›d�¦  «        ‚|S )	aÉ   assert that calling ``func(*args, **kwargs)`` triggers a
    ``DeprecationWarning`` or ``PendingDeprecationWarning``.

    This function can be used as a context manager::

        >>> with deprecated_call():
        ...    myobject.deprecated_method()

    Note: we cannot use WarningsRecorder here because it is still subject
    to the mechanism that prevents warnings of the same type from being
    triggered twice for the same module. See #1190.
    )Úexpected_warningc                 óL   •— ‰                      |¦  «          ‰| |g|¢R i |¤Ž d S ©N)Úappend)ÚmessageÚcategoryÚargsÚkwargsÚ
categoriesÚold_warn_explicits       €€r
   Úwarn_explicitz&deprecated_call.<locals>.warn_explicit3   s@   ø€ Ø×Ò˜(Ñ#Ô#Ð#ØÐ˜' 8Ð=¨dÐ=Ð=Ð=°fÐ=Ð=Ð=Ð=Ð=r   Nc                 ó¬   •— t          | t          ¦  «        r‰                     | j        ¦  «         n‰                     |¦  «          ‰| |g|¢R i |¤Ž d S r   )Ú
isinstanceÚWarningr   Ú	__class__)r   r   r   r   r   Úold_warns       €€r
   Úwarnzdeprecated_call.<locals>.warn7   sk   ø€ Ý�g�wÑ'Ô'ð 	(Ø×Ò˜gÔ/Ñ0Ô0Ð0Ð0à×Ò˜hÑ'Ô'Ð'Øˆ�˜(Ð4 TÐ4Ð4Ð4¨VÐ4Ð4Ð4Ð4Ð4r   c              3   ó8   •K  — | ]}t          |‰¦  «        V — Œd S r   )Ú
issubclass)Ú.0ÚcÚdeprecation_categoriess     €r
   ú	<genexpr>z"deprecated_call.<locals>.<genexpr>H   s.   øè è € ÐIÐI¸�z˜!Ð3Ñ4Ô4ÐIÐIÐIÐIÐIÐIr   Tz# did not produce DeprecationWarningr   )ÚWarningsCheckerÚDeprecationWarningr   r$   r   ÚPendingDeprecationWarningÚanyÚAssertionError)Úfuncr   r   r   r$   ÚretÚ__tracebackhide__r   r)   r#   r   s          @@@@r
   r   r   !   s$  øøøø€ ð ð DÝÕ0BÐCÑCÔCÐCà€Jð>ð >ð >ð >ð >ð >ð5ð 5ð 5ð 5ð 5ð 5ð 5õ Œ}€HÝ Ô.ÐØ*…HÔØ…H„Mð!Øˆd�DÐ#˜FÐ#Ð#ˆà!2�ÔØ �Œˆøð "3�ÔØ �ŒÐ Ð Ð Ð Ý0Õ2KÐLÐÝÐIÐIÐIÐI¸jÐIÑIÔIÑIÔIð PØ ÐÝÈÈÈÐNÑOÔOÐOØ€Js   ÁA= Á=Bc                 óh  — t          | ¦  «        }|s|S t          |d         t          ¦  «        rÑ|\  }t          |t          ¦  «        sJ ‚t          j        d¦  «        }|j                             ¦   «         }|                     |¦  «         |5  t          j	         
                    |¦  «                             ¦   «         }t          j                             ||j        |¦  «         ddd¦  «         dS # 1 swxY w Y   dS |d         }|5   ||dd…         i |¤Žcddd¦  «         S # 1 swxY w Y   dS )aG  Assert that code raises a particular class of warning.

    Specifically, the input @expected_warning can be a warning class or
    tuple of warning classes, and the code must return that warning
    (if a single class) or one of those warnings (if a tuple).

    This helper produces a list of ``warnings.WarningMessage`` objects,
    one for each warning raised.

    This function can be used as a context manager, or any of the other ways
    ``pytest.raises`` can be used::

        >>> with warns(RuntimeWarning):
        ...    warnings.warn("my warning", RuntimeWarning)
    r   é   N)r+   r    ÚstrÚsysÚ	_getframeÚf_localsÚcopyÚupdateÚ_pytestÚ_codeÚSourceÚcompileÚpyÚbuiltinÚexec_Ú	f_globals)r   r   r   ÚwcheckÚcodeÚframeÚlocr0   s           r
   r   r   N   s¼  € õ  Ð-Ñ.Ô.€FØð -ØˆÝ	�D˜”G�SÑ	!Ô	!ð -Ø‰ˆÝ˜$¥Ñ$Ô$Ð$Ð$Ð$Ý”˜aÑ Ô ˆØŒn×!Ò!Ñ#Ô#ˆØ�
Š
�6ÑÔÐàð 	9ð 	9Ý”=×'Ò'¨Ñ-Ô-×5Ò5Ñ7Ô7ˆDÝŒJ×Ò˜T 5¤?°CÑ8Ô8Ð8ð	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð �AŒwˆØð 	-ð 	-Ø�4˜˜a˜b˜bœÐ, VÐ,Ð,ð	-ð 	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-ð 	-ð 	-s%   ÂAC3Ã3C7Ã:C7Ä
D'Ä'D+Ä.D+c                   ó   — e Zd Zd„ ZdS )ÚRecordedWarningc                 óZ   — || _         || _        || _        || _        || _        || _        d S r   )r   r   ÚfilenameÚlinenoÚfileÚline)Úselfr   r   rJ   rK   rL   rM   s          r
   Ú__init__zRecordedWarning.__init__r   s0   € ØˆŒØ ˆŒØ ˆŒØˆŒØˆŒ	ØˆŒ	ˆ	ˆ	r   N)Ú__name__Ú
__module__Ú__qualname__rO   r   r   r
   rH   rH   q   s#   € € € € € ðð ð ð ð r   rH   c                   ó^   — e Zd ZdZdd„Zed„ ¦   «         Zd„ Zd„ Zd„ Z	e
fd„Zd	„ Zd
„ Zd„ ZdS )r   z^A context manager to record raised warnings.

    Adapted from `warnings.catch_warnings`.
    Nc                 óX   — |€t           j        d         n|| _        d| _        g | _        d S )Nr   F)r6   ÚmodulesÚ_moduleÚ_enteredÚ_list)rN   Úmodules     r
   rO   zWarningsRecorder.__init__�   s+   € Ø28°.•s”{ :Ô.Ð.ÀfˆŒØˆŒØˆŒ
ˆ
ˆ
r   c                 ó   — | j         S )zThe list of recorded warnings.©rX   ©rN   s    r
   ÚlistzWarningsRecorder.list†   s   € ð ŒzÐr   c                 ó   — | j         |         S )z Get a recorded warning by index.r[   )rN   Úis     r
   Ú__getitem__zWarningsRecorder.__getitem__‹   s   € àŒz˜!Œ}Ðr   c                 ó*   — t          | j        ¦  «        S )z&Iterate through the recorded warnings.)ÚiterrX   r\   s    r
   Ú__iter__zWarningsRecorder.__iter__�   s   € å�D”JÑÔÐr   c                 ó*   — t          | j        ¦  «        S )z The number of recorded warnings.)ÚlenrX   r\   s    r
   Ú__len__zWarningsRecorder.__len__“   s   € å�4”:‰ŒÐr   c                 óÀ   — t          | j        ¦  «        D ]6\  }}t          |j        |¦  «        r| j                             |¦  «        c S Œ7d}t          d|z  ¦  «        ‚)z>Pop the first recorded warning, raise exception if not exists.Tz%r not found in warning list)Ú	enumeraterX   r&   r   Úpopr/   )rN   Úclsr_   Úwr2   s        r
   ri   zWarningsRecorder.pop—   sl   € å˜dœjÑ)Ô)ð 	)ð 	)‰DˆAˆqÝ˜!œ* cÑ*Ô*ð )Ø”z—~’~ aÑ(Ô(Ð(Ð(Ð(ð)à ÐÝÐ;¸cÑAÑBÔBÐBr   c                 ó   — g | j         dd…<   dS )z$Clear the list of recorded warnings.Nr[   r\   s    r
   ÚclearzWarningsRecorder.clearŸ   s   € àˆŒ
�1�1�1‰ˆˆr   c                 ó  ‡ — ‰ j         rd}t          d‰ z  ¦  «        ‚d‰ _         ‰ j        j        ‰ _        ‰ j        d d …         ‰ j        _        ‰ j        j        ‰ _        	 dˆ fd„	}|‰ j        _        ‰ j                             d¦  «         ‰ S )NTzCannot enter %r twicec           
      ó–   •— ‰j                              t          | |||||¦  «        ¦  «         ‰                     | |||||¬¦  «         d S )N)rL   rM   )rX   r   rH   Ú_showwarning)r   r   rJ   rK   rL   rM   rN   s         €r
   Úshowwarningz/WarningsRecorder.__enter__.<locals>.showwarning¬   sv   ø€ àŒJ×Ò�oØ˜ 8¨V°T¸4ñAô Añ Bô Bð Bð ×ÒØ˜ 8¨V¸$ÀTð ñ Kô Kð Kð Kð Kr   Úalways©NN)rW   ÚRuntimeErrorrV   ÚfiltersÚ_filtersrq   rp   r   )rN   r2   rq   s   `  r
   Ú	__enter__zWarningsRecorder.__enter__£   s®   ø€ ØŒ=ð 	?Ø $ÐÝÐ6¸Ñ=Ñ>Ô>Ð>ØˆŒØœÔ,ˆŒØ#œ}¨Q¨Q¨QÔ/ˆŒÔØ œLÔ4ˆÔð )-ð	Kð 	Kð 	Kð 	Kð 	Kð 	Kð $/ˆŒÔ ð 	Œ×!Ò! (Ñ+Ô+Ð+Øˆr   c                 ó€   — | j         sd}t          d| z  ¦  «        ‚| j        | j        _        | j        | j        _        d S )NTz%Cannot exit %r without entering first)rW   rt   rv   rV   ru   rp   rq   )rN   Úexc_infor2   s      r
   Ú__exit__zWarningsRecorder.__exit__¼   sF   € ØŒ}ð 	OØ $ÐÝÐFÈÑMÑNÔNÐNØ#œ}ˆŒÔØ#'Ô#4ˆŒÔ Ð Ð r   r   )rP   rQ   rR   Ú__doc__rO   Úpropertyr]   r`   rc   rf   r!   ri   rm   rw   rz   r   r   r
   r   r   {   sÄ   € € € € € ðð ð
ð ð ð ð
 ðð ñ „Xððð ð ð ð  ð  ðð ð ð ð Cð Cð Cð Cðð ð ðð ð ð25ð 5ð 5ð 5ð 5r   r   c                   ó*   ‡ — e Zd Zdˆ fd„	Zˆ fd„Zˆ xZS )r+   Nc                 óz  •— t          t          | ¦  «                             |¬¦  «         d}t          |t          ¦  «        r9|D ]5}t          j        |¦  «        st          |t          |¦  «        z  ¦  «        ‚Œ6n9t          j        |¦  «        r|f}n!|�t          |t          |¦  «        z  ¦  «        ‚|| _	        d S )N)rY   zDexceptions must be old-style classes or derived from Warning, not %s)
Úsuperr+   rO   r    ÚtupleÚinspectÚisclassÚ	TypeErrorÚtyper   )rN   r   rY   ÚmsgÚexcr"   s        €r
   rO   zWarningsChecker.__init__Å   sÒ   ø€ Ý�o˜tÑ$Ô$×-Ò-°VÐ-Ñ<Ô<Ð<ð.ˆåÐ&­Ñ.Ô.ð 	:Ø'ð 5ð 5�Ý” sÑ+Ô+ð 5Ý# C­$¨s©)¬)¡OÑ4Ô4Ð4ð5ð5õ Œ_Ð-Ñ.Ô.ð 	:Ø 0Ð2ÐÐØÐ)Ý˜C¥$Ð'7Ñ"8Ô"8Ñ8Ñ9Ô9Ð9à 0ˆÔÐÐr   c                 óò   •‡ —  t          t          ‰ ¦  «        j        |Ž  t          d„ |D ¦   «         ¦  «        r:‰ j        �5t          ˆ fd„‰ D ¦   «         ¦  «        sd}t          j        d¦  «         d S d S d S d S )Nc              3   ó   K  — | ]}|d u V — Œ	d S r   r   )r'   Úas     r
   r*   z+WarningsChecker.__exit__.<locals>.<genexpr>Ù   s&   è è € Ð+Ð+˜Qˆq�DˆyÐ+Ð+Ð+Ð+Ð+Ð+r   c              3   ó4   •K  — | ]}|j         ‰j        v V — Œd S r   )r   r   )r'   ÚrrN   s     €r
   r*   z+WarningsChecker.__exit__.<locals>.<genexpr>Û   s-   øè è € ÐMÐMÀ1˜1œ:¨Ô)>Ð>ÐMÐMÐMÐMÐMÐMr   TzDID NOT WARN)r   r+   rz   Úallr   r.   ÚpytestÚfail)rN   ry   r2   r"   s   `  €r
   rz   zWarningsChecker.__exit__Õ   s£   øø€ Ø-��o˜tÑ$Ô$Ô-¨xÐ8Ð8õ Ð+Ð+ (Ð+Ñ+Ô+Ñ+Ô+ð 	0ØÔ$Ð0ÝÐMÐMÐMÐMÈÐMÑMÔMÑMÔMð 0Ø(,Ð%Ý”K Ñ/Ô/Ð/Ð/Ð/ð		0ð 	0Ø0Ð0ð0ð 0r   rs   )rP   rQ   rR   rO   rz   Ú__classcell__)r"   s   @r
   r+   r+   Ä   sV   ø€ € € € € ð1ð 1ð 1ð 1ð 1ð 1ð 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0r   r+   r   )r{   r�   Ú_pytest._coder;   r?   r6   r   r�   Úyield_fixturer   r   r   r   ÚobjectrH   r   r+   r   r   r
   ú<module>r“      s)  ðØ :Ð :à €€€à Ð Ð Ð Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø €€€ð Ôðð ñ Ôððð ð ð
*ð *ð *ð *ðZ -ð  -ð  -ðFð ð ð ð �fñ ô ð ðF5ð F5ð F5ð F5ð F5�vñ F5ô F5ð F5ðR0ð 0ð 0ð 0ð 0Ð&ñ 0ô 0ð 0ð 0ð 0r   