Submit
Path:
~
/
/
opt
/
cloudlinux
/
venv
/
lib64
/
python3.11
/
site-packages
/
pytest_check
/
__pycache__
/
File Content:
check_raises.cpython-311.opt-1.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 � � d}t | t � � r| f}n| }|� dd� � }|st |d|i�S |d }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`. T�msgNr r )� isinstance�type�pop�CheckRaisesContext)r r r �__tracebackhide__�expected_exceptionsr �funcs �N/opt/cloudlinux/venv/lib/python3.11/site-packages/pytest_check/check_raises.py�raisesr s� � �F ���$�d�+�+� 1�/A�.C���0�� �*�*�U�D� !� !�C�� &�!�#6�@�C�@�@�@��A�w�� �!4� >�#� >� >� &� &��D�$�q�r�r�(�%�f�%�%�%� &� &� &� &� &� &� &� &� &� &� &� &���� &� &� &� &� &� &s �A4�4A8�;A8c �0 � e Zd ZdZdd�dd �Zdd�Zdd�ZdS )r a8 Helper context for `raises` that can be parameterized by error type. Note that CheckRaisesContext is instantiated whenever needed; it is not a global variable like `check`. Therefore, we don't need to curate `self.msg` in `__exit__` for this class like we do with CheckContextManager. N)r � expected_excsr r r r �Nonec �"