f٥TddlmZddlmZmZddlmZdZdd ZGddZ dS)) annotations)IterableAny) log_failureFexpected_exceptiontype | Iterable[type]argsrkwargsobjectreturncxd}t|tr|f}n|}td|DsJ|dd}|s|r Jd|t |d|iS|d}t |sJt |d|i5||ddi|ddddS#1swxYwYdS)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`. Tc3jK|].}t|tpt|tV/dSN) isinstancetype issubclass BaseException).0excs k/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pytest_check/check_raises.py zraises..7sO  3?C!?!?msgNz+Unexpected kwargs for pytest_check.raises: rr)rrallpopCheckRaisesContextcallable)rr r __tracebackhide__expected_exceptionsrfuncs rraisesr" sdF$d++1/A.C0 &    **UD ! !C &QQQQQQQz!#6@C@@@Aw~~~ !4 ># > > & & D$qrr( %f % % % & & & & & & & & & & & & & & & & & &sB//B36B3c0eZdZdZdddd Zdd ZddZdS)ra8 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_excsrrr r Nonec"||_||_dSr)r$r)selfrr$s r__init__zCheckRaisesContext.__init__Qs*r'CheckRaisesContext'c|Sr)r's r __enter__zCheckRaisesContext.__enter__Us rexc_typeexc_valexc_tbboolcd}|t||jrdStst|jr|jn|dSdS)NTF)rr$ _stop_on_failrr)r'r-r.r/rs r__exit__zCheckRaisesContext.__exit__XsX   Jx9K$L$L  4  DH9' : : :4ur)r$rrr r r%)r r))r-rr.r r/r r r0)__name__ __module__ __qualname____doc__r(r,r3r+rrrrGsj<@rrN)rr r rr r r r) __future__rtypingrr check_logrr2r"rr+rrr;s"""""" """""" 7&7&7&7&t((((((((((r