????

Your IP : 18.219.68.121


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest/__pycache__/recwarn.cpython-311.pyc

�

�܋f�*����dZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZed��Zede
dfd���Zedd�de
eeeefddfd���Z ede	defd ed!edefd"���Z 	d+de
e	defd ed!ededeffd#�Z e	d,dd�d$eee!eee!dffde
eeeefdd%fd&���Z"ed$eee!eee!dffde	defd ed!edef
d'���Z"e!fdd�d$eee!eee!dffd ede
eeeefd!eded%eff
d(�Z"Gd)�dej#��Z$eGd*�d%e$����Z%dS)-z/Record warnings during test function execution.�N��pformat)�
TracebackType)�Any)�Callable)�	Generator)�Iterator)�List)�Optional)�Pattern)�Tuple)�Type)�TypeVar)�Union)�final)�overload)�check_ispytest)�WARNS_NONE_ARG)�fixture)�fail�T�return)�WarningsRecorderNNc#�K�td���}|5tjd��|V�ddd��dS#1swxYwYdS)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 �`/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/_pytest/recwarn.py�recwarnr"s������d�+�+�+�D�	
�����i�(�(�(��
�
�
���������������������s
�;�?�?.��matchr$rc��dS�N�r#s r!�deprecated_callr(*�	���C��func�args�kwargsc��dSr&r')r+r,r-s   r!r(r(1r)r*c�N�d}|�|f|z}tttfg|�Ri|��S)a�Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning``.

    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)r+r,r-�__tracebackhide__s    r!r(r(8s@��4�����w��~���$�&?�@�R�4�R�R�R�6�R�R�Rr*�expected_warning�WarningsCheckerc��dSr&r')r4r$s  r!r0r0Xs	���Cr*c��dSr&r')r4r+r,r-s    r!r0r0as	���Cr*c��d}|sI|r5d�t|����}td|�d����t||d���S|d}t	|��s"t|�dt|���d����t|d�	��5||d
d�i|��cddd��S#1swxYwYdS)a�Assert that code raises a particular class of warning.

    Specifically, the parameter ``expected_warning`` can be a warning class or sequence
    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 raised (regardless of whether it is an ``expected_warning`` or not).

    This function can be used as a context manager, which will capture all the raised
    warnings inside it::

        >>> 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, 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_exprrrz object (type: z) must be callabler�N)�join�sorted�	TypeErrorr5�callable�type)r4r$r,r-r3�argnamesr+s       r!r0r0ksA��\���
-��	��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�5B9�<B9c���eZdZdZdd�deddf�fd�Zededfd	���Zd
e	ddfd�Z
dedfd�Zde	fd
�Z
efdeeddfd�Zdd�Zd�fd�Zdeeedeedeeddf�fd�Z�xZS)raFA 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`.

    FrrrNc���t|��t���d���d|_g|_dS)NT)�recordF)r�super�__init__�_entered�_list)�selfr�	__class__s  �r!rEzWarningsRecorder.__init__�s>����y�!�!�!�
�������%�%�%���
�46��
�
�
r*zwarnings.WarningMessagec��|jS)zThe list of recorded warnings.�rG�rHs r!�listzWarningsRecorder.list�s���z�r*�ic��|j|S)z Get a recorded warning by index.rK)rHrNs  r!�__getitem__zWarningsRecorder.__getitem__�s���z�!�}�r*c�*�t|j��S)z&Iterate through the recorded warnings.)�iterrGrLs r!�__iter__zWarningsRecorder.__iter__�s���D�J���r*c�*�t|j��S)z The number of recorded warnings.)�lenrGrLs r!�__len__zWarningsRecorder.__len__�s���4�:���r*�clsc��t|j��D]6\}}t|j|��r|j�|��cS�7d}t|�d����)z>Pop the first recorded warning, raise exception if not exists.Tz not found in warning list)�	enumeraterG�
issubclass�category�pop�AssertionError)rHrWrN�wr3s     r!r\zWarningsRecorder.pop�so���d�j�)�)�	)�	)�D�A�q��!�*�c�*�*�
)��z�~�~�a�(�(�(�(�(�
)� ����A�A�A�B�B�Br*c��g|jdd�<dS)z$Clear the list of recorded warnings.NrKrLs r!�clearzWarningsRecorder.clear�s����
�1�1�1�
�
�
r*c���|jrd}td|�d����t�����}|�J�||_tjd��|S)NTz
Cannot enter z twice�always)rF�RuntimeErrorrD�	__enter__rGrr)rHr3rGrIs   �r!rdzWarningsRecorder.__enter__�sk����=�	?� $���=�t�=�=�=�>�>�>����!�!�#�#��� � � ���
���h�'�'�'��r*�exc_type�exc_val�exc_tbc���|jsd}td|�d����t���|||��d|_dS)NTzCannot exit z without entering firstF)rFrcrD�__exit__)rHrerfrgr3rIs     �r!rizWarningsRecorder.__exit__�sY����}�	O� $���M�d�M�M�M�N�N�N�
������7�F�3�3�3���
�
�
r*)rN)rr)�__name__�
__module__�__qualname__�__doc__�boolrE�propertyr
rM�intrPr	rSrV�Warningrr\r`rdr�
BaseExceptionrri�
__classcell__�rIs@r!rr�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
����eZdZedfdd�deeeeeeedffdeeee	efde
ddf�fd	�Zd
eeedeedee
ddf�fd
�Z�xZS)r5NFrr4.r9rrc����t|��t���d���d}|�tjt
d���d}n�t
|t��r<|D]6}t|t��st|t|��z����7|}n8t|t��r|f}nt|t|��z���||_||_
dS)NTrz/exceptions must be derived from Warning, not %s�)�
stacklevel)rrDrEr�warnr�
isinstance�tuplerZrqr=r?r4r9)rHr4r9r�msg�expected_warning_tup�excrIs       �r!rEzWarningsChecker.__init__�s����	�y�!�!�!�
�����4��(�(�(�?���#��M�.�Q�7�7�7�7�#'� � �
�(�%�
0�
0�	:�'�
5�
5��!�#�w�/�/�5�#�C�$�s�)�)�O�4�4�4�5�#3� � �
�(�'�
2�
2�	:�$4�#6� � ��C�$�'7�"8�"8�8�9�9�9� 4���$����r*rerfrgc	�2���t���|||��d}�fd�}|��|��|��j��t�fd��D����s'd}t	d�j�d|���d���dS�j���D]]}t
|j�j��rAtj	�j���
t|j����rdS�^t	d�j�d�j�d|������dSdSdSdSdSdS)	NTc�:��td��D��d���S)Nc��g|]	}|j��
Sr')�message)�.0rCs  r!�
<listcomp>z?WarningsChecker.__exit__.<locals>.found_str.<locals>.<listcomp>#s��>�>�>�v�F�N�>�>�>r*�)�indentrrLs�r!�	found_strz+WarningsChecker.__exit__.<locals>.found_str"s%����>�>��>�>�>�q�I�I�I�Ir*c3�L�K�|]}t|j�j��V��dSr&)rZr[r4)r��rrHs  �r!�	<genexpr>z+WarningsChecker.__exit__.<locals>.<genexpr>(s2�����W�W�Q�:�a�j�$�2G�H�H�W�W�W�W�W�Wr*z"DID NOT WARN. No warnings of type z0 were emitted.
The list of emitted warnings is: �.z* matching the regex were emitted.
 Regex: z
 Emitted warnings: )
rDrir4�anyrr9rZr[�re�compile�search�strr�)rHrerfrgr3r�r�rIs`      �r!rizWarningsChecker.__exit__s�����	������7�F�3�3�3� ��	J�	J�	J�	J�	J�����F�N��$�0��W�W�W�W�RV�W�W�W�W�W��(,�%��K�T�=R�K�K�<E�I�K�K�K�K�K�������_�0�!�
�
��%�a�j�$�2G�H�H�&�!�z�$�/�:�:�A�A�#�a�i�.�.�Q�Q�&� %�����$�#'�#8�$�$�	
��$�$��I�K�K�$�$����������N�N�0�0�1�0r*)rjrkrlrqrrrr
r�rrnrErrrrirsrts@r!r5r5�s�������
�9=�%� �%�%�%�"��$�w�-��t�G�}�c�'9�!:�:�;�
�%�
�U�3����#4�5�6�%��%�
�%�%�%�%�%�%�:!��4�
�.�/�!��-�(�!���'�	!�

�!�!�!�!�!�!�!�!�!�!r*r&).)&rmr�r�pprintr�typesr�typingrrrr	r
rrr
rrr�_pytest.compatrr�_pytest.deprecatedrr�_pytest.fixturesr�_pytest.outcomesrrr"r�r(rqr0�catch_warningsrr5r'r*r!�<module>r�s���5�5�	�	�	�	����������������������������������������������������������������������������������� � � � � � �#�#�#�#�#�#�-�-�-�-�-�-�-�-�-�-�-�-�$�$�$�$�$�$�!�!�!�!�!�!��G�C�L�L��	�	��9�:�	�	�	�	��	�
�36�����u�S�'�#�,�.�/�0������
���
��
�3��6�
��#&��25������
���*.�S�S�
�8�C��H�%�
&�S�69�S�EH�S�
��s�"�#�S�S�S�S�@
�HK��14�����D��M�5��g���1C�+D�D�E���E�#�w�s�|�+�,�-���	���
���
���D��M�5��g���1C�+D�D�E��
�3��6�
�����	�
����
���IP�<-�15�<-�<-�<-��D��M�5��g���1C�+D�D�E�<-��<-��E�#�w�s�|�+�,�-�<-��	<-�
��c�!�"�<-�<-�<-�<-�~L�L�L�L�L�x�.�L�L�L�^�?�?�?�?�?�&�?�?���?�?�?r*