U  e)@sddlZddlZddlZd*ddZd+ddZd,ddZd-dd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZd.ddZGdddZejd/dd Zd0d!d"Zd1d#d$Zd2d&d'Zd3d(d)ZdS)4NcCs ||kst|pd||fdS)z.Assert a == b, with repr messaging on failure.z%r != %rNAssertionErrorabmsgrE/opt/hc_python/lib/python3.8/site-packages/mako/testing/assertions.pyeq_sr cCs ||kst|pd||fdS)z.Assert a != b, with repr messaging on failure.z%r == %rNrrrrr ne_ sr cCs ||kst|pd||fdS)z.Assert a in b, with repr messaging on failure.z %r not in %rNrrrrr in_sr cCs ||kst|pd||fdS)z2Assert a in not b, with repr messaging on failure.z %r is in %rNrrrrr not_insr cCs,|j|jk r(|js(ds(td||jfdS)Gassert that any exception we're catching does not have a __context__ without a __cause__, and that __suppress_context__ is never set. Python 3 will report nested as exceptions as "during the handling of error X, error Y occurred". That's not what we want to do. We want these exceptions in a cause chain. FzZException %r was correctly raised but did not set a cause, within context %r as its cause.N) __context__ __cause____suppress_context__r) exceptionrrr _assert_proper_exception_contexts rcCs$t|j|s td||j|fdS)rzcException %r was correctly raised but has cause %r, which does not have the expected cause type %r.N) isinstancerr)r cause_clsrrr _assert_proper_cause_cls/s  rcOst||||SN_assert_raises except_cls callable_argskwrrr assert_raises?srcOst||||ddS)NT check_contextrrrrr !assert_raises_with_proper_contextCsr"cOst|||||dS)N)rr)rrrrrrrr assert_raises_with_given_causeGsr#cOst|||||dS)N)rrrrrrkwargsrrr assert_raises_messageMsr&cOst|||||ddS)NTrr!rr$rrr )assert_raises_message_with_proper_contextQsr(cOst||||||dS)N)rrr)rrrrrr%rrr &assert_raises_message_with_given_causeYsr)Fc Cs*t||||}|||W5QRX|jSr)_expect_raiseserror)rrrr%rr!recrrr ras rc@seZdZdZdS)_ErrorContainerN)__name__ __module__ __qualname__r+rrrr r-osr-c cst}|rtd}z|Vd}Wn|k r}zr||_d}|dk rpt|}t||tjsptd||f|dk rt |||r|st |t t| dW5d}~XYnX~|stddS)NrFTz%r !~ %szutf-8z#Callable did not raise an exception) r-sysexc_infor+strresearchUNICODErrrprintencode) rrr!rr,Zare_we_already_in_a_tracebacksuccesserrZerror_as_stringrrr r*ss,  $r*cCs t||dSNr r*rr!rrr expect_raisessr>cCst|||dSNr'r<rrr!rrr expect_raises_messagesrATcCs t||dSr;r<r=rrr !expect_raises_with_proper_contextsrBcCst|||dSr?r<r@rrr )expect_raises_message_with_proper_contextsrC)N)N)N)N)NFN)NFN)F)F)T)T) contextlibr4r1r r r r rrrr"r#r&r(r)rr-contextmanagerr*r>rArBrCrrrr s4       #