Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/pandas/_testing/__pycache__/_warnings.cpython-37.pyc
Назад
B �5�g5 � @ s� d dl mZ d dlmZ d dlZd dlmZmZmZ d dl Z ee ddddfdddd d �dd��Zd dd ddd�dd�Zd ddd�dd�Z dddd�dd�Zddd�dd�ZdS )� )�annotations)�contextmanagerN)�Sequence�Type�cast�alwaysTztype[Warning] | bool | None�boolz str | None)�expected_warning�check_stacklevel�raise_on_extra_warnings�matchc c sb d}t jdd��H}t �|� |V | rDttt | �} t|| ||d� |rTt|| d� W dQ R X dS )a� Context manager for running code expected to either raise a specific warning, or not raise any warnings. Verifies that the code raises the expected warning, and that it does not raise any other unexpected warnings. It is basically a wrapper around ``warnings.catch_warnings``. Parameters ---------- expected_warning : {Warning, False, None}, default Warning The type of Exception raised. ``exception.Warning`` is the base class for all warnings. To check that no warning is returned, specify ``False`` or ``None``. filter_level : str or None, default "always" Specifies whether warnings are ignored, displayed, or turned into errors. Valid values are: * "error" - turns matching warnings into exceptions * "ignore" - discard the warning * "always" - always emit a warning * "default" - print the warning the first time it is generated from each location * "module" - print the warning the first time it is generated from each module * "once" - print the warning the first time it is generated check_stacklevel : bool, default True If True, displays the line that called the function containing the warning to show were the function is called. Otherwise, the line that implements the function is displayed. raise_on_extra_warnings : bool, default True Whether extra warnings not of the type `expected_warning` should cause the test to fail. match : str, optional Match warning message. Examples -------- >>> import warnings >>> with assert_produces_warning(): ... warnings.warn(UserWarning()) ... >>> with assert_produces_warning(False): ... warnings.warn(RuntimeWarning()) ... Traceback (most recent call last): ... AssertionError: Caused unexpected warning(s): ['RuntimeWarning']. >>> with assert_produces_warning(UserWarning): ... warnings.warn(RuntimeWarning()) Traceback (most recent call last): ... AssertionError: Did not see expected warning of class 'UserWarning'. ..warn:: This is *not* thread-safe. T)�record)�caught_warningsr r r )r r N)�warnings�catch_warnings�simplefilterr r �Warning�_assert_caught_expected_warning� _assert_caught_no_extra_warnings)r Zfilter_levelr r r Z__tracebackhide__�w� r �O/home/digitalm-up/venv/lib/python3.7/site-packages/pandas/_testing/_warnings.py�assert_produces_warning s @ r z!Sequence[warnings.WarningMessage]z type[Warning]�None)r r r r �returnc C s� d}d}xV| D ]N}t |j|�rd}|r>t |jttf�r>t|� |dk rt�|t|j��rd}qW |sxt dt |j�� ���|r�|s�t dt |j�� d|� ���dS )zEAssert that there was the expected warning among the caught warnings.FTNz&Did not see expected warning of class zDid not see warning z matching )� issubclass�category� FutureWarning�DeprecationWarning�&_assert_raised_with_correct_stacklevel�re�search�str�message�AssertionError�repr�__name__)r r r r Zsaw_warningZmatched_message�actual_warningr r r r c s r )r r r c C sp g }xP| D ]H}t ||�r d}|jtkr6|t|j�kr6q |�|jj|j|j|jf� q W |rlt dt |�� ���dS )zFAssert that no extra warnings apart from the expected ones are caught.z:unclosed transport <asyncio.sslproto._SSLProtocolTransportzCaused unexpected warning(s): N)�_is_unexpected_warningr �ResourceWarningr"