403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/_pytest/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/_pytest/__pycache__/recwarn.cpython-39.pyc
a

05d�*�	@s�dZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZed�Zee
dd�dd��Zedd�e
eeeefdd�dd ��Z ee	defeeed!�d"d ��Z d.e
e	defeeedefd!�d#d �Z ed/dd�eee!eee!dffe
eeeefd$d%�d&d'��Z"eeee!eee!dffe	defeeed(�d)d'��Z"e!fdd�eee!eee!dffee
eeeefeed$efd*�d+d'�Z"Gd,d�dej#�Z$eGd-d$�d$e$��Z%dS)0z/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)�WarningsRecorderNN��returnccsBtdd�}|� t�d�|VWd�n1s40YdS)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)Zwrec�r�3/usr/lib/python3.9/site-packages/_pytest/recwarn.py�recwarns

r!.��matchr)r#rcCsdS�Nrr"rrr �deprecated_call*sr%)�func�args�kwargsrcOsdSr$r)r&r'r(rrr r%1scOs0d}|dur|f|}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.
    TN)�warns�DeprecationWarning�PendingDeprecationWarning)r&r'r(�__tracebackhide__rrr r%8s
�WarningsChecker)�expected_warningr#rcCsdSr$r)r.r#rrr r)Xsr))r.r&r'r(rcOsdSr$r)r.r&r'r(rrr r)as)r.r'r#r(rcOs�d}|s8|r*d�t|��}td|�d���t||dd�S|d}t|�s`t|�dt|��d���t|dd	��&||d
d�i|��Wd�S1s�0YdS)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�	TypeErrorr-�callable�type)r.r#r'r(r,Zargnamesr&rrr r)ks.
�cs�eZdZdZdd�edd��fdd�Zeedd	�d
d��Ze	dd�d
d�Z
edd	�dd�Ze	d	�dd�Z
efeedd�dd�Zdd	�dd�Zdd	��fdd�Zeeeeeeedd��fdd�Z�ZS)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`.

    FrN)rrcs&t|�t�jdd�d|_g|_dS)NT)�recordF)r�super�__init__�_entered�_list)�selfr��	__class__rr r8�szWarningsRecorder.__init__zwarnings.WarningMessagercCs|jS)zThe list of recorded warnings.�r:�r;rrr �list�szWarningsRecorder.list)�ircCs
|j|S)z Get a recorded warning by index.r>)r;rArrr �__getitem__�szWarningsRecorder.__getitem__cCs
t|j�S)z&Iterate through the recorded warnings.)�iterr:r?rrr �__iter__�szWarningsRecorder.__iter__cCs
t|j�S)z The number of recorded warnings.)�lenr:r?rrr �__len__�szWarningsRecorder.__len__)�clsrcCsFt|j�D]$\}}t|j|�r
|j�|�Sq
d}t|�d���dS)z>Pop the first recorded warning, raise exception if not exists.Tz not found in warning listN)�	enumerater:�
issubclass�category�pop�AssertionError)r;rGrA�wr,rrr rK�s
zWarningsRecorder.popcCsg|jdd�<dS)z$Clear the list of recorded warnings.Nr>r?rrr �clear�szWarningsRecorder.clearcsD|jrd}td|�d���t���}|dus0J�||_t�d�|S)NTz
Cannot enter z twice�always)r9�RuntimeErrorr7�	__enter__r:rr)r;r,r:r<rr rQ�s

zWarningsRecorder.__enter__��exc_type�exc_val�exc_tbrcs4|jsd}td|�d���t��|||�d|_dS)NTzCannot exit z without entering firstF)r9rPr7�__exit__)r;rSrTrUr,r<rr rV�s
zWarningsRecorder.__exit__)�__name__�
__module__�__qualname__�__doc__�boolr8�propertyr	r@�intrBrrDrF�Warningr
rKrNrQr
�
BaseExceptionrrV�
__classcell__rrr<r r�s
�cs�eZdZedfdd�eeeeeeedffeeee	efe
dd��fdd�Zeeeeeee
dd��fd	d
�Z�ZS)r-NFr.)r.r/rrcs�t|�t�jdd�d}|dur6tjtdd�d}nVt|t�rj|D]}t|t	�sDt
|t|���qD|}n"t|t	�r||f}nt
|t|���||_||_
dS)NTrz/exceptions must be derived from Warning, not %s�)�
stacklevel)rr7r8r�warnr�
isinstance�tuplerIr^r3r5r.r/)r;r.r/r�msgZexpected_warning_tup�excr<rr r8�s 	


zWarningsChecker.__init__rRcs�t��|||�d}�fdd�}|dur�|dur�|durֈjdur�t�fdd��D��sxd}td�j�d|��d��n^�jdurֈD].}t|j�j�r�t�	�j��
t|j��r�q�q�td�j�d	�j�d
|����dS)NTcstdd��D�dd�S)NcSsg|]
}|j�qSr)�message)�.0r6rrr �
<listcomp>#�z?WarningsChecker.__exit__.<locals>.found_str.<locals>.<listcomp>�)�indentrrr?rr �	found_str"sz+WarningsChecker.__exit__.<locals>.found_strc3s|]}t|j�j�VqdSr$)rIrJr.)ri�rr?rr �	<genexpr>(rkz+WarningsChecker.__exit__.<locals>.<genexpr>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: )
r7rVr.�anyrr/rIrJ�re�compile�search�strrh)r;rSrTrUr,rnror<r?r rVs4

��
����zWarningsChecker.__exit__)rWrXrYr^r
rr
rrvrr[r8r_rrVr`rrr<r r-�s"����
�)N).)&rZrsrZpprintr�typesr�typingrrrrr	r
rrr
rrZ_pytest.compatrrZ_pytest.deprecatedrrZ_pytest.fixturesrZ_pytest.outcomesrrr!rvr%r^r)�catch_warningsrr-rrrr �<module>s�����
� ���
�
��
�?O

Youez - 2016 - github.com/yon3zu
LinuXploit