U of@shUddlmZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZddZddZddZddZddZd5ddZGdddZej d6d d!Z!d7d#d$Z"d8d%d&Z#d9d'd(Z$iZ%d)e&d*<d+d,Z'd-d.Z(d/d0Z)d1d2Z*d3d4Z+dS):) annotationsN)Any)Dict)exc)default)_expect_warnings)eq_)is_)is_false)is_not_)is_true)ne_ decorator) sqla_compatcCs,|j|jk r(|js(ds(td||jfdS)aHassert 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__AssertionError) exceptionrH/opt/hc_python/lib/python3.8/site-packages/alembic/testing/assertions.py _assert_proper_exception_contexts rcOst||||ddS)NT check_context_assert_raises except_cls callable_argskwrrr assert_raises,sr#cOst||||SNrrrrrassert_raises_context_ok0sr%cOst|||||ddS)NTmsgrrrr'r r!kwargsrrrassert_raises_message4sr*cOst|||||dS)N)r'rr(rrr assert_raises_message_context_ok:sr+Fc Cs(t|||}|||W5QRX|jSr$)_expect_raiseserror)rr r!r)r'recrrrr@src@seZdZUdZded<dS)_ErrorContainerNrr-)__name__ __module__ __qualname__r-__annotations__rrrrr/Hs r/c cst}|rtd}z|Vd}Wn||k r}z^||_d}|dk rnt|t|tjsnt|d||r~|s~t |t t| dW5d}~XYnX|stddS)NrFTz !~ zutf-8z#Callable did not raise an exception) r/sysexc_infor-researchstrUNICODErrprintencode)rr'rr.Zare_we_already_in_a_tracebacksuccesserrrrrr,Ls &$r,TcCs t||dS)Nrr,)rrrrr expect_raisesasr?cCst|||dS)Nr&r>)rr'rrrrexpect_raises_messageesr@cCsXtdd|}tdd|}tdd|}tdd|}||ksTt|pPd||fdS)Nz^\s+?|\nz {2,} z%r != %r)r6subr)abr'rrreq_ignore_whitespaceis rFzDict[Any, Any] _dialect_modscCsN|dks|dkrtSt|}|dkr8d|_n|dkrFd|_|SdS)Nr postgresqlTZmssqlF)rZDefaultDialectrZ _create_url get_dialectZimplicit_returningZlegacy_schema_aliasing)namedrrr _get_dialectusrLcOstt|f|S)aContext manager which expects one or more warnings. With no arguments, squelches all SAWarnings emitted via sqlalchemy.util.warn and sqlalchemy.util.warn_limited. Otherwise pass string expressions that will match selected warnings via regex; all non-matching warnings are sent through. The expect version **asserts** that the warnings were in fact seen. Note that the test suite sets SAWarning warnings to raise exceptions. )rWarningmessagesr"rrrexpect_warningss rPcstfdd}|S)zDecorator form of expect_warnings(). Note that emits_warning does **not** assert that the warnings were in fact seen. c s6ttfddi|||W5QRSQRXdS)NZassert_F)rDeprecationWarning)fnr!r"rOrrdecoratesz2emits_python_deprecation_warning..decorater)rOrTrrSr emits_python_deprecation_warningsrUcOsttj|f|Sr$)rsa_excZSADeprecationWarningrNrrrexpect_sqlalchemy_deprecatedsrWcOsttj|f|Sr$)rrVZRemovedIn20WarningrNrrrexpect_sqlalchemy_deprecated_20srX)NF)NF)T)T)N), __future__r contextlibr6r4typingrrZ sqlalchemyrrVZsqlalchemy.enginerZsqlalchemy.testing.assertionsrrr r r r r Zsqlalchemy.utilrutilrrr#r%r*r+rr/contextmanagerr,r?r@rFrGr3rLrPrUrWrXrrrrsJ