Rh ddlZddlZddlZddlZddlZddlZdZdddddZdZGdd e Z ejd Z ejde d fd Zejd ZddZejdZdZy)Nctj5tjdtt j |cdddS#1swYyxYw)z3Import *name* while suppressing DeprecationWarning.ignorecategoryN)warningscatch_warnings simplefilterDeprecationWarning importlib import_module)names 3/usr/lib/python3.12/test/support/warnings_helper.pyimport_deprecatedr sB  "-h1CD&&t,---s 0AAlinenooffsetcddlm}tjd5}tjdt t |ddddd|jtd||\}|jt|jt |j|r%|jt|j||j|jd|j!|j"||j|j"|tjd5}tjd t |||||| ddd|j|gy#1swY3xYw#1swY)xYw) Nr)check_syntax_errorTrecordalwaysz execrerrorr) test.supportrrrr SyntaxWarningcompile assertEquallen assertTrue issubclassr assertRegexstrmessagefilenameassertIsNotNoner)testcase statementerrtextrrrwarnswarns rcheck_syntax_warningr-sA0   -1h 6 <01 UQ. ED  4==-@ 'S.8  5 T[[) T[[&1   -9g}58Y"( 99  #/11$99s(E63(F6FF cfd}|S)zDecorator to suppress warnings. Use of context managers to hide warnings make diffs more noisy and tools like 'git blame' less useful. cFtjfd}|S)Nctj5tjd|g|i|cdddS#1swYyxYw)Nrr)rrr )selfargskwargsrtests rwrapperz3ignore_warnings..decorator..wrapper5sF((* 3%%hBD24262 3 3 3s #AA ) functoolswraps)r4r5rs` r decoratorz"ignore_warnings..decorator4s%   3  3)rr8s` rignore_warningsr;.s  r9c2eZdZdZdZdZedZdZy)WarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. c ||_d|_y)Nr _warnings_last)r1 warnings_lists r__init__zWarningsRecorder.__init__Bs& r9ct|j|jkDrt|jd|S|tj j vryt|d|)Nz has no attribute )r r@rAgetattrrWarningMessage_WARNING_DETAILSAttributeError)r1attrs r __getattr__zWarningsRecorder.__getattr__FsT t~~  +4>>"-t4 4 X,,== =tDEEr9c4|j|jdSNr?r1s rrzWarningsRecorder.warningsMs~~djjk**r9c8t|j|_yrM)r r@rArNs rresetzWarningsRecorder.resetQs( r9N) __name__ __module__ __qualname____doc__rCrKpropertyrrPr:r9rr=r=>s+F++)r9r=cZ|jd}|s dtff}|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) quietrT)getWarning_filterwarnings)filtersr3rWs rcheck_warningsr\Us8 JJw E =" =E 7E **r9Fc#Kddlm}tjd5}tjd||d|r|ddd|j gy#1swYxYww)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_warningsramsd(   -(/)1 3   L  #sA,&A A, A)%A,c#bKt|td5ddddy#1swYyxYww)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 s/# /,/c#Ktjd}|jjd}|r|j t j d5}tjdjdt|dddt}g}|D]\}}d} |ddD]g}|j} tj|t| tjs>t!| j"|sUd} |j%|i| rz|r}|j'||j(f|rt+d |d z|rt+d |d zy#1swYxYww) 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 rrZrZsW MM! E""#89H   -" J,,X6q!! "1gGG 0S "AiiGc'lBDD17,,c2q!  "E NNC. / 03gaj@AAH$QZ() )/""s8AE10E% A!E1-E1E1E1AE1%E.*E1c#Ktjdd} d|tjddy#|tjddwxYwwrM)rr[) old_filterss rsave_restore_warnings_filtersrs>""1%K* )ksA/AAAc<tjdtdy)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_deprecationrs MM *  r9)r)F) contextlibr6r rnrhrrr-r;objectr=contextmanagerr\rYrardrZrrr:r9rrs -$#$T$<  )v). ++. (*Wu$$0 "$)N **r9