j7i(ddlmZddlmZddlmZddlZddlmZddlZddlm Z ddl m Z ddl m Z dd l m Z dd l mZdd l mZdd l mZdd l mZddl mZddl mZddlZddlmZddlmZddlmZddlmZerBddlmZddlmZddl Z ddl m!Z!ddl"m#Z#ddl"m$Z$e#dZ%e$de&e&dZ'e$de&e&Z(nddl m$Z$e$de&dZ'e$d e&dZ)e$d!e&"Z*e$d#e&"Z+e$d$e,"Z-e$d%e,"Z.ej^d&kr dd'l0m1Z1dd(l0m2Z2ejfd)jhZ5ed*d*d+ dDd,Z6ed*d- dEd.Z6edFd/Z6e dGd0Z6 dH dId1Z6ejXe6_,dJd2Z7dKd3Z8dLd4Z9 dMd5Z: dNd6Z;dOd7Ze Gd;de'Z?e Gd=d>e>e1e)Z@e Gd?d@ZAGdAdBZBdHdPdCZCy)Q) annotations)ABC)abstractmethodN)Pattern)indent)Any)cast)final)Generic)get_args) get_origin)Literal)overload) TYPE_CHECKING) ExceptionInfo)stringify_exception)fail) PytestWarning)Callable)Sequence) TypeGuard) ParamSpec)TypeVarPBaseExcT_co_defaultT)bounddefault covariantE)rr)rr BaseExcT_co BaseExcT_1)r BaseExcT_2ExcT_1ExcT_2) )BaseExceptionGroup)ExceptionGroup.matchcheckcyN)expected_exceptionr+r,s W/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/_pytest/raises.pyraisesr2Is r,cyr.r/r*s r1r2r2Rs #r3cyr.r/r4s r1r2r2[sSVr3cyr.r/)r0funcargskwargss r1r2r2_s r3cd}|sXt|hdz r/d}|djt|z }|dz }t|| t d i|St |fi|S|st d|d|d }t |st|d t|d t |5}||d di|ddd ~S#1swY xYw#~wxYw)aAssert that a code block/function call raises an exception type, or one of its subclasses. :param expected_exception: The expected exception type, or a tuple if one of multiple possible exception types are expected. Note that subclasses of the passed exceptions will also match. This is not a required parameter, you may opt to only use ``match`` and/or ``check`` for verifying the raised exception. :kwparam str | re.Pattern[str] | None match: If specified, a string containing a regular expression, or a regular expression object, that is tested against the string representation of the exception and its :pep:`678` `__notes__` using :func:`re.search`. To match a literal string that may contain :ref:`special characters `, the pattern can first be escaped with :func:`re.escape`. (This is only used when ``pytest.raises`` is used as a context manager, and passed through to the function otherwise. When using ``pytest.raises`` as a function, you can use: ``pytest.raises(Exc, func, match="passed on").match("my pattern")``.) :kwparam Callable[[BaseException], bool] check: .. versionadded:: 8.4 If specified, a callable that will be called with the exception as a parameter after checking the type and the match regex if specified. If it returns ``True`` it will be considered a match, if not it will be considered a failed match. Use ``pytest.raises`` as a context manager, which will capture the exception of the given type, or any of its subclasses:: >>> import pytest >>> with pytest.raises(ZeroDivisionError): ... 1/0 If the code block does not raise the expected exception (:class:`ZeroDivisionError` in the example above), or no exception at all, the check will fail instead. You can also use the keyword argument ``match`` to assert that the exception matches a text or regex:: >>> with pytest.raises(ValueError, match='must be 0 or None'): ... raise ValueError("value must be 0 or None") >>> with pytest.raises(ValueError, match=r'must be \d+$'): ... raise ValueError("value must be 42") The ``match`` argument searches the formatted exception string, which includes any `PEP-678 `__ ``__notes__``: >>> with pytest.raises(ValueError, match=r"had a note added"): # doctest: +SKIP ... e = ValueError("value must be 42") ... e.add_note("had a note added") ... raise e The ``check`` argument, if provided, must return True when passed the raised exception for the match to be successful, otherwise an :exc:`AssertionError` is raised. >>> import errno >>> with pytest.raises(OSError, check=lambda e: e.errno == errno.EACCES): ... raise OSError(errno.EACCES, "no permission to view") The context manager produces an :class:`ExceptionInfo` object which can be used to inspect the details of the captured exception:: >>> with pytest.raises(ValueError) as exc_info: ... raise ValueError("value must be 42") >>> assert exc_info.type is ValueError >>> assert exc_info.value.args[0] == "value must be 42" .. warning:: Given that ``pytest.raises`` matches subclasses, be wary of using it to match :class:`Exception` like this:: # Careful, this will catch ANY exception raised. with pytest.raises(Exception): some_function() Because :class:`Exception` is the base class of almost all exceptions, it is easy for this to hide real bugs, where the user wrote this expecting a specific exception, but some other exception is being raised due to a bug introduced during a refactoring. Avoid using ``pytest.raises`` to catch :class:`Exception` unless certain that you really want to catch **any** exception raised. .. note:: When using ``pytest.raises`` as a context manager, it's worthwhile to note that normal context manager rules apply and that the exception raised *must* be the final line in the scope of the context manager. Lines of code after that, within the scope of the context manager will not be executed. For example:: >>> value = 15 >>> with pytest.raises(ValueError) as exc_info: ... if value > 10: ... raise ValueError("value must be <= 10") ... assert exc_info.type is ValueError # This will not execute. Instead, the following approach must be taken (note the difference in scope):: >>> with pytest.raises(ValueError) as exc_info: ... if value > 10: ... raise ValueError("value must be <= 10") ... >>> assert exc_info.type is ValueError **Expecting exception groups** When expecting exceptions wrapped in :exc:`BaseExceptionGroup` or :exc:`ExceptionGroup`, you should instead use :class:`pytest.RaisesGroup`. **Using with** ``pytest.mark.parametrize`` When using :ref:`pytest.mark.parametrize ref` it is possible to parametrize tests such that some runs raise an exception and others do not. See :ref:`parametrizing_conditional_raising` for an example. .. seealso:: :ref:`assertraises` for more examples and detailed discussion. **Legacy form** It is possible to specify a callable by passing a to-be-called lambda:: >>> raises(ZeroDivisionError, lambda: 1/0) or you can specify an arbitrary callable with arguments:: >>> def f(x): return 1/x ... >>> raises(ZeroDivisionError, f, 0) >>> raises(ZeroDivisionError, f, x=0) The form above is fully supported but discouraged for new code because the context manager form is regarded as more readable and less error-prone. .. note:: Similar to caught exception objects in Python, explicitly clearing local references to returned ``ExceptionInfo`` objects can help the Python interpreter speed up its garbage collection. Clearing those references breaks a reference cycle (``ExceptionInfo`` --> caught exception --> frame stack raising the exception --> current frame stack --> local variables --> ``ExceptionInfo``) which makes Python keep all objects referenced from that cycle (including all local variables in the current frame) alive until the next cyclic garbage collection run. More detailed information can be found in the official Python documentation for :ref:`the try statement `. T>r,r+r0z6Unexpected keyword arguments passed to pytest.raises: , z" Use context-manager form instead?NzCExpected an exception type or a tuple of exception types, but got `z`. Raising exceptions is already understood as failing the test, so you don't need any special code to say 'this should never raise an exception'.rz object (type: z) must be callabler/)setjoinsorted TypeError RaisesExc ValueErrorcallabletype)r0r9r:__tracebackhide__msgr8excinfos r1r2r2hs R  v;A AJC 499VF^, ,C 8 8CC.  %&v& &+6v66 QRdQghN O  7D D>4(/$t*=OPQQ % &"' d12h!&!"  "" s# B;8C;CC cD|jtk(r |jS|S)zJHelper function to remove redundant `re.compile` calls when printing regex)flags_REGEX_NO_FLAGSpattern)r+s r1_match_patternrM:s!KK?:5==EEr3ct|S)zjGet the repr of a ``check`` parameter. Split out so it can be monkeypatched (e.g. by hypothesis) )repr)funs r1 repr_callablerQ?s 9r3cd|zdzS)N`r/ss r1 backquoterVGs 7S=r3ct|tr |jSt|dk(r|djSddj d|DzdzS)Nr=r(r<c34K|]}|jywr.)__name__).0ees r1 z'_exception_type_name..Rs322;;3s)) isinstancerErZlenr?es r1_exception_type_namercKsP!Tzz 1v{t}} 333 3c 99r3c||dk(ryt||ssttt|dz}tt|}t|tr(t|trt |tsd|d|S|d|Sy)Nr/z()zUnexpected nested z , expected z is not an instance of )r_rVrcrEr' issubclass) expected_type exceptionactual_type_strexpected_type_strs r1_check_raw_typerjUs  3  $$8i$ID$PQ%&:=&IJ y"4 5=$/}.@A''8 DUCVW W!""9:K9LMM r3cHdtfdtD S)Nz {}()+.*?^$[]c3TK|]\}}|vxr|dk(xs |dz dk7!yw)rr=\Nr/)r[icmetacharactersrUs r1r]z#is_fully_escaped..os=AG!Q^<a!;1QU8t+;<s%()any enumerate)rUrps`@r1is_fully_escapedrsls,#NKTUV< r3c0tjdd|S)Nz\\([{}()+-.*?^$\[\]\s\\])z\1)resubrTs r1unescaperwts 66.q 99r3ceZdZdZ d dZ d dZed dZ d dZd dZ e ddZ y)AbstractRaiseszFABC with common functionality shared between RaisesExc and RaisesGroupcft|trSd} tj||_|t d||dk(r(tjtddn||_d|_ t|ts#t|trb|jtk(rOt|tr |j}|r1|ddk(r)|dd k(r!t|d drt!|d d|_ ||_d|_d |_d |_y#tj $r }|}Yd}~d}~wwxYw) Nz+Invalid regex pattern provided to 'match': r)zmatching against an empty string will *always* pass. If you want to check for an empty message you need to pass '^$'. If you don't want to match you should pass `None` or leave out the parameter.) stacklevelr^$r=F)r_strrucompiler+errorrwarningswarnrrawmatchrrJrKrLrsrwr, _fail_reason_nestedis_baseexception)selfr+r,re_errorrbs r1__init__zAbstractRaises.__init__s" eS !H 24**U2C #B8*MN{ ![ ! DJ%) eS ! ug &5;;/+I%) !HO"I$$U1R[1 (q 5  (,# !&O88  sDD0$D++D0ct|tr)t|trt|tsd|_|St |}|rt|trt|d}t|tr|ttfvst|tr<|ttfvr.t|tsd|_ttt|Std|dd|d}t|trt||jzt|tr$t|dt|jzt|t!t|jz)NTrzoOnly `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseException]` are accepted as generic types but got `z`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`. Expected , but got zan exception instance: )r_rEre BaseException Exceptionrr r'r r(rr r!rCrZrArO)rexcexpected origin_excexc_typerGs r1 _parse_exczAbstractRaises._parse_excsF c4 Z]%Cc9-(,%J2>AUC*+(:. c4 Scll%567 7 c= )C$;DI!!/ !; >?!!6 9 ;  $** %)> >   !N N r3cy)zCheck if an exception matches the requirements of this AbstractRaises. If it fails, :meth:`AbstractRaises.fail_reason` should be set. Nr/rrgs r1matcheszAbstractRaises.matchessr3N)r+str | Pattern[str] | Noner,z$Callable[[BaseExcT_co], bool] | NonereturnNone)rz%type[BaseExcT_1] | types.GenericAliasrrrztype[BaseExcT_1])r str | None)rAbstractRaises[BaseExcT_1]rgr!rbool)rbrrr)rrrgrrzTypeGuard[BaseExcT_1]) rZ __module__ __qualname____doc__rrpropertyrrrrrr/r3r1ryry~sP2&)2&4 2&  2&h#88#8DG#8 #8J!! (    !F ( 5B   r3ryceZdZdZeddd ddZedd ddZeddZ dddd dfd Z dd Zdd Zdd Zdd Z ddZ xZ S)rBa .. versionadded:: 8.4 This is the class constructed when calling :func:`pytest.raises`, but may be used directly as a helper class with :class:`RaisesGroup` when you want to specify requirements on sub-exceptions. You don't need this if you only want to specify the type, since :class:`RaisesGroup` accepts ``type[BaseException]``. :param type[BaseException] | tuple[type[BaseException]] | None expected_exception: The expected type, or one of several possible types. May be ``None`` in order to only make use of ``match`` and/or ``check`` The type is checked with :func:`isinstance`, and does not need to be an exact match. If that is wanted you can use the ``check`` parameter. :kwparam str | Pattern[str] match: A regex to match. :kwparam Callable[[BaseException], bool] check: If specified, a callable that will be called with the exception as a parameter after checking the type and the match regex if specified. If it returns ``True`` it will be considered a match, if not it will be considered a failed match. :meth:`RaisesExc.matches` can also be used standalone to check individual exceptions. Examples:: with RaisesGroup(RaisesExc(ValueError, match="string")) ... with RaisesGroup(RaisesExc(check=lambda x: x.args == (3, "hello"))): ... with RaisesGroup(RaisesExc(check=lambda x: type(x) is ValueError)): ... .r*cyr.r/)rr0r+r,s r1rzRaisesExc.__init__Kr3r4cyr.r/)rr+r,s r1rzRaisesExc.__init__Wr3cyr.r/)rr,s r1rzRaisesExc.__init__asNQr3Nct||t|tr|}n|d}n|f}|dk(r| | t dtfd|D_d_y)Nr*r/z4You must specify at least one parameter to match on.c3DK|]}j|dyw)za BaseException type)rN)rr[rbrs r1r]z%RaisesExc.__init__..ys')  OOA(>O ?) s F)superrr_tuplerCexpected_exceptions_just_propagate)rr0r+r,r __class__s` r1rzRaisesExc.__init__ds} uE2 (% 0"4   '"$ #5"7  2 %5=U]ST T#() () $  %r3cd|_|d|_y|j|sd|_y|j|sy|j |S)aCheck if an exception matches the requirements of this :class:`RaisesExc`. If it fails, :attr:`RaisesExc.fail_reason` will be set. Examples:: assert RaisesExc(ValueError).matches(my_exception): # is equivalent to assert isinstance(my_exception, ValueError) # this can be useful when checking e.g. the ``__cause__`` of an exception. with pytest.raises(ValueError) as excinfo: ... assert RaisesExc(SyntaxError, match="foo").matches(excinfo.value.__cause__) # above line is equivalent to assert isinstance(excinfo.value.__cause__, SyntaxError) assert re.search("foo", str(excinfo.value.__cause__) Fexception is NoneT)rr _check_typerrrs r1rzRaisesExc.matchessX, %   3D  *#'D   +  ++r3c\g}|jr$|jt|j|j'|jdt |j|j '|jdt |j ddj|dS)Nmatch=check=z RaisesExc(r<r^)rappendrcr+rMr,rQr?)r parameterss r1__repr__zRaisesExc.__repr__s  # #   243K3KL M :: !    367  :: !   }TZZ'@&AB CDIIj12!44r3cTt|j||_|jduSr.)rjrrrs r1rzRaisesExc._check_types(+D,D,DiP  D((r3cLtj|_|jSr.r for_laterrHrs r1 __enter__zRaisesExc.__enter__s;H;R;R;T ||r3cd}|b|js tdt|jdkDrtd|jtd|jd|jJd|j |s"|j ryt |jtd |||f}|jj|y) NTzDID NOT RAISE any exceptionr=zDID NOT RAISE any of zDID NOT RAISE r:Internal error - should have been constructed in __enter__FzJtuple[type[BaseExcT_co_default], BaseExcT_co_default, types.TracebackType]) rrr`rHrrAssertionErrorrr fill_unfilled)rrexc_valexc_tbrFexc_infos r1__exit__zRaisesExc.__exit__s !  ++234++,q0,T-E-E,HIJ >$":":1"=!@A B||' H '||G$## !2!23 3 X w '  ""8,r3)r0zAtype[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...]r+rr,,Callable[[BaseExcT_co_default], bool] | Nonerr)rRaisesExc[BaseException]r+rr,z&Callable[[BaseException], bool] | Nonerr)r,Callable[[BaseException], bool]rrr.)r0zHtype[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] | Noner+rr,r)rgBaseException | NonerTypeGuard[BaseExcT_co_default]rr)rgrrr)rz"ExceptionInfo[BaseExcT_co_default]rztype[BaseException] | Nonerrrztypes.TracebackType | Nonerr) rZrrrrrrrrrr __classcell__rs@r1rBrBs%%Z,/>A  N ) <    9< &)  6  QQ  %,0>B% U%)%<%8!,'!, (!,F 5) ,&+   r3rBc eZdZdZedd d dZeddd d!dZeddd d"dZeddd d#d Zeddd d$d Zeddd d%d Zeddd d&d Zeddd d'd Zddddd d(fdZ d)fd Ze d*dZe d+dZd,dZd-dZ d.dZ e d/dZ e d0dZ d1dZ e d2dZ e d3dZ e d4dZe d5dZ d6dZ d7dZd-dZxZS)8 RaisesGroupad .. versionadded:: 8.4 Contextmanager for checking for an expected :exc:`ExceptionGroup`. This works similar to :func:`pytest.raises`, but allows for specifying the structure of an :exc:`ExceptionGroup`. :meth:`ExceptionInfo.group_contains` also tries to handle exception groups, but it is very bad at checking that you *didn't* get unexpected exceptions. The catching behaviour differs from :ref:`except* `, being much stricter about the structure by default. By using ``allow_unwrapped=True`` and ``flatten_subgroups=True`` you can match :ref:`except* ` fully when expecting a single exception. :param args: Any number of exception types, :class:`RaisesGroup` or :class:`RaisesExc` to specify the exceptions contained in this exception. All specified exceptions must be present in the raised group, *and no others*. If you expect a variable number of exceptions you need to use :func:`pytest.raises(ExceptionGroup) ` and manually check the contained exceptions. Consider making use of :meth:`RaisesExc.matches`. It does not care about the order of the exceptions, so ``RaisesGroup(ValueError, TypeError)`` is equivalent to ``RaisesGroup(TypeError, ValueError)``. :kwparam str | re.Pattern[str] | None match: If specified, a string containing a regular expression, or a regular expression object, that is tested against the string representation of the exception group and its :pep:`678` `__notes__` using :func:`re.search`. To match a literal string that may contain :ref:`special characters `, the pattern can first be escaped with :func:`re.escape`. Note that " (5 subgroups)" will be stripped from the ``repr`` before matching. :kwparam Callable[[E], bool] check: If specified, a callable that will be called with the group as a parameter after successfully matching the expected exceptions. If it returns ``True`` it will be considered a match, if not it will be considered a failed match. :kwparam bool allow_unwrapped: If expecting a single exception or :class:`RaisesExc` it will match even if the exception is not inside an exceptiongroup. Using this together with ``match``, ``check`` or expecting multiple exceptions will raise an error. :kwparam bool flatten_subgroups: "flatten" any groups inside the raised exception group, extracting all exceptions inside any nested groups, before matching. Without this it expects you to fully specify the nesting structure by passing :class:`RaisesGroup` as expected parameter. Examples:: with RaisesGroup(ValueError): raise ExceptionGroup("", (ValueError(),)) # match with RaisesGroup( ValueError, ValueError, RaisesExc(TypeError, match="^expected int$"), match="^my group$", ): raise ExceptionGroup( "my group", [ ValueError(), TypeError("expected int"), ValueError(), ], ) # check with RaisesGroup( KeyboardInterrupt, match="^hello$", check=lambda x: isinstance(x.__cause__, ValueError), ): raise BaseExceptionGroup("hello", [KeyboardInterrupt()]) from ValueError # nested groups with RaisesGroup(RaisesGroup(ValueError)): raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) # flatten_subgroups with RaisesGroup(ValueError, flatten_subgroups=True): raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) # allow_unwrapped with RaisesGroup(ValueError, allow_unwrapped=True): raise ValueError :meth:`RaisesGroup.matches` can also be used directly to check a standalone exception group. The matching algorithm is greedy, which means cases such as this may fail:: with RaisesGroup(ValueError, RaisesExc(ValueError, match="hello")): raise ExceptionGroup("", (ValueError("hello"), ValueError("goodbye"))) even though it generally does not care about the order of the exceptions in the group. To avoid the above you should specify the first :exc:`ValueError` with a :class:`RaisesExc` as well. .. note:: When raised exceptions don't match the expected ones, you'll get a detailed error message explaining why. This includes ``repr(check)`` if set, which in Python can be overly verbose, showing memory locations etc etc. If installed and imported (in e.g. ``conftest.py``), the ``hypothesis`` library will monkeypatch this output to provide shorter & more readable repr's. F)flatten_subgroupscyr.r/)rr0allow_unwrappedrs r1rzRaisesGroup.__init__Nrr3Nr*cyr.r/)rr0rr+r,other_exceptionss r1rzRaisesGroup.__init__Ysr3cyr.r/rr0r+r,rs r1rzRaisesGroup.__init__irr3cyr.r/rs r1rzRaisesGroup.__init__srr3cyr.r/rs r1rzRaisesGroup.__init__}rr3cyr.r/rs r1rzRaisesGroup.__init__rr3cyr.r/rs r1rzRaisesGroup.__init__rr3cyr.r/rs r1rzRaisesGroup.__init__s$r3)rrr+r,c td|}t |||_|_d_|r |r t d|rt|tr t d|r|| t dtfd|g|D_ y)NzVCallable[[BaseExceptionGroup[ExcT_1|BaseExcT_1|BaseExceptionGroup[BaseExcT_2]]], bool]r*FzYou cannot specify multiple exceptions with `allow_unwrapped=True.` If you want to match one of multiple possible exceptions you should use a `RaisesExc`. E.g. `RaisesExc(check=lambda e: isinstance(e, (...)))`z`allow_unwrapped=True` has no effect when expecting a `RaisesGroup`. You might want it in the expected `RaisesGroup`, or `flatten_subgroups=True` if you don't care about the structure.ax`allow_unwrapped=True` bypasses the `match` and `check` parameters if the exception is unwrapped. If you intended to match/check the exception you should use a `RaisesExc` object. If you want to match/check the exceptiongroup when the exception *is* wrapped you need to do e.g. `if isinstance(exc.value, ExceptionGroup): assert RaisesGroup(...).matches(exc.value)` afterwards.c3BK|]}j|dyw)z/a BaseException type, RaisesExc, or RaisesGroupN)_parse_excgrouprs r1r]z'RaisesGroup.__init__..s'   $U V s) r rrrrrrCr_rrr)rr0rrr+r,rrs` r1rzRaisesGroup.__init__s* d   uE2.'8 % /J  z*? @ :: ! KK&tzz!: ;< =diio.a00 s.Dcg}|D]N}t|tr+|j|j|j>|j |P|S)z!Used if `flatten_subgroups=True`.)r_r'extend_unroll_exceptions exceptionsr)rrresrs r1rzRaisesGroup._unroll_exceptions6sR $& C#12 4223>>BC 3   r3cyr.r/rs r1rzRaisesGroup.matchesDs-0r3cyr.r/rs r1rzRaisesGroup.matchesIs58r3c \d|_|d|_yt|tsdt|jd}t |j dkDr||_y|j|j d|}| |jry| |d |_y|jr||_y||_y|j}|jr|j|}|j|stt|j|_|j}t |t |j cxk(rdk(rnnt|j dx}trt|dx}|r|j|ru|jJd |j|cxurJJ|xjd |j!|d |jd t#|jdz c_y||_y|j%||stt|j|_|jJ|j}|jszt'd|j Ds^t'd|DrL|j%||j|jr!d|jvrdnd}|d|dz|_y||_y|j)|stt|jdt|jz} t |t |j cxk(rdk(rann^t|j dx}tr?|j)|dr+| d|j!|d|jdz|_y| |_yy)a0Check if an exception matches the requirements of this RaisesGroup. If it fails, `RaisesGroup.fail_reason` will be set. Example:: with pytest.raises(TypeError) as excinfo: ... assert RaisesGroup(ValueError).matches(excinfo.value.__cause__) # the above line is equivalent to myexc = excinfo.value.__cause assert isinstance(myexc, BaseExceptionGroup) assert len(myexc.exceptions) == 1 assert isinstance(myexc.exceptions[0], ValueError) NrFrSz()` is not an exception groupr=rTz-, but would match with `allow_unwrapped=True`z$can't be None if _check_match failedz but matched the expected `z*`. You might want `RaisesGroup(RaisesExc(z, match=z))`c3<K|]}t|tywr.)r_rr[rbs r1r]z&RaisesGroup.matches..s34Jq+.c3<K|]}t|tywr.)r_r'rs r1r]z&RaisesGroup.matches..sUa 1&89Urr r)z-Did you mean to use `flatten_subgroups=True`?z on the z', but did return True for the expected z'. You might want RaisesGroup(RaisesExc(z, check=<...>)))rr_r'rErZr`r_check_expectedrrrrrr rr+_repr_expectedrM_check_exceptionsrqr) rrg not_group_msgractual_exceptions old_reasonractualrreasons r1rzRaisesGroup.matchesOs$!   3D )%78 Y 8 899VWM4++,q0$1!&&t'?'?'BINC{t33{$o%RS! %%$'!%2!5>5I5I  ! ! $ 7 78I J   + $S$*;*; ->!>B6("OPQ! %/!  +S$++,$y/:R:R9S/TT %&#d.F.F*GL1L4+C+CA+FFxM%%&7&:;$*=d>Q>QRZ>[=\]==E=N=N%>$?@@r3cNt|tr t|St|S)zhGet the repr of an expected type/RaisesExc/RaisesGroup, but we only want the name if it's a type)r_rErcrOras r1rzRaisesGroup._repr_expecteds" a '* *Awr3cyr.r/r _exceptionr s r1r zRaisesGroup._check_exceptionss -0r3cyr.r/rs r1r zRaisesGroup._check_exceptionss 58r3c>tj|}ttt |}g}i}t jD]_\}}|D]D} j ||| } |j|| | | .|j| | ||<N|j|a|s|sydt |cxk(rt jk(rnn |rJ _ yt jD]N\}}t |D];\} } |j|| r|j|| j || =P|r!t |dt |dkDrdnddnd} |s/|j|r| d|Dcgc]}|| c}_ y|s9|j|r(d jfd |D}| d |d _ ydt |cxk(rt |k(rGnnD|j|r3|j|r"| |j|d |d _ yd}|r|d| z }d}d}|s|dz }n|s|dz }|r(|dz }|j!Dcic]\}}|| }}}|D]}|d|j#j|z }t |D]a\} } |j| |d|dt%t'| dt%j#j| zz }c|r|dz }|D]} |d||| dz }t jD]|\}}|j|| } ||vr | J| d dk7r|dz }|t)| |z }| ?|d|dt%j#|dt%t'|||z }~t jt |k(rt+|r|dz }|_ ycc}wcc}}w)z]Helper method for RaisesGroup.matches that attempts to pair up expected and actual exceptionsTr=Fz matched exceptionrUr)z. zUnexpected exception(s): r<c3ZK|]"}jj|$ywr.)rr)r[rnrs r1r]z0RaisesGroup._check_exceptions..3s/)##D$<$%'"$ ))A)AB .OE8) .**85Fu5MN""5%5;$++E2%*GEN  . &&u- .  %& G#d.F.F*G G ; #D  ))A)AB OE8$-.?$@  &%%eX6""8T%9%9(F%K  7|n.c'lQ6FsB.Or R 7#>#>?O#P!"#3CDa&q)DGI  G$A$A/$R#yy)()  $2"22bcsbttu vD  %& >#o*> >++,<=--o>#1"273E3EoVWFXZjklZm3n2o pD    2n%& &A / /A - -A  L LA,3MMOXJk)DL2I1JJab# // $ 8 8X9N OA     I IA( H 2hZ 1( ;>a@ @A#,T-E-E#F x((9O+?*?1v~T X..A;XJk)Dr+rr,z?Callable[[ExceptionGroup[ExceptionGroup[ExcT_2]]], bool] | Nonerr) rz,RaisesGroup[ExcT_1 | ExceptionGroup[ExcT_2]]r06type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2]rr?r+rr,zHCallable[[ExceptionGroup[ExcT_1 | ExceptionGroup[ExcT_2]]], bool] | Nonerr) rRaisesGroup[BaseExcT_1]r0(type[BaseExcT_1] | RaisesExc[BaseExcT_1]rrAr+rr,z7Callable[[BaseExceptionGroup[BaseExcT_1]], bool] | Nonerr) rz+RaisesGroup[BaseExceptionGroup[BaseExcT_2]]r0RaisesGroup[BaseExcT_2]rrBr+rr,zKCallable[[BaseExceptionGroup[BaseExceptionGroup[BaseExcT_2]]], bool] | Nonerr) rz8RaisesGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]]r0Btype[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2]rrCr+rr,zXCallable[[BaseExceptionGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]]], bool] | Nonerr)rzARaisesGroup[ExcT_1 | BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]]r0rCrrCrrrrr+rr,zbCallable[[BaseExceptionGroup[BaseExcT_1]], bool] | Callable[[ExceptionGroup[ExcT_1]], bool] | None)rzXtype[BaseExcT_co] | types.GenericAlias | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2]rrrzCtype[BaseExcT_co] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2])rr<rz%ExceptionInfo[ExceptionGroup[ExcT_1]])rr@rz-ExceptionInfo[BaseExceptionGroup[BaseExcT_1]])rz0ExceptionInfo[BaseExceptionGroup[BaseException]]r)rSequence[BaseException]rrD)rr<rgrr!TypeGuard[ExceptionGroup[ExcT_1]])rr@rgrr)TypeGuard[BaseExceptionGroup[BaseExcT_1]])rgrrr)rfzKtype[BaseException] | RaisesExc[BaseException] | RaisesGroup[BaseException]rgrrr)rbz3type[BaseException] | AbstractRaises[BaseException]rr)rr<rrr zSequence[Exception]rrE)rr@rrr rDrrF)rrr rDrrr)rZrrrrrrrrrr staticmethodrrr rrfrrs@r1rrsmb#( F '    ,0JNFF  )  ) H  ,0AE !<<  )  ?   ,0QU 1//  )  O   ,0  : R R  )  U     ,0IM %DD  )  G   ,0  9 3 3  )  X    ,0 !F" " ) " #8!&"'+/ != O= "= " = =  = )=  = ~"5 &"5"5 M"5H4!4 .44<%< 6<< 1 +  ! 0!0'0 +008%8'8 388 y'y yvA WA! A  AA$0!00/0 + 00 8%8!838 3 88 M!M3M  M^ , & +   D Cr3rceZdZdZy) NotCheckedz.Singleton for unchecked values in ResultHolderN)rZrrrr/r3r1rIrIs8r3rIcLeZdZdZ d dZd dZd dZd dZd dZddZ y)rzpContainer for results of checking exceptions. Used in RaisesGroup._check_exceptions and possible_match. cf|Dcgc]}|Dcgc]}t c}c}|_ycc}wcc}wr.)rIr%)rrr _s r1rzResultHolder.__init__s4@QC :;!4 5AZ 5C  5C s . ) ..c(||j||<yr.)r%)rrr results r1rzResultHolder.set_results)/ VX&r3c>|j||}|tusJ|Sr.r%rI)rrr rs r1r"zResultHolder.get_results(ll6"8,*$$$ r3c2|j||tuSr.rP)rrr s r1rzResultHolder.has_results||F#H-Z??r3c^|D](}|jD]}||tusJ||y*yNFTrP)rrrnactual_resultss r1r!z"ResultHolder.no_match_for_expectedsJ !A"&,, !%a( :::!!$,  ! ! r3cX|D]%}|j|D]}|tusJ|y'yrSrP)rr rnrs r1r z ResultHolder.no_match_for_actualsC !A||A !*,,,;  ! ! r3N)rz?tuple[type[BaseException] | AbstractRaises[BaseException], ...]r rDrr)rintr rVrNrrr)rrVr rVrr)rrVr rVrr)r list[int]rr)r rWrr) rZrrrrrr"rr!r r/r3r1rrsD     3    0 @r3rc tt}|tjk(rytfdt j|DS)NTc3\K|]#\}}|duxr|vxrt|hz%ywr.)r$)r[rnvalr%useds r1r]z!possible_match..s? Q t M M.$!**MMs),)r>r`r%rqrr)r%r[curr_rows`` r1r$r$sT |u4yH3w'' !'//(";< r3)r0type[E] | tuple[type[E], ...]r+zstr | re.Pattern[str] | Noner,zCallable[[E], bool]rz RaisesExc[E])r+zstr | re.Pattern[str]r,rrr)r,rrr) r0r]r8zCallable[..., Any]r9rr:rrzExceptionInfo[E]r.)r0z$type[E] | tuple[type[E], ...] | Noner9rr:rrz+RaisesExc[BaseException] | ExceptionInfo[E])r+z Pattern[str]rzstr | Pattern[str])rPzCallable[[BaseExcT_1], bool]rr)rUrrr)rbz5type[BaseException] | tuple[type[BaseException], ...]rr)rfzrls"   '2!/(( +)#A"  =-@A!]d m=DI \ 7 \ 7  +  +g1-"**S/'' +.!$ 5 (      .1 # # + #  # # V V 5      @DD<D DD1 D^>>F :<::O.:[ S'+.[ |{23{{|S C.!3K!@AS CS Cl999**Z r3