bgPddlmZddlmZddlmZmZmZddlm Z m Z ee ee fZ dZ GddeZGdd Zed efd Zd S) )contextmanagerwraps)UnionTypeCallable)diffcomparea+ :param exception: This can be one of the following: * `None`, indicating that an exception must be raised, but the type is unimportant. * An exception class, indicating that the type of the exception is important but not the parameters it is created with. * An exception instance, indicating that an exception exactly matching the one supplied should be raised. :param unless: Can be passed a boolean that, when ``True`` indicates that no exception is expected. This is useful when checking that exceptions are only raised on certain versions of Python. c:eZdZdezZdZd dedefdZdZ dZ dS) ShouldRaisezs This context manager is used to assert that an exception is raised within the context it is managing. NF exceptionunlessc$||_| |_dSN)r expectedselfr rs i/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/testfixtures/shouldraise.py__init__zShouldRaise.__init__*s""  c|Sr)rs r __enter__zShouldRaise.__enter__.s rcJd}||_|jr|jru|Zt|jtrt |}|j|urdSn%t |jt |urdSt |j|ddn|st dn|rdSdS)NTFrraisedx_labely_labelzNo exception raised!)rrr isinstancetyper AssertionError)rtype_actual traceback__tracebackhide__s r__exit__zShouldRaise.__exit__1s  = ~ =%!$.$77)!%f>77#(58 //tF||CC#(5 * (***** =$%;<<< =  5tr)NF) __name__ __module__ __qualname__ param_docs__doc__rExceptionOrTypeboolrrr&rrrr r sq GF##/#$####rr c:eZdZdezZd dedefdZdedefdZ dS) should_raisez A decorator to assert that the decorated function will raised an exception. An exception class or exception instance may be passed to check more specifically exactly what exception will be raised. Nr rc"||_||_dSr)r rrs rrzshould_raise.__init__Qs" rtargetreturnc@tfd}|S)Nc~tjj5|i|ddddS#1swxYwYdSr)r r r)argskwrr1s r_should_raise_wrapperz4should_raise.__call__.._should_raise_wrapperWsT^T[99 $ $#### $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s 266r)rr1r7s`` r__call__zshould_raise.__call__Us: v $ $ $ $ $  $%$r)NN) r'r(r)r*r+r,r-rrr8rrrr/r/Isn  G/$%x%H%%%%%%rr/ expected_textc #K dVtd|z#t$r@}t|}||kr tt||ddYd}~dSd}~wwxYw)zo A context manager to check that an :class:`AssertionError` is raised and its text is as expected. Nz)Expected AssertionError(%r), None raised!rr#r)r!strr )r9e actual_texts r ShouldAssertr>_s , H*+,, , MMM!ff K ' ' m[.8("L"L"LMM M ( ' ' ' ' 'Ms A$5AA$N) contextlibr functoolsrtypingrrr testfixturesr r Exceptionr,r*objectr r/r;r>rrrrEs%%%%%%((((((((((&&&&&&&& 4 ?23 ,&&&&&&&&&R%%%%%%%%,,,,,,,,r