hddlZddlZddlZddlZddlZddlZdZdddddZdZGdd e Z ej d Z ej de d fd Zej d ZddZej dZdZdS)Nctj5tjdtt j|cdddS#1swxYwYdS)z3Import *name* while suppressing DeprecationWarning.ignorecategoryN)warningscatch_warnings simplefilterDeprecationWarning importlib import_module)names 3/usr/lib/python3.11/test/support/warnings_helper.pyimport_deprecatedr s  " "--h1CDDDD&t,,------------------s/AAAlinenooffsetcJddlm}tjd5}tjdt t |dddddn #1swxYwY|t|d||\}| t|j t |j |r(| t|j|||jd||j|||j|tjd5}tjd t |||||| dddn #1swxYwY||gdS) Nr)check_syntax_errorTrecordalwaysz execrerrorr) test.supportrrrr SyntaxWarningcompile assertEquallen assertTrue issubclassr assertRegexstrmessagefilenameassertIsNotNoner)testcase statementerrtextrrrwarnswarns rcheck_syntax_warningr-s%0/////   - - -1h 666 <000111111111111111 UQ... ED  4=-@@ '''9S..888  555 T[))) T[&111   - - -9g}5558Y"( 9 9 9 9999999999999999  #####s#,AAA +FF Fcfd}|S)zDecorator to suppress deprecation warnings. Use of context managers to hide warnings make diffs more noisy and tools like 'git blame' less useful. cJtjfd}|S)Nctj5tjd|g|Ri|cdddS#1swxYwYdS)Nrr)rrr )selfargskwargsrtests rwrapperz3ignore_warnings..decorator..wrapper5s(** 3 3%hBBBBtD24222622 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s"AA A) functoolswraps)r4r5rs` r decoratorz"ignore_warnings..decorator4s>    3 3 3 3 3   3)rr8s` rignore_warningsr;.s$  r9c:eZdZdZdZdZedZdZdS)WarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. c"||_d|_dS)Nr _warnings_last)r1 warnings_lists r__init__zWarningsRecorder.__init__Bs& r9ct|j|jkrt|jd|S|tjjvrdSt|d|)Nz has no attribute )r r@rAgetattrrWarningMessage_WARNING_DETAILSAttributeError)r1attrs r __getattr__zWarningsRecorder.__getattr__Fs_ t~   + +4>"-t44 4 X,= = =4ttDEEEr9c*|j|jdSNr?r1s rrzWarningsRecorder.warningsMs~djkk**r9c8t|j|_dSrM)r r@rArNs rresetzWarningsRecorder.resetQs(( r9N) __name__ __module__ __qualname____doc__rCrKpropertyrrPr:r9rr=r=>siFFF++X+)))))r9r=cl|d}|sdtff}|d}t||S)aContext manager to silence warnings. Accept 2-tuples as positional arguments: ("message regexp", WarningCategory) Optional argument: - if 'quiet' is True, it does not fail if a filter catches nothing (default True without argument, default False if some filters are defined) Without argument, it defaults to: check_warnings(("", Warning), quiet=True) quietrNT)getWarning_filterwarnings)filtersr3rWs rcheck_warningsr\UsC JJw  E =" =E 7E * **r9Fc#Kddlm}tjd5}tjd||dV|r |dddn #1swxYwY||gdS)aContext manager to check that no warnings are emitted. This context manager enables a given warning within its scope and checks that no warnings are emitted even with that warning enabled. If force_gc is True, a garbage collection is attempted before checking for warnings. This may help to catch warnings emitted when objects are deleted, such as ResourceWarning. Other keyword arguments are passed to warnings.filterwarnings(). r) gc_collectTrr)r%rN)rr^rrfilterwarningsr)r(r%rforce_gcr^r+s rcheck_no_warningsrams('''''   - - -(/)1 3 3 3 3    JLLL  #####s(AAAc#rKt|td5dVddddS#1swxYwYdS)a"Context manager to check that no ResourceWarning is emitted. Usage: with check_no_resource_warning(self): f = open(...) ... del f You must remove the object which may emit ResourceWarning before the end of the context manager. T)rr`N)raResourceWarning)r(s rcheck_no_resource_warningrds 8o M M M s ,00c#Ktjd}|jd}|r|t jd5}tjddt|Vdddn #1swxYwYt|}g}|D]\}}d} |ddD]b}|j } tj |t| tjr,t!| j|rd} ||c| s|s|||jf|rt+d |d z|rt+d |d zdS) zCatch the warnings, then check if all the expected warnings have been raised and re-raise unexpected warnings. If 'quiet' is True, only re-raise the unexpected warnings. __warningregistry__TrrrNFzunhandled warning %srz)filter (%r, %s) did not catch any warning)sys _getframe f_globalsrXclearrrmodulesr r=listr%rematchr$Ir" __class__removeappendrQAssertionError) r[rWframeregistrywreraisemissingmsgcatseenwarnings rrZrZs M!  E""#899H   - - -" J,,X666q!!!!! """""""""""""""1ggGG 0 0S " "AiGc'llBD11 "7,c22 "q!!! 0E 0 NNC. / / /B3gaj@AAA)H$QZ()) )))s7BB#&B#c#Ktjdd} dV|tjdd<dS#|tjdd<wxYwrM)rr[) old_filterss rsave_restore_warnings_filtersrsY"111%K* )k))))s /Ac>tjdtddS)NzThis is used in test_support test to ensure support.ignore_deprecations_from() works as expected. You should not be seeing this.r) stacklevel)rr,r r:r9r_warn_about_deprecationrs2 M *  r9)r)F) contextlibr6r rnrhrrr-r;objectr=contextmanagerr\rYrardrZrrr:r9rrse ---$#$T$$$$$<    )))))v))). +++. (*Wu$$$$0 "$)$)$)$)N ***r9