OwlCyberSecurity - MANAGER
Edit File: check_raises.cpython-311.pyc
� � h � �T � d dl mZ d dlmZmZ ddlmZ dZdd �Z G d� d� � Z dS )� )�annotations)�Iterable�Any� )�log_failureF�expected_exception�type | Iterable[type]�argsr �kwargs�object�returnc �x � d}t | t � � r| f}n| }t d� |D � � � � sJ �|� dd� � }|s|r J d|� �� � �t |d|i�S |d }t |� � sJ �t |d|i�5 ||dd� i |�� ddd� � dS # 1 swxY w Y dS )a7 Check that a given callable or context raises an error of a given type. Can be used as either a context manager: >>> with raises(AssertionError): >>> raise AssertionError or as a function: >>> def raises_assert(): >>> raise AssertionError >>> raises(AssertionError, raises_assert) `expected_exception` follows the same format rules as the second argument to `issubclass`, so multiple possible exception types can be used. When args[0] is callable, the remainder of args and all of kwargs except for any called `msg` are passed to args[0] as arguments. Note that because `raises` is implemented using a context manager, the usual control flow warnings apply: within the context, execution stops on the first error encountered *and does not resume after this error has been logged*. Therefore, the line you expect to raise an error must be the last line of the context: any subsequent lines won't be executed. Pull such lines out of the context if they don't raise errors, or use more calls to `raises` if they do. This function is modeled loosely after Pytest's own `raises`, except for the latter's `match`-ing logic. We should strive to keep the call signature of this `raises` as close as possible to the other `raises`. Tc 3 �j K � | ].}t |t � � pt |t � � V � �/d S �N)� isinstance�type� issubclass� BaseException)�.0�excs �j/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/pytest_check/check_raises.py� <genexpr>zraises.<locals>.<genexpr>7 sO � � � � � �� �3����?��C��!?�!?�� � � � � � �msgNz+Unexpected kwargs for pytest_check.raises: r r )r r �all�pop�CheckRaisesContext�callable)r r r �__tracebackhide__�expected_exceptionsr �funcs r �raisesr"