a  ze@sddlZddlZddlZddlZddlZddddddZddZGd d d eZej d d Z ej de d fddZ ej ddZ dddZej ddZddZdS)NlinenooffsetcCs ddlm}tjdd(}tdtt|ddWdn1sF0Y|t|d||\}| t |j t|j |r| t |j|||jd||j|dur||j|tjdd.}td t||||||d Wdn1s0Y||gdS) Nr)check_syntax_errorTrecordalwaysz execrerrorr) test.supportrwarningscatch_warnings simplefilter SyntaxWarningcompile assertEquallenZ assertTrue issubclasscategoryZ assertRegexstrmessagefilenameZassertIsNotNoner)testcaseZ statementZerrtextrrrwarnswarnrP/opt/bitninja-python-dojo/embedded/lib/python3.9/test/support/warnings_helper.pycheck_syntax_warnings*  *  &rcsfdd}|S)zDecorator to suppress deprecation warnings. Use of context managers to hide warnings make diffs more noisy and tools like 'git blame' less useful. cstfdd}|S)NcsPt4tjdd|g|Ri|WdS1sB0YdS)Nignorer)rrr)selfargskwargs)rtestrrwrapper-s z3ignore_warnings..decorator..wrapper) functoolswraps)r%r&r!)r%r decorator,sz"ignore_warnings..decoratorr)rr)rr!rignore_warnings&s r*c@s4eZdZdZddZddZeddZdd Zd S) WarningsRecorderzyConvenience wrapper for the warnings list returned on entry to the warnings.catch_warnings() context manager. cCs||_d|_dS)Nr _warnings_last)r"Z warnings_listrrr__init__:szWarningsRecorder.__init__cCsDt|j|jkr t|jd|S|tjjvr0dStd||fdS)Nz%r has no attribute %r)rr-r.getattrrWarningMessage_WARNING_DETAILSAttributeError)r"attrrrr __getattr__>s  zWarningsRecorder.__getattr__cCs|j|jdSNr,r"rrrrEszWarningsRecorder.warningscCst|j|_dSr7)rr-r.r8rrrresetIszWarningsRecorder.resetN) __name__ __module__ __qualname____doc__r/r6propertyrr9rrrrr+6s  r+cOs.|d}|s$dtff}|dur$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)filtersr$r?rrrcheck_warningsMs   rDFccshddlm}tjdd0}tjd||ddV|r:|Wdn1sN0Y||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 )rrN)r rErrfilterwarningsr)rrrforce_gcrErrrrcheck_no_warningses $rHccs8t|tdddVWdn1s*0YdS)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)rrGN)rHResourceWarning)rrrrcheck_no_resource_warning~srJc cstd}|jd}|r"|tjdd*}tjddt |VWdn1s^0Yt |}g}|D]j\}}d} |ddD]8}|j } t |t| t jrt| j|rd} ||q| sx|sx|||jfqx|rtd |d |rtd |d dS) 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. Z__warningregistry__Trrr NFzunhandled warning %srz)filter (%r, %s) did not catch any warning)sys _getframe f_globalsr@clearrrmodulesrr+listrrematchrIr __class__removeappendr:AssertionError) rCr?frameregistrywZreraisemissingmsgcatseenwarningrrrrBs4  (   rBc cs<tjdd}zdVW|tjdd<n|tjdd<0dSr7)rrC)Z old_filtersrrrsave_restore_warnings_filterssracCstjdtdddS)NzThis is used in test_support test to ensure support.ignore_deprecations_from() works as expected. You should not be seeing this.r) stacklevel)rrDeprecationWarningrrrr_warn_about_deprecations rd)r)F) contextlibr'rRrLrrr*objectr+contextmanagerrDrArHrJrBrardrrrrs&    '